Fork me on GitHub

source: git/examples/Example5.C@ c1780a5

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

added X,Y,Z,T to Example5

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[f118021]1/*
[ecf5f26]2Prints complete input particle arborescence for the first 10 events. Useful for debugging purposes.
[f118021]3root -l examples/Example5.C'("delphes_output.root")'
4*/
5
[391fd58]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
[f118021]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);
[a7bd051]39
[ecf5f26]40 if(entry>10) break;
[a7bd051]41
[f118021]42 cout<<"" <<endl;
43 cout<<"--------- New Event ---------" <<endl;
44 cout<<"" <<endl;
[a7bd051]45
[f118021]46 // loop over all input particles in the event
47 for(Int_t i=0; i < branchParticle->GetEntriesFast(); i++)
[a7bd051]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;
[f118021]51 }
52 }
53}
Note: See TracBrowser for help on using the repository browser.