diff --git a/CMakeLists.txt b/CMakeLists.txt index 602d249870ca77e4dd45ea14539caa9406c80796..02535aed0b88d5fa7311c04a78e4eb1eaa2e26df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,7 @@ if(roofit) endif() ROOT_ADD_TEST_SUBDIRECTORY(test) +ROOT_ADD_TEST_SUBDIRECTORY(tutorials) #---Global PCH----------------------------------------------------------------------------------- get_property(__allTargets GLOBAL PROPERTY ROOT_DICTIONARY_TARGETS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9cc4e772da9ab0684cd54de21f292145f70c3834..85a7e004f20296521a8f070d2f0fb82915efbb43 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,20 +28,12 @@ else() include_directories(${ROOT_INCLUDE_DIRS}/../tutorials) endif() -macro(ROOT_ADD_MACRO macrofile) - get_filename_component(name ${macrofile} NAME_WE) - ROOT_ADD_TEST(macro-${name} COMMAND ${ROOT_root_CMD} -b -q ${macrofile} PASSRC 1 FAILREGEX Error) -endmacro() - #---environment------------------------------------------------------------------------------- ROOT_ADD_TEST(show-environment COMMAND ${CMAKE_COMMAND} -E environment) #---hworld------------------------------------------------------------------------------------ ROOT_EXECUTABLE(hworld hworld.cxx LIBRARIES Gpad) -#---Defines some of the tutorials as tests---------------------------------------------------- -ROOT_ADD_MACRO(${ROOT_SOURCE_DIR}/tutorials/hsimple.C) - #---event------------------------------------------------------------------------------------- ROOT_GENERATE_DICTIONARY(EventDict ${CMAKE_CURRENT_SOURCE_DIR}/Event.h MODULE Event LINKDEF EventLinkDef.h) ROOT_LINKER_LIBRARY(Event Event.cxx EventDict.cxx LIBRARIES Hist MathCore) diff --git a/tutorials/CMakeLists.txt b/tutorials/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9ae7f32704c31c542f9118c83b9167739dcf6213 --- /dev/null +++ b/tutorials/CMakeLists.txt @@ -0,0 +1,156 @@ +# CMakeLists.txt for the ROOT tutorials programs. +# Author: Pere Mato, 25/10/2010 +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) + +project(tutorials) +find_package(ROOT REQUIRED) + +include(${ROOT_USE_FILE}) + +#---Definition of the helper function-------------------------------- +function(ROOT_ADD_TUTORIAL macrofile rc) + string(REPLACE ".C" "" name ${macrofile}) + string(REPLACE "/" "-" name ${name}) + ROOT_ADD_TEST(tutorial-${name} COMMAND ${ROOT_root_CMD} -b -l -q ${CMAKE_CURRENT_SOURCE_DIR}/${macrofile} + PASSRC ${rc} FAILREGEX "Error in" "error:" LABELS tutorial) +endfunction() + +#---Tutorials disabled depending on the build components------------- +if(NOT ROOT_minuit2_FOUND) + set(minuit2_veto fit/fit2dHist.C fit/fit2dHist.C + fit/fitCircle.C fit/minuit2FitBench2D.C + fit/minuit2FitBench2D.C fit/minuit2FitBench.C + fit/minuit2FitBench.C fit/minuit2GausFit.C + fit/minuit2GausFit.C fit/NumericalMinimization.C + fit/combinedFit.C) +endif() + +if(NOT ROOT_roofit_FOUND) + set(roofit_veto fit/RoofitDemo.C + roofit/*.C roostats/*.C histfactory/*.C) +endif() + +if(NOT ROOT_unuran_FOUND) + set(unuran_veto math/testrandom.C unuran/unuranDemo.C unuran/unuranFoamTest.C) +endif() + +if(NOT ROOT_xml_FOUND) + set(xml_veto xml/*.C) +endif() + +if(NOT ROOT_fitsio_FOUND) + set(fitsio_veto fitsio/*.C) +endif() + +if(NOT ROOT_mathmore_FOUND) + set(mathmore_veto math/quasirandom.C math/exampleMultiRoot.C) +endif() + +if(NOT ROOT_fftw3_FOUND) + set(fftw3_veto roofit/rf208_convolution.C + roofit/rf210_angularconv.C + roofit/rf211_paramconv.C) +endif() + +#---These ones requires a display to run----------------------------- +set(gui_veto fit/fitpanel_playback.C + cocoa/*.C + geom/*.C + gl/*.C + gui/*.C + hist/exec1.C hist/exec2.C + image/*.C + graphics/psview.C graphics/gtime.C + graphics/graph_edit_playback.C + tree/tvdemo.C + eve/*.C) + +#---These ones are disabled !!! ------------------------------------ +set(extra_veto + htmlex.C + rootalias.C + rootlogon.C + rootlogoff.C + fft/FFT.C + fit/fit1_C.C fit/TwoHistoFit2D.C fit/line3Dfit.C fit/MDF.C + foam/*.C + graphs/graphstruct.C + html/*.C + math/Bessel.C math/LegendreAssoc.C math/Legendre.C + math/mathmoreIntegration.C math/normalDist.C math/tStudent.C + math/testUnfold2.C math/pca.C + net/*.C + proof/*.C + pythia/*.C + sql/*.C + tree/hsimpleProxy.C tree/tree0.C tree/tree2a.C tree/tree4.C + roostats/rs401d_FeldmanCousins.C + roofit/rf104_classfactory.C + histfactory/ModifyInterpolation.C + tree/copytree2.C tree/copytree3.C tree/copytree.C + math/testUnfold4.C + fit/minuit2FitBench.C + fit/minuit2FitBench2D.C + roostats/*.C + http/*.C) + +set(all_veto hsimple.C + ${extra_veto} + ${gui_veto} + ${minuit2_veto} + ${roofit_veto} + ${unuran_veto} + ${xml_veto} + ${fitsio_veto} + ${mathmore_veto} + ${fftw3_veto}) + +file(GLOB_RECURSE tutorials RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.C) +file(GLOB tutorials_veto RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${all_veto}) + +list(LENGTH tutorials total) +list(LENGTH tutorials_veto veto) +message(STATUS "${veto}/${total} tutorials have been vetoed for various reasons") + +list(REMOVE_ITEM tutorials ${tutorials_veto}) + +set(returncode_1 fit/fit2a.C fit/graph2dfit.C fit/multidimfit.C + graphics/archi.C graphics/arrow.C + graphics/crown.C graphics/diamond.C + graphics/earth.C graphics/ellipse.C + graphics/event.C graphics/pavetext.C + graphics/tmathtext.C graphics/tmathtext2.C + graphs/exclusiongraph.C graphs/multigraph.C + graphs/multipalette.C + hist/ContourList.C hist/hstack.C + hist/th2polyBoxes.C + io/fildir.C + math/chi2test.C ) + +#---Loop over all tutorials and define the corresponding test--------- + +ROOT_ADD_TEST(tutorial-hsimple COMMAND ${ROOT_root_CMD} -b -l -q ${CMAKE_CURRENT_SOURCE_DIR}/hsimple.C + PASSRC 1 FAILREGEX "Error in" "error:" LABELS tutorial) +foreach(t ${tutorials}) + list(FIND returncode_1 ${t} index) + if(index EQUAL -1) + set(rc 0) + else() + set(rc 1) + endif() + string(REPLACE ".C" "" tname ${t}) + string(REPLACE "/" "-" tname ${tname}) + ROOT_ADD_TEST(tutorial-${tname} + COMMAND ${ROOT_root_CMD} -b -l -q ${CMAKE_CURRENT_SOURCE_DIR}/${t} + PASSRC ${rc} FAILREGEX "Error in" "error:" + LABELS tutorial + DEPENDS tutorial-hsimple ) +endforeach() + + + + + + + + diff --git a/tutorials/fitsio/FITS_tutorial1.C b/tutorials/fitsio/FITS_tutorial1.C index bea7521826daa2e1157668b6040abfb7a9fc5169..a677b27a10929227b6eab6bb53725e435223a627 100644 --- a/tutorials/fitsio/FITS_tutorial1.C +++ b/tutorials/fitsio/FITS_tutorial1.C @@ -13,9 +13,10 @@ void FITS_tutorial1() if (!gROOT->IsBatch()) { //printf("Press ENTER to start..."); getchar(); } - + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); + // Open primary HDU from file - TFITSHDU *hdu = new TFITSHDU("sample1.fits"); + TFITSHDU *hdu = new TFITSHDU(dir+"/sample1.fits"); if (hdu == 0) { printf("ERROR: could not access the HDU\n"); return; } diff --git a/tutorials/fitsio/FITS_tutorial2.C b/tutorials/fitsio/FITS_tutorial2.C index 1929b5f5320e005311902b6d0511ddc5e2beca11..c16f2ca83c69c58619f7ca309374fcbb3c50db6a 100644 --- a/tutorials/fitsio/FITS_tutorial2.C +++ b/tutorials/fitsio/FITS_tutorial2.C @@ -15,9 +15,10 @@ void FITS_tutorial2() if (!gROOT->IsBatch()) { //printf("Press ENTER to start..."); getchar(); } + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); // Open primary HDU from file - TFITSHDU *hdu = new TFITSHDU("sample2.fits"); + TFITSHDU *hdu = new TFITSHDU(dir+"/sample2.fits"); if (hdu == 0) { printf("ERROR: could not access the HDU\n"); return; } diff --git a/tutorials/fitsio/FITS_tutorial3.C b/tutorials/fitsio/FITS_tutorial3.C index 991d3e36cd1642bc264431d3a0804cdcda56c4d9..34dab386d0a64bfd03c6cf854c481b1a0be01015 100644 --- a/tutorials/fitsio/FITS_tutorial3.C +++ b/tutorials/fitsio/FITS_tutorial3.C @@ -15,11 +15,12 @@ void FITS_tutorial3() // Open extensions 1 to 5 from file //printf("Press ENTER to see a canvas with all images within the file:"); getchar(); - + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); + TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 700); c->Divide(2,3); for (int i=1; i <= 5; i++) { - TFITSHDU *hdu = new TFITSHDU("sample3.fits", i); + TFITSHDU *hdu = new TFITSHDU(dir+"/sample3.fits", i); if (hdu == 0) { printf("ERROR: could not access the HDU\n"); return; } diff --git a/tutorials/fitsio/FITS_tutorial4.C b/tutorials/fitsio/FITS_tutorial4.C index 791072c906bbe812eb52a7faf9ca7cf096640d04..63fc04197258df65963a3faa52e1bc09e127dc4f 100644 --- a/tutorials/fitsio/FITS_tutorial4.C +++ b/tutorials/fitsio/FITS_tutorial4.C @@ -16,9 +16,10 @@ void FITS_tutorial4() if (!gROOT->IsBatch()) { //printf("Press ENTER to start..."); getchar(); } - + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); + //Open the table extension number 1) - TFITSHDU *hdu = new TFITSHDU("sample2.fits[1][DATAMAX > 2e-15]"); + TFITSHDU *hdu = new TFITSHDU(dir+"/sample2.fits[1][DATAMAX > 2e-15]"); if (hdu == 0) { printf("ERROR: could not access the HDU\n"); return; } diff --git a/tutorials/fitsio/FITS_tutorial5.C b/tutorials/fitsio/FITS_tutorial5.C index cb600d5d065cff8d2051c72de4c5b07d5d98680d..0e484d22916496557066dc05f1046a41da9e174d 100755 --- a/tutorials/fitsio/FITS_tutorial5.C +++ b/tutorials/fitsio/FITS_tutorial5.C @@ -19,9 +19,11 @@ void FITS_tutorial5() //printf("Press ENTER to start..."); getchar(); //printf("\n"); } - + + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); + //Open the table - TFITSHDU *hdu = new TFITSHDU("sample4.fits[1]"); + TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]"); if (hdu == 0) { printf("ERROR: could not access the HDU\n"); return; } diff --git a/tutorials/fitsio/FITS_tutorial6.C b/tutorials/fitsio/FITS_tutorial6.C index 458d680f44099e3a75e07d40e00f8b77986d4b66..ad0294b3e137b1c4bb8260b39ea487f34a85786c 100644 --- a/tutorials/fitsio/FITS_tutorial6.C +++ b/tutorials/fitsio/FITS_tutorial6.C @@ -10,9 +10,10 @@ void FITS_tutorial6() printf("We are going to open a table from a FITS file\n"); printf("and dump its columns.\n\n"); - + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); + //Open the table - TFITSHDU *hdu = new TFITSHDU("sample4.fits[1]"); + TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]"); if (hdu == 0) { printf("ERROR: could not access the HDU\n"); return; } diff --git a/tutorials/tree/cernstaff.C b/tutorials/tree/cernstaff.C index 85062739c99122deb13db7c77264e49f91abd6b4..480133df26e48caa6ec3e873494d64ecbcd5c4c4 100644 --- a/tutorials/tree/cernstaff.C +++ b/tutorials/tree/cernstaff.C @@ -1,10 +1,12 @@ // Playing with a Tree containing variables of type character // Author: Rene Brun void cernstaff () { - if (gSystem->AccessPathName("cernstaff.root")) { + TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName()); + if (gSystem->AccessPathName(dir+"/cernstaff.root")) { + gROOT->SetMacroPath(dir); gROOT->ProcessLine(".x cernbuild.C"); } - TFile *f = new TFile("cernstaff.root"); + TFile *f = new TFile(dir+"/cernstaff.root"); TTree *T = (TTree*)f->Get("T"); TCanvas *c1 = new TCanvas("c1","CERN staff",10,10,1000,750); c1->SetFillColor(17);