Fork me on GitHub

source: svn/trunk/modules/Isolation.cc@ 1273

Last change on this file since 1273 was 1267, checked in by Pavel Demin, 11 years ago

added UsePTSum and PTSumMax parameters to the Isolation module

  • Property svn:keywords set to Id Revision Date
File size: 4.6 KB
Line 
1
2/** \class Isolation
3 *
4 * Sums transverse momenta of isolation objects (tracks, calorimeter towers, etc)
5 * within a DeltaR cone around a candidate and calculates fraction of this sum
6 * to the candidate's transverse momentum. outputs candidates that have
7 * the transverse momenta fraction within (PTRatioMin, PTRatioMax].
8 *
9 * $Date: 2013-08-19 13:40:54 +0000 (Mon, 19 Aug 2013) $
10 * $Revision: 1267 $
11 *
12 *
13 * \author P. Demin - UCL, Louvain-la-Neuve
14 *
15 */
16
17#include "modules/Isolation.h"
18
19#include "classes/DelphesClasses.h"
20#include "classes/DelphesFactory.h"
21#include "classes/DelphesFormula.h"
22
23#include "ExRootAnalysis/ExRootResult.h"
24#include "ExRootAnalysis/ExRootFilter.h"
25#include "ExRootAnalysis/ExRootClassifier.h"
26
27#include "TMath.h"
28#include "TString.h"
29#include "TFormula.h"
30#include "TRandom3.h"
31#include "TObjArray.h"
32#include "TDatabasePDG.h"
33#include "TLorentzVector.h"
34
35#include <algorithm>
36#include <stdexcept>
37#include <iostream>
38#include <sstream>
39
40using namespace std;
41
42//------------------------------------------------------------------------------
43
44class IsolationClassifier : public ExRootClassifier
45{
46public:
47
48 IsolationClassifier() {}
49
50 Int_t GetCategory(TObject *object);
51
52 Double_t fPTMin;
53};
54
55//------------------------------------------------------------------------------
56
57Int_t IsolationClassifier::GetCategory(TObject *object)
58{
59 Candidate *track = static_cast<Candidate*>(object);
60 const TLorentzVector &momentum = track->Momentum;
61
62 if(momentum.Pt() < fPTMin) return -1;
63
64 return 0;
65}
66
67//------------------------------------------------------------------------------
68
69Isolation::Isolation() :
70 fClassifier(0), fFilter(0),
71 fItIsolationInputArray(0), fItCandidateInputArray(0)
72{
73 fClassifier = new IsolationClassifier;
74}
75
76//------------------------------------------------------------------------------
77
78Isolation::~Isolation()
79{
80}
81
82//------------------------------------------------------------------------------
83
84void Isolation::Init()
85{
86 const char *rhoInputArrayName;
87
88 fDeltaRMax = GetDouble("DeltaRMax", 0.5);
89
90 fPTRatioMax = GetDouble("PTRatioMax", 0.1);
91
92 fPTSumMax = GetDouble("PTSumMax", 5.0);
93
94 fUsePTSum = GetBool("UsePTSum", false);
95
96 fClassifier->fPTMin = GetDouble("PTMin", 0.5);
97
98 // import input array(s)
99
100 fIsolationInputArray = ImportArray(GetString("IsolationInputArray", "Delphes/partons"));
101 fItIsolationInputArray = fIsolationInputArray->MakeIterator();
102
103 fFilter = new ExRootFilter(fIsolationInputArray);
104
105 fCandidateInputArray = ImportArray(GetString("CandidateInputArray", "Calorimeter/electrons"));
106 fItCandidateInputArray = fCandidateInputArray->MakeIterator();
107
108 rhoInputArrayName = GetString("RhoInputArray", "");
109 if(rhoInputArrayName[0] != '\0')
110 {
111 fRhoInputArray = ImportArray(rhoInputArrayName);
112 }
113 else
114 {
115 fRhoInputArray = 0;
116 }
117
118 // create output array
119
120 fOutputArray = ExportArray(GetString("OutputArray", "electrons"));
121}
122
123//------------------------------------------------------------------------------
124
125void Isolation::Finish()
126{
127 if(fFilter) delete fFilter;
128 if(fItCandidateInputArray) delete fItCandidateInputArray;
129 if(fItIsolationInputArray) delete fItIsolationInputArray;
130}
131
132//------------------------------------------------------------------------------
133
134void Isolation::Process()
135{
136 Candidate *candidate, *isolation;
137 TObjArray *isolationArray;
138 Double_t sum, ratio;
139 Int_t counter;
140 Double_t rho = 0.0;
141
142 if(fRhoInputArray && fRhoInputArray->GetEntriesFast() > 0)
143 {
144 candidate = static_cast<Candidate*>(fRhoInputArray->At(0));
145 rho = candidate->Momentum.Pt();
146 }
147
148 // select isolation objects
149 fFilter->Reset();
150 isolationArray = fFilter->GetSubArray(fClassifier, 0);
151
152 if(isolationArray == 0) return;
153
154 TIter itIsolationArray(isolationArray);
155
156 // loop over all input jets
157 fItCandidateInputArray->Reset();
158 while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
159 {
160 const TLorentzVector &candidateMomentum = candidate->Momentum;
161
162 // loop over all input tracks
163 sum = 0.0;
164 counter = 0;
165 itIsolationArray.Reset();
166 while((isolation = static_cast<Candidate*>(itIsolationArray.Next())))
167 {
168 const TLorentzVector &isolationMomentum = isolation->Momentum;
169
170 if(candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
171 !candidate->Overlaps(isolation))
172 {
173 sum += isolationMomentum.Pt();
174 ++counter;
175 }
176 }
177
178 // correct sum for pile-up contamination
179 sum = sum - rho*fDeltaRMax*fDeltaRMax*TMath::Pi();
180
181 ratio = sum/candidateMomentum.Pt();
182 if((fUsePTSum && sum > fPTSumMax) || ratio > fPTRatioMax) continue;
183
184 fOutputArray->Add(candidate);
185 }
186}
187
188//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.