Logo ROOT   6.14/05
Reference Guide
mp105_processEntryList.C File Reference

Detailed Description

View in nbviewer Open in SWAN Illustrate the usage of the multiproc to process TEntryList with 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 = "mp105_processEntryList: ";
static std::string logfile = "mp105_processEntryList.log";
static RedirectHandle_t gRH;
const char *fh1[] = {"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 mp105_processEntryList()
{
// MacOSX may generate connection to WindowServer errors
gROOT->SetBatch(kTRUE);
// Prepare dataset: vector of files
std::vector<std::string> files;
for (int i = 0; i < 4; i++) {
files.push_back(fh1[i]);
}
#include "mp_H1_lambdas.C"
std::cout << tutname << "creating the entry list \n";
auto sumElist = pool.Process(files, doH1fillList, "h42");
// Print the entry list
if (sumElist) {
sumElist->Print();
} else {
std::cout << tutname << " ERROR creating the entry list \n";
return -1;
}
// Time taken
stp.Print();
stp.Start();
// Let's analyse H1 with the list
std::cout << tutname << "processing the entry list with a lambda \n";
// Run the analysis
auto hListFun = pool.Process(files, doH1useList, *sumElist, "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 entry list with selector '" << selectorPath << "'\n";
TSelector *sel = TSelector::GetSelector(selectorPath);
// In a second run we use sel
sel->SetOption("useList");
gSystem->RedirectOutput(logfile.c_str(), "w", &gRH);
auto hListSel = pool.Process(files, *sel, *sumElist, "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 mp105_processEntryList.C.