Illustrate the usage of the multiproc to process 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 = "mp104_processH1: ";
static std::string logfile = "mp104_processH1.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;
Check and fit lambdas
%%cpp -d
#include "mp_H1_lambdas.C"
ROOT::TTreeProcessorMP pool(3);
std::cout << tutname << "processing the H1 dataset with a lambda \n";
auto hListFun = pool.Process(files, doH1, "h42");
input_line_53:1:10: fatal error: 'mp_H1_lambdas.C' file not found #include "mp_H1_lambdas.C" ^~~~~~~~~~~~~~~~~
Check the output
if (checkH1(hListFun) < 0)
return -1;
input_line_55: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_57:2:9: error: use of undeclared identifier 'hListFun' (doFit(hListFun, ((*(std::string*)0x7f349423f020)).c_str()) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListFun, ((*(std::string*)0x7f349423f020)).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 H1 dataset with selector '" << selectorPath << "'\n";
auto sel = TSelector::GetSelector(selectorPath);
mp104_processH1: processing the H1 dataset 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
In a second run we use sel
gSystem->RedirectOutput(logfile.c_str(), "w", &gRH);
auto hListSel = pool.Process(files, *sel, "h42");
gSystem->RedirectOutput(nullptr, nullptr, &gRH);
input_line_62:3:1: error: Syntax error auto hListSel = pool.Process(files, *sel, "h42"); ^ FunctionDecl 0x7f347ff1e330 <input_line_62:1:1, line:6:1> line:1:6 __cling_Un1Qu325 'void (void *)' |-ParmVarDecl 0x7f347ff1e278 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f347ff1ea48 <col:43, line:6:1> | |-CXXMemberCallExpr 0x7f347ff1e5a8 <line:2:2, col:52> 'Int_t':'int' | | |-MemberExpr 0x7f347ff1e438 <col:2, col:11> '<bound member function type>' ->RedirectOutput 0x752bb38 | | | `-ImplicitCastExpr 0x7f347ff1e420 <col:2> 'TSystem *' <LValueToRValue> | | | `-DeclRefExpr 0x7f347ff1e400 <col:2> 'TSystem *' lvalue Var 0x619e040 'gSystem' 'TSystem *' | | |-CXXMemberCallExpr 0x7f347ff1e4b8 <col:26, col:40> 'const char *' | | | `-MemberExpr 0x7f347ff1e488 <col:26, col:34> '<bound member function type>' .c_str 0x7f347cc61c28 | | | `-ImplicitCastExpr 0x7f347ff1e4d8 <col:26> 'const std::basic_string<char>' lvalue <NoOp> | | | `-DeclRefExpr 0x7f347ff1e468 <col:26> 'std::string':'std::basic_string<char>' lvalue Var 0x8dc7be0 'logfile' 'std::string':'std::basic_string<char>' | | |-ImplicitCastExpr 0x7f347ff1e5e0 <col:43> 'const char *' <ArrayToPointerDecay> | | | `-StringLiteral 0x7f347ff1e4f0 <col:43> 'const char[2]' lvalue "w" | | `-UnaryOperator 0x7f347ff1e530 <col:48, col:49> 'RedirectHandle_t *' prefix '&' cannot overflow | | `-DeclRefExpr 0x7f347ff1e510 <col:49> 'RedirectHandle_t':'RedirectHandle_t' lvalue Var 0x8dc7df8 'gRH' 'RedirectHandle_t':'RedirectHandle_t' | |-DeclStmt 0x7f347ff1e900 <line:3:1, col:49> | | `-VarDecl 0x7f347ff1e640 <col:1, col:48> col:6 hListSel 'auto' cinit | | `-CallExpr 0x7f347ff1e8c8 <col:17, col:48> '<dependent type>' | | |-CXXDependentScopeMemberExpr 0x7f347ff1e7f0 <col:17, col:22> '<dependent type>' lvalue .Process | | | `-DeclRefExpr 0x7f347ff1e7b0 <col:17> '<dependent type>' lvalue Var 0x7f347ff1e6b0 'pool' '<dependent type>' | | |-DeclRefExpr 0x7f347ff1e838 <col:30> 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' lvalue Var 0x8dc97d0 'files' 'std::vector<std::string>':'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >' | | |-UnaryOperator 0x7f347ff1e890 <col:37, col:38> 'TSelector':'TSelector' lvalue prefix '*' cannot overflow | | | `-ImplicitCastExpr 0x7f347ff1e878 <col:38> 'TSelector *':'TSelector *' <LValueToRValue> | | | `-DeclRefExpr 0x7f347ff1e858 <col:38> 'TSelector *':'TSelector *' lvalue Var 0x7f347cc783f8 'sel' 'TSelector *':'TSelector *' | | `-StringLiteral 0x7f347ff1e8a8 <col:43> 'const char[4]' lvalue "h42" | |-CXXMemberCallExpr 0x7f347ff1e9d8 <line:4:1, col:47> 'Int_t':'int' | | |-MemberExpr 0x7f347ff1e950 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x752bb38 | | | `-ImplicitCastExpr 0x7f347ff1e938 <col:1> 'TSystem *' <LValueToRValue> | | | `-DeclRefExpr 0x7f347ff1e918 <col:1> 'TSystem *' lvalue Var 0x619e040 'gSystem' 'TSystem *' | | |-ImplicitCastExpr 0x7f347ff1ea10 <col:25> 'const char *' <NullToPointer> | | | `-CXXNullPtrLiteralExpr 0x7f347ff1e980 <col:25> 'std::nullptr_t' | | |-ImplicitCastExpr 0x7f347ff1ea28 <col:34> 'const char *' <NullToPointer> | | | `-CXXNullPtrLiteralExpr 0x7f347ff1e990 <col:34> 'std::nullptr_t' | | `-UnaryOperator 0x7f347ff1e9c0 <col:43, col:44> 'RedirectHandle_t *' prefix '&' cannot overflow | | `-DeclRefExpr 0x7f347ff1e9a0 <col:44> 'RedirectHandle_t':'RedirectHandle_t' lvalue Var 0x8dc7df8 'gRH' 'RedirectHandle_t':'RedirectHandle_t' | `-NullStmt 0x7f347ff1ea40 <line:5:1> `-AnnotateAttr 0x7f347ff1e718 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
Check the output
if (checkH1(hListSel) < 0)
return -1;
input_line_64: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_66:2:9: error: use of undeclared identifier 'hListSel' (doFit(hListSel, ((*(std::string*)0x7f349423f020)).c_str()) < 0) ^ Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListSel, ((*(std::string*)0x7f349423f020)).c_str()) < 0) Execution of your code was aborted.