Fork me on GitHub

WorkBook/TutorialBologna: TimingAnalysis.C

File TimingAnalysis.C, 2.4 KB (added by Michele Selvaggi, 8 years ago)
Line 
1/*
2Prints complete input particle arborescence for the first 100 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
17template<typename T>
18void CollectionFilter(const TClonesArray& inColl ,vector<T*>& outColl, Double_t ptMin=30, Double_t etaMax=2.5)
19{
20
21 const TObject *object;
22
23 for (Int_t i = 0; i < inColl.GetEntriesFast(); i++)
24 {
25
26 object = inColl.At(i);
27 const T *t = static_cast<const T*>(object);
28
29 if(t->P4().Pt() < ptMin) continue;
30 if(TMath::Abs(t->P4().Eta()) > etaMax) continue;
31 if(TMath::Abs(t->PID) != 11 && TMath::Abs(t->PID) != 13) continue;
32
33 outColl.push_back(t);
34
35 }
36}
37
38
39//------------------------------------------------------------------------------
40
41void TimingAnalysis(const char *inputFile)
42{
43 gSystem->Load("libDelphes");
44
45 // Create chain of root trees
46 TChain chain("Delphes");
47 chain.Add(inputFile);
48
49 // Create object of class ExRootTreeReader
50 ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
51 Long64_t numberOfEntries = treeReader->GetEntries();
52
53 // Get pointers to branches used in this analysis
54 TClonesArray *branchTrack = treeReader->UseBranch("Track");
55
56 // Book histogram
57 TH1F *hDeltaT = new TH1F("hDeltaT", "hDeltaT", 100, -0.5e-9, 0.5e-9);
58
59 // define vector of tracks
60 vector<const Track*> *tracks = new vector<const Track*>();;
61
62 // define variables
63 Double_t recoVertexTime, recoTrackTime;
64
65 // Loop over all events
66 for(Int_t entry = 0; entry < numberOfEntries; ++entry)
67 {
68 // Load selected branches with data from specified event
69 treeReader->ReadEntry(entry);
70
71 tracks -> clear();
72
73 // Select 4 highest pT tracks with pT > 2 GeV
74 CollectionFilter(*branchTrack, *tracks , 2.0 , 2.5);
75 if(tracks->size() < 4) continue;
76
77 // given that we have no vertexing, decide that time coordinate given by high pest pT track
78 recoVertexTime = tracks->at(0)->T0;
79
80 // take the time at vertex of the 4th most energetic track
81 recoTrackTime = tracks->at(3)->T0;
82
83 // fill the difference
84 hDeltaT -> Fill(recoTrackTime - recoVertexTime);
85
86 } // end of event loop
87
88 // Plot the time difference observables
89
90 hDeltaT -> Draw();
91 gPad -> SetLogy();
92
93}