Mp 1 0 4_Process H 1

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, February 24, 2021 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_51: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_53: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_55:2:9: error: use of undeclared identifier 'hListFun'
 (doFit(hListFun, ((*(std::string*)0x7f4839eb8060)).c_str()) < 0)
        ^
Error in <HandleInterpreterException>: Error evaluating expression (doFit(hListFun, ((*(std::string*)0x7f4839eb8060)).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_60:3:1: error: Syntax error
auto hListSel = pool.Process(files, *sel, "h42");
^
FunctionDecl 0x7f4817a62320 <input_line_60:1:1, line:6:1> line:1:6 __cling_Un1Qu326 'void (void *)'
|-ParmVarDecl 0x7f4817a62270 <col:23, col:29> col:29 vpClingValue 'void *'
|-CompoundStmt 0x7f4817a62a68 <col:43, line:6:1>
| |-CXXMemberCallExpr 0x7f4817a62570 <line:2:2, col:52> 'Int_t':'int'
| | |-MemberExpr 0x7f4817a62420 <col:2, col:11> '<bound member function type>' ->RedirectOutput 0x4fb75c0
| | | `-ImplicitCastExpr 0x7f4817a62408 <col:2> 'class TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f4817a623e0 <col:2> 'class TSystem *' lvalue Var 0x4755ee8 'gSystem' 'class TSystem *'
| | |-CXXMemberCallExpr 0x7f4817a624b8 <col:26, col:40> 'const char *'
| | | `-MemberExpr 0x7f4817a62480 <col:26, col:34> '<bound member function type>' .c_str 0x7f4814771008
| | |   `-ImplicitCastExpr 0x7f4817a624e0 <col:26> 'const class std::__cxx11::basic_string<char>' lvalue <NoOp>
| | |     `-DeclRefExpr 0x7f4817a62458 <col:26> 'std::string':'class std::__cxx11::basic_string<char>' lvalue Var 0x600cd38 'logfile' 'std::string':'class std::__cxx11::basic_string<char>'
| | |-ImplicitCastExpr 0x7f4817a625b0 <col:43> 'const char *' <ArrayToPointerDecay>
| | | `-StringLiteral 0x7f4817a624f8 <col:43> 'const char [2]' lvalue "w"
| | `-UnaryOperator 0x7f4817a62550 <col:48, col:49> 'struct RedirectHandle_t *' prefix '&'
| |   `-DeclRefExpr 0x7f4817a62528 <col:49> 'struct RedirectHandle_t' lvalue Var 0x600cf88 'gRH' 'struct RedirectHandle_t'
| |-DeclStmt 0x7f4817a628d0 <line:3:1, col:49>
| | `-VarDecl 0x7f4817a625e0 <col:1, col:48> col:6 hListSel 'auto' cinit
| |   `-CallExpr 0x7f4817a62868 <col:17, col:48> '<dependent type>'
| |     |-CXXDependentScopeMemberExpr 0x7f4817a62758 <col:17, col:22> '<dependent type>' lvalue .Process
| |     | `-DeclRefExpr 0x7f4817a62710 <col:17> '<dependent type>' lvalue Var 0x7f4817a62648 'pool' '<dependent type>'
| |     |-DeclRefExpr 0x7f4817a627b0 <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 0x600e2f0 'files' 'std::vector<std::string>':'class std::vector<class std::__cxx11::basic_string<char>, class std::allocator<class std::__cxx11::basic_string<char> > >'
| |     |-UnaryOperator 0x7f4817a62818 <col:37, col:38> 'class TSelector' lvalue prefix '*'
| |     | `-ImplicitCastExpr 0x7f4817a62800 <col:38> 'class TSelector *':'class TSelector *' <LValueToRValue>
| |     |   `-DeclRefExpr 0x7f4817a627d8 <col:38> 'class TSelector *':'class TSelector *' lvalue Var 0x7f48147f43d8 'sel' 'class TSelector *':'class TSelector *'
| |     `-StringLiteral 0x7f4817a62838 <col:43> 'const char [4]' lvalue "h42"
| |-CXXMemberCallExpr 0x7f4817a629e8 <line:4:1, col:35> 'Int_t':'int'
| | |-MemberExpr 0x7f4817a62928 <col:1, col:10> '<bound member function type>' ->RedirectOutput 0x4fb75c0
| | | `-ImplicitCastExpr 0x7f4817a62910 <col:1> 'class TSystem *' <LValueToRValue>
| | |   `-DeclRefExpr 0x7f4817a628e8 <col:1> 'class TSystem *' lvalue Var 0x4755ee8 'gSystem' 'class TSystem *'
| | |-ImplicitCastExpr 0x7f4817a62a28 <col:25> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7f4817a62960 <col:25> 'int' 0
| | |-ImplicitCastExpr 0x7f4817a62a40 <col:28> 'const char *' <NullToPointer>
| | | `-IntegerLiteral 0x7f4817a62980 <col:28> 'int' 0
| | `-UnaryOperator 0x7f4817a629c8 <col:31, col:32> 'struct RedirectHandle_t *' prefix '&'
| |   `-DeclRefExpr 0x7f4817a629a0 <col:32> 'struct RedirectHandle_t' lvalue Var 0x600cf88 'gRH' 'struct RedirectHandle_t'
| `-NullStmt 0x7f4817a62a58 <line:5:1>
`-AnnotateAttr 0x7f4817a626a8 <<invalid sloc>> R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP"
<<<NULL>>>

Check the output

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