mp105_processEntryList

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 Sunday, October 02, 2022 at 09:33 AM.

In [1]:
%%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.ch/files/h1/dstarmb.root",
                                  "http://root.cern.ch/files/h1/dstarp1a.root",
                                  "http://root.cern.ch/files/h1/dstarp1b.root",
                                  "http://root.cern.ch/files/h1/dstarp2.root"};

MacOSX may generate connection to WindowServer errors

In [2]:
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_43:6:10: fatal error: 'mp_H1_lambdas.C' file not found
#include "mp_H1_lambdas.C"
         ^~~~~~~~~~~~~~~~~

Print the entry list

In [3]:
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

In [4]:
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

In [5]:
std::cout << tutname << "processing the entry list with a lambda \n";
mp105_processEntryList: processing the entry list with a lambda 

Run the analysis

In [6]:
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 0x7f075d67e900 <input_line_58:1:1, line:4:1> line:1:6 __cling_Un1Qu326 'void (void *)'
|-ParmVarDecl 0x7f075d67e848 <col:23, col:29> col:29 vpClingValue 'void *'
|-CompoundStmt 0x7f075d67f048 <col:43, line:4:1>
| |-DeclStmt 0x7f075d67f028 <line:2:2, col:68>
| | `-VarDecl 0x7f075d67e9e0 <col:2, col:67> col:7 hListFun 'auto' cinit
| |   `-CallExpr 0x7f075d67efe8 <col:18, col:67> '<dependent type>'
| |     |-CXXDependentScopeMemberExpr 0x7f075d67eb58 <col:18, col:23> '<dependent type>' lvalue .Process
| |     | `-DeclRefExpr 0x7f075d67eb18 <col:18> '<dependent type>' lvalue Var 0x7f075d67ea50 'pool' '<dependent type>'
| |     |-DeclRefExpr 0x7f075d67eba0 <col:31> 'std::vector<std::string>':'std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >' lvalue Var 0x60f5930 'files' 'std::vector<std::string>':'std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >'
| |     |-DeclRefExpr 0x7f075d67ec60 <col:38> '<dependent type>' lvalue Var 0x7f075d67ebc8 'doH1useList' '<dependent type>'
| |     |-CXXOperatorCallExpr 0x7f075d67ef98 <col:51, col:52> '<dependent type>'
| |     | |-UnresolvedLookupExpr 0x7f075d67ed80 <col:51> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x4486690 0x4add1c8 0x4add680 0x4addb30 0x4ade088 0x4ade5e8 0x4adeb48 0x462ccd0 0x462d180 0x4639050 0x46395a8 0x4639b08 0x463a068 0x463a520 0x4adf0e8 0x4adf618 0x4adfbb8 0x4ae0158 0x4ae06f8 0x4ae0bf0 0x466f428 0x466f8b0 0x4670510 0x4670e88 0x4671310 0x4671f70 0x46728f8 0x4672d80 0x46739e0 0x46741a0 0x4674630 0x4675290 0x4675a50 0x4675ee0 0x4676b40 0x46fdd10 0x46fe100 0x46fe4f0 0x498bcd0 0x498b510 0x498b8f0 0x498ee08 0x498f070 0x498f2d0 0x498f530 0x49ac8a8 0x2b8b7b8 0x2b8cee8 0x3b47310 0x3b47868 0x3b47d50 0x4013350 0x4019920 0x401a350 0x401ad80 0x401b820 0x40c0028 0x40c0a38 0x40c1418
| |     | `-DeclRefExpr 0x7f075d67ed40 <col:52> '<dependent type>' lvalue Var 0x7f075d67eca8 'sumElist' '<dependent type>'
| |     `-StringLiteral 0x7f075d67efc8 <col:62> 'const char [4]' lvalue "h42"
| `-NullStmt 0x7f075d67f040 <line:3:1>
|-AnnotateAttr 0x7f075d67eab8 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
|-AnnotateAttr 0x7f075d67ec30 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
`-AnnotateAttr 0x7f075d67ed10 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
<<<NULL>>>

Check the output

In [7]:
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

In [8]:
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*)0x7f078a852060)).c_str()) < 0)
        ^
Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListFun, ((*(std::string*)0x7f078a852060)).c_str()) < 0)
Execution of your code was aborted.

Run the analysis with a selector

In [9]:
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 -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe -W -Woverloaded-virtual -fsigned-char -pthread  -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   "/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/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/_queue.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/libcppyy3_8.so" "/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/lib/libcppyy_backend3_8.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/libROOTPythonizations3_8.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/libJupyROOT3_8.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/constants.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/error.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/message.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/context.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/socket.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/utils.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/_poll.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/_version.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/_device.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/zmq/backend/cython/_proxy_steerable.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_decimal.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3/dist-packages/simplejson/_speedups.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_uuid.cpython-38-x86_64-linux-gnu.so" "/usr/local/lib/python3.8/dist-packages/tornado/speedups.cpython-38-x86_64-linux-gnu.so" "/usr/lib/python3.8/lib-dynload/_curses.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

In [10]:
sel->SetOption("useList");
gSystem->RedirectOutput(logfile.c_str(), "w", &gRH);
auto hListSel = pool.Process(files, *sel, *sumElist, "h42");
gSystem->RedirectOutput(0, 0, &gRH);
input_line_67:4:1: error: Syntax error
auto hListSel = pool.Process(files, *sel, *sumElist, "h42");
^
FunctionDecl 0x7f07545d44b0 <input_line_67:1:1, line:7:1> line:1:6 __cling_Un1Qu332 'void (void *)'
|-ParmVarDecl 0x7f07545d43f8 <col:23, col:29> col:29 vpClingValue 'void *'
|-CompoundStmt 0x7f07545d5010 <col:43, line:7:1>
| |-CXXMemberCallExpr 0x7f07545d4700 <line:2:2, col:26> 'void'
| | |-MemberExpr 0x7f07545d45b0 <col:2, col:7> '<bound member function type>' ->SetOption 0x7f075e6dafd8
| | | `-ImplicitCastExpr 0x7f07545d4598 <col:2> 'TSelector *':'TSelector *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f07545d4578 <col:2> 'TSelector *':'TSelector *' lvalue Var 0x7f075e6c1050 'sel' 'TSelector *':'TSelector *'
| | `-ImplicitCastExpr 0x7f07545d4728 <col:17> 'const char *' <ArrayToPointerDecay>
| |   `-StringLiteral 0x7f07545d46e0 <col:17> 'const char [8]' lvalue "useList"
| |-CXXMemberCallExpr 0x7f07545d4888 <line:3:1, col:51> 'Int_t':'int'
| | |-MemberExpr 0x7f07545d4778 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x5042330
| | | `-ImplicitCastExpr 0x7f07545d4760 <col:1> 'TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f07545d4740 <col:1> 'TSystem *' lvalue Var 0x43881b0 'gSystem' 'TSystem *'
| | |-CXXMemberCallExpr 0x7f07545d47f8 <col:25, col:39> 'const char *'
| | | `-MemberExpr 0x7f07545d47c8 <col:25, col:33> '<bound member function type>' .c_str 0x7f075e310ce0
| | |   `-ImplicitCastExpr 0x7f07545d4818 <col:25> 'const std::__cxx11::basic_string<char>' lvalue <NoOp>
| | |     `-DeclRefExpr 0x7f07545d47a8 <col:25> 'std::string':'std::__cxx11::basic_string<char>' lvalue Var 0x60f4440 'logfile' 'std::string':'std::__cxx11::basic_string<char>'
| | |-ImplicitCastExpr 0x7f07545d48c0 <col:42> 'const char *' <ArrayToPointerDecay>
| | | `-StringLiteral 0x7f07545d4830 <col:42> 'const char [2]' lvalue "w"
| | `-UnaryOperator 0x7f07545d4870 <col:47, col:48> 'RedirectHandle_t *' prefix '&' cannot overflow
| |   `-DeclRefExpr 0x7f07545d4850 <col:48> 'RedirectHandle_t' lvalue Var 0x60f4638 'gRH' 'RedirectHandle_t'
| |-DeclStmt 0x7f07545d4ea8 <line:4:1, col:60>
| | `-VarDecl 0x7f07545d48f0 <col:1, col:59> col:6 hListSel 'auto' cinit
| |   `-CallExpr 0x7f07545d4e68 <col:17, col:59> '<dependent type>'
| |     |-CXXDependentScopeMemberExpr 0x7f07545d4a68 <col:17, col:22> '<dependent type>' lvalue .Process
| |     | `-DeclRefExpr 0x7f07545d4a28 <col:17> '<dependent type>' lvalue Var 0x7f07545d4960 'pool' '<dependent type>'
| |     |-DeclRefExpr 0x7f07545d4ab0 <col:30> 'std::vector<std::string>':'std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >' lvalue Var 0x60f5930 'files' 'std::vector<std::string>':'std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >'
| |     |-UnaryOperator 0x7f07545d4b08 <col:37, col:38> 'TSelector' lvalue prefix '*' cannot overflow
| |     | `-ImplicitCastExpr 0x7f07545d4af0 <col:38> 'TSelector *':'TSelector *' <LValueToRValue>
| |     |   `-DeclRefExpr 0x7f07545d4ad0 <col:38> 'TSelector *':'TSelector *' lvalue Var 0x7f075e6c1050 'sel' 'TSelector *':'TSelector *'
| |     |-CXXOperatorCallExpr 0x7f07545d4e18 <col:43, col:44> '<dependent type>'
| |     | |-UnresolvedLookupExpr 0x7f07545d4c00 <col:43> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x4486690 0x4add1c8 0x4add680 0x4addb30 0x4ade088 0x4ade5e8 0x4adeb48 0x462ccd0 0x462d180 0x4639050 0x46395a8 0x4639b08 0x463a068 0x463a520 0x4adf0e8 0x4adf618 0x4adfbb8 0x4ae0158 0x4ae06f8 0x4ae0bf0 0x466f428 0x466f8b0 0x4670510 0x4670e88 0x4671310 0x4671f70 0x46728f8 0x4672d80 0x46739e0 0x46741a0 0x4674630 0x4675290 0x4675a50 0x4675ee0 0x4676b40 0x46fdd10 0x46fe100 0x46fe4f0 0x498bcd0 0x498b510 0x498b8f0 0x498ee08 0x498f070 0x498f2d0 0x498f530 0x49ac8a8 0x2b8b7b8 0x2b8cee8 0x3b47310 0x3b47868 0x3b47d50 0x4013350 0x4019920 0x401a350 0x401ad80 0x401b820 0x40c0028 0x40c0a38 0x40c1418
| |     | `-DeclRefExpr 0x7f07545d4bc0 <col:44> '<dependent type>' lvalue Var 0x7f07545d4b28 'sumElist' '<dependent type>'
| |     `-StringLiteral 0x7f07545d4e48 <col:54> 'const char [4]' lvalue "h42"
| |-CXXMemberCallExpr 0x7f07545d4fa0 <line:5:1, col:35> 'Int_t':'int'
| | |-MemberExpr 0x7f07545d4ef8 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x5042330
| | | `-ImplicitCastExpr 0x7f07545d4ee0 <col:1> 'TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f07545d4ec0 <col:1> 'TSystem *' lvalue Var 0x43881b0 'gSystem' 'TSystem *'
| | |-ImplicitCastExpr 0x7f07545d4fd8 <col:25> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7f07545d4f28 <col:25> 'int' 0
| | |-ImplicitCastExpr 0x7f07545d4ff0 <col:28> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7f07545d4f48 <col:28> 'int' 0
| | `-UnaryOperator 0x7f07545d4f88 <col:31, col:32> 'RedirectHandle_t *' prefix '&' cannot overflow
| |   `-DeclRefExpr 0x7f07545d4f68 <col:32> 'RedirectHandle_t' lvalue Var 0x60f4638 'gRH' 'RedirectHandle_t'
| `-NullStmt 0x7f07545d5008 <line:6:1>
|-AnnotateAttr 0x7f07545d49c8 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
`-AnnotateAttr 0x7f07545d4b90 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
<<<NULL>>>

Check the output

In [11]:
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

In [12]:
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*)0x7f078a852060)).c_str()) < 0)
        ^
Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListSel, ((*(std::string*)0x7f078a852060)).c_str()) < 0)
Execution of your code was aborted.