Illustrate the usage of the multiproc to process TEntryList with the H1 analysis example.
Author: Gerardo Ganis
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, March 19, 2024 at 07:13 PM.
%%cpp -d
#include "TString.h"
#include "TROOT.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TEntryList.h"
#include "TTreeReader.h"
#include "TTreeReaderArray.h"
#include "TTreeReaderValue.h"
#include "TSystem.h"
#include "TMath.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TF1.h"
#include "TLine.h"
#include "TPaveStats.h"
#include "TStopwatch.h"
#include "ROOT/TTreeProcessorMP.hxx"
static std::string tutname = "mp105_processEntryList: ";
static std::string logfile = "mp105_processEntryList.log";
static RedirectHandle_t gRH;
std::vector<std::string> 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"};
MacOSX may generate connection to WindowServer errors
gROOT->SetBatch(kTRUE);
TStopwatch stp;
#include "mp_H1_lambdas.C"
ROOT::TTreeProcessorMP pool(3);
std::cout << tutname << "creating the entry list \n";
auto sumElist = pool.Process(files, doH1fillList, "h42");
input_line_44:6:10: fatal error: 'mp_H1_lambdas.C' file not found #include "mp_H1_lambdas.C" ^~~~~~~~~~~~~~~~~
Print the entry list
if (sumElist) {
sumElist->Print();
} else {
std::cout << tutname << " ERROR creating the entry list \n";
return -1;
}
input_line_54:2:3: error: use of undeclared identifier 'sumElist' (sumElist) ^ Error in <HandleInterpreterException>: Error evaluating expression (sumElist) Execution of your code was aborted.
Time taken
stp.Print();
stp.Start();
input_line_56:2:3: error: use of undeclared identifier 'stp' (stp.Print()) ^ Error in <HandleInterpreterException>: Error evaluating expression (stp.Print()) Execution of your code was aborted.
Let's analyse H1 with the list
std::cout << tutname << "processing the entry list with a lambda \n";
mp105_processEntryList: processing the entry list with a lambda
Run the analysis
auto hListFun = pool.Process(files, doH1useList, *sumElist, "h42");
input_line_58:2:2: error: Syntax error auto hListFun = pool.Process(files, doH1useList, *sumElist, "h42"); ^ FunctionDecl 0x7fbc0cc90980 <input_line_58:1:1, line:4:1> line:1:6 __cling_Un1Qu325 'void (void *)' |-ParmVarDecl 0x7fbc0cc908c8 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7fbc0cc911f0 <col:43, line:4:1> | |-DeclStmt 0x7fbc0cc911d0 <line:2:2, col:68> | | `-VarDecl 0x7fbc0cc90a98 <col:2, col:67> col:7 hListFun 'auto' cinit | | `-CallExpr 0x7fbc0cc91190 <col:18, col:67> '<dependent type>' | | |-CXXDependentScopeMemberExpr 0x7fbc0cc90c50 <col:18, col:23> '<dependent type>' lvalue .Process | | | `-DeclRefExpr 0x7fbc0cc90c10 <col:18> '<dependent type>' lvalue Var 0x7fbc0cc90b08 'pool' '<dependent type>' | | |-DeclRefExpr 0x7fbc0cc90c98 <col:31> 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' lvalue Var 0x7aa2cd0 'files' 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' | | |-DeclRefExpr 0x7fbc0cc90d90 <col:38> '<dependent type>' lvalue Var 0x7fbc0cc90cc0 'doH1useList' '<dependent type>' | | |-CXXOperatorCallExpr 0x7fbc0cc91140 <col:51, col:52> '<dependent type>' '*' | | | |-UnresolvedLookupExpr 0x7fbc0cc90ef0 <col:51> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x4fa34a0 0x57732b0 0x57737a8 0x5773ca8 0x5774270 0x5774840 0x5774e10 0x50b0198 0x50b0698 0x50d2708 0x50d2cd0 0x50d32a0 0x50d3870 0x50d3d78 0x5775420 0x57759a0 0x5775fb0 0x57765c0 0x5776bd0 0x5777118 0x5112198 0x51126b0 0x5113400 0x5113e38 0x5114350 0x51150a0 0x5115ae8 0x5116000 0x5116d50 0x5117798 0x5117cb0 0x5118a00 0x5119240 0x5119760 0x511a4b0 0x511acf0 0x511b210 0x511bf60 0x51bdda0 0x51be1c0 0x51be5e0 0x541d190 0x541c970 0x541cd80 0x54206c0 0x5420950 0x5420bd8 0x5420e58 0x544eaf8 0x545bd70 0x545d6f0 0x7fbc0c56dd78 0x7fbc0c572378 0x7fbc0c572ec0 0x7fbc0c579810 0x451fe98 0x4520450 0x4520988 0x4a38218 0x4a38eb0 0x4a39918 0x4a3a378 0x4a3ae68 0x4ae5cd0 0x4ae6730 0x4ae7130 | | | `-DeclRefExpr 0x7fbc0cc90eb0 <col:52> '<dependent type>' lvalue Var 0x7fbc0cc90dd8 'sumElist' '<dependent type>' | | `-StringLiteral 0x7fbc0cc91170 <col:62> 'const char[4]' lvalue "h42" | `-NullStmt 0x7fbc0cc911e8 <line:3:1> |-AnnotateAttr 0x7fbc0cc90b70 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7fbc0cc90d28 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7fbc0cc90e40 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
Check the output
if (checkH1(hListFun) < 0)
return -1;
input_line_60:2:11: error: use of undeclared identifier 'hListFun' (checkH1(hListFun) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (checkH1(hListFun) < 0) Execution of your code was aborted.
Do the fit
if (doFit(hListFun, logfile.c_str()) < 0)
return -1;
stp.Print();
stp.Start();
input_line_62:2:9: error: use of undeclared identifier 'hListFun' (doFit(hListFun, ((*(std::string*)0x7fbc2829e020)).c_str()) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListFun, ((*(std::string*)0x7fbc2829e020)).c_str()) < 0) Execution of your code was aborted.
Run the analysis with a selector
TString selectorPath = gROOT->GetTutorialDir();
selectorPath += "/tree/h1analysisTreeReader.C+";
std::cout << tutname << "processing the entry list with selector '" << selectorPath << "'\n";
auto sel = TSelector::GetSelector(selectorPath);
mp105_processEntryList: processing the entry list with selector '/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree/h1analysisTreeReader.C+'
In a second run we use sel
sel->SetOption("useList");
gSystem->RedirectOutput(logfile.c_str(), "w", &gRH);
auto hListSel = pool.Process(files, *sel, *sumElist, "h42");
gSystem->RedirectOutput(nullptr, nullptr, &gRH);
input_line_67:4:1: error: Syntax error auto hListSel = pool.Process(files, *sel, *sumElist, "h42"); ^ FunctionDecl 0x7fbc041e42f0 <input_line_67:1:1, line:7:1> line:1:6 __cling_Un1Qu331 'void (void *)' |-ParmVarDecl 0x7fbc041e4238 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7fbc041e4f68 <col:43, line:7:1> | |-CXXMemberCallExpr 0x7fbc041e4548 <line:2:2, col:26> 'void' | | |-MemberExpr 0x7fbc041e43f8 <col:2, col:7> '<bound member function type>' ->SetOption 0x7fbc0feabb68 | | | `-ImplicitCastExpr 0x7fbc041e43e0 <col:2> 'TSelector *':'TSelector *' <LValueToRValue> | | | `-DeclRefExpr 0x7fbc041e43c0 <col:2> 'TSelector *':'TSelector *' lvalue Var 0x7fbc0dee0b58 'sel' 'TSelector *':'TSelector *' | | `-ImplicitCastExpr 0x7fbc041e4570 <col:17> 'const char *' <ArrayToPointerDecay> | | `-StringLiteral 0x7fbc041e4528 <col:17> 'const char[8]' lvalue "useList" | |-CXXMemberCallExpr 0x7fbc041e4728 <line:3:1, col:51> 'Int_t':'int' | | |-MemberExpr 0x7fbc041e45c0 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x61366f8 | | | `-ImplicitCastExpr 0x7fbc041e45a8 <col:1> 'TSystem *' <LValueToRValue> | | | `-DeclRefExpr 0x7fbc041e4588 <col:1> 'TSystem *' lvalue Var 0x4e01e00 'gSystem' 'TSystem *' | | |-CXXMemberCallExpr 0x7fbc041e4640 <col:25, col:39> 'const char *' | | | `-MemberExpr 0x7fbc041e4610 <col:25, col:33> '<bound member function type>' .c_str 0x7fbc0ded2308 | | | `-ImplicitCastExpr 0x7fbc041e4660 <col:25> 'const std::basic_string<char>' lvalue <NoOp> | | | `-DeclRefExpr 0x7fbc041e45f0 <col:25> 'std::string':'std::basic_string<char>' lvalue Var 0x7aa10e0 'logfile' 'std::string':'std::basic_string<char>' | | |-ImplicitCastExpr 0x7fbc041e4760 <col:42> 'const char *' <ArrayToPointerDecay> | | | `-StringLiteral 0x7fbc041e4678 <col:42> 'const char[2]' lvalue "w" | | `-UnaryOperator 0x7fbc041e46b8 <col:47, col:48> 'RedirectHandle_t *' prefix '&' cannot overflow | | `-DeclRefExpr 0x7fbc041e4698 <col:48> 'RedirectHandle_t':'RedirectHandle_t' lvalue Var 0x7aa1300 'gRH' 'RedirectHandle_t':'RedirectHandle_t' | |-DeclStmt 0x7fbc041e4e20 <line:4:1, col:60> | | `-VarDecl 0x7fbc041e47c0 <col:1, col:59> col:6 hListSel 'auto' cinit | | `-CallExpr 0x7fbc041e4de0 <col:17, col:59> '<dependent type>' | | |-CXXDependentScopeMemberExpr 0x7fbc041e4970 <col:17, col:22> '<dependent type>' lvalue .Process | | | `-DeclRefExpr 0x7fbc041e4930 <col:17> '<dependent type>' lvalue Var 0x7fbc041e4830 'pool' '<dependent type>' | | |-DeclRefExpr 0x7fbc041e49b8 <col:30> 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' lvalue Var 0x7aa2cd0 'files' 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' | | |-UnaryOperator 0x7fbc041e4a10 <col:37, col:38> 'TSelector':'TSelector' lvalue prefix '*' cannot overflow | | | `-ImplicitCastExpr 0x7fbc041e49f8 <col:38> 'TSelector *':'TSelector *' <LValueToRValue> | | | `-DeclRefExpr 0x7fbc041e49d8 <col:38> 'TSelector *':'TSelector *' lvalue Var 0x7fbc0dee0b58 'sel' 'TSelector *':'TSelector *' | | |-CXXOperatorCallExpr 0x7fbc041e4d90 <col:43, col:44> '<dependent type>' '*' | | | |-UnresolvedLookupExpr 0x7fbc041e4b40 <col:43> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x4fa34a0 0x57732b0 0x57737a8 0x5773ca8 0x5774270 0x5774840 0x5774e10 0x50b0198 0x50b0698 0x50d2708 0x50d2cd0 0x50d32a0 0x50d3870 0x50d3d78 0x5775420 0x57759a0 0x5775fb0 0x57765c0 0x5776bd0 0x5777118 0x5112198 0x51126b0 0x5113400 0x5113e38 0x5114350 0x51150a0 0x5115ae8 0x5116000 0x5116d50 0x5117798 0x5117cb0 0x5118a00 0x5119240 0x5119760 0x511a4b0 0x511acf0 0x511b210 0x511bf60 0x51bdda0 0x51be1c0 0x51be5e0 0x541d190 0x541c970 0x541cd80 0x54206c0 0x5420950 0x5420bd8 0x5420e58 0x544eaf8 0x545bd70 0x545d6f0 0x7fbc0c56dd78 0x7fbc0c572378 0x7fbc0c572ec0 0x7fbc0c579810 0x451fe98 0x4520450 0x4520988 0x4a38218 0x4a38eb0 0x4a39918 0x4a3a378 0x4a3ae68 0x4ae5cd0 0x4ae6730 0x4ae7130 | | | `-DeclRefExpr 0x7fbc041e4b00 <col:44> '<dependent type>' lvalue Var 0x7fbc041e4a30 'sumElist' '<dependent type>' | | `-StringLiteral 0x7fbc041e4dc0 <col:54> 'const char[4]' lvalue "h42" | |-CXXMemberCallExpr 0x7fbc041e4ef8 <line:5:1, col:47> 'Int_t':'int' | | |-MemberExpr 0x7fbc041e4e70 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x61366f8 | | | `-ImplicitCastExpr 0x7fbc041e4e58 <col:1> 'TSystem *' <LValueToRValue> | | | `-DeclRefExpr 0x7fbc041e4e38 <col:1> 'TSystem *' lvalue Var 0x4e01e00 'gSystem' 'TSystem *' | | |-ImplicitCastExpr 0x7fbc041e4f30 <col:25> 'const char *' <NullToPointer> | | | `-CXXNullPtrLiteralExpr 0x7fbc041e4ea0 <col:25> 'std::nullptr_t' | | |-ImplicitCastExpr 0x7fbc041e4f48 <col:34> 'const char *' <NullToPointer> | | | `-CXXNullPtrLiteralExpr 0x7fbc041e4eb0 <col:34> 'std::nullptr_t' | | `-UnaryOperator 0x7fbc041e4ee0 <col:43, col:44> 'RedirectHandle_t *' prefix '&' cannot overflow | | `-DeclRefExpr 0x7fbc041e4ec0 <col:44> 'RedirectHandle_t':'RedirectHandle_t' lvalue Var 0x7aa1300 'gRH' 'RedirectHandle_t':'RedirectHandle_t' | `-NullStmt 0x7fbc041e4f60 <line:6:1> |-AnnotateAttr 0x7fbc041e4898 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7fbc041e4a98 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
Check the output
if (checkH1(hListSel) < 0)
return -1;
input_line_69:2:11: error: use of undeclared identifier 'hListSel' (checkH1(hListSel) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (checkH1(hListSel) < 0) Execution of your code was aborted.
Do the fit
if (doFit(hListSel, logfile.c_str()) < 0)
return -1;
stp.Print();
stp.Start();
return 0;
input_line_71:2:9: error: use of undeclared identifier 'hListSel' (doFit(hListSel, ((*(std::string*)0x7fbc2829e020)).c_str()) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListSel, ((*(std::string*)0x7fbc2829e020)).c_str()) < 0) Execution of your code was aborted.