Logo ROOT  
Reference Guide
ProofEventProc.C File Reference

Detailed Description

Selector to process trees containing Event structures.

#define ProofEventProc_cxx
#include "ProofEventProc.h"
#include <TStyle.h>
#include "TCanvas.h"
#include "TPad.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TParameter.h"
#include "TRandom.h"
#include "TNamed.h"
#include "TROOT.h"
#include "EmptyInclude.h"
// The Begin() function is called at the start of the query.
// When running with PROOF Begin() is only called on the client.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
Info("Begin", "starting a simple exercise with process option: %s", option.Data());
void ProofEventProc::SlaveBegin(TTree * /*tree*/)
// The SlaveBegin() function is called after the Begin() function.
// When running with PROOF SlaveBegin() is called on each slave server.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
// How much to read
fFullRead = kFALSE;
TNamed *nm = 0;
if (fInput) {
if ((nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofEventProc_Read")))) {
if (!strcmp(nm->GetTitle(), "readall")) fFullRead = kTRUE;
if (!nm) {
// Check option
if (option == "readall") fFullRead = kTRUE;
Info("SlaveBegin", "'%s' reading", (fFullRead ? "full" : "optimized"));
fPtHist = new TH1F("pt_dist","p_{T} Distribution",100,0,5);
fPzHist = new TH1F("pz_dist","p_{Z} Distribution",100,0,5.);
fPxPyHist = new TH2F("px_py","p_{X} vs p_{Y} Distribution",100,-5.,5.,100,-5.,5.);
// Abort test, if any
if (fInput)
pi = dynamic_cast<TParameter<Int_t> *>(fInput->FindObject("ProofEventProc_TestAbort"));
if (pi) fTestAbort = pi->GetVal();
if (fTestAbort < -1 || fTestAbort > 1) {
Info("SlaveBegin", "unsupported value for the abort test: %d not in [-1,1] - ignore", fTestAbort);
fTestAbort = -1;
} else if (fTestAbort > -1) {
Info("SlaveBegin", "running abort test: %d", fTestAbort);
if (fTestAbort == 0)
Abort("Test abortion during init", kAbortProcess);
Bool_t ProofEventProc::Process(Long64_t entry)
// The Process() function is called for each entry in the tree (or possibly
// keyed object in the case of PROOF) to be processed. The entry argument
// specifies which entry in the currently loaded tree is to be processed.
// It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
// to read either all or the required parts of the data. When processing
// keyed objects with PROOF, the object is already loaded and is available
// via the fObject pointer.
// This function should contain the "body" of the analysis. It can contain
// simple or elaborate selection criteria, run algorithms on the data
// of the event and typically fill histograms.
// WARNING when a selector is used with a TChain, you must use
// the pointer to the current TTree to call GetEntry(entry).
// The entry is always the local entry number in the current tree.
// Assuming that fChain is the pointer to the TChain being processed,
// use fChain->GetTree()->GetEntry(entry).
if (fEntMin == -1 || entry < fEntMin) fEntMin = entry;
if (fEntMax == -1 || entry > fEntMax) fEntMax = entry;
if (fTestAbort == 1) {
if (rr > 0.999) {
Info("Process", "%lld -> %f", entry, rr);
Abort("Testing file abortion", kAbortFile);
return kTRUE;
if (fFullRead) {
} else {
if (fNtrack > 0) {
if (!fFullRead) b_fTracks->GetEntry(entry);
if (fTracks) {
for (Int_t j=0;j<fTracks->GetEntries();j++){
Track *curtrack = dynamic_cast<Track*>(fTracks->At(j));
if (curtrack) {
if (j == 0) fPzHist->Fill(curtrack->GetPz());
return kTRUE;
void ProofEventProc::SlaveTerminate()
// The SlaveTerminate() function is called after all entries or objects
// have been processed. When running with PROOF SlaveTerminate() is called
// on each slave server.
// Save information about previous element, if any
if (fProcElem) fProcElem->Add(fEntMin, fEntMax);
if (!fProcElems) {
Warning("SlaveTerminate", "no proc elements list found!");
// Add proc elements to the output list
TIter nxpe(fProcElems);
TObject *o = 0;
while ((o = nxpe())) { fOutput->Add(o); };
void ProofEventProc::Terminate()
// The Terminate() function is the last function to be called during
// a query. It always runs on the client, it can be used to present
// the results graphically or save the results to file.
// Check ranges
if (gROOT->IsBatch()) return;
TCanvas* canvas = new TCanvas("event","event",800,10,700,780);
TPad *pad1 = (TPad *) canvas->GetPad(1);
TPad *pad2 = (TPad *) canvas->GetPad(2);
TPad *pad3 = (TPad *) canvas->GetPad(3);
TPad *pad4 = (TPad *) canvas->GetPad(4);
// The number of tracks
TH1F *hi = dynamic_cast<TH1F*>(fOutput->FindObject("pz_dist"));
if (hi) {
} else { Warning("Terminate", "no pz dist found"); }
// The Pt distribution
TH1F *hf = dynamic_cast<TH1F*>(fOutput->FindObject("pt_dist"));
if (hf) {
} else { Warning("Terminate", "no pt dist found"); }
// The Px,Py distribution, color surface
TH2F *h2f = dynamic_cast<TH2F*>(fOutput->FindObject("px_py"));
if (h2f) {
// Color surface
h2f->DrawCopy("SURF1 ");
// Lego
} else {
Warning("Terminate", "no px py found");
// Final update
void ProofEventProc::CheckRanges()
// Check the processed event ranges when there is enough information
// The result is added to the output list
// Must be something in output
if (!fOutput || (fOutput && fOutput->GetSize() <= 0)) return;
// Create the result object and add it to the list
TNamed *nout = new TNamed("Range_Check", "OK");
// Get info to check from the input list
if (!fInput || (fInput && fInput->GetSize() <= 0)) {
nout->SetTitle("No input list");
TNamed *ffst = dynamic_cast<TNamed *>(fInput->FindObject("Range_First_File"));
if (!ffst) {
nout->SetTitle("No first file");
TNamed *flst = dynamic_cast<TNamed *>(fInput->FindObject("Range_Last_File"));
if (!flst) {
nout->SetTitle("No last file");
dynamic_cast<TParameter<Int_t> *>(fInput->FindObject("Range_Num_Files"));
if (!fnum) {
nout->SetTitle("No number of files");
// Check first file
TString fn(ffst->GetTitle()), sfst(ffst->GetTitle());
Ssiz_t ifst = fn.Index("?fst=");
if (ifst == kNPOS) {
nout->SetTitle("No first entry information in first file name");
sfst.Remove(0, ifst + sizeof("?fst=") - 1);
if (!sfst.IsDigit()) {
nout->SetTitle("Badly formatted first entry information in first file name");
Long64_t fst = (Long64_t) sfst.Atoi();
ProcFileElements *pfef = dynamic_cast<ProcFileElements *>(fOutput->FindObject(fn));
if (!pfef) {
nout->SetTitle("ProcFileElements for first file not found in the output list");
if (pfef->GetFirst() != fst) {
TString t = TString::Format("First entry differs {found: %lld, expected: %lld}", pfef->GetFirst(), fst);
// Check last file
fn = flst->GetTitle();
TString slst(flst->GetTitle());
Ssiz_t ilst = fn.Index("?lst=");
if (ilst == kNPOS) {
nout->SetTitle("No last entry information in last file name");
slst.Remove(0, ilst + sizeof("?lst=") - 1);
if (!slst.IsDigit()) {
nout->SetTitle("Badly formatted last entry information in last file name");
Long64_t lst = (Long64_t) slst.Atoi();
ProcFileElements *pfel = dynamic_cast<ProcFileElements *>(fOutput->FindObject(fn));
if (!pfel) {
nout->SetTitle("ProcFileElements for last file not found in the output list");
if (pfel->GetLast() != lst) {
nout->SetTitle("Last entry differs");
// Check Number of files
Int_t nproc = 0;
TIter nxo(fOutput);
TObject *o = 0;
while ((o = nxo())) {
if (dynamic_cast<ProcFileElements *>(o)) nproc++;
if (fnum->GetVal() != nproc) {
nout->SetTitle("Number of processed files differs");
Empty file to test TProof::Load in runProof.C and StressProof.cxx in conjunction with ProcFileElement...
Selector to process trees containing Event structures.
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
int Int_t
Definition: RtypesCore.h:45
int Ssiz_t
Definition: RtypesCore.h:67
const Bool_t kFALSE
Definition: RtypesCore.h:92
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:73
const Bool_t kTRUE
Definition: RtypesCore.h:91
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition: TError.cxx:220
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition: TError.cxx:231
float type_of_call hi(const int &, const int &)
#define gROOT
Definition: TROOT.h:406
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
The Canvas class.
Definition: TCanvas.h:23
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition: TCanvas.cxx:708
void Update() override
Update canvas pad buffers.
Definition: TCanvas.cxx:2504
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:3120
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Clear(Option_t *="")
Definition: TObject.h:115
The most important graphics class in the ROOT system.
Definition: TPad.h:26
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
Definition: TPad.cxx:1177
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition: TPad.cxx:5947
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition: TPad.cxx:603
TVirtualPad * GetPad(Int_t subpadnumber) const override
Get a pointer to subpadnumber of this pad.
Definition: TPad.cxx:2908
Named parameter, streamable and storable.
Definition: TParameter.h:35
const AParamType & GetVal() const
Definition: TParameter.h:67
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:552
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2331
A TTree represents a columnar dataset.
Definition: TTree.h:79
Definition: JetEvent.h:30
void Begin(Int_t type)
static constexpr double nm
static constexpr double pi
Gerardo Ganis (gerar.nosp@m.do.g.nosp@m.anis@.nosp@m.cern.nosp@m..ch)

Definition in file ProofEventProc.C.