Fork me on GitHub

source: git/examples/Example5.C

Last change on this file was a7bd051, checked in by michele <michele.selvaggi@…>, 3 years ago

added X,Y,Z,T to Example5

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2Prints complete input particle arborescence for the first 10 events. Useful for debugging purposes.
3root -l examples/Example5.C'("delphes_output.root")'
4*/
5
6#ifdef __CLING__
7R__LOAD_LIBRARY(libDelphes)
8#include "classes/DelphesClasses.h"
9#include "external/ExRootAnalysis/ExRootTreeReader.h"
10#include "external/ExRootAnalysis/ExRootResult.h"
11#else
12class ExRootTreeReader;
13class ExRootResult;
14#endif
15
16
17//------------------------------------------------------------------------------
18
19void Example5(const char *inputFile)
20{
21 gSystem->Load("libDelphes");
22
23 // Create chain of root trees
24 TChain chain("Delphes");
25 chain.Add(inputFile);
26
27 // Create object of class ExRootTreeReader
28 ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
29 Long64_t numberOfEntries = treeReader->GetEntries();
30
31 // Get pointers to branches used in this analysis
32 TClonesArray *branchParticle = treeReader->UseBranch("Particle");
33
34 // Loop over all events
35 for(Int_t entry = 0; entry < numberOfEntries; ++entry)
36 {
37 // Load selected branches with data from specified event
38 treeReader->ReadEntry(entry);
39
40 if(entry>10) break;
41
42 cout<<"" <<endl;
43 cout<<"--------- New Event ---------" <<endl;
44 cout<<"" <<endl;
45
46 // loop over all input particles in the event
47 for(Int_t i=0; i < branchParticle->GetEntriesFast(); i++)
48 {
49 GenParticle *gen = (GenParticle*) branchParticle->At(i);
50 cout<<"N: "<<i<<", St: "<<gen->Status<<", PID: "<<gen->PID<<", E: "<<gen->E<<", Px: "<<gen->Px<<", Py: "<<gen->Py<<", Pz: "<<gen->Pz<<", M: "<<gen->Mass<<", T: "<<gen->T<<", X: "<<gen->X<<", Y: "<<gen->Y<<", Z: "<<gen->Z<<", M1: "<<gen->M1<<", M2: "<<gen->M2<<", D1: "<<gen->D1<<", D2: "<<gen->D2<<endl;
51 }
52 }
53}
Note: See TracBrowser for help on using the repository browser.