Mp 1 0 5_Process Entry List

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 Thursday, February 25, 2021 at 09:32 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_45: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_52: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_54: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_56:2:2: error: Syntax error
 auto hListFun = pool.Process(files, doH1useList, *sumElist, "h42");
 ^
FunctionDecl 0x7f909c719f50 <input_line_56:1:1, line:4:1> line:1:6 __cling_Un1Qu326 'void (void *)'
|-ParmVarDecl 0x7f909c719ea0 <col:23, col:29> col:29 vpClingValue 'void *'
|-CompoundStmt 0x7f909c71a708 <col:43, line:4:1>
| |-DeclStmt 0x7f909c71a6e0 <line:2:2, col:68>
| | `-VarDecl 0x7f909c71a028 <col:2, col:67> col:7 hListFun 'auto' cinit
| |   `-CallExpr 0x7f909c71a678 <col:18, col:67> '<dependent type>'
| |     |-CXXDependentScopeMemberExpr 0x7f909c71a1a0 <col:18, col:23> '<dependent type>' lvalue .Process
| |     | `-DeclRefExpr 0x7f909c71a158 <col:18> '<dependent type>' lvalue Var 0x7f909c71a090 'pool' '<dependent type>'
| |     |-DeclRefExpr 0x7f909c71a1f8 <col:31> 'std::vector<std::string>':'class std::vector<class std::__cxx11::basic_string<char>, class std::allocator<class std::__cxx11::basic_string<char> > >' lvalue Var 0x5f4b170 'files' 'std::vector<std::string>':'class std::vector<class std::__cxx11::basic_string<char>, class std::allocator<class std::__cxx11::basic_string<char> > >'
| |     |-DeclRefExpr 0x7f909c71a2b8 <col:38> '<dependent type>' lvalue Var 0x7f909c71a228 'doH1useList' '<dependent type>'
| |     |-CXXOperatorCallExpr 0x7f909c71a608 <col:51, col:52> '<dependent type>'
| |     | |-UnresolvedLookupExpr 0x7f909c71a3e0 <col:51> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x4799728 0x48a7b78 0x48a8038 0x48a84f8 0x48a8a70 0x48a8fe0 0x48a9550 0x48be2a8 0x48be768 0x3e69da8 0x3e6a320 0x3e6a890 0x3e6ae00 0x3e6b2b8 0x3e70fa0 0x3e714d0 0x3e71a80 0x3e72030 0x3e725e0 0x3e72ad8 0x3eabf28 0x3eac388 0x3eacf58 0x3ead878 0x3eadcd8 0x3eae8a8 0x3eaf1d8 0x3eaf638 0x3ed45a8 0x3ed4d08 0x3ed5168 0x3ed5d38 0x3ed6498 0x3ed68f8 0x3ed74c8 0x3f02a08 0x3f02dc8 0x3f03188 0x4d52dd8 0x4d53208 0x4d535b8 0x4d53968 0x4d53bb8 0x4d53e08 0x4d54058 0x4d54308 0x4d54848 0x4d54a18 0x3852308 0x3852880 0x3852d68 0x439bcd8 0x439c908 0x439d358 0x439dda8 0x439e878 0x4447950 0x4448380 0x4448d80
| |     | `-DeclRefExpr 0x7f909c71a398 <col:52> '<dependent type>' lvalue Var 0x7f909c71a308 'sumElist' '<dependent type>'
| |     `-StringLiteral 0x7f909c71a648 <col:62> 'const char [4]' lvalue "h42"
| `-NullStmt 0x7f909c71a6f8 <line:3:1>
|-AnnotateAttr 0x7f909c71a0f0 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
|-AnnotateAttr 0x7f909c71a288 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
`-AnnotateAttr 0x7f909c71a368 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
<<<NULL>>>

Check the output

In [7]:
if (checkH1(hListFun) < 0)
   return -1;
input_line_58: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_60:2:9: error: use of undeclared identifier 'hListFun'
 (doFit(hListFun, ((*(std::string*)0x7f90c94f1060)).c_str()) < 0)
        ^
Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListFun, ((*(std::string*)0x7f90c94f1060)).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+'

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_65:4:1: error: Syntax error
auto hListSel = pool.Process(files, *sel, *sumElist, "h42");
^
FunctionDecl 0x7f909ff5a460 <input_line_65:1:1, line:7:1> line:1:6 __cling_Un1Qu332 'void (void *)'
|-ParmVarDecl 0x7f909ff5a3b0 <col:23, col:29> col:29 vpClingValue 'void *'
|-CompoundStmt 0x7f909ff5afc0 <col:43, line:7:1>
| |-CXXMemberCallExpr 0x7f909ff5a5c8 <line:2:2, col:26> 'void'
| | |-MemberExpr 0x7f909ff5a560 <col:2, col:7> '<bound member function type>' ->SetOption 0x7f909d611168
| | | `-ImplicitCastExpr 0x7f909ff5a548 <col:2> 'class TSelector *':'class TSelector *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f909ff5a520 <col:2> 'class TSelector *':'class TSelector *' lvalue Var 0x7f909d5fc3e8 'sel' 'class TSelector *':'class TSelector *'
| | `-ImplicitCastExpr 0x7f909ff5a5f8 <col:17> 'const char *' <ArrayToPointerDecay>
| |   `-StringLiteral 0x7f909ff5a598 <col:17> 'const char [8]' lvalue "useList"
| |-CXXMemberCallExpr 0x7f909ff5a7a0 <line:3:1, col:51> 'Int_t':'int'
| | |-MemberExpr 0x7f909ff5a650 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x4ef4bc0
| | | `-ImplicitCastExpr 0x7f909ff5a638 <col:1> 'class TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f909ff5a610 <col:1> 'class TSystem *' lvalue Var 0x4693b58 'gSystem' 'class TSystem *'
| | |-CXXMemberCallExpr 0x7f909ff5a6e8 <col:25, col:39> 'const char *'
| | | `-MemberExpr 0x7f909ff5a6b0 <col:25, col:33> '<bound member function type>' .c_str 0x7f909d5a6b50
| | |   `-ImplicitCastExpr 0x7f909ff5a710 <col:25> 'const class std::__cxx11::basic_string<char>' lvalue <NoOp>
| | |     `-DeclRefExpr 0x7f909ff5a688 <col:25> 'std::string':'class std::__cxx11::basic_string<char>' lvalue Var 0x5f49bb8 'logfile' 'std::string':'class std::__cxx11::basic_string<char>'
| | |-ImplicitCastExpr 0x7f909ff5a7e0 <col:42> 'const char *' <ArrayToPointerDecay>
| | | `-StringLiteral 0x7f909ff5a728 <col:42> 'const char [2]' lvalue "w"
| | `-UnaryOperator 0x7f909ff5a780 <col:47, col:48> 'struct RedirectHandle_t *' prefix '&'
| |   `-DeclRefExpr 0x7f909ff5a758 <col:48> 'struct RedirectHandle_t' lvalue Var 0x5f49e10 'gRH' 'struct RedirectHandle_t'
| |-DeclStmt 0x7f909ff5ae28 <line:4:1, col:60>
| | `-VarDecl 0x7f909ff5a810 <col:1, col:59> col:6 hListSel 'auto' cinit
| |   `-CallExpr 0x7f909ff5ade0 <col:17, col:59> '<dependent type>'
| |     |-CXXDependentScopeMemberExpr 0x7f909ff5a988 <col:17, col:22> '<dependent type>' lvalue .Process
| |     | `-DeclRefExpr 0x7f909ff5a940 <col:17> '<dependent type>' lvalue Var 0x7f909ff5a878 'pool' '<dependent type>'
| |     |-DeclRefExpr 0x7f909ff5a9e0 <col:30> 'std::vector<std::string>':'class std::vector<class std::__cxx11::basic_string<char>, class std::allocator<class std::__cxx11::basic_string<char> > >' lvalue Var 0x5f4b170 'files' 'std::vector<std::string>':'class std::vector<class std::__cxx11::basic_string<char>, class std::allocator<class std::__cxx11::basic_string<char> > >'
| |     |-UnaryOperator 0x7f909ff5aa48 <col:37, col:38> 'class TSelector' lvalue prefix '*'
| |     | `-ImplicitCastExpr 0x7f909ff5aa30 <col:38> 'class TSelector *':'class TSelector *' <LValueToRValue>
| |     |   `-DeclRefExpr 0x7f909ff5aa08 <col:38> 'class TSelector *':'class TSelector *' lvalue Var 0x7f909d5fc3e8 'sel' 'class TSelector *':'class TSelector *'
| |     |-CXXOperatorCallExpr 0x7f909ff5ad70 <col:43, col:44> '<dependent type>'
| |     | |-UnresolvedLookupExpr 0x7f909ff5ab48 <col:43> '<overloaded function type>' lvalue (ADL) = 'operator*' 0x4799728 0x48a7b78 0x48a8038 0x48a84f8 0x48a8a70 0x48a8fe0 0x48a9550 0x48be2a8 0x48be768 0x3e69da8 0x3e6a320 0x3e6a890 0x3e6ae00 0x3e6b2b8 0x3e70fa0 0x3e714d0 0x3e71a80 0x3e72030 0x3e725e0 0x3e72ad8 0x3eabf28 0x3eac388 0x3eacf58 0x3ead878 0x3eadcd8 0x3eae8a8 0x3eaf1d8 0x3eaf638 0x3ed45a8 0x3ed4d08 0x3ed5168 0x3ed5d38 0x3ed6498 0x3ed68f8 0x3ed74c8 0x3f02a08 0x3f02dc8 0x3f03188 0x4d52dd8 0x4d53208 0x4d535b8 0x4d53968 0x4d53bb8 0x4d53e08 0x4d54058 0x4d54308 0x4d54848 0x4d54a18 0x3852308 0x3852880 0x3852d68 0x439bcd8 0x439c908 0x439d358 0x439dda8 0x439e878 0x4447950 0x4448380 0x4448d80
| |     | `-DeclRefExpr 0x7f909ff5ab00 <col:44> '<dependent type>' lvalue Var 0x7f909ff5aa70 'sumElist' '<dependent type>'
| |     `-StringLiteral 0x7f909ff5adb0 <col:54> 'const char [4]' lvalue "h42"
| |-CXXMemberCallExpr 0x7f909ff5af40 <line:5:1, col:35> 'Int_t':'int'
| | |-MemberExpr 0x7f909ff5ae80 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x4ef4bc0
| | | `-ImplicitCastExpr 0x7f909ff5ae68 <col:1> 'class TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f909ff5ae40 <col:1> 'class TSystem *' lvalue Var 0x4693b58 'gSystem' 'class TSystem *'
| | |-ImplicitCastExpr 0x7f909ff5af80 <col:25> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7f909ff5aeb8 <col:25> 'int' 0
| | |-ImplicitCastExpr 0x7f909ff5af98 <col:28> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7f909ff5aed8 <col:28> 'int' 0
| | `-UnaryOperator 0x7f909ff5af20 <col:31, col:32> 'struct RedirectHandle_t *' prefix '&'
| |   `-DeclRefExpr 0x7f909ff5aef8 <col:32> 'struct RedirectHandle_t' lvalue Var 0x5f49e10 'gRH' 'struct RedirectHandle_t'
| `-NullStmt 0x7f909ff5afb0 <line:6:1>
|-AnnotateAttr 0x7f909ff5a8d8 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
`-AnnotateAttr 0x7f909ff5aad0 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
<<<NULL>>>

Check the output

In [11]:
if (checkH1(hListSel) < 0)
   return -1;
input_line_67: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_69:2:9: error: use of undeclared identifier 'hListSel'
 (doFit(hListSel, ((*(std::string*)0x7f90c94f1060)).c_str()) < 0)
        ^
Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListSel, ((*(std::string*)0x7f90c94f1060)).c_str()) < 0).
Execution of your code was aborted.