ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/IsolationTools.cc
Revision: 1.31
Committed: Fri May 25 19:41:11 2012 UTC (12 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_028a
Changes since 1.30: +98 -89 lines
Log Message:
Update Photon PF Isolation implementation and first CiC4PF attempt plus new regression

File Contents

# Content
1 // $Id: IsolationTools.cc,v 1.30 2012/05/22 23:46:26 mingyang Exp $
2
3 #include "MitPhysics/Utils/interface/IsolationTools.h"
4 #include "MitPhysics/Utils/interface/PhotonTools.h"
5 #include "MitCommon/MathTools/interface/MathUtils.h"
6
7 ClassImp(mithep::IsolationTools)
8
9 using namespace mithep;
10
11 //--------------------------------------------------------------------------------------------------
12 Double_t IsolationTools::TrackIsolation(const Track *p, Double_t extRadius, Double_t intRadius,
13 Double_t ptLow, Double_t maxVtxZDist,
14 const Collection<Track> *tracks)
15 {
16 //Computes the Track Isolation: Summed Transverse Momentum of all tracks inside an
17 //annulus around the electron seed track.
18
19 Double_t ptSum =0.;
20 for (UInt_t i=0; i<tracks->GetEntries();i++) {
21 Double_t tmpPt = tracks->At(i)->Pt();
22 Double_t deltaZ = fabs(p->Z0() - tracks->At(i)->Z0());
23
24 //ignore the track if it is below the pt threshold
25 if (tmpPt < ptLow)
26 continue;
27 //ingore the track if it is too far away in Z
28 if (deltaZ > maxVtxZDist)
29 continue;
30
31 Double_t dr = MathUtils::DeltaR(p->Phi(),p->Eta(),tracks->At(i)->Phi(), tracks->At(i)->Eta());
32 //add the track pt if it is inside the annulus
33 if ( dr < extRadius &&
34 dr >= intRadius ) {
35 ptSum += tmpPt;
36 }
37 }
38 return ptSum;
39 }
40
41 //--------------------------------------------------------------------------------------------------
42 Double_t IsolationTools::EcalIsolation(const SuperCluster *sc, Double_t coneSize, Double_t etLow,
43 const Collection<BasicCluster> *basicClusters)
44 {
45 //Computes the Ecal Isolation: Summed Transverse Energy of all Basic Clusters inside a
46 //cone around the electron, excluding those that are inside the electron super cluster.
47
48 Double_t ecalIsol=0.;
49 const BasicCluster *basicCluster= 0;
50 for (UInt_t i=0; i<basicClusters->GetEntries();i++) {
51 basicCluster = basicClusters->At(i);
52 Double_t basicClusterEnergy = basicCluster->Energy();
53 Double_t basicClusterEta = basicCluster->Eta();
54 Double_t basicClusterEt = basicClusterEnergy*sin(2*atan(exp(basicClusterEta)));
55
56 if (basicClusterEt > etLow) {
57 bool inSuperCluster = false;
58
59 // loop over the basic clusters of the supercluster
60 // to make sure that the basic cluster is not inside
61 // the super cluster. We exclude those.
62 for (UInt_t j=0; j<sc->ClusterSize(); j++) {
63 const BasicCluster *tempBasicClusterInSuperCluster = sc->Cluster(j);
64 if (tempBasicClusterInSuperCluster == basicCluster) {
65 inSuperCluster = true;
66 }
67 }
68
69 if (!inSuperCluster) {
70 Double_t dr = MathUtils::DeltaR(sc->Phi(), sc->Eta(),
71 basicCluster->Phi(),basicCluster->Eta());
72 if(dr < coneSize) {
73 ecalIsol += basicClusterEt;
74 }
75 }
76 }
77 }
78 return ecalIsol;
79 }
80
81 //--------------------------------------------------------------------------------------------------
82 Double_t IsolationTools::CaloTowerHadIsolation(const ThreeVector *p, Double_t extRadius,
83 Double_t intRadius, Double_t etLow,
84 const Collection<CaloTower> *caloTowers)
85 {
86 //Computes the CaloTower Had Et Isolation: Summed Hadronic Transverse Energy of all Calo Towers
87 //inside an annulus around the electron super cluster position.
88
89 Double_t sumEt = 0;
90 for (UInt_t i=0; i<caloTowers->GetEntries();i++) {
91 Double_t caloTowerEt = caloTowers->At(i)->HadEt();
92 Double_t dr = MathUtils::DeltaR(caloTowers->At(i)->Phi(), caloTowers->At(i)->Eta(),
93 p->Phi(), p->Eta());
94 if (dr < extRadius && dr > intRadius && caloTowerEt > etLow) {
95 sumEt += caloTowerEt;
96 }
97 }
98 return sumEt;
99 }
100
101 //--------------------------------------------------------------------------------------------------
102 Double_t IsolationTools::CaloTowerEmIsolation(const ThreeVector *p, Double_t extRadius,
103 Double_t intRadius, Double_t etLow,
104 const Collection<CaloTower> *caloTowers)
105 {
106 //Computes the CaloTower Em Et Isolation: Summed Hadronic Transverse Energy of all Calo Towers
107 //inside an annulus around the electron super cluster position.
108
109 Double_t sumEt = 0;
110 for (UInt_t i=0; i<caloTowers->GetEntries();i++) {
111 Double_t caloTowerEt = caloTowers->At(i)->EmEt();
112 Double_t dr = MathUtils::DeltaR(caloTowers->At(i)->Phi(), caloTowers->At(i)->Eta(),
113 p->Phi(), p->Eta());
114 if (dr < extRadius && dr > intRadius && caloTowerEt > etLow) {
115 sumEt += caloTowerEt;
116 }
117 }
118 return sumEt;
119 }
120
121 //--------------------------------------------------------------------------------------------------
122 Double_t IsolationTools::PFRadialMuonIsolation(const Muon *p, const PFCandidateCol *PFCands,
123 Double_t ptMin, Double_t extRadius)
124 {
125 //Computes the PF Radial Muon Isolation: Summed Transverse Momentum of all PF candidates inside an
126 //annulus around the particle seed track with a dR weighting
127
128 double RadialIso = 0;
129 for (UInt_t i=0; i<PFCands->GetEntries();i++) {
130 const PFCandidate *pf = PFCands->At(i);
131
132 // exclude muon
133 if(pf->TrackerTrk() && p->TrackerTrk() &&
134 pf->TrackerTrk() == p->TrackerTrk()) continue;
135
136 Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
137
138 // inner cone veto for tracks
139 if (dr < 0.01) continue;
140
141 // pt cut applied to neutrals
142 if(!pf->HasTrk() && pf->Pt() <= ptMin) continue;
143
144 // exclude PFMuons and PFElectrons within the cone
145 if (pf->HasTrk() &&
146 (pf->PFType() == PFCandidate::eElectron ||
147 pf->PFType() == PFCandidate::eMuon)) continue;
148
149 // add the pf pt if it is inside the extRadius
150 if (dr < extRadius) RadialIso += pf->Pt() * (1.0 - 3.0*dr);
151 }
152 return RadialIso;
153 }
154
155 //--------------------------------------------------------------------------------------------------
156 Double_t IsolationTools::PFMuonIsolation(const Muon *p, const PFCandidateCol *PFCands,
157 const Vertex *vertex, Double_t delta_z, Double_t ptMin,
158 Double_t extRadius, Double_t intRadiusGamma, Double_t intRadius)
159 {
160 //Computes the PF Isolation: Summed Transverse Momentum of all PF candidates inside an
161 //annulus around the particle seed track.
162
163 Double_t zLepton = 0.0;
164 if(p->BestTrk()) zLepton = p->BestTrk()->DzCorrected(*vertex);
165
166 Double_t ptSum =0.;
167 for (UInt_t i=0; i<PFCands->GetEntries();i++) {
168 const PFCandidate *pf = PFCands->At(i);
169
170 // exclude muon
171 if(pf->TrackerTrk() && p->TrackerTrk() &&
172 pf->TrackerTrk() == p->TrackerTrk()) continue;
173
174 Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
175
176 // pt cut applied to neutrals
177 if(!pf->HasTrk() && pf->Pt() <= ptMin) continue;
178
179 // ignore the pf candidate if it is too far away in Z
180 if(pf->HasTrk()) {
181 Double_t deltaZ = TMath::Abs(pf->BestTrk()->DzCorrected(*vertex) - zLepton);
182 if (deltaZ >= delta_z) continue;
183 }
184
185 // inner cone veto for gammas
186 if (pf->PFType() == PFCandidate::eGamma && dr < intRadiusGamma) continue;
187
188 // inner cone veto for tracks
189 if (dr < intRadius) continue;
190
191 // add the pf pt if it is inside the extRadius
192 if (dr < extRadius) ptSum += pf->Pt();
193
194 }
195 return ptSum;
196 }
197
198 //--------------------------------------------------------------------------------------------------
199 Double_t IsolationTools::PFMuonIsolation(const Muon *p, const PFCandidateCol *PFCands,
200 const MuonCol *goodMuons, const ElectronCol *goodElectrons,
201 const Vertex *vertex, Double_t delta_z, Double_t ptMin,
202 Double_t extRadius, Double_t intRadiusGamma, Double_t intRadius)
203 {
204 //Computes the PF Isolation: Summed Transverse Momentum of all PF candidates inside an
205 //annulus around the particle seed track.
206
207 Double_t zLepton = 0.0;
208 if(p->BestTrk()) zLepton = p->BestTrk()->DzCorrected(*vertex);
209
210 Double_t ptSum =0.;
211 for (UInt_t i=0; i<PFCands->GetEntries();i++) {
212 const PFCandidate *pf = PFCands->At(i);
213
214 // exclude muon
215 if(pf->TrackerTrk() && p->TrackerTrk() &&
216 pf->TrackerTrk() == p->TrackerTrk()) continue;
217
218 Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
219
220 // pt cut applied to neutrals
221 if(!pf->HasTrk() && pf->Pt() <= ptMin) continue;
222
223 // ignore the pf candidate if it is too far away in Z
224 if(pf->HasTrk()) {
225 Double_t deltaZ = TMath::Abs(pf->BestTrk()->DzCorrected(*vertex) - zLepton);
226 if (deltaZ >= delta_z) continue;
227 }
228
229 // inner cone veto for gammas
230 if (pf->PFType() == PFCandidate::eGamma && dr < intRadiusGamma) continue;
231
232 // inner cone veto for tracks
233 if (dr < intRadius) continue;
234
235 // add the pf pt if it is inside the extRadius and outside the intRadius
236 if (dr < extRadius ) {
237 Bool_t isLepton = kFALSE;
238 if(goodMuons){
239 for (UInt_t nl=0; nl<goodMuons->GetEntries();nl++) {
240 const Muon *m = goodMuons->At(nl);
241 if(pf->TrackerTrk() && m->TrackerTrk() &&
242 pf->TrackerTrk() == m->TrackerTrk()) {
243 isLepton = kTRUE;
244 break;
245 }
246 }
247 }
248 if(goodElectrons && isLepton == kFALSE){
249 for (UInt_t nl=0; nl<goodElectrons->GetEntries();nl++) {
250 const Electron *e = goodElectrons->At(nl);
251 if(pf->TrackerTrk() && e->TrackerTrk() &&
252 pf->TrackerTrk() == e->TrackerTrk()) {
253 isLepton = kTRUE;
254 break;
255 }
256 if(pf->GsfTrk() && e->GsfTrk() &&
257 pf->GsfTrk() == e->GsfTrk()) {
258 isLepton = kTRUE;
259 break;
260 }
261 }
262 }
263 if (isLepton == kTRUE) continue;
264 ptSum += pf->Pt();
265 }
266 }
267 return ptSum;
268 }
269
270 //--------------------------------------------------------------------------------------------------
271 Double_t IsolationTools::PFElectronIsolation(const Electron *p, const PFCandidateCol *PFCands,
272 const Vertex *vertex, Double_t delta_z, Double_t ptMin,
273 Double_t extRadius, Double_t intRadius, Int_t PFCandidateType)
274 {
275
276 //Computes the PF Isolation: Summed Transverse Momentum of all PF candidates inside an
277 //annulus around the particle seed track.
278
279 Double_t zLepton = 0.0;
280 if(p->BestTrk()) zLepton = p->BestTrk()->DzCorrected(*vertex);
281
282 Double_t ptSum =0.;
283 for (UInt_t i=0; i<PFCands->GetEntries();i++) {
284 const PFCandidate *pf = PFCands->At(i);
285
286 //select only specified PFCandidate types
287 if (PFCandidateType >= 0) {
288 if (pf->PFType() != PFCandidateType) continue;
289 }
290
291 // pt cut applied to neutrals
292 if(!pf->HasTrk() && pf->Pt() <= ptMin) continue;
293
294 if(pf->TrackerTrk() && p->TrackerTrk() &&
295 pf->TrackerTrk() == p->TrackerTrk()) continue;
296
297 if(pf->GsfTrk() && p->GsfTrk() &&
298 pf->GsfTrk() == p->GsfTrk()) continue;
299
300 // ignore the pf candidate if it is too far away in Z
301 if(pf->BestTrk()) {
302 Double_t deltaZ = TMath::Abs(pf->BestTrk()->DzCorrected(*vertex) - zLepton);
303 if (deltaZ >= delta_z) continue;
304 }
305
306
307 Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
308 // add the pf pt if it is inside the extRadius and outside the intRadius
309 if ( dr < extRadius &&
310 dr >= intRadius ) {
311
312 //EtaStrip Veto for Gamma
313 if (pf->PFType() == PFCandidate::eGamma && fabs(p->Eta() - pf->Eta()) < 0.025) continue;
314
315 //InnerCone (One Tower = dR < 0.07) Veto for non-gamma neutrals
316 if (!pf->HasTrk() && pf->PFType() == PFCandidate::eNeutralHadron
317 && MathUtils::DeltaR(p->Mom(), pf->Mom()) < 0.07 ) continue;
318
319 ptSum += pf->Pt();
320
321 }
322 }
323 return ptSum;
324 }
325
326
327 //--------------------------------------------------------------------------------------------------
328 Double_t IsolationTools::PFElectronIsolation(const Electron *p, const PFCandidateCol *PFCands,
329 const MuonCol *goodMuons, const ElectronCol *goodElectrons,
330 const Vertex *vertex, Double_t delta_z, Double_t ptMin,
331 Double_t extRadius, Double_t intRadius, Int_t PFCandidateType)
332 {
333
334 //Computes the PF Isolation: Summed Transverse Momentum of all PF candidates inside an
335 //annulus around the particle seed track.
336
337 Double_t zLepton = 0.0;
338 if(p->BestTrk()) zLepton = p->BestTrk()->DzCorrected(*vertex);
339
340 Double_t ptSum =0.;
341 for (UInt_t i=0; i<PFCands->GetEntries();i++) {
342 const PFCandidate *pf = PFCands->At(i);
343
344 //select only specified PFCandidate types
345 if (PFCandidateType >= 0) {
346 if (pf->PFType() != PFCandidateType) continue;
347 }
348
349 // pt cut applied to neutrals
350 if(!pf->HasTrk() && pf->Pt() <= ptMin) continue;
351
352 if(pf->TrackerTrk() && p->TrackerTrk() &&
353 pf->TrackerTrk() == p->TrackerTrk()) continue;
354
355 if(pf->GsfTrk() && p->GsfTrk() &&
356 pf->GsfTrk() == p->GsfTrk()) continue;
357
358 // ignore the pf candidate if it is too far away in Z
359 if(pf->BestTrk()) {
360 Double_t deltaZ = TMath::Abs(pf->BestTrk()->DzCorrected(*vertex) - zLepton);
361 if (deltaZ >= delta_z) continue;
362 }
363
364 Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
365 // add the pf pt if it is inside the extRadius and outside the intRadius
366 if ( dr < extRadius &&
367 dr >= intRadius ) {
368
369 //EtaStrip Veto for Gamma
370 if (pf->PFType() == PFCandidate::eGamma && fabs(p->Eta() - pf->Eta()) < 0.025) continue;
371
372 //InnerCone (One Tower = dR < 0.07) Veto for non-gamma neutrals
373 if (!pf->HasTrk() && pf->PFType() == PFCandidate::eNeutralHadron
374 && MathUtils::DeltaR(p->Mom(), pf->Mom()) < 0.07 ) continue;
375
376 Bool_t isLepton = kFALSE;
377 if(goodMuons){
378 for (UInt_t nl=0; nl<goodMuons->GetEntries();nl++) {
379 const Muon *m = goodMuons->At(nl);
380 if(pf->TrackerTrk() && m->TrackerTrk() &&
381 pf->TrackerTrk() == m->TrackerTrk()) {
382 isLepton = kTRUE;
383 break;
384 }
385 }
386 }
387 if(goodElectrons && isLepton == kFALSE){
388 for (UInt_t nl=0; nl<goodElectrons->GetEntries();nl++) {
389 const Electron *e = goodElectrons->At(nl);
390 if(pf->TrackerTrk() && e->TrackerTrk() &&
391 pf->TrackerTrk() == e->TrackerTrk()) {
392 isLepton = kTRUE;
393 break;
394 }
395 if(pf->GsfTrk() && e->GsfTrk() &&
396 pf->GsfTrk() == e->GsfTrk()) {
397 isLepton = kTRUE;
398 break;
399 }
400 }
401 }
402
403 if (isLepton == kTRUE) continue;
404 ptSum += pf->Pt();
405
406 }
407 }
408 return ptSum;
409 }
410 //--------------------------------------------------------------------------------------------------
411 Double_t IsolationTools::PFElectronIsolation2012(const Electron *ele, const Vertex *vertex,
412 const PFCandidateCol *PFCands,
413 const PileupEnergyDensityCol *PileupEnergyDensity,
414 ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaTarget,
415 const ElectronCol *goodElectrons,
416 const MuonCol *goodMuons, Double_t dRMax, Bool_t isDebug){
417
418 Double_t tmpChargedIso_DR = 0;
419 Double_t tmpGammaIso_DR = 0;
420 Double_t tmpNeutralHadronIso_DR = 0;
421
422 for (UInt_t p=0; p<PFCands->GetEntries();p++) {
423 const PFCandidate *pf = PFCands->At(p);
424
425 //exclude the electron itself
426 //if(pf->GsfTrk() && ele->GsfTrk() &&
427 // pf->GsfTrk() == ele->GsfTrk()) continue;
428 //if(pf->TrackerTrk() && ele->TrackerTrk() &&
429 // pf->TrackerTrk() == ele->TrackerTrk()) continue;
430
431 //************************************************************
432 // New Isolation Calculations
433 //************************************************************
434 Double_t dr = MathUtils::DeltaR(ele->Mom(), pf->Mom());
435
436 if (dr < 1.0) {
437 Bool_t IsLeptonFootprint = kFALSE;
438 //************************************************************
439 // Lepton Footprint Removal
440 //************************************************************
441 for (UInt_t q=0; q < goodElectrons->GetEntries() ; ++q) {
442 //if pf candidate matches an electron passing ID cuts, then veto it
443 if(pf->GsfTrk() && goodElectrons->At(q)->GsfTrk() &&
444 pf->GsfTrk() == goodElectrons->At(q)->GsfTrk()) IsLeptonFootprint = kTRUE;
445 if(pf->TrackerTrk() && goodElectrons->At(q)->TrackerTrk() &&
446 pf->TrackerTrk() == goodElectrons->At(q)->TrackerTrk()) IsLeptonFootprint = kTRUE;
447 //if pf candidate lies in veto regions of electron passing ID cuts, then veto it
448 if(pf->BestTrk() && fabs(goodElectrons->At(q)->SCluster()->Eta()) >= 1.479
449 && MathUtils::DeltaR(goodElectrons->At(q)->Mom(), pf->Mom()) < 0.015) IsLeptonFootprint = kTRUE;
450 if(pf->PFType() == PFCandidate::eGamma && fabs(goodElectrons->At(q)->SCluster()->Eta()) >= 1.479 &&
451 MathUtils::DeltaR(goodElectrons->At(q)->Mom(), pf->Mom()) < 0.08) IsLeptonFootprint = kTRUE;
452 }
453 for (UInt_t q=0; q < goodMuons->GetEntries() ; ++q) {
454 //if pf candidate matches an muon passing ID cuts, then veto it
455 if(pf->TrackerTrk() && goodMuons->At(q)->TrackerTrk() &&
456 pf->TrackerTrk() == goodMuons->At(q)->TrackerTrk()) IsLeptonFootprint = kTRUE;
457 //if pf candidate lies in veto regions of muon passing ID cuts, then veto it
458 if(pf->BestTrk() && MathUtils::DeltaR(goodMuons->At(q)->Mom(), pf->Mom()) < 0.01) IsLeptonFootprint = kTRUE;
459 }
460
461 if (!IsLeptonFootprint) {
462 Bool_t passVeto = kTRUE;
463 //Charged
464 if(pf->BestTrk()) {
465 // CMS DOESN"T WANT THIS
466 //if (!(fabs(pf->BestTrk()->DzCorrected(*vertex) - ele->BestTrk()->DzCorrected(*vertex)) < 0.2)) passVeto = kFALSE;
467 //************************************************************
468 // Veto any PFmuon, or PFEle
469 if (pf->PFType() == PFCandidate::eElectron || pf->PFType() == PFCandidate::eMuon) passVeto = kFALSE;
470 //************************************************************
471 //************************************************************
472 // Footprint Veto
473 if (fabs(ele->SCluster()->Eta()) >= 1.479 && dr < 0.015) passVeto = kFALSE;
474 //************************************************************
475 if (passVeto) {
476 if (dr < dRMax) tmpChargedIso_DR += pf->Pt();
477 } //pass veto
478
479 }
480 //Gamma
481 else if (pf->PFType() == PFCandidate::eGamma) {
482 //************************************************************
483 // Footprint Veto
484 if (fabs(ele->SCluster()->Eta()) >= 1.479) {
485 if (dr < 0.08) passVeto = kFALSE;
486 }
487 //************************************************************
488
489 if (passVeto) {
490 if (dr < dRMax) tmpGammaIso_DR += pf->Pt();
491 }
492 }
493 //NeutralHadron
494 else {
495 if (dr < dRMax) tmpNeutralHadronIso_DR += pf->Pt();
496 }
497 } //not lepton footprint
498 } //in 1.0 dr cone
499 } //loop over PF candidates
500
501 Double_t Rho = 0;
502 if (!(TMath::IsNaN(PileupEnergyDensity->At(0)->Rho()) || isinf(PileupEnergyDensity->At(0)->Rho()))) Rho = PileupEnergyDensity->At(0)->Rho();
503
504 Double_t IsoVar_ChargedIso_DR = tmpChargedIso_DR/ele->Pt();
505 Double_t IsoVar_NeutralIso_DR = tmpGammaIso_DR + tmpNeutralHadronIso_DR;
506 // Careful here, we have kEleNeutralIso04 only for now
507 if(dRMax != 0.4) assert(0);
508 double EA = ElectronTools::ElectronEffectiveArea(ElectronTools::kEleNeutralIso04, ele->SCluster()->Eta(), EffectiveAreaTarget);
509 IsoVar_NeutralIso_DR = TMath::Max((IsoVar_NeutralIso_DR - Rho*EA)/ele->Pt(), 0.0);
510
511 if(isDebug == kTRUE){
512 printf("Iso(ch, em, nh), EA, RelIso = (%f, %f, %f), %f, %f\n",tmpChargedIso_DR,tmpGammaIso_DR,tmpNeutralHadronIso_DR,
513 EA,IsoVar_ChargedIso_DR + IsoVar_NeutralIso_DR);
514 }
515
516 return (IsoVar_ChargedIso_DR + IsoVar_NeutralIso_DR);
517 }
518 //--------------------------------------------------------------------------------------------------
519 Double_t IsolationTools::BetaM(const TrackCol *tracks, const Muon *p, const Vertex *vertex,
520 Double_t ptMin, Double_t delta_z, Double_t extRadius,
521 Double_t intRadius){
522
523 if(!tracks) return 1.0;
524 if(tracks->GetEntries() <= 0) return 1.0;
525
526 double Pt_jets_X = 0. ;
527 double Pt_jets_Y = 0. ;
528 double Pt_jets_X_tot = 0. ;
529 double Pt_jets_Y_tot = 0. ;
530
531 for(int i=0;i<int(tracks->GetEntries());i++){
532 const Track *pTrack = tracks->At(i);
533
534 if(pTrack && p->TrackerTrk() &&
535 pTrack == p->TrackerTrk()) continue;
536
537 if(pTrack->Pt() <= ptMin) continue;
538
539 Double_t dr = MathUtils::DeltaR(pTrack->Mom(),p->Mom());
540 if ( dr < extRadius && dr >= intRadius ) {
541 Pt_jets_X_tot += pTrack->Px();
542 Pt_jets_Y_tot += pTrack->Py();
543 double pDz = TMath::Abs(pTrack->DzCorrected(*vertex));
544 if(pDz < delta_z){
545 Pt_jets_X += pTrack->Px();
546 Pt_jets_Y += pTrack->Py();
547 }
548 }
549 }
550
551 if(sqrt(Pt_jets_X_tot*Pt_jets_X_tot + Pt_jets_Y_tot*Pt_jets_Y_tot) > 0)
552 return sqrt(Pt_jets_X*Pt_jets_X + Pt_jets_Y*Pt_jets_Y) / sqrt(Pt_jets_X_tot*Pt_jets_X_tot + Pt_jets_Y_tot*Pt_jets_Y_tot);
553
554 return 1.0;
555 }
556
557 //--------------------------------------------------------------------------------------------------
558 Double_t IsolationTools::BetaE(const TrackCol *tracks, const Electron *p, const Vertex *vertex,
559 Double_t ptMin, Double_t delta_z, Double_t extRadius,
560 Double_t intRadius){
561
562 if(!tracks) return 1.0;
563 if(tracks->GetEntries() <= 0) return 1.0;
564
565 double Pt_jets_X = 0. ;
566 double Pt_jets_Y = 0. ;
567 double Pt_jets_X_tot = 0. ;
568 double Pt_jets_Y_tot = 0. ;
569
570 for(int i=0;i<int(tracks->GetEntries());i++){
571 const Track *pTrack = tracks->At(i);
572
573 if(pTrack && p->TrackerTrk() &&
574 pTrack == p->TrackerTrk()) continue;
575
576 if(pTrack && p->GsfTrk() &&
577 pTrack == p->GsfTrk()) continue;
578
579 if(pTrack->Pt() <= ptMin) continue;
580
581 Double_t dr = MathUtils::DeltaR(pTrack->Mom(),p->Mom());
582 if ( dr < extRadius && dr >= intRadius ) {
583 Pt_jets_X_tot += pTrack->Px();
584 Pt_jets_Y_tot += pTrack->Py();
585 double pDz = TMath::Abs(pTrack->DzCorrected(*vertex));
586 if(pDz < delta_z){
587 Pt_jets_X += pTrack->Px();
588 Pt_jets_Y += pTrack->Py();
589 }
590 }
591 }
592
593 if(sqrt(Pt_jets_X_tot*Pt_jets_X_tot + Pt_jets_Y_tot*Pt_jets_Y_tot) > 0)
594 return sqrt(Pt_jets_X*Pt_jets_X + Pt_jets_Y*Pt_jets_Y) / sqrt(Pt_jets_X_tot*Pt_jets_X_tot + Pt_jets_Y_tot*Pt_jets_Y_tot);
595
596 return 1.0;
597 }
598
599
600 // method added by F.Stoeckli: computes the track isolation with NO constrint on the OV-track compatibility
601 Double_t IsolationTools::TrackIsolationNoPV(const mithep::Particle* p, const BaseVertex* bsp,
602 Double_t extRadius,
603 Double_t intRadius,
604 Double_t ptLow,
605 Double_t etaStrip,
606 Double_t maxD0,
607 mithep::TrackQuality::EQuality quality,
608 const mithep::Collection<mithep::Track> *tracks,
609 UInt_t maxNExpectedHitsInner,
610 const mithep::DecayParticleCol *conversions) {
611
612 // loop over all tracks
613 Double_t tPt = 0.;
614 //std::cout<<" *** TrackIso:"<<std::endl;
615 for(UInt_t i=0; i<tracks->GetEntries(); ++i) {
616 const Track* t = tracks->At(i);
617 if(t->Pt()>1. && false) {
618 std::cout<<" "<<i<<" pt = "<<t->Pt()<<" ("<<ptLow<<")"<<std::endl;
619 std::cout<<" d0 = "<<fabs(t->D0Corrected( *bsp) )<<" ("<<maxD0<<")"<<std::endl;
620 //std::cout<<" conv ? "<<PhotonTools::MatchedConversion(t,conversions,bsp)<<std::endl;
621 std::cout<<" dR = "<<MathUtils::DeltaR(t->Mom(),p->Mom())<<" ("<<extRadius<<","<<intRadius<<")"<<std::endl;
622 std::cout<<" dEta = "<<fabs(t->Eta()-p->Eta())<<" ("<<etaStrip<<")"<<std::endl;
623 }
624 if ( t->Pt() < ptLow ) continue;
625 if ( ! t->Quality().Quality(quality) ) continue;
626 // only check for beamspot if available, otherwise ignore cut
627 if ( bsp && fabs(t->D0Corrected( *bsp) ) > maxD0) continue;
628 if (t->NExpectedHitsInner()>maxNExpectedHitsInner) continue;
629 if (conversions && PhotonTools::MatchedConversion(t,conversions,bsp)) continue;
630 Double_t dR = MathUtils::DeltaR(t->Mom(),p->Mom());
631 Double_t dEta = fabs(t->Eta()-p->Eta());
632 if(dR < extRadius && dR > intRadius && dEta > etaStrip) tPt += t->Pt();
633 }
634 return tPt;
635 }
636
637
638 Double_t IsolationTools::CiCTrackIsolation(const mithep::Photon* p,
639 const BaseVertex* theVtx,
640 Double_t extRadius,
641 Double_t intRadius,
642 Double_t ptLow,
643 Double_t etaStrip,
644 Double_t maxD0,
645 Double_t maxDZ,
646 const mithep::Collection<mithep::Track> *tracks,
647 unsigned int* worstVtxIndex,
648 const mithep::Collection<mithep::Vertex> *vtxs,
649 const mithep::Collection<mithep::Electron> *eles,
650 bool print,
651 double* ptmax, double* dRmax) {
652
653 UInt_t numVtx = 1;
654 const BaseVertex* iVtx = theVtx;
655 if( vtxs ) {
656 numVtx = vtxs->GetEntries();
657 if (numVtx > 0)
658 iVtx = vtxs->At(0);
659 else
660 return 0.;
661 }
662
663 // NEW for Electron T&P: need to remove the electron Gsf Track (applied if eles != NULL)
664 const Track* theGsfTrack = NULL;
665 if ( eles ) {
666 // find the electron that matches the Photon SC
667 for(UInt_t j=0; j<eles->GetEntries(); ++j) {
668 if ( eles->At(j)->SCluster() == p->SCluster() ) {
669 if( eles->At(j)->HasTrackerTrk() )
670 theGsfTrack = eles->At(j)->TrackerTrk();
671 break;
672 }
673 }
674 }
675
676 if(print) {
677 std::cout<<" Testing photon with"<<std::endl;
678 std::cout<<" Et = "<<p->Et()<<std::endl;
679 std::cout<<" Eta = "<<p->Eta()<<std::endl;
680 std::cout<<" Phi = "<<p->Phi()<<std::endl;
681 }
682
683 Double_t iIso = 0.;
684 Double_t maxIso = 0.;
685
686 if(worstVtxIndex)
687 *worstVtxIndex=0;
688
689 double t_ptmax = 0.;
690 double t_dRmax = 0.;
691
692 for(UInt_t i=0; i<numVtx; ++i) {
693
694 if(i>0) iVtx = vtxs->At(i);
695
696
697 if(print) {
698 std::cout<<" Vertex #"<<i<<std::endl;
699 std::cout<<" with X = "<<iVtx->X()<<std::endl;
700 std::cout<<" with Y = "<<iVtx->Y()<<std::endl;
701 std::cout<<" with Z = "<<iVtx->Z()<<std::endl;
702 }
703
704 Photon* phTemp = new Photon(*p);
705
706 // RESET CALO_POS!
707 phTemp->SetCaloPosXYZ(p->SCluster()->Point().X(),p->SCluster()->Point().Y(),p->SCluster()->Point().Z());
708
709 // compute the ph momentum with respect to this Vtx
710 //FourVectorM phMom = p->MomVtx(iVtx->Position());
711 FourVectorM phMom = phTemp->MomVtx(iVtx->Position());
712
713 delete phTemp;
714
715 if(print) {
716 std::cout<<" photon has changed to:"<<std::endl;
717 std::cout<<" Et = "<<phMom.Et()<<std::endl;
718 std::cout<<" eta = "<<phMom.Eta()<<std::endl;
719 std::cout<<" Phi = "<<phMom.Phi()<<std::endl;
720 }
721
722 iIso = 0.;
723 for(UInt_t j=0; j<tracks->GetEntries(); ++j) {
724 const Track* t = tracks->At(j);
725 if( theGsfTrack && t == theGsfTrack ) continue;
726
727 //Double_t dR = MathUtils::DeltaR(t->Mom(),p->Mom());
728 //Double_t dEta = TMath::Abs(t->Eta()-p->Eta());
729
730 Double_t dR = MathUtils::DeltaR(t->Mom(),phMom);
731 Double_t dEta = TMath::Abs(t->Eta()-phMom.Eta());
732
733 if(print && t->Pt()>1. && false) {
734 std::cout<<" passing track #"<<j<<std::endl;
735 std::cout<<" pt = "<<t->Pt()<<std::endl;
736 std::cout<<" eta = "<<t->Eta()<<std::endl;
737 std::cout<<" phi = "<<t->Phi()<<std::endl;
738 std::cout<<" d0 = "<<fabs(t->D0Corrected( *iVtx ))<<std::endl;
739 std::cout<<" dZ = "<<fabs(t->DzCorrected( *iVtx ))<<std::endl;
740 std::cout<<" dR = "<<dR<<std::endl;
741 std::cout<<" dEta = "<<dEta<<std::endl;
742 std::cout<<" vx = "<<t->X0()<<std::endl;
743 std::cout<<" vy = "<<t->Y0()<<std::endl;
744 std::cout<<" vz = "<<t->Z0()<<std::endl;
745 }
746
747 if ( t->Pt() < ptLow ) continue;
748 // only check for beamspot if available, otherwise ignore cut
749 if ( fabs(t->D0Corrected( *iVtx )) > maxD0) continue;
750 if ( fabs(t->DzCorrected( *iVtx )) > maxDZ) continue;
751
752
753 if(dR < extRadius && dR > intRadius && dEta > etaStrip) {
754 iIso += t->Pt();
755
756 if(t->Pt() > t_ptmax) {
757 t_ptmax=t->Pt();
758 t_dRmax=dR;
759 }
760
761 if(print && t->Pt()>1.) {
762 std::cout<<" passing track #"<<j<<std::endl;
763 std::cout<<" pt = "<<t->Pt()<<std::endl;
764 std::cout<<" eta = "<<t->Eta()<<std::endl;
765 std::cout<<" phi = "<<t->Phi()<<std::endl;
766 std::cout<<" d0 = "<<fabs(t->D0Corrected( *iVtx ))<<std::endl;
767 std::cout<<" dZ = "<<fabs(t->DzCorrected( *iVtx ))<<std::endl;
768 std::cout<<" dR = "<<dR<<std::endl;
769 std::cout<<" dEta = "<<dEta<<std::endl;
770 std::cout<<" vx = "<<t->X0()<<std::endl;
771 std::cout<<" vy = "<<t->Y0()<<std::endl;
772 std::cout<<" vz = "<<t->Z0()<<std::endl;
773 std::cout<<" new tIso = "<<iIso<<std::endl;
774 }
775 }
776 }
777 if ( iIso > maxIso ) {
778 maxIso = iIso;
779 if(worstVtxIndex)
780 *worstVtxIndex=i;
781 }
782 }
783
784 if(ptmax) (*ptmax)=t_ptmax;
785 if(dRmax) (*dRmax)=t_dRmax;
786
787 if(print) {
788 if(worstVtxIndex)
789 std::cout<<" max TrkIso is given by Vtx #"<<*worstVtxIndex<<" with an amount of tIso = "<<maxIso<<std::endl;
790 else
791 std::cout<<" max TrkIso is given by Vtx #0 with an amount of tIso = "<<maxIso<<std::endl;
792 }
793 return maxIso;
794 }
795
796 //ChargedIso_selvtx_DR0To0p001=IsolationTools::PFChargedIsolation(p, SelVtx, 0.01, 0, 0.0, 0.0, 0.1, 0.2,fPFCands);
797
798 Double_t IsolationTools::PFChargedIsolation(const mithep::Photon *p,
799 const BaseVertex *theVtx,
800 Double_t extRadius,
801 Double_t intRadius,
802 const PFCandidateCol *PFCands,
803 unsigned int* worstVtxIndex,
804 const mithep::Collection<mithep::Vertex> *vtxs,
805 bool print)
806 {
807
808 UInt_t numVtx = 1;
809
810 const BaseVertex* iVtx = theVtx;
811
812 if( vtxs ) {
813 numVtx = vtxs->GetEntries();
814 if (numVtx > 0)
815 iVtx = vtxs->At(0);
816 else
817 return 0.;
818 }
819
820 if(print) {
821 std::cout<<" Testing photon with"<<std::endl;
822 std::cout<<" Et = "<<p->Et()<<std::endl;
823 std::cout<<" Eta = "<<p->Eta()<<std::endl;
824 std::cout<<" Phi = "<<p->Phi()<<std::endl;
825 }
826
827 Double_t iIso = 0.;
828 Double_t maxIso = 0.;
829
830 if(worstVtxIndex)
831 *worstVtxIndex=0;
832
833 for(UInt_t i=0; i<numVtx; ++i) {
834
835 if(i>0) iVtx = vtxs->At(i);
836
837
838 if(print) {
839 std::cout<<" Vertex #"<<i<<std::endl;
840 std::cout<<" with X = "<<iVtx->X()<<std::endl;
841 std::cout<<" with Y = "<<iVtx->Y()<<std::endl;
842 std::cout<<" with Z = "<<iVtx->Z()<<std::endl;
843 }
844
845 ThreeVector photondir = ThreeVector(p->SCluster()->Point()) - iVtx->Position();
846
847 iIso = 0.;
848
849 for(UInt_t j=0; j<PFCands->GetEntries(); ++j) {
850 const PFCandidate *pf= PFCands->At(j);
851 if(pf->HasTrackerTrk() && pf->PFType()==PFCandidate::eHadron) {
852 const Track* t = pf->TrackerTrk();
853
854 Double_t dR = MathUtils::DeltaR(*pf,photondir);
855 //Double_t dEta = TMath::Abs(pf->Eta()-photondir.Eta());
856
857 if (dR<0.02) continue;
858 if (dR<intRadius) continue;
859 if (dR>extRadius) continue;
860
861 if(print && pf->Pt()>1. && false) {
862 std::cout<<" passing track #"<<j<<std::endl;
863 std::cout<<" pt = "<<pf->Pt()<<std::endl;
864 std::cout<<" eta = "<<pf->Eta()<<std::endl;
865 std::cout<<" phi = "<<pf->Phi()<<std::endl;
866 std::cout<<" d0 = "<<fabs(t->D0Corrected( *iVtx ))<<std::endl;
867 std::cout<<" dZ = "<<fabs(t->DzCorrected( *iVtx ))<<std::endl;
868 std::cout<<" dR = "<<dR<<std::endl;
869 //std::cout<<" dEta = "<<dEta<<std::endl;
870 std::cout<<" vx = "<<t->X0()<<std::endl;
871 std::cout<<" vy = "<<t->Y0()<<std::endl;
872 std::cout<<" vz = "<<t->Z0()<<std::endl;
873 }
874
875
876 // only check for beamspot if available, otherwise ignore cut
877 if ( fabs(t->D0Corrected( *iVtx )) > 0.1) continue;
878 if ( fabs(t->DzCorrected( *iVtx )) > 0.2) continue;
879
880 iIso += pf->Pt();
881
882 }
883 }
884
885 if ( iIso > maxIso ) {
886 maxIso = iIso;
887 if(worstVtxIndex)
888 *worstVtxIndex=i;
889 }
890 }
891
892
893 if(print) {
894 if(worstVtxIndex)
895 std::cout<<" max TrkIso is given by Vtx #"<<*worstVtxIndex<<" with an amount of tIso = "<<maxIso<<std::endl;
896 else
897 std::cout<<" max TrkIso is given by Vtx #0 with an amount of tIso = "<<maxIso<<std::endl;
898 }
899 return maxIso;
900 }
901
902 //
903 Float_t IsolationTools::PFChargedCount(const mithep::Photon* p,
904 const BaseVertex* theVtx,
905 Double_t extRadius,
906 Double_t intRadius,
907 Double_t ptLow,
908 Double_t etaStrip,
909 Double_t maxD0,
910 Double_t maxDZ,
911 const PFCandidateCol *PFCands,
912 unsigned int* worstVtxIndex,
913 const mithep::Collection<mithep::Vertex> *vtxs,
914 const mithep::Collection<mithep::Electron> *eles,
915 bool print,
916 double* ptmax,
917 double* dRmax) {
918
919 UInt_t numVtx = 1;
920
921 const BaseVertex* iVtx = theVtx;
922
923 if( vtxs ) {
924 numVtx = vtxs->GetEntries();
925 if (numVtx > 0)
926 iVtx = vtxs->At(0);
927 else
928 return 0.;
929 }
930
931 // NEW for Electron T&P: need to remove the electron Gsf Track (applied if eles != NULL)
932 const Track* theGsfTrack = NULL;
933 if ( eles ) {
934 // find the electron that matches the Photon SC
935 for(UInt_t j=0; j<eles->GetEntries(); ++j) {
936 if ( eles->At(j)->SCluster() == p->SCluster() ) {
937 if( eles->At(j)->HasTrackerTrk() )
938 theGsfTrack = eles->At(j)->TrackerTrk();
939 break;
940 }
941 }
942 }
943
944 if(print) {
945 std::cout<<" Testing photon with"<<std::endl;
946 std::cout<<" Et = "<<p->Et()<<std::endl;
947 std::cout<<" Eta = "<<p->Eta()<<std::endl;
948 std::cout<<" Phi = "<<p->Phi()<<std::endl;
949 }
950
951 Double_t iIso = 0.;
952 Double_t maxIso = 0.;
953
954 Float_t iNumParticles = 0.;
955 Float_t maxNumParticles = 0.;
956
957 if(worstVtxIndex)
958 *worstVtxIndex=0;
959
960 double t_ptmax = 0.;
961 double t_dRmax = 0.;
962
963 for(UInt_t i=0; i<numVtx; ++i) {
964
965 if(i>0) iVtx = vtxs->At(i);
966
967
968 if(print) {
969 std::cout<<" Vertex #"<<i<<std::endl;
970 std::cout<<" with X = "<<iVtx->X()<<std::endl;
971 std::cout<<" with Y = "<<iVtx->Y()<<std::endl;
972 std::cout<<" with Z = "<<iVtx->Z()<<std::endl;
973 }
974
975 Photon* phTemp = new Photon(*p);
976
977 // RESET CALO_POS! //ming: why?
978 phTemp->SetCaloPosXYZ(p->SCluster()->Point().X(),p->SCluster()->Point().Y(),p->SCluster()->Point().Z());
979
980 // compute the ph momentum with respect to this Vtx
981 FourVectorM phMom = phTemp->MomVtx(iVtx->Position());
982
983 delete phTemp;
984
985 if(print) {
986 std::cout<<" photon has changed to:"<<std::endl;
987 std::cout<<" Et = "<<phMom.Et()<<std::endl;
988 std::cout<<" eta = "<<phMom.Eta()<<std::endl;
989 std::cout<<" Phi = "<<phMom.Phi()<<std::endl;
990 }
991
992 iIso = 0.;
993 iNumParticles = 0.;
994
995 for(UInt_t j=0; j<PFCands->GetEntries(); ++j) {
996 const PFCandidate *pf= PFCands->At(j);
997 if(pf->HasTrk() && (pf->PFType()==PFCandidate::eHadron || pf->PFType()==PFCandidate::eElectron || pf->PFType()==PFCandidate::eMuon)){
998 const Track* t = pf->BestTrk();
999 if(pf->PFType()==PFCandidate::eElectron && pf->HasGsfTrk()){t = pf->GsfTrk();}
1000 if(!(pf->PFType()==PFCandidate::eElectron) && pf->HasTrackerTrk()){t = pf->TrackerTrk();}
1001
1002 if( theGsfTrack && t == theGsfTrack ) continue;
1003
1004 Double_t dR = MathUtils::DeltaR(pf->Mom(),phMom);
1005 Double_t dEta = TMath::Abs(pf->Eta()-phMom.Eta());
1006
1007 if(print && pf->Pt()>1. && false) {
1008 std::cout<<" passing track #"<<j<<std::endl;
1009 std::cout<<" pt = "<<pf->Pt()<<std::endl;
1010 std::cout<<" eta = "<<pf->Eta()<<std::endl;
1011 std::cout<<" phi = "<<pf->Phi()<<std::endl;
1012 std::cout<<" d0 = "<<fabs(t->D0Corrected( *iVtx ))<<std::endl;
1013 std::cout<<" dZ = "<<fabs(t->DzCorrected( *iVtx ))<<std::endl;
1014 std::cout<<" dR = "<<dR<<std::endl;
1015 std::cout<<" dEta = "<<dEta<<std::endl;
1016 std::cout<<" vx = "<<t->X0()<<std::endl;
1017 std::cout<<" vy = "<<t->Y0()<<std::endl;
1018 std::cout<<" vz = "<<t->Z0()<<std::endl;
1019 }
1020
1021 if ( pf->Pt() < ptLow ) continue;
1022
1023 // only check for beamspot if available, otherwise ignore cut
1024 if ( fabs(t->D0Corrected( *iVtx )) > maxD0) continue;
1025 if ( fabs(t->DzCorrected( *iVtx )) > maxDZ) continue;
1026
1027
1028 if(dR < extRadius && dR > intRadius && dEta > etaStrip) {
1029 iIso += pf->Pt();
1030 iNumParticles += 1;
1031
1032 if(pf->Pt() > t_ptmax) {
1033 t_ptmax=pf->Pt();
1034 t_dRmax=dR;
1035 }
1036
1037 if(print && pf->Pt()>1.) {
1038 std::cout<<" passing track #"<<j<<std::endl;
1039 std::cout<<" pt = "<<pf->Pt()<<std::endl;
1040 std::cout<<" eta = "<<pf->Eta()<<std::endl;
1041 std::cout<<" phi = "<<pf->Phi()<<std::endl;
1042 std::cout<<" d0 = "<<fabs(t->D0Corrected( *iVtx ))<<std::endl;
1043 std::cout<<" dZ = "<<fabs(t->DzCorrected( *iVtx ))<<std::endl;
1044 std::cout<<" dR = "<<dR<<std::endl;
1045 std::cout<<" dEta = "<<dEta<<std::endl;
1046 std::cout<<" vx = "<<t->X0()<<std::endl;
1047 std::cout<<" vy = "<<t->Y0()<<std::endl;
1048 std::cout<<" vz = "<<t->Z0()<<std::endl;
1049 std::cout<<" new tIso = "<<iIso<<std::endl;
1050 }
1051 }
1052 }
1053 }
1054
1055 if ( iIso > maxIso ) {
1056 maxIso = iIso;
1057 maxNumParticles = iNumParticles;
1058
1059 if(worstVtxIndex)
1060 *worstVtxIndex=i;
1061 }
1062 }
1063
1064 if(ptmax) (*ptmax)=t_ptmax;
1065 if(dRmax) (*dRmax)=t_dRmax;
1066
1067 if(print) {
1068 if(worstVtxIndex)
1069 std::cout<<" max TrkIso is given by Vtx #"<<*worstVtxIndex<<" with an amount of tIso = "<<maxIso<<std::endl;
1070 else
1071 std::cout<<" max TrkIso is given by Vtx #0 with an amount of tIso = "<<maxIso<<std::endl;
1072 }
1073 return maxNumParticles;
1074 }
1075
1076 Double_t IsolationTools::PFGammaIsolation(const mithep::Photon *p,
1077 Double_t extRadius,
1078 Double_t intRadius,
1079 const PFCandidateCol *PFCands)
1080 {
1081
1082 Double_t iso = 0.;
1083
1084 ThreeVector photondir;
1085 Bool_t setdir = kFALSE;
1086
1087 for (UInt_t ipfc = 0; ipfc<PFCands->GetEntries(); ++ipfc) {
1088 const PFCandidate *pfc = PFCands->At(ipfc);
1089 if (pfc->PFType()!=PFCandidate::eGamma) continue;
1090 if (!setdir) {
1091 photondir = ThreeVector(p->SCluster()->Point() - pfc->SourceVertex());
1092 setdir = kTRUE;
1093 }
1094
1095 Double_t dR = MathUtils::DeltaR(*pfc,photondir);
1096 Double_t dEta = TMath::Abs(pfc->Eta()-photondir.Eta());
1097
1098 Bool_t isbarrel = p->SCluster()->AbsEta()<1.5;
1099
1100 if (isbarrel && dEta<0.015) continue;
1101 if (!isbarrel && dR<0.07) continue;
1102 if (dR<intRadius) continue;
1103 if (dR>extRadius) continue;
1104
1105 iso += pfc->Pt();
1106
1107 }
1108
1109 return iso;
1110
1111
1112 }
1113
1114 Double_t IsolationTools::PFNeutralHadronIsolation(const mithep::Photon *p,
1115 Double_t extRadius,
1116 Double_t intRadius,
1117 const PFCandidateCol *PFCands)
1118 {
1119
1120 Double_t iso = 0.;
1121
1122 ThreeVector photondir;
1123 Bool_t setdir = kFALSE;
1124
1125 for (UInt_t ipfc = 0; ipfc<PFCands->GetEntries(); ++ipfc) {
1126 const PFCandidate *pfc = PFCands->At(ipfc);
1127 if (pfc->PFType()!=PFCandidate::eGamma) continue;
1128 if (!setdir) {
1129 photondir = ThreeVector(p->SCluster()->Point() - pfc->SourceVertex());
1130 setdir = kTRUE;
1131 }
1132
1133 Double_t dR = MathUtils::DeltaR(*pfc,photondir);
1134
1135 if (dR<intRadius) continue;
1136 if (dR>extRadius) continue;
1137
1138 iso += pfc->Pt();
1139
1140 }
1141
1142 return iso;
1143
1144
1145 }