diff --git a/.github/workflows/root-ci.yml b/.github/workflows/root-ci.yml index bdca8a31ff677..3b75040d98a4e 100644 --- a/.github/workflows/root-ci.yml +++ b/.github/workflows/root-ci.yml @@ -153,6 +153,9 @@ jobs: with: build-directory: /Users/sftnight/ROOT-CI/src/ + - name: Set up curl CA bundle for Davix to work with https + run: 'echo SSL_CERT_FILE=/opt/local/share/curl/curl-ca-bundle.crt >> $GITHUB_ENV' + - name: Pull Request Build if: github.event_name == 'pull_request' env: diff --git a/io/io/test/TFileTests.cxx b/io/io/test/TFileTests.cxx index 52dfc944e2d03..0a5aad45d06ed 100644 --- a/io/io/test/TFileTests.cxx +++ b/io/io/test/TFileTests.cxx @@ -126,6 +126,8 @@ void TestReadWithoutGlobalRegistrationIfPossible(const char *fname) } // https://github.com/root-project/root/issues/10742 +#ifndef R__WIN32 +// We prefer not to read remotely files from Windows, if possible TEST(TFile, ReadWithoutGlobalRegistrationWeb) { const auto webFile = "http://root.cern/files/h1/dstarmb.root"; @@ -136,6 +138,7 @@ TEST(TFile, ReadWithoutGlobalRegistrationNet) const auto netFile = "root://eospublic.cern.ch//eos/root-eos/h1/dstarmb.root"; TestReadWithoutGlobalRegistrationIfPossible(netFile); } +#endif // https://github.com/root-project/root/issues/16189 TEST(TFile, k630forwardCompatibility) diff --git a/net/davix/src/RRawFileDavix.cxx b/net/davix/src/RRawFileDavix.cxx index 76373b9f4ccdc..da958fe0209d3 100644 --- a/net/davix/src/RRawFileDavix.cxx +++ b/net/davix/src/RRawFileDavix.cxx @@ -11,7 +11,9 @@ #include "ROOT/RRawFileDavix.hxx" +#include #include +#include "utils.h" #include #include @@ -28,7 +30,14 @@ namespace ROOT { namespace Internal { struct RDavixFileDes { - RDavixFileDes() : fd(nullptr), pos(&ctx) {} + + RDavixFileDes() : fd(nullptr), pos(&ctx) + { + // CA Check + const auto ca_check_local_str = gEnv->GetValue("Davix.GSI.CACheck", (const char *)"y"); + bool ca_check_local = isno(ca_check_local_str); + pars.setSSLCAcheck(ca_check_local); + } RDavixFileDes(const RDavixFileDes &) = delete; RDavixFileDes &operator=(const RDavixFileDes &) = delete; ~RDavixFileDes() = default; @@ -36,6 +45,7 @@ struct RDavixFileDes { DAVIX_FD *fd; Davix::Context ctx; Davix::DavPosix pos; + Davix::RequestParams pars; }; } // namespace Internal @@ -62,7 +72,7 @@ std::uint64_t ROOT::Internal::RRawFileDavix::GetSizeImpl() { struct stat buf; Davix::DavixError *err = nullptr; - if (fFileDes->pos.stat(nullptr, fUrl, &buf, &err) == -1) { + if (fFileDes->pos.stat(&fFileDes->pars, fUrl, &buf, &err) == -1) { throw std::runtime_error("Cannot determine size of '" + fUrl + "', error: " + err->getErrMsg()); } return buf.st_size; @@ -71,7 +81,7 @@ std::uint64_t ROOT::Internal::RRawFileDavix::GetSizeImpl() void ROOT::Internal::RRawFileDavix::OpenImpl() { Davix::DavixError *err = nullptr; - fFileDes->fd = fFileDes->pos.open(nullptr, fUrl, O_RDONLY, &err); + fFileDes->fd = fFileDes->pos.open(&fFileDes->pars, fUrl, O_RDONLY, &err); if (fFileDes->fd == nullptr) { throw std::runtime_error("Cannot open '" + fUrl + "', error: " + err->getErrMsg()); } diff --git a/net/davix/src/TDavixFile.cxx b/net/davix/src/TDavixFile.cxx index 1dd7e49dfe2ad..10c690d82f393 100644 --- a/net/davix/src/TDavixFile.cxx +++ b/net/davix/src/TDavixFile.cxx @@ -40,6 +40,7 @@ #include "TBase64.h" #include "TVirtualPerfStats.h" #include "TDavixFileInternal.h" +#include "utils.h" #include "snprintf.h" #include @@ -89,16 +90,6 @@ ROOT::Experimental::RLogChannel &TDavixLogChannel() //////////////////////////////////////////////////////////////////////////////// -bool isno(const char *str) -{ - if (!str) return false; - - if (!strcmp(str, "n") || !strcmp(str, "no") || !strcmp(str, "0") || !strcmp(str, "false")) return true; - - return false; - -} - bool strToBool(const char *str, bool defvalue) { if(!str) return defvalue; diff --git a/net/davix/src/utils.h b/net/davix/src/utils.h new file mode 100644 index 0000000000000..75ec7a9a14200 --- /dev/null +++ b/net/davix/src/utils.h @@ -0,0 +1,20 @@ +/************************************************************************* + * Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#include + +inline bool isno(const char *str) +{ + if (!str) + return false; + + if (!strcmp(str, "n") || !strcmp(str, "no") || !strcmp(str, "0") || !strcmp(str, "false")) + return true; + + return false; +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b529095c31154..57927c68f21d1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -140,17 +140,20 @@ if(geom) FAILREGEX "FAILED|Error in") #--stressGeometry------------------------------------------------------------------------------------ - ROOT_EXECUTABLE(stressGeometry stressGeometry.cxx LIBRARIES Geom Tree GenVector Gpad) - ROOT_ADD_TEST(test-stressgeometry COMMAND stressGeometry -b FAILREGEX "FAILED|Error in" LABELS longtest) - ROOT_ADD_TEST(test-stressgeometry-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGeometry.cxx - FAILREGEX "FAILED|Error in" DEPENDS test-stressgeometry LABELS longtest) + if (NOT MSVC) # Prevents the access to the web, which could happen through https + ROOT_EXECUTABLE(stressGeometry stressGeometry.cxx LIBRARIES Geom Tree GenVector Gpad) + ROOT_ADD_TEST(test-stressgeometry COMMAND stressGeometry -b FAILREGEX "FAILED|Error in" LABELS longtest) + ROOT_ADD_TEST(test-stressgeometry-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGeometry.cxx + FAILREGEX "FAILED|Error in" DEPENDS test-stressgeometry LABELS longtest) + endif() endif() #--stressLinear------------------------------------------------------------------------------------ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/linearIO.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) ROOT_EXECUTABLE(stressLinear stressLinear.cxx LIBRARIES Matrix Hist RIO) ROOT_ADD_TEST(test-stresslinear COMMAND stressLinear FAILREGEX "FAILED|Error in" LABELS longtest) ROOT_ADD_TEST(test-stresslinear-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressLinear.cxx - FAILREGEX "FAILED|Error in" DEPENDS test-stresslinear LABELS longtest) + FAILREGEX "FAILED|Error in" LABELS longtest) #--stressGraphics------------------------------------------------------------------------------------ if(ROOT_opengl_FOUND) @@ -195,10 +198,11 @@ if(ROOT_opengl_FOUND) endif() #--stressHistogram------------------------------------------------------------------------------------ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.5.18.00.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) ROOT_EXECUTABLE(stressHistogram stressHistogram.cxx LIBRARIES Hist RIO) ROOT_ADD_TEST(test-stresshistogram COMMAND stressHistogram FAILREGEX "FAILED|Error in" LABELS longtest) ROOT_ADD_TEST(test-stresshistogram-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.cxx - FAILREGEX "FAILED|Error in" DEPENDS test-stresshistogram ) + FAILREGEX "FAILED|Error in") #--stressGUI--------------------------------------------------------------------------------------- if(ROOT_asimage_FOUND) diff --git a/test/linearIO.root b/test/linearIO.root new file mode 100644 index 0000000000000..d6170f5e1fa39 Binary files /dev/null and b/test/linearIO.root differ diff --git a/test/stressHistogram.5.18.00.root b/test/stressHistogram.5.18.00.root new file mode 100644 index 0000000000000..4d6f2e314921c Binary files /dev/null and b/test/stressHistogram.5.18.00.root differ diff --git a/test/stressHistogram.cxx b/test/stressHistogram.cxx index 01d10d3052b25..8e153d92209d9 100644 --- a/test/stressHistogram.cxx +++ b/test/stressHistogram.cxx @@ -97,6 +97,12 @@ #include #include +#ifdef __CLING__ +const auto tmp_root_file_name = "tmp_hist_interpreted.root"; +#else +const auto tmp_root_file_name = "tmp_hist.root"; +#endif + using std::ostringstream, std::cout, std::endl, std::string; const unsigned int __DRAW__ = 0; @@ -132,7 +138,7 @@ enum RefFileEnum { const int refFileOption = 1; TFile * refFile = 0; -const char* refFileName = "http://root.cern/files/stressHistogram.5.18.00.root"; +const char* refFileName = "./stressHistogram.5.18.00.root"; TRandom2 r; // set to zero if want to run different numbers every time @@ -2956,11 +2962,11 @@ bool testWriteRead1D() h1->Fill(value, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); h1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TH1D* h2 = static_cast ( f2.Get("wr1D_h1") ); bool ret = equals("Read/Write Hist 1D", h1, h2, cmpOptStats); @@ -2984,11 +2990,11 @@ bool testWriteReadVar1D() h1->Fill(value, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); h1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TH1D* h2 = static_cast ( f2.Get("wr1D_h1") ); bool ret = equals("Read/Write VarH 1D", h1, h2, cmpOptStats); @@ -3008,11 +3014,11 @@ bool testWriteReadProfile1D() p1->Fill(x, y, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); p1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TProfile* p2 = static_cast ( f2.Get("wr1D_p1") ); bool ret = equals("Read/Write Prof 1D", p1, p2, cmpOptStats); @@ -3035,11 +3041,11 @@ bool testWriteReadProfileVar1D() p1->Fill(x, y, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); p1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TProfile* p2 = static_cast ( f2.Get("wr1D_p1") ); bool ret = equals("Read/Write VarP 1D", p1, p2, cmpOptStats); @@ -3063,11 +3069,11 @@ bool testWriteRead2D() h1->Fill(x, y, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); h1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TH2D* h2 = static_cast ( f2.Get("wr2D_h1") ); bool ret = equals("Read/Write Hist 2D", h1, h2, cmpOptStats); @@ -3090,11 +3096,11 @@ bool testWriteReadProfile2D() p1->Fill(x, y, z, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); p1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TProfile2D* p2 = static_cast ( f2.Get("wr2D_p1") ); bool ret = equals("Read/Write Prof 2D", p1, p2, cmpOptStats); @@ -3120,11 +3126,11 @@ bool testWriteRead3D() h1->Fill(x, y, z, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); h1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TH3D* h2 = static_cast ( f2.Get("wr3D_h1") ); bool ret = equals("Read/Write Hist 3D", h1, h2, cmpOptStats); @@ -3149,11 +3155,11 @@ bool testWriteReadProfile3D() p1->Fill(x, y, z, t, 1.0); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); p1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); TProfile3D* p2 = static_cast ( f2.Get("wr3D_p1") ); // In this particular case the statistics are not checked. The @@ -3188,11 +3194,11 @@ bool testWriteReadHn() s1->Fill(points); } - TFile f("tmpHist.root", "RECREATE"); + TFile f(tmp_root_file_name, "RECREATE"); s1->Write(); f.Close(); - TFile f2("tmpHist.root"); + TFile f2(tmp_root_file_name); HIST* s2 = static_cast ( f2.Get("wrS-s1") ); bool ret = equals(TString::Format("Read/Write Hist %s", HIST::Class()->GetName()), s1, s2, cmpOptStats); diff --git a/test/stressLinear.cxx b/test/stressLinear.cxx index 5169f8bd7ed27..71846f53ac276 100644 --- a/test/stressLinear.cxx +++ b/test/stressLinear.cxx @@ -120,6 +120,16 @@ #include "TMatrixDEigen.h" #include "TMatrixDSymEigen.h" +#ifdef __CLING__ +const auto tmp_vmatrix_file_name = "stress-vmatrix_interpreted.root"; +const auto tmp_vvector_file_name = "stress-vvector_interpreted.root"; +const auto tmp_vdecomp_file_name ="stress-vdecomp_interpreted.root"; +#else +const auto tmp_vmatrix_file_name = "stress-vmatrix.root"; +const auto tmp_vvector_file_name = "stress-vvector.root"; +const auto tmp_vdecomp_file_name = "stress-vdecomp.root"; +#endif + void stressLinear (Int_t maxSizeReq=100,Int_t verbose=0); void StatusPrint (Int_t id,const TString &title,Bool_t status); @@ -2075,7 +2085,7 @@ void mstress_matrix_io() Bool_t ok = kTRUE; const Double_t pattern = TMath::Pi(); - TFile *f = new TFile("stress-vmatrix.root", "RECREATE"); + TFile *f = new TFile(tmp_vmatrix_file_name, "RECREATE"); Char_t name[80]; Int_t iloop = gNrLoop; @@ -2122,7 +2132,7 @@ void mstress_matrix_io() if (gVerbose) std::cout << "\nOpen database in read-only mode and read matrix" << std::endl; - TFile *f1 = new TFile("stress-vmatrix.root"); + TFile *f1 = new TFile(tmp_vmatrix_file_name); iloop = gNrLoop; while (iloop >= 0) { @@ -3110,7 +3120,7 @@ void spstress_matrix_io() Bool_t ok = kTRUE; const Double_t pattern = TMath::Pi(); - TFile *f = new TFile("stress-vmatrix.root", "RECREATE"); + TFile *f = new TFile(tmp_vmatrix_file_name, "RECREATE"); Char_t name[80]; Int_t iloop = gNrLoop; @@ -3143,7 +3153,7 @@ void spstress_matrix_io() if (gVerbose) std::cout << "\nOpen database in read-only mode and read matrix" << std::endl; - TFile *f1 = new TFile("stress-vmatrix.root"); + TFile *f1 = new TFile(tmp_vmatrix_file_name); iloop = gNrLoop; while (iloop >= 0) { @@ -3749,7 +3759,7 @@ void vstress_vector_io() Bool_t ok = kTRUE; const Double_t pattern = TMath::Pi(); - TFile *f = new TFile("stress-vvector.root","RECREATE"); + TFile *f = new TFile(tmp_vvector_file_name,"RECREATE"); Char_t name[80]; Int_t iloop = gNrLoop; @@ -3786,7 +3796,7 @@ void vstress_vector_io() if (gVerbose) std::cout << "\nOpen database in read-only mode and read vector" << std::endl; - TFile *f1 = new TFile("stress-vvector.root"); + TFile *f1 = new TFile(tmp_vvector_file_name); iloop = gNrLoop; while (iloop >= 0) { @@ -4275,7 +4285,7 @@ void astress_decomp_io(Int_t msize) if (gVerbose) std::cout << "\nWrite decomp m to database" << std::endl; - TFile *f = new TFile("stress-vdecomp.root", "RECREATE"); + TFile *f = new TFile(tmp_vdecomp_file_name, "RECREATE"); TDecompLU lu(m,1.0e-20); TDecompQRH qrh(m,1.0e-20); @@ -4295,7 +4305,7 @@ void astress_decomp_io(Int_t msize) if (gVerbose) std::cout << "\nOpen database in read-only mode and read matrix" << std::endl; - TFile *f1 = new TFile("stress-vdecomp.root"); + TFile *f1 = new TFile(tmp_vdecomp_file_name); if (gVerbose) std::cout << "\nRead decompositions should create same solutions" << std::endl; @@ -4379,8 +4389,7 @@ void astress_decomp_io(Int_t msize) void stress_backward_io() { - TFile::SetCacheFileDir("."); - TFile *f = TFile::Open("http://root.cern/files/linearIO.root","CACHEREAD"); + TFile *f = TFile::Open("./linearIO.root"); TMatrixF mf1 = THilbertMatrixF(-5,5,-5,5); mf1[1][2] = TMath::Pi(); @@ -4418,7 +4427,7 @@ void stress_backward_io() void cleanup() { - gSystem->Unlink("stress-vmatrix.root"); - gSystem->Unlink("stress-vvector.root"); - gSystem->Unlink("stress-vdecomp.root"); + gSystem->Unlink(tmp_vmatrix_file_name); + gSystem->Unlink(tmp_vvector_file_name); + gSystem->Unlink(tmp_vdecomp_file_name); } diff --git a/tutorials/CMakeLists.txt b/tutorials/CMakeLists.txt index e2ce3465f2ce0..4ff603360eac3 100644 --- a/tutorials/CMakeLists.txt +++ b/tutorials/CMakeLists.txt @@ -44,6 +44,9 @@ set(TUTORIAL_ENV ${ROOT_environ} OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MKL_NU #---Copy the CTestCustom.cmake file into the build directory-------- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) +#---Copy the input file of the quadp portfolio example to the build directory-------- +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/quadp/stock.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + #---Provide a rootlogon.C file in the current build directory that # will affect the way we run all tutorials. # This overwrites the existing rootlogon.C and rootalias.C in the @@ -427,6 +430,7 @@ if(MSVC) # disable run_h1analysis.C because of Endpoint Security HTTP traffic scanning, # which is corrupting the data on Windows list(APPEND extra_veto tree/run_h1analysis.C) + list(APPEND extra_veto legacy/th2polyEurope.C) # needs to download from the web endif() if(MSVC AND NOT llvm13_broken_tests) @@ -653,6 +657,13 @@ if (PY_SONNET_FOUND AND PY_GRAPH_NETS_FOUND) set (tmva-TMVA_SOFIE_GNN_Application-depends tutorial-tmva-TMVA_SOFIE_GNN_Parser) endif() +# Download open data csv only once from a python tutorial, the C++ ones depend on it +set(dataframe-df014_CSVDataSource-depends tutorial-dataframe-df014_CSVDataSource-py) +set(dataframe-df015_LazyDataSource-depends tutorial-dataframe-df014_CSVDataSource-py) + +# Download the input root file only once from a python tutorial, the C++ one depends on it +set(hist-th2polyUSA-depends tutorial-hist-th2polyUSA-py) + #---Loop over all tutorials and define the corresponding test--------- foreach(t ${tutorials}) list(FIND returncode_1 ${t} index) @@ -933,11 +944,17 @@ if(ROOT_pyroot_FOUND) endif() endforeach() + if(NOT ${${tname}-depends} STREQUAL ${tutorial_name}) + set(tutorial_dependency ${${tname}-depends}) + else() + set(tutorial_dependency "") + endif() + ROOT_ADD_TEST(${tutorial_name} COMMAND ${Python3_EXECUTABLE} ${setThreadPoolSize} ${thisTestPoolSize} ${CMAKE_CURRENT_SOURCE_DIR}/${t} PASSRC ${rc} FAILREGEX "Error in" ": error:" "segmentation violation" LABELS ${labels} - DEPENDS ${${tname}-depends} + DEPENDS ${tutorial_dependency} ENVIRONMENT ${TUTORIAL_ENV} PYTHON_DEPS ${python_deps} ${py_will_fail}) diff --git a/tutorials/dataframe/df014_CSVDataSource.C b/tutorials/dataframe/df014_CSVDataSource.C index c01ae1f03ee70..8e7a039db6de9 100644 --- a/tutorials/dataframe/df014_CSVDataSource.C +++ b/tutorials/dataframe/df014_CSVDataSource.C @@ -24,7 +24,7 @@ int df014_CSVDataSource() // Let's first create a RDF that will read from the CSV file. // The types of the columns will be automatically inferred. auto fileNameUrl = "http://root.cern/files/tutorials/df014_CsvDataSource_MuRun2010B.csv"; - auto fileName = "df014_CsvDataSource_MuRun2010B_cpp.csv"; + auto fileName = "CsvDataSource_MuRun2010B.csv"; if(gSystem->AccessPathName(fileName)) TFile::Cp(fileNameUrl, fileName); auto df = ROOT::RDF::FromCSV(fileName); diff --git a/tutorials/dataframe/df014_CSVDataSource.py b/tutorials/dataframe/df014_CSVDataSource.py index 54bddcb5972b0..28fdb9337900c 100644 --- a/tutorials/dataframe/df014_CSVDataSource.py +++ b/tutorials/dataframe/df014_CSVDataSource.py @@ -20,14 +20,15 @@ ## \author Enric Tejedor (CERN) import ROOT +import urllib.request import os # Let's first create a RDF that will read from the CSV file. # The types of the columns will be automatically inferred. fileNameUrl = "http://root.cern/files/tutorials/df014_CsvDataSource_MuRun2010B.csv" -fileName = "df014_CsvDataSource_MuRun2010B_py.csv" +fileName = "CsvDataSource_MuRun2010B.csv" if not os.path.isfile(fileName): - ROOT.TFile.Cp(fileNameUrl, fileName) + urllib.request.urlretrieve(fileNameUrl, fileName) df = ROOT.RDF.FromCSV(fileName) diff --git a/tutorials/dataframe/df015_LazyDataSource.C b/tutorials/dataframe/df015_LazyDataSource.C index 93005dbe4fe44..f9e8fee18d9b3 100644 --- a/tutorials/dataframe/df015_LazyDataSource.C +++ b/tutorials/dataframe/df015_LazyDataSource.C @@ -26,7 +26,7 @@ int df015_LazyDataSource() // Let's first create a RDF that will read from the CSV file. // See the tutorial (https://root.cern/doc/master/df014__CSVDataSource_8C.html) on CSV data sources for more details! auto fileNameUrl = "http://root.cern/files/tutorials/df014_CsvDataSource_MuRun2010B.csv"; - auto fileName = "df015_CsvDataSource_MuRun2010B.csv"; + auto fileName = "CsvDataSource_MuRun2010B.csv"; if(gSystem->AccessPathName(fileName)) TFile::Cp(fileNameUrl, fileName); diff --git a/tutorials/graphics/AtlasExample.C b/tutorials/graphics/AtlasExample.C deleted file mode 100644 index b603c525731dc..0000000000000 --- a/tutorials/graphics/AtlasExample.C +++ /dev/null @@ -1,225 +0,0 @@ -/// \file -/// \ingroup tutorial_graphics -/// \notebook -js -/// Show how ATLAS Style looks like. It is based on a style file from BaBar. -/// -/// \macro_image -/// \macro_code -/// -/// \author M.Sutton - -const Int_t GMAX=864; - -const int nren=3; -static const double mur[nren] = {1.0,0.25,4.0}; -static const double muf[nren] = {1.0,0.25,4.0}; -const unsigned int NUMPDF=41; - -TGraphErrors* GetGraph(Int_t ir, Int_t ifs,Int_t icut, Int_t ipdf); -void AddtoBand(TGraphErrors* g1, TGraphAsymmErrors* g2); -TGraphAsymmErrors* MakeBand(TGraphErrors* g0, TGraphErrors* g1,TGraphErrors* g2); - -void AtlasExample() -{ - gROOT->SetStyle("ATLAS"); - - Int_t icol1=5; - Int_t icol2=5; - - auto canvas = new TCanvas("canvas","single inclusive jets",50,50,600,600); - canvas->SetLogy(); - - Double_t ymin = 1.e-3; Double_t ymax = 2e7; - Double_t xmin = 60.00; Double_t xmax = 3500.; - auto frame = canvas->DrawFrame(xmin,ymin,xmax,ymax); - frame->SetYTitle("d#sigma_{jet}/dE_{T,jet} [fb/GeV]"); - frame->SetXTitle("E_{T,jet} [GeV]"); - frame->GetYaxis()->SetTitleOffset(1.4); - frame->GetXaxis()->SetTitleOffset(1.4); - - const Int_t ncut=1; - TGraphErrors *data[ncut]; - - for (Int_t icut=0; icutSetLineColor(1); - g1[ir][icut]->SetMarkerStyle(0); - } - - char daname[100]; - sprintf(daname,"data_%d",icut); - data[icut] = (TGraphErrors*)g1[0][icut]->Clone(daname); - data[icut]->SetMarkerStyle(20); - data[icut]->SetMarkerColor(1); - - // Just invent some data - for (Int_t i=0; i< data[icut]->GetN(); i++) { - Double_t x1,y1,e,dx1=0.; - data[icut]->GetPoint(i,x1,y1); - Double_t r1 = 0.4*(gRandom->Rndm(1)+2); - Double_t r2 = 0.4*(gRandom->Rndm(1)+2); - Double_t y; - if (icut==0) y = r1*y1+r1*r2*r2*x1/50000.; - else y = r1*y1; - e = sqrt(y*1000)/200; - data[icut]->SetPoint(i, x1,y); - data[icut]->SetPointError(i,dx1,e); - } - - TGraphAsymmErrors* scale[ncut]; - TGraphAsymmErrors* scalepdf[ncut]; - - scale[icut] = MakeBand(g1[0][icut],g1[1][icut],g1[2][icut]); - scalepdf[icut]=(TGraphAsymmErrors* ) scale[icut]->Clone("scalepdf"); - - TGraphErrors *gpdf[NUMPDF][ncut]; - for (Int_t ipdf=0; ipdfSetLineColor(2); - gpdf[ipdf][icut]->SetLineStyle(1); - gpdf[ipdf][icut]->SetMarkerStyle(0); - AddtoBand(gpdf[ipdf][icut],scalepdf[icut]); - } - - scalepdf[icut]->SetFillColor(icol2); - scalepdf[icut]->Draw("zE2"); - scalepdf[icut]->SetLineWidth(3); - scale[icut]->SetFillColor(icol1); - scale[icut]->Draw("zE2"); - g1[0][icut]->SetLineWidth(3); - g1[0][icut]->Draw("z"); - data[icut]->Draw("P"); - } - - TLatex t; t.SetNDC(); - t.DrawLatex(0.3, 0.85, "#sqrt{s}= 14 TeV"); - t.DrawLatex(0.57, 0.85, "|#eta_{jet}|<0.5"); - - auto l = new TLegend(0.45,0.65,0.8,0.8,"","NDC"); - l->SetBorderSize(0.); - l->SetTextFont(42); - l->AddEntry("data_0", "Data 2009", "ep"); - l->AddEntry("scalepdf", "NLO QCD", "lf"); - l->Draw(); -} - -TGraphErrors* GetGraph(Int_t ir, Int_t ifs,Int_t icut, Int_t ipdf) -{ - const char *cuts[5] = - {"0.0 <= |eta| < 0.5", - "0.5 <= |eta| < 1.0", - "1.0 <= |eta| < 1.5", - "1.5 <= |eta| < 2.0", - "2.0 <= |eta| < 3.0"}; - - const double mur[] = {1.0,0.25,4.0}; - const double muf[] = {1.0,0.25,4.0}; - - TFile::SetCacheFileDir("."); - TFile *file = TFile::Open("http://root.cern/files/AtlasGraphs.root", "CACHEREAD"); - - char gname[100]; - char tname[100]; - - if (ipdf>=0) - sprintf(tname," E_T (mu_r=%g, mu_f=%g);%s Pdf: %d",mur[ir],muf[ifs],cuts[icut],ipdf); - else - sprintf(tname," E_T %s Ms= %d",cuts[icut],-ipdf); - - TGraphErrors* g1 = 0; - - for (int i=1; i<=GMAX; i++) { - sprintf(gname,"full_%d",i); - g1 = (TGraphErrors*) file->Get(gname); - if (!g1) { - cout << gname << " not found " << endl; - return nullptr; - } - - const char *title = g1->GetTitle(); - - if (strcmp(title,tname)==0) break; - g1 = 0; - } - - if (!g1) return nullptr; - return g1; -} - -TGraphAsymmErrors* MakeBand(TGraphErrors* g0, TGraphErrors* g1,TGraphErrors* g2) { - - TGraphAsymmErrors* g3 = new TGraphAsymmErrors(); - - Double_t x1 = 0., y1 = 0., x2 = 0., y2 = 0., y0 = 0, x3 = 0.; - Double_t dum; - for (Int_t i=0; iGetN(); i++) { - g0->GetPoint(i, x1, y0); - g1->GetPoint(i, x1, y1); - g2->GetPoint(i, x1, y2); - - if (i==g1->GetN()-1) x2=x1; - else g2->GetPoint(i+1,x2,dum); - - if (i==0) x3=x1; - else g2->GetPoint(i-1,x3,dum); - - Double_t tmp = y2; - if (y1 < y2) { - y2 = y1; - y1 = tmp; - } - g3->SetPoint(i,x1,y0); - - Double_t binwl = (x1-x3)/2.; - Double_t binwh = (x2-x1)/2.; - if (binwl == 0.) binwl = binwh; - if (binwh == 0.) binwh = binwl; - g3->SetPointError(i, binwl, binwh, y0-y2, y1-y0); - - } - return g3; -} - -void AddtoBand(TGraphErrors* g1, TGraphAsymmErrors* g2) { - - Double_t x1=0., y1=0., y2=0., y0=0; - - if (g1->GetN()!=g2->GetN()) - cout << " graphs don't have the same number of elements " << endl; - - Double_t* EYhigh = g2-> GetEYhigh(); - Double_t* EYlow = g2-> GetEYlow(); - - for (Int_t i=0; iGetN(); i++) { - g1->GetPoint(i, x1, y1); - g2->GetPoint(i, x1, y2); - - if ( y1==0 || y2==0 ) - cerr << "check these points very carefully : AddtoBand() : point " << i << endl; - - Double_t eyh=0., eyl=0.; - - y0 = y1-y2; - if (y0 != 0) { - if (y0 > 0) { - eyh = EYhigh[i]; - eyh = sqrt(eyh*eyh+y0*y0); - g2->SetPointEYhigh(i, eyh); - } else { - eyl = EYlow[i]; - eyl = sqrt(eyl*eyl+y0*y0); - g2->SetPointEYlow (i, eyl); - } - } - } -} diff --git a/tutorials/hist/hist039_TH2Poly_usa.py b/tutorials/hist/hist039_TH2Poly_usa.py new file mode 100644 index 0000000000000..db487e74e47af --- /dev/null +++ b/tutorials/hist/hist039_TH2Poly_usa.py @@ -0,0 +1,68 @@ +# \file +# \ingroup tutorial_hist +# \notebook -js +# \preview This tutorial illustrates how to create an histogram with polygonal +# bins (TH2Poly), fill it and draw it using the `col` option. The initial data +# are stored in TMultiGraphs. They represent the USA map. Such histograms can +# be rendered in 3D using the option `legogl`. +# +# The initial data have been downloaded from: http://www.maproom.psu.edu/dcw/ +# This database was developed in 1991/1992 and national boundaries reflect +# political reality as of that time. +# +# \macro_code +# \macro_image +# +# \date February 2024 +# \author Olivier Couet + +import ROOT +import os.path +import urllib.request + +states = ["alabama", "arizona", "arkansas", "california", "colorado", "connecticut", "delaware", + "florida", "georgia", "idaho", "illinois", "indiana", "iowa", "kansas", + "kentucky", "louisiana", "maine", "maryland", "massachusetts", "michigan", "minnesota", + "mississippi", "missouri", "montana", "nebraska", "nevada", "new_hampshire", "new_jersey", + "new_mexico", "new_york", "north_carolina", "north_dakota", "ohio", "oklahoma", "oregon", + "pennsylvania", "rhode_island", "south_carolina", "south_dakota", "tennessee", "texas", "utah", + "vermont", "virginia", "washington", "west_virginia", "wisconsin", "wyoming"] + +pops = [4708708, 6595778, 2889450, 36961664, 5024748, 3518288, 885122, 18537969, 9829211, 1545801, + 12910409, 6423113, 3007856, 2818747, 4314113, 4492076, 1318301, 5699478, 6593587, 9969727, + 5266214, 2951996, 5987580, 974989, 1796619, 2643085, 1324575, 8707739, 2009671, 19541453, + 9380884, 646844, 11542645, 3687050, 3825657, 12604767, 1053209, 4561242, 812383, 6296254, + 24782302, 2784572, 621760, 7882590, 6664195, 1819777, 5654774, 544270] + +usa = ROOT.TCanvas("USA", "USA") +usa.ToggleEventStatus() +lon1 = -130 +lon2 = -65 +lat1 = 24 +lat2 = 50 +p = ROOT.TH2Poly("Lower48", "Lower 48 Population (2009);Latitude;Longitude", lon1, lon2, lat1, lat2) + +fileName = "usa.root" +fileNameUrl = "http://root.cern/files/usa.root" +if not os.path.isfile(fileName): + urllib.request.urlretrieve(fileNameUrl, fileName) +f = ROOT.TFile.Open(fileName) + +# Define the TH2Poly bins. +mg = ROOT.TMultiGraph +for key in f.GetListOfKeys(): + obj = key.ReadObj() + if (obj.InheritsFrom("TMultiGraph")): + p.AddBin(obj) + +# Fill TH2Poly, with capital letters for the states names +for state, pop in zip (states, pops): + p.Fill(state, pop) + +ROOT.gStyle.SetOptStat(0) +p.Draw("colz textn") + +# Add the reference for the population +pupulationRef = ROOT.TLatex(-128, 27, "#scale[.55]{#splitline{Source:}{http://eadiv.state.wy.us/pop/st-09est.htm}}") +pupulationRef.DrawClone() + diff --git a/tutorials/hist/th2polyUSA.C b/tutorials/hist/th2polyUSA.C index 5c089ee1820bf..234c7faf68d1a 100644 --- a/tutorials/hist/th2polyUSA.C +++ b/tutorials/hist/th2polyUSA.C @@ -1,7 +1,7 @@ /// \file /// \ingroup tutorial_hist /// \notebook -js -/// This tutorial illustrates how to create an histogram with polygonal +/// \preview This tutorial illustrates how to create an histogram with polygonal /// bins (TH2Poly), fill it and draw it using the `col` option. The initial data /// are stored in TMultiGraphs. They represent the USA map. Such histograms can /// be rendered in 3D using the option `legogl`. @@ -19,42 +19,37 @@ void th2polyUSA() { Int_t i, bin; const Int_t nx = 48; - const char *states [nx] = { - "alabama", "arizona", "arkansas", "california", - "colorado", "connecticut", "delaware", "florida", - "georgia", "idaho", "illinois", "indiana", - "iowa", "kansas", "kentucky", "louisiana", - "maine", "maryland", "massachusetts", "michigan", - "minnesota", "mississippi", "missouri", "montana", - "nebraska", "nevada", "new_hampshire", "new_jersey", - "new_mexico", "new_york", "north_carolina", "north_dakota", - "ohio", "oklahoma", "oregon", "pennsylvania", - "rhode_island", "south_carolina", "south_dakota", "tennessee", - "texas", "utah", "vermont", "virginia", - "washington", "west_virginia", "wisconsin", "wyoming" - }; - Double_t pop[nx] = { - 4708708, 6595778, 2889450, 36961664, 5024748, 3518288, 885122, 18537969, - 9829211, 1545801, 12910409, 6423113, 3007856, 2818747, 4314113, 4492076, - 1318301, 5699478, 6593587, 9969727, 5266214, 2951996, 5987580, 974989, - 1796619, 2643085, 1324575, 8707739, 2009671, 19541453, 9380884, 646844, - 11542645, 3687050, 3825657, 12604767, 1053209, 4561242, 812383, 6296254, - 24782302, 2784572, 621760, 7882590, 6664195, 1819777, 5654774, 544270 - }; + const char *states[nx] = { + "alabama", "arizona", "arkansas", "california", "colorado", "connecticut", "delaware", + "florida", "georgia", "idaho", "illinois", "indiana", "iowa", "kansas", + "kentucky", "louisiana", "maine", "maryland", "massachusetts", "michigan", "minnesota", + "mississippi", "missouri", "montana", "nebraska", "nevada", "new_hampshire", "new_jersey", + "new_mexico", "new_york", "north_carolina", "north_dakota", "ohio", "oklahoma", "oregon", + "pennsylvania", "rhode_island", "south_carolina", "south_dakota", "tennessee", "texas", "utah", + "vermont", "virginia", "washington", "west_virginia", "wisconsin", "wyoming"}; + Double_t pop[nx] = {4708708, 6595778, 2889450, 36961664, 5024748, 3518288, 885122, 18537969, 9829211, 1545801, + 12910409, 6423113, 3007856, 2818747, 4314113, 4492076, 1318301, 5699478, 6593587, 9969727, + 5266214, 2951996, 5987580, 974989, 1796619, 2643085, 1324575, 8707739, 2009671, 19541453, + 9380884, 646844, 11542645, 3687050, 3825657, 12604767, 1053209, 4561242, 812383, 6296254, + 24782302, 2784572, 621760, 7882590, 6664195, 1819777, 5654774, 544270}; - TCanvas *usa = new TCanvas("USA", "USA"); + auto usa = new TCanvas("USA", "USA"); usa->ToggleEventStatus(); Double_t lon1 = -130; Double_t lon2 = -65; Double_t lat1 = 24; Double_t lat2 = 50; - TH2Poly *p = new TH2Poly("Lower48","Lower 48 Population (2009);Latitude;Longitude",lon1,lon2,lat1,lat2); + auto p = new TH2Poly("Lower48", "Lower 48 Population (2009);Latitude;Longitude", lon1, lon2, lat1, lat2); - TFile::SetCacheFileDir("."); - TFile *f = TFile::Open("http://root.cern/files/usa.root", "CACHEREAD"); + const auto fileName = "usa.root"; + const auto fileNameUrl = "http://root.cern/files/usa.root"; + if(gSystem->AccessPathName(fileName)) + TFile::Cp(fileNameUrl, fileName); + + auto f = TFile::Open(fileName); if (!f) { - printf("Cannot access usa.root. Is internet working ?\n"); + printf("Cannot access %s. Is internet working ?\n", fileName); return; } @@ -62,16 +57,17 @@ void th2polyUSA() TMultiGraph *mg; TKey *key; TIter nextkey(gDirectory->GetListOfKeys()); - while ((key = (TKey*)nextkey())) { + while ((key = (TKey *)nextkey())) { TObject *obj = key->ReadObj(); if (obj->InheritsFrom("TMultiGraph")) { - mg = (TMultiGraph*)obj; + mg = (TMultiGraph *)obj; bin = p->AddBin(mg); } } // Fill TH2Poly, with capital letters for the states names - for (i=0; iFill(states[i], pop[i]); + for (i = 0; i < nx; i++) + p->Fill(states[i], pop[i]); gStyle->SetOptStat(0); p->Draw("colz textn"); diff --git a/tutorials/hist/th2polyEurope.C b/tutorials/legacy/th2polyEurope.C similarity index 100% rename from tutorials/hist/th2polyEurope.C rename to tutorials/legacy/th2polyEurope.C diff --git a/tutorials/multicore/imt001_parBranchProcessing.C b/tutorials/multicore/imt001_parBranchProcessing.C deleted file mode 100644 index ea185b9c06c48..0000000000000 --- a/tutorials/multicore/imt001_parBranchProcessing.C +++ /dev/null @@ -1,58 +0,0 @@ -/// \file -/// \ingroup tutorial_multicore -/// \notebook -/// Demonstrate how to activate and use the implicit parallelisation of TTree::GetEntry. -/// Such parallelisation creates one task per top-level branch of the tree being read. -/// In this example, most of the branches are floating point numbers, which are very fast to read. -/// This parallelisation can be used, though, on bigger trees with many (complex) branches, which -/// are more likely to benefit from speedup gains. -/// -/// \macro_code -/// -/// \date 26/09/2016 -/// \author Enric Tejedor - -int imt001_parBranchProcessing() -{ - // First enable implicit multi-threading globally, so that the implicit parallelisation is on. - // The parameter of the call specifies the number of threads to use. - int nthreads = 4; - ROOT::EnableImplicitMT(nthreads); - - // Open the file containing the tree - auto file = TFile::Open("http://root.cern/files/h1/dstarmb.root"); - - // Get the tree - auto tree = file->Get("h42"); - - const auto nEntries = tree->GetEntries(); - - // Read the branches in parallel. - // Note that the interface does not change, the parallelisation is internal - for (auto i : ROOT::TSeqUL(nEntries)) { - tree->GetEntry(i); // parallel read - } - - // IMT parallelisation can be disabled for a specific tree - tree->SetImplicitMT(false); - - // If now GetEntry is invoked on the tree, the reading is sequential - for (auto i : ROOT::TSeqUL(nEntries)) { - tree->GetEntry(i); // sequential read - } - - // Parallel reading can be re-enabled - tree->SetImplicitMT(true); - - // IMT can be also disabled globally. - // As a result, no tree will run GetEntry in parallel - ROOT::DisableImplicitMT(); - - // This is still sequential: the global flag is disabled, even if the - // flag for this particular tree is enabled - for (auto i : ROOT::TSeqUL(nEntries)) { - tree->GetEntry(i); // sequential read - } - - return 0; -} diff --git a/tutorials/multicore/mp103_processSelector.C b/tutorials/multicore/mp103_processSelector.C index 74e26d97e3a73..69fd366570767 100644 --- a/tutorials/multicore/mp103_processSelector.C +++ b/tutorials/multicore/mp103_processSelector.C @@ -19,11 +19,11 @@ #include -const auto file0 = "http://root.cern/files/h1/dstarmb.root"; +const auto file0 = "root://eospublic.cern.ch//eos/root-eos/h1/dstarmb.root"; const std::vector files = {file0, - "http://root.cern/files/h1/dstarp1a.root", - "http://root.cern/files/h1/dstarp1b.root", - "http://root.cern/files/h1/dstarp2.root"}; + "root://eospublic.cern.ch//eos/root-eos/h1/dstarp1a.root", + "root://eospublic.cern.ch//eos/root-eos/h1/dstarp1b.root", + "root://eospublic.cern.ch//eos/root-eos/h1/dstarp2.root"}; int mp103_processSelector() { diff --git a/tutorials/multicore/mp104_processH1.C b/tutorials/multicore/mp104_processH1.C index 066c68e9bf729..d4b7a0f7cab3c 100644 --- a/tutorials/multicore/mp104_processH1.C +++ b/tutorials/multicore/mp104_processH1.C @@ -31,10 +31,10 @@ static std::string tutname = "mp104_processH1: "; static std::string logfile = "mp104_processH1.log"; static RedirectHandle_t gRH; -std::vector files {"http://root.cern/files/h1/dstarmb.root", - "http://root.cern/files/h1/dstarp1a.root", - "http://root.cern/files/h1/dstarp1b.root", - "http://root.cern/files/h1/dstarp2.root"}; +std::vector files {"root://eospublic.cern.ch//eos/root-eos/h1/dstarmb.root", + "root://eospublic.cern.ch//eos/root-eos/h1/dstarp1a.root", + "root://eospublic.cern.ch//eos/root-eos/h1/dstarp1b.root", + "root://eospublic.cern.ch//eos/root-eos/h1/dstarp2.root"}; int mp104_processH1() { diff --git a/tutorials/quadp/portfolio.C b/tutorials/quadp/portfolio.C index 7ed61f018e84b..c7c0826ff900d 100644 --- a/tutorials/quadp/portfolio.C +++ b/tutorials/quadp/portfolio.C @@ -297,6 +297,7 @@ void portfolio() printf("accessing %s file from http://root.cern/files\n",fname); f = TFile::Open(Form("http://root.cern/files/%s",fname)); } + if (!f) return; TArrayF *data = new TArrayF[nrStocks]; diff --git a/tutorials/tree/run_h1analysis.C b/tutorials/tree/run_h1analysis.C index a64aeea1392c9..a5b42e92e4771 100644 --- a/tutorials/tree/run_h1analysis.C +++ b/tutorials/tree/run_h1analysis.C @@ -25,7 +25,7 @@ void run_h1analysis(int type = 0, const char * h1dir = 0) { gSystem->Setenv("H1",h1dir); } else - gSystem->Setenv("H1","http://root.cern/files/h1/"); + gSystem->Setenv("H1","root://eospublic.cern.ch//eos/root-eos/h1/"); std::cout << "Creating the chain" << std::endl;