mp104_processH1

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 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 = "mp104_processH1: ";
static std::string logfile = "mp104_processH1.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;

Check and fit lambdas

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

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

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

Run the analysis with a selector

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

In [7]:
gSystem->RedirectOutput(logfile.c_str(), "w", &gRH);
auto hListSel = pool.Process(files, *sel, "h42");
gSystem->RedirectOutput(0, 0, &gRH);
input_line_62:3:1: error: Syntax error
auto hListSel = pool.Process(files, *sel, "h42");
^
FunctionDecl 0x7fb9dc416e50 <input_line_62:1:1, line:6:1> line:1:6 __cling_Un1Qu326 'void (void *)'
|-ParmVarDecl 0x7fb9dc416d98 <col:23, col:29> col:29 vpClingValue 'void *'
|-CompoundStmt 0x7fb9dc4174b8 <col:43, line:6:1>
| |-CXXMemberCallExpr 0x7fb9dc417060 <line:2:2, col:52> 'Int_t':'int'
| | |-MemberExpr 0x7fb9dc416f50 <col:2, col:11> '<bound member function type>' ->RedirectOutput 0x567b1c0
| | | `-ImplicitCastExpr 0x7fb9dc416f38 <col:2> 'TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7fb9dc416f18 <col:2> 'TSystem *' lvalue Var 0x49c1130 'gSystem' 'TSystem *'
| | |-CXXMemberCallExpr 0x7fb9dc416fd0 <col:26, col:40> 'const char *'
| | | `-MemberExpr 0x7fb9dc416fa0 <col:26, col:34> '<bound member function type>' .c_str 0x7fb9ed3b8f00
| | |   `-ImplicitCastExpr 0x7fb9dc416ff0 <col:26> 'const std::__cxx11::basic_string<char>' lvalue <NoOp>
| | |     `-DeclRefExpr 0x7fb9dc416f80 <col:26> 'std::string':'std::__cxx11::basic_string<char>' lvalue Var 0x672dfb0 'logfile' 'std::string':'std::__cxx11::basic_string<char>'
| | |-ImplicitCastExpr 0x7fb9dc417098 <col:43> 'const char *' <ArrayToPointerDecay>
| | | `-StringLiteral 0x7fb9dc417008 <col:43> 'const char [2]' lvalue "w"
| | `-UnaryOperator 0x7fb9dc417048 <col:48, col:49> 'RedirectHandle_t *' prefix '&' cannot overflow
| |   `-DeclRefExpr 0x7fb9dc417028 <col:49> 'RedirectHandle_t' lvalue Var 0x672e1a0 'gRH' 'RedirectHandle_t'
| |-DeclStmt 0x7fb9dc417350 <line:3:1, col:49>
| | `-VarDecl 0x7fb9dc4170c8 <col:1, col:48> col:6 hListSel 'auto' cinit
| |   `-CallExpr 0x7fb9dc417318 <col:17, col:48> '<dependent type>'
| |     |-CXXDependentScopeMemberExpr 0x7fb9dc417240 <col:17, col:22> '<dependent type>' lvalue .Process
| |     | `-DeclRefExpr 0x7fb9dc417200 <col:17> '<dependent type>' lvalue Var 0x7fb9dc417138 'pool' '<dependent type>'
| |     |-DeclRefExpr 0x7fb9dc417288 <col:30> 'std::vector<std::string>':'std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >' lvalue Var 0x672f490 'files' 'std::vector<std::string>':'std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >'
| |     |-UnaryOperator 0x7fb9dc4172e0 <col:37, col:38> 'TSelector' lvalue prefix '*' cannot overflow
| |     | `-ImplicitCastExpr 0x7fb9dc4172c8 <col:38> 'TSelector *':'TSelector *' <LValueToRValue>
| |     |   `-DeclRefExpr 0x7fb9dc4172a8 <col:38> 'TSelector *':'TSelector *' lvalue Var 0x7fb9ed5a5f10 'sel' 'TSelector *':'TSelector *'
| |     `-StringLiteral 0x7fb9dc4172f8 <col:43> 'const char [4]' lvalue "h42"
| |-CXXMemberCallExpr 0x7fb9dc417448 <line:4:1, col:35> 'Int_t':'int'
| | |-MemberExpr 0x7fb9dc4173a0 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x567b1c0
| | | `-ImplicitCastExpr 0x7fb9dc417388 <col:1> 'TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7fb9dc417368 <col:1> 'TSystem *' lvalue Var 0x49c1130 'gSystem' 'TSystem *'
| | |-ImplicitCastExpr 0x7fb9dc417480 <col:25> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7fb9dc4173d0 <col:25> 'int' 0
| | |-ImplicitCastExpr 0x7fb9dc417498 <col:28> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7fb9dc4173f0 <col:28> 'int' 0
| | `-UnaryOperator 0x7fb9dc417430 <col:31, col:32> 'RedirectHandle_t *' prefix '&' cannot overflow
| |   `-DeclRefExpr 0x7fb9dc417410 <col:32> 'RedirectHandle_t' lvalue Var 0x672e1a0 'gRH' 'RedirectHandle_t'
| `-NullStmt 0x7fb9dc4174b0 <line:5:1>
`-AnnotateAttr 0x7fb9dc4171a0 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
<<<NULL>>>

Check the output

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

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