Fork me on GitHub

source: git/modules/Isolation.cc@ 7010454

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 7010454 was 7010454, checked in by Michele Selvaggi <michele.selvaggi@…>, 8 years ago

remove iso array condition

  • Property mode set to 100644
File size: 7.6 KB
RevLine 
[b443089]1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
[1fa50c2]4 *
[b443089]5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
[1fa50c2]9 *
[b443089]10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
[1fa50c2]14 *
[b443089]15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
[d7d2da3]19
20/** \class Isolation
21 *
22 * Sums transverse momenta of isolation objects (tracks, calorimeter towers, etc)
23 * within a DeltaR cone around a candidate and calculates fraction of this sum
24 * to the candidate's transverse momentum. outputs candidates that have
25 * the transverse momenta fraction within (PTRatioMin, PTRatioMax].
26 *
[7f9ae0a]27 * \author P. Demin, M. Selvaggi, R. Gerosa - UCL, Louvain-la-Neuve
[d7d2da3]28 *
29 */
30
31#include "modules/Isolation.h"
32
33#include "classes/DelphesClasses.h"
34#include "classes/DelphesFactory.h"
35#include "classes/DelphesFormula.h"
36
37#include "ExRootAnalysis/ExRootResult.h"
38#include "ExRootAnalysis/ExRootFilter.h"
39#include "ExRootAnalysis/ExRootClassifier.h"
40
41#include "TMath.h"
42#include "TString.h"
43#include "TFormula.h"
44#include "TRandom3.h"
45#include "TObjArray.h"
46#include "TDatabasePDG.h"
47#include "TLorentzVector.h"
48
49#include <algorithm>
50#include <stdexcept>
51#include <iostream>
52#include <sstream>
53
54using namespace std;
55
56//------------------------------------------------------------------------------
57
58class IsolationClassifier : public ExRootClassifier
59{
60public:
61
62 IsolationClassifier() {}
63
64 Int_t GetCategory(TObject *object);
65
66 Double_t fPTMin;
67};
68
69//------------------------------------------------------------------------------
70
71Int_t IsolationClassifier::GetCategory(TObject *object)
72{
73 Candidate *track = static_cast<Candidate*>(object);
74 const TLorentzVector &momentum = track->Momentum;
75
76 if(momentum.Pt() < fPTMin) return -1;
77
78 return 0;
79}
80
81//------------------------------------------------------------------------------
82
83Isolation::Isolation() :
84 fClassifier(0), fFilter(0),
[e9023b9]85 fItIsolationInputArray(0), fItCandidateInputArray(0),
86 fItRhoInputArray(0)
[d7d2da3]87{
88 fClassifier = new IsolationClassifier;
89}
90
91//------------------------------------------------------------------------------
92
93Isolation::~Isolation()
94{
95}
96
97//------------------------------------------------------------------------------
98
99void Isolation::Init()
100{
101 const char *rhoInputArrayName;
102
103 fDeltaRMax = GetDouble("DeltaRMax", 0.5);
104
105 fPTRatioMax = GetDouble("PTRatioMax", 0.1);
106
[b286067]107 fPTSumMax = GetDouble("PTSumMax", 5.0);
108
109 fUsePTSum = GetBool("UsePTSum", false);
110
[844a970]111 fUseRhoCorrection = GetBool("UseRhoCorrection", true);
112
[e2339af]113 fDeltaRMin = GetDouble("DeltaRMin", 0.01);
114 fUseMiniCone = GetBool("UseMiniCone", false);
115
[d7d2da3]116 fClassifier->fPTMin = GetDouble("PTMin", 0.5);
117
118 // import input array(s)
119
120 fIsolationInputArray = ImportArray(GetString("IsolationInputArray", "Delphes/partons"));
121 fItIsolationInputArray = fIsolationInputArray->MakeIterator();
122
123 fFilter = new ExRootFilter(fIsolationInputArray);
124
125 fCandidateInputArray = ImportArray(GetString("CandidateInputArray", "Calorimeter/electrons"));
126 fItCandidateInputArray = fCandidateInputArray->MakeIterator();
127
[48b6e45]128 rhoInputArrayName = GetString("RhoInputArray", "");
[d7d2da3]129 if(rhoInputArrayName[0] != '\0')
130 {
131 fRhoInputArray = ImportArray(rhoInputArrayName);
[e9023b9]132 fItRhoInputArray = fRhoInputArray->MakeIterator();
[d7d2da3]133 }
134 else
135 {
136 fRhoInputArray = 0;
137 }
138
139 // create output array
140
141 fOutputArray = ExportArray(GetString("OutputArray", "electrons"));
142}
143
144//------------------------------------------------------------------------------
145
146void Isolation::Finish()
147{
[e9023b9]148 if(fItRhoInputArray) delete fItRhoInputArray;
[d7d2da3]149 if(fFilter) delete fFilter;
150 if(fItCandidateInputArray) delete fItCandidateInputArray;
151 if(fItIsolationInputArray) delete fItIsolationInputArray;
152}
153
154//------------------------------------------------------------------------------
155
156void Isolation::Process()
157{
[e9023b9]158 Candidate *candidate, *isolation, *object;
[d7d2da3]159 TObjArray *isolationArray;
[cef50c9]160 Double_t sumChargedNoPU, sumChargedPU, sumNeutral, sumAllParticles;
[004aa60]161 Double_t sumDBeta, ratioDBeta, sumRhoCorr, ratioRhoCorr, sum, ratio;
[e2339af]162 Bool_t pass = kFALSE;
[e9023b9]163 Double_t eta = 0.0;
[d7d2da3]164 Double_t rho = 0.0;
165
166 // select isolation objects
167 fFilter->Reset();
168 isolationArray = fFilter->GetSubArray(fClassifier, 0);
169
[7010454]170 //if(isolationArray == 0) return;
[d7d2da3]171
172 TIter itIsolationArray(isolationArray);
173
[c4e18da]174
[d7d2da3]175 // loop over all input jets
176 fItCandidateInputArray->Reset();
177 while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
178 {
179 const TLorentzVector &candidateMomentum = candidate->Momentum;
[e9023b9]180 eta = TMath::Abs(candidateMomentum.Eta());
[d7d2da3]181
[7aea88d]182 // find rho
183 rho = 0.0;
184 if(fRhoInputArray)
185 {
186 fItRhoInputArray->Reset();
187 while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
188 {
189 if(eta >= object->Edges[0] && eta < object->Edges[1])
190 {
191 rho = object->Momentum.Pt();
192 }
193 }
194 }
195
[d7d2da3]196 // loop over all input tracks
[004aa60]197
[3db5282]198 sumNeutral = 0.0;
[cef50c9]199 sumChargedNoPU = 0.0;
[7f9ae0a]200 sumChargedPU = 0.0;
201 sumAllParticles = 0.0;
[004aa60]202
[d7d2da3]203 itIsolationArray.Reset();
204 while((isolation = static_cast<Candidate*>(itIsolationArray.Next())))
205 {
206 const TLorentzVector &isolationMomentum = isolation->Momentum;
207
[e2339af]208 if(fUseMiniCone)
209 {
210 pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
211 candidateMomentum.DeltaR(isolationMomentum) > fDeltaRMin;
212 }
213 else
214 {
215 pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
216 candidate->GetUniqueID() != isolation->GetUniqueID();
217 }
218
219 if(pass)
[d7d2da3]220 {
[e2339af]221
[7f9ae0a]222 sumAllParticles += isolationMomentum.Pt();
[fdfac34]223 if(isolation->Charge != 0)
[004aa60]224 {
[fdfac34]225 if(isolation->IsRecoPU)
226 {
227 sumChargedPU += isolationMomentum.Pt();
228 }
229 else
230 {
[cef50c9]231 sumChargedNoPU += isolationMomentum.Pt();
[fdfac34]232 }
[004aa60]233 }
[e8abecd]234 else
[004aa60]235 {
236 sumNeutral += isolationMomentum.Pt();
[e8abecd]237 }
[d7d2da3]238 }
[e2339af]239
[d7d2da3]240 }
241
[e2339af]242 // find rho
[e9023b9]243 rho = 0.0;
244 if(fRhoInputArray)
245 {
246 fItRhoInputArray->Reset();
247 while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
248 {
249 if(eta >= object->Edges[0] && eta < object->Edges[1])
250 {
251 rho = object->Momentum.Pt();
252 }
253 }
254 }
255
[e2339af]256
257
[004aa60]258 // correct sum for pile-up contamination
[cef50c9]259 sumDBeta = sumChargedNoPU + TMath::Max(sumNeutral - 0.5*sumChargedPU, 0.0);
260 sumRhoCorr = sumChargedNoPU + TMath::Max(sumNeutral - TMath::Max(rho, 0.0)*fDeltaRMax*fDeltaRMax*TMath::Pi(), 0.0);
[7f9ae0a]261 ratioDBeta = sumDBeta/candidateMomentum.Pt();
262 ratioRhoCorr = sumRhoCorr/candidateMomentum.Pt();
[004aa60]263
[b62c2da]264 candidate->IsolationVar = ratioDBeta;
[7f9ae0a]265 candidate->IsolationVarRhoCorr = ratioRhoCorr;
[cef50c9]266 candidate->SumPtCharged = sumChargedNoPU;
[b62c2da]267 candidate->SumPtNeutral = sumNeutral;
268 candidate->SumPtChargedPU = sumChargedPU;
269 candidate->SumPt = sumAllParticles;
[7f9ae0a]270
[844a970]271 sum = fUseRhoCorrection ? sumRhoCorr : sumDBeta;
[004aa60]272 if(fUsePTSum && sum > fPTSumMax) continue;
273
[844a970]274 ratio = fUseRhoCorrection ? ratioRhoCorr : ratioDBeta;
[004aa60]275 if(!fUsePTSum && ratio > fPTRatioMax) continue;
276
[d7d2da3]277 fOutputArray->Add(candidate);
278 }
279}
280
281//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.