/// \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 #include #include #include #include #include #include #include #include #include #include #include #include #include "TCut.h" #include "TEventList.h" #include #include #include #include #include int main(void) { Long64_t i ; TCut pCut ; // 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. ROOT::EnableImplicitMT(0); // Open the file containing the tree //TFile *file = TFile::Open("http://root.cern.ch/files/h1/dstarmb.root"); TFile *file = TFile::Open("Loc_210506_100k.root"); // 350 MB Large File //TTreeFormula::SetMaxima(10000, 10000, 10000) ; // with or without // Get the tree TTree *tree = nullptr; file->GetObject("dbT", tree); //tree->Print() ; // ==> Multithread //pCut = "(dbMinute==935) ||(dbMinute==940) ||(dbMinute==945) ||(dbMinute==950)"; // ==> Single-thread //pCut = "(dbMinute==935 && abs(dbLong-8.638614)<=0.000021 )"; // ==> Single-thread pCut = "(dbMinute==935 && abs(dbLong-8.638614)<=0.000021 && abs(dbLat-49.857365)<=0.000013)||(dbMinute==940 && abs(dbLong-8.639461)<=0.000021 && abs(dbLat-49.858223)<=0.000013)" ; gROOT->cd(); printf("\n tree->CopyTree START \n") ; TTree *stree = nullptr; stree = tree->CopyTree(pCut) ; printf(" tree->CopyTree END\n") ; // Read the branches in parallel. // Note that the interface does not change, the parallelisation is internal printf(" stree->GetEntry %lld START\n", stree->GetEntries()) ; for (i = 0; i < stree->GetEntries(); ++i) // { stree->GetEntry(i); // parallel read } printf(" stree->GetEntry END\n") ; return 0 ; }