Logo ROOT  
Reference Guide
mp104_processH1.C File Reference

Detailed Description

View in nbviewer Open in SWAN Illustrate the usage of the multiproc to process the H1 analysis example.

#include "TString.h"
#include "TROOT.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TEntryList.h"
#include "TTreeReader.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"
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"};
int mp104_processH1()
{
// MacOSX may generate connection to WindowServer errors
gROOT->SetBatch(kTRUE);
// Check and fit lambdas
#include "mp_H1_lambdas.C"
std::cout << tutname << "processing the H1 dataset with a lambda \n";
auto hListFun = pool.Process(files, doH1, "h42");
// Check the output
if (checkH1(hListFun) < 0)
return -1;
// Do the fit
if (doFit(hListFun, logfile.c_str()) < 0)
return -1;
stp.Print();
stp.Start();
// 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);
// In a second run we use sel
gSystem->RedirectOutput(logfile.c_str(), "w", &gRH);
auto hListSel = pool.Process(files, *sel, "h42");
gSystem->RedirectOutput(0, 0, &gRH);
// Check the output
if (checkH1(hListSel) < 0)
return -1;
// Do the fit
if (doFit(hListSel, logfile.c_str()) < 0)
return -1;
stp.Print();
stp.Start();
return 0;
}
Author
Gerardo Ganis

Definition in file mp104_processH1.C.

kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TH1F.h
TLine.h
TTreeReaderValue.h
TSelector::GetSelector
static TSelector * GetSelector(const char *filename)
The code in filename is loaded (interpreted or compiled, see below), filename must contain a valid cl...
Definition: TSelector.cxx:142
TStopwatch.h
TTreeProcessorMP.hxx
TStyle.h
ROOT::TTreeProcessorMP
This class provides an interface to process a TTree dataset in parallel with multi-process technology...
Definition: TTreeProcessorMP.hxx:44
TPaveStats.h
TCanvas.h
TTree.h
TString
Definition: TString.h:136
TString.h
RedirectHandle_t
Definition: TSystem.h:203
TROOT.h
mp_H1_lambdas.C
TStopwatch::Print
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:219
TTreeReader.h
TSystem::RedirectOutput
virtual Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=nullptr)
Redirect standard output (stdout, stderr) to the specified file.
Definition: TSystem.cxx:1711
TSystem.h
TTreeReaderArray.h
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
TH2F.h
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TF1.h
TStopwatch
Definition: TStopwatch.h:28
TEntryList.h
TMath.h
gROOT
#define gROOT
Definition: TROOT.h:406