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 Wednesday, April 17, 2024 at 11:15 AM.
%%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 0x7f3fe0c8a7c0 <input_line_58:1:1, line:4:1> line:1:6 __cling_Un1Qu325 'void (void *)' |-ParmVarDecl 0x7f3fe0c8a708 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f3fe0c8b030 <col:43, line:4:1> | |-DeclStmt 0x7f3fe0c8b010 <line:2:2, col:68> | | `-VarDecl 0x7f3fe0c8a8d8 <col:2, col:67> col:7 hListFun 'auto' cinit | | `-CallExpr 0x7f3fe0c8afd0 <col:18, col:67> '<dependent type>' | | |-CXXDependentScopeMemberExpr 0x7f3fe0c8aa90 <col:18, col:23> '<dependent type>' lvalue .Process | | | `-DeclRefExpr 0x7f3fe0c8aa50 <col:18> '<dependent type>' lvalue Var 0x7f3fe0c8a948 'pool' '<dependent type>' | | |-DeclRefExpr 0x7f3fe0c8aad8 <col:31> 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' lvalue Var 0x8c9f070 'files' 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' | | |-DeclRefExpr 0x7f3fe0c8abd0 <col:38> '<dependent type>' lvalue Var 0x7f3fe0c8ab00 'doH1useList' '<dependent type>' | | |-CXXOperatorCallExpr 0x7f3fe0c8af80 <col:51, col:52> '<dependent type>' '*' | | | |-UnresolvedLookupExpr 0x7f3fe0c8ad30 <col:51> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x6232ac0 0x69f6cf0 0x69f71e8 0x69f76e8 0x69f7cb0 0x69f8280 0x69f8850 0x63416d8 0x6341bd8 0x634e738 0x634ed00 0x634f2d0 0x634f8a0 0x634fda8 0x69f8e60 0x69f93e0 0x69f99f0 0x69fa000 0x69fa610 0x69fab58 0x63b7cd8 0x63b81f0 0x63b8f40 0x63b9978 0x63b9e90 0x63babe0 0x63bb628 0x63bbb40 0x63bc890 0x63bd2d8 0x63bd7f0 0x63be540 0x63bed80 0x63bf2a0 0x63bfff0 0x63c0830 0x63c0d50 0x63c1aa0 0x643cb90 0x643cfb0 0x643d3d0 0x6690d40 0x6690520 0x6690930 0x6694250 0x66944e0 0x6694768 0x66949e8 0x66c32a8 0x66d0520 0x66de820 0x7f3fe0575568 0x7f3fe0579b68 0x7f3fe057a6b0 0x7f3fe0581000 0x57a1538 0x57a1af0 0x57a2028 0x5cb15c8 0x5cb2260 0x5cb2cc8 0x5cb3728 0x5cb4218 0x5d6a5d0 0x5d6b030 0x5d6ba30 | | | `-DeclRefExpr 0x7f3fe0c8acf0 <col:52> '<dependent type>' lvalue Var 0x7f3fe0c8ac18 'sumElist' '<dependent type>' | | `-StringLiteral 0x7f3fe0c8afb0 <col:62> 'const char[4]' lvalue "h42" | `-NullStmt 0x7f3fe0c8b028 <line:3:1> |-AnnotateAttr 0x7f3fe0c8a9b0 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f3fe0c8ab68 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f3fe0c8ac80 <<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*)0x7f3ffc00a020)).c_str()) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListFun, ((*(std::string*)0x7f3ffc00a020)).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+'
Info in <TUnixSystem::ACLiC>: creating shared library /home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree/h1analysisTreeReader_C.so c++: error: /home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree/h1analysisTreeReader_C_ACLiC_dict.o: No such file or directory Error in <ACLiC>: Executing 'cd "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree" ; c++ -fPIC -c -O3 -DNDEBUG -fdiagnostics-color=always -Wno-implicit-fallthrough -Wno-noexcept-type -pipe -W -Woverloaded-virtual -fsigned-char -pthread -std=c++17 -I$ROOTSYS/include -I"/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/etc/" -I"/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/etc//cling" -I"/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/etc//cling/plugins/include" -I"/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/" -I"/usr/include/python3.8" -D__ACLIC__ "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree/h1analysisTreeReader_C_ACLiC_dict.cxx" ; c++ -O3 -DNDEBUG "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree/h1analysisTreeReader_C_ACLiC_dict.o" -shared -rdynamic "/lib/x86_64-linux-gnu/libz.so" "/lib/x86_64-linux-gnu/libexpat.so" "/lib/x86_64-linux-gnu/libm.so" "/lib/x86_64-linux-gnu/libutil.so" "/lib/x86_64-linux-gnu/libdl.so" "/lib/x86_64-linux-gnu/libpthread.so" "/lib/x86_64-linux-gnu/libc.so" "/usr/lib/python3.8/lib-dynload/_bz2.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_lzma.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_hashlib.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_opcode.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_json.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_queue.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/termios.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/resource.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_ssl.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_contextvars.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_asyncio.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_lsprof.cpython-38-x86_64-linux-gnu.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libcppyy_backend.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libCore.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libRIO.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libThread.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libCling.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libcppyy.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libROOTPythonizations.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libTree.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libImt.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libNet.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libMultiProc.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libJupyROOT.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/_device.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/../../../pyzmq.libs/libzmq-bf11ef0c.so.5.2.4" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/../../../pyzmq.libs/libsodium-6eb86948.so.23.3.0" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/context.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/socket.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/message.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/_poll.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/_proxy_steerable.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/_version.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/error.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/zmq/backend/cython/utils.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/tornado/speedups.abi3.so" "/usr/lib/python3.8/lib-dynload/_curses.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_decimal.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_uuid.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/netifaces.cpython-38-x86_64-linux-gnu.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libRint.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libROOTGpadv7.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libGeom.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libMathCore.so" -o "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/tutorials/tree/h1analysisTreeReader_C.so"' failed!
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 0x7f3fd8276930 <input_line_67:1:1, line:7:1> line:1:6 __cling_Un1Qu331 'void (void *)' |-ParmVarDecl 0x7f3fd8276878 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f3fd82775a8 <col:43, line:7:1> | |-CXXMemberCallExpr 0x7f3fd8276b88 <line:2:2, col:26> 'void' | | |-MemberExpr 0x7f3fd8276a38 <col:2, col:7> '<bound member function type>' ->SetOption 0x7f3fe22779b8 | | | `-ImplicitCastExpr 0x7f3fd8276a20 <col:2> 'TSelector *':'TSelector *' <LValueToRValue> | | | `-DeclRefExpr 0x7f3fd8276a00 <col:2> 'TSelector *':'TSelector *' lvalue Var 0x7f3fe1eebbe8 'sel' 'TSelector *':'TSelector *' | | `-ImplicitCastExpr 0x7f3fd8276bb0 <col:17> 'const char *' <ArrayToPointerDecay> | | `-StringLiteral 0x7f3fd8276b68 <col:17> 'const char[8]' lvalue "useList" | |-CXXMemberCallExpr 0x7f3fd8276d68 <line:3:1, col:51> 'Int_t':'int' | | |-MemberExpr 0x7f3fd8276c00 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x73ff9f8 | | | `-ImplicitCastExpr 0x7f3fd8276be8 <col:1> 'TSystem *' <LValueToRValue> | | | `-DeclRefExpr 0x7f3fd8276bc8 <col:1> 'TSystem *' lvalue Var 0x60718c0 'gSystem' 'TSystem *' | | |-CXXMemberCallExpr 0x7f3fd8276c80 <col:25, col:39> 'const char *' | | | `-MemberExpr 0x7f3fd8276c50 <col:25, col:33> '<bound member function type>' .c_str 0x7f3fe1edd398 | | | `-ImplicitCastExpr 0x7f3fd8276ca0 <col:25> 'const std::basic_string<char>' lvalue <NoOp> | | | `-DeclRefExpr 0x7f3fd8276c30 <col:25> 'std::string':'std::basic_string<char>' lvalue Var 0x8c9d480 'logfile' 'std::string':'std::basic_string<char>' | | |-ImplicitCastExpr 0x7f3fd8276da0 <col:42> 'const char *' <ArrayToPointerDecay> | | | `-StringLiteral 0x7f3fd8276cb8 <col:42> 'const char[2]' lvalue "w" | | `-UnaryOperator 0x7f3fd8276cf8 <col:47, col:48> 'RedirectHandle_t *' prefix '&' cannot overflow | | `-DeclRefExpr 0x7f3fd8276cd8 <col:48> 'RedirectHandle_t':'RedirectHandle_t' lvalue Var 0x8c9d6a0 'gRH' 'RedirectHandle_t':'RedirectHandle_t' | |-DeclStmt 0x7f3fd8277460 <line:4:1, col:60> | | `-VarDecl 0x7f3fd8276e00 <col:1, col:59> col:6 hListSel 'auto' cinit | | `-CallExpr 0x7f3fd8277420 <col:17, col:59> '<dependent type>' | | |-CXXDependentScopeMemberExpr 0x7f3fd8276fb0 <col:17, col:22> '<dependent type>' lvalue .Process | | | `-DeclRefExpr 0x7f3fd8276f70 <col:17> '<dependent type>' lvalue Var 0x7f3fd8276e70 'pool' '<dependent type>' | | |-DeclRefExpr 0x7f3fd8276ff8 <col:30> 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' lvalue Var 0x8c9f070 'files' 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' | | |-UnaryOperator 0x7f3fd8277050 <col:37, col:38> 'TSelector':'TSelector' lvalue prefix '*' cannot overflow | | | `-ImplicitCastExpr 0x7f3fd8277038 <col:38> 'TSelector *':'TSelector *' <LValueToRValue> | | | `-DeclRefExpr 0x7f3fd8277018 <col:38> 'TSelector *':'TSelector *' lvalue Var 0x7f3fe1eebbe8 'sel' 'TSelector *':'TSelector *' | | |-CXXOperatorCallExpr 0x7f3fd82773d0 <col:43, col:44> '<dependent type>' '*' | | | |-UnresolvedLookupExpr 0x7f3fd8277180 <col:43> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x6232ac0 0x69f6cf0 0x69f71e8 0x69f76e8 0x69f7cb0 0x69f8280 0x69f8850 0x63416d8 0x6341bd8 0x634e738 0x634ed00 0x634f2d0 0x634f8a0 0x634fda8 0x69f8e60 0x69f93e0 0x69f99f0 0x69fa000 0x69fa610 0x69fab58 0x63b7cd8 0x63b81f0 0x63b8f40 0x63b9978 0x63b9e90 0x63babe0 0x63bb628 0x63bbb40 0x63bc890 0x63bd2d8 0x63bd7f0 0x63be540 0x63bed80 0x63bf2a0 0x63bfff0 0x63c0830 0x63c0d50 0x63c1aa0 0x643cb90 0x643cfb0 0x643d3d0 0x6690d40 0x6690520 0x6690930 0x6694250 0x66944e0 0x6694768 0x66949e8 0x66c32a8 0x66d0520 0x66de820 0x7f3fe0575568 0x7f3fe0579b68 0x7f3fe057a6b0 0x7f3fe0581000 0x57a1538 0x57a1af0 0x57a2028 0x5cb15c8 0x5cb2260 0x5cb2cc8 0x5cb3728 0x5cb4218 0x5d6a5d0 0x5d6b030 0x5d6ba30 | | | `-DeclRefExpr 0x7f3fd8277140 <col:44> '<dependent type>' lvalue Var 0x7f3fd8277070 'sumElist' '<dependent type>' | | `-StringLiteral 0x7f3fd8277400 <col:54> 'const char[4]' lvalue "h42" | |-CXXMemberCallExpr 0x7f3fd8277538 <line:5:1, col:47> 'Int_t':'int' | | |-MemberExpr 0x7f3fd82774b0 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x73ff9f8 | | | `-ImplicitCastExpr 0x7f3fd8277498 <col:1> 'TSystem *' <LValueToRValue> | | | `-DeclRefExpr 0x7f3fd8277478 <col:1> 'TSystem *' lvalue Var 0x60718c0 'gSystem' 'TSystem *' | | |-ImplicitCastExpr 0x7f3fd8277570 <col:25> 'const char *' <NullToPointer> | | | `-CXXNullPtrLiteralExpr 0x7f3fd82774e0 <col:25> 'std::nullptr_t' | | |-ImplicitCastExpr 0x7f3fd8277588 <col:34> 'const char *' <NullToPointer> | | | `-CXXNullPtrLiteralExpr 0x7f3fd82774f0 <col:34> 'std::nullptr_t' | | `-UnaryOperator 0x7f3fd8277520 <col:43, col:44> 'RedirectHandle_t *' prefix '&' cannot overflow | | `-DeclRefExpr 0x7f3fd8277500 <col:44> 'RedirectHandle_t':'RedirectHandle_t' lvalue Var 0x8c9d6a0 'gRH' 'RedirectHandle_t':'RedirectHandle_t' | `-NullStmt 0x7f3fd82775a0 <line:6:1> |-AnnotateAttr 0x7f3fd8276ed8 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f3fd82770d8 <<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*)0x7f3ffc00a020)).c_str()) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListSel, ((*(std::string*)0x7f3ffc00a020)).c_str()) < 0) Execution of your code was aborted.