ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/FakeMods/src/GenFakeableObjsMod.cc
Revision: 1.4
Committed: Tue Jul 21 16:35:12 2009 UTC (15 years, 9 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_010
Changes since 1.3: +3 -3 lines
Log Message:
Migrate removed accessors to equivalent replacements

File Contents

# Content
1 // $Id: GenFakeableObjsMod.cc,v 1.3 2009/07/13 11:27:13 loizides Exp $
2
3 #include "MitPhysics/FakeMods/interface/GenFakeableObjsMod.h"
4 #include "MitCommon/MathTools/interface/MathUtils.h"
5 #include "MitAna/DataUtil/interface/Debug.h"
6 #include "MitAna/DataTree/interface/ElectronCol.h"
7 #include "MitAna/DataTree/interface/MuonCol.h"
8 #include "MitAna/DataTree/interface/SuperClusterCol.h"
9 #include "MitAna/DataTree/interface/TrackCol.h"
10 #include "MitAna/DataTree/interface/JetCol.h"
11 #include "MitAna/DataTree/interface/VertexCol.h"
12 #include "MitAna/DataTree/interface/DecayParticleCol.h"
13 #include "MitAna/DataTree/interface/StableData.h"
14 #include "MitPhysics/Init/interface/ModNames.h"
15 #include "MitPhysics/Utils/interface/IsolationTools.h"
16
17 using namespace mithep;
18
19 ClassImp(mithep::GenFakeableObjsMod)
20
21 //--------------------------------------------------------------------------------------------------
22 GenFakeableObjsMod::GenFakeableObjsMod(const char *name, const char *title) :
23 BaseMod(name,title),
24 fVetoTriggerJet(false),
25 fVetoGenLeptons(true),
26 fVetoCleanLeptons(false),
27 fElectronFOType("GsfPlusSC"),
28 fMuonFOType("IsoTrack"),
29 fTriggerName("NotSpecified"),
30 fTriggerObjectsName("NotSpecified"),
31 fElectronBranchName(Names::gkElectronBrn),
32 fMuonBranchName(Names::gkMuonBrn),
33 fTrackBranchName(Names::gkTrackBrn),
34 fGsfTrackBranchName(Names::gkGsfTrackBrn),
35 fBarrelSuperClusterBranchName(Names::gkBarrelSuperClusterBrn),
36 fEndcapSuperClusterBranchName(Names::gkEndcapSuperClusterBrn),
37 fVertexBranchName(Names::gkPVBeamSpotBrn),
38 fConversionBranchName(Names::gkMvfConversionBrn),
39 fGoodJetsName(ModNames::gkGoodJetsName),
40 fCleanElectronsName(ModNames::gkCleanElectronsName),
41 fCleanMuonsName(ModNames::gkCleanMuonsName),
42 fMCLeptonsName(ModNames::gkMCLeptonsName),
43 fMCTausName(ModNames::gkMCTausName),
44 fElFakeableObjsName(ModNames::gkElFakeableObjsName),
45 fMuFakeableObjsName(ModNames::gkMuFakeableObjsName),
46 fElFOType(kElFOUndef),
47 fMuFOType(kMuFOUndef),
48 fBarrelSuperClusters(0),
49 fEndcapSuperClusters(0),
50 fTracks(0),
51 fGsfTracks(0),
52 fVertices(0),
53 fConversions(0)
54 {
55 // Constructor.
56 }
57
58 //--------------------------------------------------------------------------------------------------
59 void GenFakeableObjsMod::SlaveBegin()
60 {
61 // Run startup code on the computer (slave) doing the actual analysis. Here,
62 // we typically initialize histograms and other analysis objects and request
63 // branches. For this module, we request a branch of the MitTree.
64
65 //------------------------------------------------------------------------------------------------
66 // Request the branches (no significant time safed by not doing this)
67 //------------------------------------------------------------------------------------------------
68 ReqBranch(fElectronBranchName, fElectrons);
69 ReqBranch(fMuonBranchName, fMuons);
70 ReqBranch(fTrackBranchName, fTracks);
71 ReqBranch(fGsfTrackBranchName, fGsfTracks);
72 ReqBranch(fBarrelSuperClusterBranchName, fBarrelSuperClusters);
73 ReqBranch(fEndcapSuperClusterBranchName, fEndcapSuperClusters);
74 ReqBranch(fConversionBranchName, fConversions);
75 ReqBranch(fVertexBranchName, fVertices);
76
77 if (fElectronFOType.CompareTo("GsfPlusSC") == 0)
78 fElFOType = kElFOGsfPlusSC;
79 else if (fElectronFOType.CompareTo("Reco") == 0)
80 fElFOType = kElFOReco;
81 else if (fElectronFOType.CompareTo("Loose") == 0)
82 fElFOType = kElFOLoose;
83 else {
84 SendError(kAbortAnalysis, "SlaveBegin",
85 "The specified electron fakeable object %s is not defined.",
86 fElectronFOType.Data());
87 return;
88 }
89
90 if (fMuonFOType.CompareTo("IsoTrack") == 0)
91 fMuFOType = kMuFOIsoTrack;
92 else if (fMuonFOType.CompareTo("Global") == 0)
93 fMuFOType = kMuFOGlobal;
94 else if (fMuonFOType.CompareTo("TrackerMuon") == 0)
95 fMuFOType = kMuFOTrackerMuon;
96 else {
97 SendError(kAbortAnalysis, "SlaveBegin",
98 "The specified muon fakeable object %s is not defined.",
99 fMuonFOType.Data());
100 return;
101 }
102
103 }
104
105 //--------------------------------------------------------------------------------------------------
106 void GenFakeableObjsMod::Process()
107 {
108 // Process entries of the tree.
109 LoadBranch(fElectronBranchName);
110 LoadBranch(fMuonBranchName);
111 LoadBranch(fTrackBranchName);
112 LoadBranch(fGsfTrackBranchName);
113 LoadBranch(fBarrelSuperClusterBranchName);
114 LoadBranch(fEndcapSuperClusterBranchName);
115 LoadBranch(fVertexBranchName);
116 LoadBranch(fConversionBranchName);
117
118 //Load Trigger Objects
119 const TriggerObjectCol *triggerObjects = GetHLTObjects(fTriggerObjectsName);
120 if (!triggerObjects && fVetoTriggerJet) {
121 cout << "Error: Could not load Trigger Object Collection with name "
122 << fTriggerObjectsName << endl;
123 }
124
125 // get input clean object collections
126 mithep::ParticleOArr *CleanLeptons = dynamic_cast<mithep::ParticleOArr*>
127 (FindObjThisEvt(ModNames::gkMergedLeptonsName));
128 const ElectronCol *CleanElectrons = 0;
129 if (!fCleanElectronsName.IsNull())
130 CleanElectrons = GetObjThisEvt<ElectronCol>(fCleanElectronsName);
131 const MuonCol *CleanMuons = 0;
132 if (!fCleanMuonsName.IsNull())
133 CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
134 const JetCol *GoodJets = 0;
135 if (!fGoodJetsName.IsNull())
136 GoodJets = GetObjThisEvt<JetCol>(fGoodJetsName);
137
138 //get input MC collections
139 const MCParticleCol *GenLeptons = 0;
140 if (!fMCLeptonsName.IsNull())
141 GenLeptons = GetObjThisEvt<MCParticleCol>(fMCLeptonsName);
142 const MCParticleCol *GenTaus = 0;
143 if (!fMCTausName.IsNull())
144 GenTaus = GetObjThisEvt<MCParticleCol>(fMCTausName);
145 ObjArray<MCParticle> *GenLeptonsAndTaus = new ObjArray<MCParticle>;
146 for (UInt_t i=0; i<GenLeptons->GetEntries(); i++)
147 GenLeptonsAndTaus->Add(GenLeptons->At(i));
148 for (UInt_t i=0; i<GenTaus->GetEntries(); i++)
149 GenLeptonsAndTaus->Add(GenTaus->At(i));
150
151 //Combine Barrel and Endcap superclusters into the same ObjArray
152 ObjArray <SuperCluster> *SuperClusters = new ObjArray <SuperCluster>;
153 for (UInt_t i=0; i<fBarrelSuperClusters->GetEntries(); i++) {
154 SuperClusters->Add(fBarrelSuperClusters->At(i));
155 }
156 for (UInt_t i=0; i<fEndcapSuperClusters->GetEntries(); i++) {
157 SuperClusters->Add(fEndcapSuperClusters->At(i));
158 }
159
160 //collections for duplicate removed electrons
161 ObjArray<Electron> *DuplicateRemovedElectrons = new ObjArray<Electron>;
162 std::vector<const Electron*> tmpDuplicateRemovedElectrons;
163
164 // create final output collection
165 ElectronArr *ElFakeableObjs = new ElectronArr;
166 MuonArr *MuFakeableObjs = new MuonArr;
167
168
169 //***********************************************************************************************
170 //First do duplicate electron removal
171 //***********************************************************************************************
172 for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
173 const Electron *e = fElectrons->At(i);
174 Bool_t isElectronOverlap = kFALSE;
175
176 for (UInt_t j=0; j<tmpDuplicateRemovedElectrons.size(); ++j) {
177 Double_t deltaR = MathUtils::DeltaR(tmpDuplicateRemovedElectrons[j]->Mom(), e->Mom());
178 if (e->SCluster() == tmpDuplicateRemovedElectrons[j]->SCluster() ||
179 e->GsfTrk() == tmpDuplicateRemovedElectrons[j]->GsfTrk() ||
180 deltaR < 0.1) {
181 isElectronOverlap = kTRUE;
182 }
183
184
185 if (isElectronOverlap) {
186 if (TMath::Abs(tmpDuplicateRemovedElectrons[j]->ESuperClusterOverP() - 1) >
187 TMath::Abs(e->ESuperClusterOverP() - 1)) {
188 tmpDuplicateRemovedElectrons[j] = e;
189 }
190 break;
191 }
192 }
193
194 if (!isElectronOverlap) {
195 tmpDuplicateRemovedElectrons.push_back(e);
196 }
197 }
198 for (UInt_t i=0; i<tmpDuplicateRemovedElectrons.size(); ++i) {
199 DuplicateRemovedElectrons->Add(tmpDuplicateRemovedElectrons[i]);
200 }
201
202 //***********************************************************************************************
203 //Fakeable Objects for Electron Fakes
204 //Supercluster matched to nearest isolated track.
205 //***********************************************************************************************
206 if (fElFOType == kElFOGsfPlusSC) {
207
208 std::vector<const Electron*> GsfTrackSCDenominators;
209
210 //loop over all super clusters
211 for (UInt_t i=0; i<SuperClusters->GetEntries(); i++) {
212 const SuperCluster *cluster = SuperClusters->At(i);
213
214 //find best matching track based on DR to the cluster
215 const Track *EOverPMatchedTrk = NULL;
216 double BestEOverP = 5000.0;
217 for (UInt_t j=0; j<fGsfTracks->GetEntries(); j++) {
218 const Track *trk = fGsfTracks->At(j);
219
220 //Use best E/P matching within dR of 0.3
221 double dR = MathUtils::DeltaR(cluster->Phi(), cluster->Eta(), trk->Phi(), trk->Eta());
222 Double_t EOverP = cluster->Energy() / trk->P();
223 if( fabs(1-EOverP) < fabs(1-BestEOverP) && dR < 0.3 ) {
224 BestEOverP = EOverP;
225 EOverPMatchedTrk = trk;
226 }
227 }
228
229 //****************************************************************************************
230 //Use Best E/P Matching and require the track is within 0.3 of the super cluster position
231 //****************************************************************************************
232 if( EOverPMatchedTrk ) {
233
234 //calculate track isolation around the matched track
235 Double_t matchiso=0;
236 matchiso = IsolationTools::TrackIsolation(EOverPMatchedTrk, 0.3, 0.015, 1.0, 0.2,
237 fTracks);
238
239 //Veto denominators matching to real electrons
240 Bool_t IsGenLepton = false;
241 for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
242 if (MathUtils::DeltaR(EOverPMatchedTrk->Phi(), EOverPMatchedTrk->Eta(),
243 GenLeptonsAndTaus->At(l)->Phi(),
244 GenLeptonsAndTaus->At(l)->Eta()) < 0.1) {
245 IsGenLepton = true;
246 }
247 }
248
249 //Veto denominators matching to clean leptons
250 Bool_t IsCleanLepton = false;
251 for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
252 if (MathUtils::DeltaR(EOverPMatchedTrk->Phi(), EOverPMatchedTrk->Eta(),
253 CleanLeptons->At(l)->Phi(),
254 CleanLeptons->At(l)->Eta()) < 0.1) {
255 IsCleanLepton = true;
256 }
257 }
258
259 //Veto on Leading jet
260 Bool_t IsTriggerJet = false;
261 if (fVetoTriggerJet) {
262 for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
263 Double_t deltaR = MathUtils::DeltaR(EOverPMatchedTrk->Phi(), EOverPMatchedTrk->Eta(),
264 triggerObjects->At(l)->Phi(), triggerObjects->At(l)->Eta());
265 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
266 && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
267 && deltaR < 0.3
268 ) {
269 IsTriggerJet = true;
270 break;
271 }
272 }
273 }
274
275 //create new electron object for the denominator under consideration
276 Bool_t denominatorSaved = false;
277 Electron *denominator = new Electron();
278 Double_t p = TMath::Sqrt(cluster->Energy()*cluster->Energy()
279 - denominator->Mass()*denominator->Mass());
280 denominator->SetPtEtaPhi(TMath::Abs(p*TMath::Cos(EOverPMatchedTrk->Lambda())),
281 EOverPMatchedTrk->Eta(),EOverPMatchedTrk->Phi());
282 denominator->SetGsfTrk(EOverPMatchedTrk);
283 denominator->SetSuperCluster(cluster);
284
285 //****************************************************************************************
286 // conversion filter
287 //****************************************************************************************
288 Bool_t isGoodConversion = kFALSE;
289 for (UInt_t ifc=0; ifc<fConversions->GetEntries(); ifc++) {
290 Bool_t ConversionMatchFound = kFALSE;
291 for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
292 const Track *trk = dynamic_cast<const ChargedParticle*>
293 (fConversions->At(ifc)->Daughter(d))->Trk();
294 if (EOverPMatchedTrk == trk) {
295 ConversionMatchFound = kTRUE;
296 break;
297 }
298 }
299
300 // if match between the gsftrack and one of the conversion legs
301 if (ConversionMatchFound == kTRUE){
302 isGoodConversion = (fConversions->At(ifc)->Prob() > 0.0005) &&
303 (fConversions->At(ifc)->Lxy() > 0) &&
304 (fConversions->At(ifc)->Lz() > 0);
305
306 if (isGoodConversion == kTRUE) {
307 for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
308 const Track *trk = dynamic_cast<const ChargedParticle*>
309 (fConversions->At(ifc)->Daughter(d))->Trk();
310
311 if (trk) {
312 // These requirements are not used for the GSF track (d == 1)
313 if (!(trk->NHits() > 8 && trk->Prob() > 0.005) && d == 0)
314 isGoodConversion = kFALSE;
315
316 const StableData *sd = dynamic_cast<const StableData*>
317 (fConversions->At(ifc)->DaughterDat(d));
318 if (sd->NWrongHits() != 0)
319 isGoodConversion = kFALSE;
320
321 } else {
322 isGoodConversion = kFALSE;
323 }
324 }
325 }
326 }
327 if (isGoodConversion == kTRUE) break;
328 } // loop over all conversions
329
330 //****************************************************************************************
331 // D0 Cut
332 //****************************************************************************************
333 double d0Min = 99999;
334 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
335 double pD0 = EOverPMatchedTrk->D0Corrected(*fVertices->At(i0));
336 if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
337 }
338
339 //****************************************************************************************
340 // Make denominator object cuts
341 //****************************************************************************************
342 if( matchiso <= 10.0 && denominator->Pt() > 10.0
343 && !isGoodConversion
344 && d0Min < 0.025
345 && !(fVetoCleanLeptons && IsCleanLepton)
346 && !(fVetoGenLeptons && IsGenLepton)
347 && !(fVetoTriggerJet && IsTriggerJet)
348 ) {
349
350 //check whether we have duplicate denominators. If yes then choose best E/P one.
351 Bool_t foundDuplicate = false;
352 for (UInt_t d=0; d<GsfTrackSCDenominators.size();++d) {
353 if (GsfTrackSCDenominators[d]->GsfTrk() == denominator->GsfTrk()) {
354 if (fabs(denominator->SCluster()->Energy()/denominator->GsfTrk()->P() - 1)
355 < fabs(GsfTrackSCDenominators[d]->SCluster()->Energy()/
356 GsfTrackSCDenominators[d]->GsfTrk()->P() - 1)) {
357 //swap this one with previous one and delete the previous one
358 const Electron *denominatorToBeDeleted = GsfTrackSCDenominators[d];
359 GsfTrackSCDenominators[d] = denominator;
360 denominatorSaved = true;
361 foundDuplicate = true;
362 delete denominatorToBeDeleted;
363 break;
364 }
365 }
366 }
367 if (!foundDuplicate) {
368 GsfTrackSCDenominators.push_back(denominator);
369 denominatorSaved = true;
370 }
371 } //end if candidate passes denominator cuts
372 //delete denominator candidate object
373 if (!denominatorSaved) {
374 delete denominator;
375 }
376 }//end if track -> SC match was found
377 } //loop over SC
378
379 //Save denominators permanently for export
380 for (UInt_t d=0; d<GsfTrackSCDenominators.size() ; ++d) {
381 Electron *tmpElectron = ElFakeableObjs->AddNew();
382 tmpElectron->SetPtEtaPhi(GsfTrackSCDenominators[d]->Pt(),
383 GsfTrackSCDenominators[d]->Eta(),GsfTrackSCDenominators[d]->Phi());
384 tmpElectron->SetGsfTrk(GsfTrackSCDenominators[d]->GsfTrk());
385 tmpElectron->SetSuperCluster(GsfTrackSCDenominators[d]->SCluster());
386 delete GsfTrackSCDenominators[d];
387 }
388 } else if (fElFOType == kElFOReco) {
389 for (UInt_t i=0; i<DuplicateRemovedElectrons->GetEntries(); i++) {
390 const Electron *denominator = DuplicateRemovedElectrons->At(i);
391 Double_t denominatorIso =
392 denominator->TrackIsolationDr03() + denominator->EcalRecHitIsoDr04() - 1.5;
393
394 //Veto denominators matching to real electrons
395 Bool_t IsGenLepton = false;
396 for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
397 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
398 GenLeptonsAndTaus->At(l)->Phi(),
399 GenLeptonsAndTaus->At(l)->Eta()) < 0.1) {
400 IsGenLepton = true;
401 }
402 }
403
404 //Veto denominators matching to clean leptons
405 Bool_t IsCleanLepton = false;
406 for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
407 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
408 CleanLeptons->At(l)->Phi(),
409 CleanLeptons->At(l)->Eta()) < 0.1) {
410 IsCleanLepton = true;
411 }
412 }
413
414 //Veto on Trigger jet
415 Bool_t IsTriggerJet = false;
416 if (fVetoTriggerJet) {
417 for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
418 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
419 triggerObjects->At(l)->Phi(), triggerObjects->At(l)->Eta());
420 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
421 && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
422 && deltaR < 0.3
423 ) {
424 IsTriggerJet = true;
425 break;
426 }
427 }
428 }
429
430 //*************************************************************
431 // conversion filter
432 //*************************************************************
433 Bool_t isGoodConversion = kFALSE;
434 for (UInt_t ifc=0; ifc<fConversions->GetEntries(); ifc++) {
435 Bool_t ConversionMatchFound = kFALSE;
436 for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
437 const Track *trk = dynamic_cast<const ChargedParticle*>
438 (fConversions->At(ifc)->Daughter(d))->Trk();
439 if (denominator->GsfTrk() == trk) {
440 ConversionMatchFound = kTRUE;
441 break;
442 }
443 }
444
445 // if match between the gsftrack and one of the conversion legs
446 if (ConversionMatchFound == kTRUE){
447 isGoodConversion = (fConversions->At(ifc)->Prob() > 0.0005) &&
448 (fConversions->At(ifc)->Lxy() > 0) &&
449 (fConversions->At(ifc)->Lz() > 0);
450
451 if (isGoodConversion == kTRUE) {
452 for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
453 const Track *trk = dynamic_cast<const ChargedParticle*>
454 (fConversions->At(ifc)->Daughter(d))->Trk();
455
456 if (trk) {
457 // These requirements are not used for the GSF track (d == 1)
458 if (!(trk->NHits() > 8 && trk->Prob() > 0.005) && d == 0)
459 isGoodConversion = kFALSE;
460
461 const StableData *sd = dynamic_cast<const StableData*>
462 (fConversions->At(ifc)->DaughterDat(d));
463 if (sd->NWrongHits() != 0)
464 isGoodConversion = kFALSE;
465
466 } else {
467 isGoodConversion = kFALSE;
468 }
469 }
470 }
471 }
472 if (isGoodConversion == kTRUE) break;
473 } // loop over all conversions
474
475 //****************************************************************************************
476 // D0 Cut
477 //****************************************************************************************
478 double d0Min = 99999;
479 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
480 double pD0 = denominator->GsfTrk()->D0Corrected(*fVertices->At(i0));
481 if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
482 }
483
484 //****************************************************************************************
485 // Apply Denominator Cuts
486 //****************************************************************************************
487 if (denominator->Pt() > 10.0 &&
488 denominatorIso < 10.0
489 && !isGoodConversion
490 && d0Min < 0.025
491 && !(fVetoGenLeptons && IsGenLepton)
492 && !(fVetoCleanLeptons && IsCleanLepton)
493 && !(fVetoTriggerJet && IsTriggerJet)
494 ) {
495 Electron *tmpElectron = ElFakeableObjs->AddNew();
496 tmpElectron->SetPtEtaPhi(denominator->Pt(), denominator->Eta(),denominator->Phi());
497 tmpElectron->SetGsfTrk(denominator->GsfTrk());
498 tmpElectron->SetSuperCluster(denominator->SCluster());
499 }
500 }
501 } else if (fElFOType == kElFOLoose) {
502 for (UInt_t i=0; i<DuplicateRemovedElectrons->GetEntries(); i++) {
503 const Electron *denominator = DuplicateRemovedElectrons->At(i);
504 Double_t denominatorIso = denominator->TrackIsolationDr03() + denominator->EcalRecHitIsoDr04() - 1.5;
505
506 //Veto denominators matching to real electrons
507 Bool_t IsGenLepton = false;
508 for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
509 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
510 GenLeptonsAndTaus->At(l)->Phi(),
511 GenLeptonsAndTaus->At(l)->Eta()) < 0.1) {
512 IsGenLepton = true;
513 }
514 }
515
516 //Veto denominators matching to clean leptons
517 Bool_t IsCleanLepton = false;
518 for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
519 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
520 CleanLeptons->At(l)->Phi(),
521 CleanLeptons->At(l)->Eta()) < 0.1) {
522 IsCleanLepton = true;
523 }
524 }
525
526 //Veto on Trigger jet
527 Bool_t IsTriggerJet = false;
528 if (fVetoTriggerJet) {
529 for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
530 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
531 triggerObjects->At(l)->Phi(), triggerObjects->At(l)->Eta());
532 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
533 && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
534 && deltaR < 0.3
535 ) {
536 IsTriggerJet = true;
537 break;
538 }
539 }
540 }
541
542 //****************************************************************************************
543 // conversion filter
544 //****************************************************************************************
545 Bool_t isGoodConversion = kFALSE;
546 for (UInt_t ifc=0; ifc<fConversions->GetEntries(); ifc++) {
547 Bool_t ConversionMatchFound = kFALSE;
548 for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
549 const Track *trk = dynamic_cast<const ChargedParticle*>
550 (fConversions->At(ifc)->Daughter(d))->Trk();
551 if (denominator->GsfTrk() == trk) {
552 ConversionMatchFound = kTRUE;
553 break;
554 }
555 }
556
557 // if match between the gsftrack and one of the conversion legs
558 if (ConversionMatchFound == kTRUE){
559 isGoodConversion = (fConversions->At(ifc)->Prob() > 0.0005) &&
560 (fConversions->At(ifc)->Lxy() > 0) &&
561 (fConversions->At(ifc)->Lz() > 0);
562
563 if (isGoodConversion == kTRUE) {
564 for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
565 const Track *trk = dynamic_cast<const ChargedParticle*>
566 (fConversions->At(ifc)->Daughter(d))->Trk();
567
568 if (trk) {
569 // These requirements are not used for the GSF track (d == 1)
570 if (!(trk->NHits() > 8 && trk->Prob() > 0.005) && d == 0)
571 isGoodConversion = kFALSE;
572
573 const StableData *sd = dynamic_cast<const StableData*>
574 (fConversions->At(ifc)->DaughterDat(d));
575 if (sd->NWrongHits() != 0)
576 isGoodConversion = kFALSE;
577
578 } else {
579 isGoodConversion = kFALSE;
580 }
581 }
582 }
583 }
584 if (isGoodConversion == kTRUE) break;
585 } // loop over all conversions
586
587 //****************************************************************************************
588 // D0 Cut
589 //****************************************************************************************
590 double d0Min = 99999;
591 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
592 double pD0 = denominator->GsfTrk()->D0Corrected(*fVertices->At(i0));
593 if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
594 }
595
596 if (denominator->Pt() > 10.0 && denominatorIso < 10.0
597 && !isGoodConversion
598 && d0Min < 0.025
599 && denominator->PassLooseID()
600 && !(fVetoGenLeptons && IsGenLepton)
601 && !(fVetoCleanLeptons && IsCleanLepton)
602 && !(fVetoTriggerJet && IsTriggerJet)
603 ) {
604 Electron *tmpElectron = ElFakeableObjs->AddNew();
605 tmpElectron->SetPtEtaPhi(denominator->Pt(), denominator->Eta(),denominator->Phi());
606 tmpElectron->SetGsfTrk(denominator->GsfTrk());
607 tmpElectron->SetSuperCluster(denominator->SCluster());
608 }
609 }
610 }
611
612 //***********************************************************************************************
613 //Fakeable Objects for Muon Fakes
614 //***********************************************************************************************
615 if (fMuFOType == kMuFOIsoTrack) {
616 for (UInt_t i=0; i<fTracks->GetEntries(); i++) {
617 const Track *track = fTracks->At(i);
618 Double_t trackIsolation = IsolationTools::TrackIsolation(track, 0.4, 0.015, 1.0,
619 0.2, fTracks);
620 //Determine if muon fakeable object matches a gen lepton
621 Bool_t IsGenLepton = false;
622 for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
623 if (MathUtils::DeltaR(track->Phi(), track->Eta(),
624 GenLeptonsAndTaus->At(l)->Phi(),
625 GenLeptonsAndTaus->At(l)->Eta()) < 0.3) {
626 IsGenLepton = true;
627 }
628 }
629
630 //Veto denominators matching to clean leptons
631 Bool_t IsCleanLepton = false;
632 for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
633 if (MathUtils::DeltaR(track->Phi(), track->Eta(),
634 CleanLeptons->At(l)->Phi(),
635 CleanLeptons->At(l)->Eta()) < 0.1) {
636 IsCleanLepton = true;
637 }
638 }
639
640 //Veto on Trigger jet
641 Bool_t IsTriggerJet = false;
642 if (fVetoTriggerJet) {
643 for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
644 Double_t deltaR = MathUtils::DeltaR(track->Phi(), track->Eta(),
645 triggerObjects->At(l)->Phi(),
646 triggerObjects->At(l)->Eta());
647 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
648 && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
649 && deltaR < 0.3
650 ) {
651 IsTriggerJet = true;
652 break;
653 }
654 }
655 }
656
657 //****************************************************************************************
658 // D0 Cut
659 //****************************************************************************************
660 double d0Min = 99999;
661 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
662 double pD0 = track->D0Corrected(*fVertices->At(i0));
663 if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
664 }
665
666
667 //define denominator cuts
668 if (track->Pt() > 10.0 && trackIsolation < 10.0
669 && d0Min < 0.025
670 && !(fVetoGenLeptons && IsGenLepton)
671 && !(fVetoCleanLeptons && IsCleanLepton)
672 && !(fVetoTriggerJet && IsTriggerJet)
673 ) {
674 //add to fakeable objects
675 Muon* tmpMuon = MuFakeableObjs->AddNew();
676 tmpMuon->SetTrackerTrk(track);
677 }
678 }
679 } else if (fMuFOType == kMuFOGlobal) {
680 for (UInt_t i=0; i<fMuons->GetEntries(); i++) {
681 const Muon *denominator = fMuons->At(i);
682 Double_t totalIsolation = denominator->IsoR03SumPt() + denominator->IsoR03EmEt() +
683 denominator->IsoR03HadEt();
684
685 //Determine if muon fakeable object matches a gen lepton
686 Bool_t IsGenLepton = false;
687 for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
688 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
689 GenLeptonsAndTaus->At(l)->Phi(),
690 GenLeptonsAndTaus->At(l)->Eta()) < 0.3) {
691 IsGenLepton = true;
692 }
693 }
694
695 //Veto denominators matching to clean leptons
696 Bool_t IsCleanLepton = false;
697 for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
698 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
699 CleanLeptons->At(l)->Phi(),
700 CleanLeptons->At(l)->Eta()) < 0.1) {
701 IsCleanLepton = true;
702 }
703 }
704
705 //Veto on Trigger jet
706 Bool_t IsTriggerJet = false;
707 if (fVetoTriggerJet) {
708 for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
709 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
710 triggerObjects->At(l)->Phi(), triggerObjects->At(l)->Eta());
711 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
712 && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
713 && deltaR < 0.3
714 ) {
715 IsTriggerJet = true;
716 break;
717 }
718 }
719 }
720
721 //****************************************************************************************
722 // D0 Cut
723 //****************************************************************************************
724 double d0Min = 99999;
725 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
726 double pD0 = denominator->Trk()->D0Corrected(*fVertices->At(i0));
727 if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
728 }
729
730 if (denominator->Pt() > 10.0 && totalIsolation < 10.0 && denominator->HasGlobalTrk()
731 && d0Min < 0.025
732 && !(fVetoGenLeptons && IsGenLepton)
733 && !(fVetoCleanLeptons && IsCleanLepton)
734 && !(fVetoTriggerJet && IsTriggerJet)
735 ) {
736 Muon* tmpMuon = MuFakeableObjs->AddNew();
737 tmpMuon->SetGlobalTrk(denominator->GlobalTrk());
738 tmpMuon->SetTrackerTrk(denominator->TrackerTrk());
739 }
740 }
741 } else if (fMuFOType == kMuFOTrackerMuon) {
742 for (UInt_t i=0; i<fMuons->GetEntries(); i++) {
743 const Muon *denominator = fMuons->At(i);
744 Double_t totalIsolation = denominator->IsoR03SumPt() + denominator->IsoR03EmEt() + denominator->IsoR03HadEt();
745
746 //Determine if muon fakeable object matches a gen lepton
747 Bool_t IsGenLepton = false;
748 for (UInt_t l=0; l<GenLeptonsAndTaus->GetEntries(); l++) {
749 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
750 GenLeptonsAndTaus->At(l)->Phi(),
751 GenLeptonsAndTaus->At(l)->Eta()) < 0.3) {
752 IsGenLepton = true;
753 }
754 }
755
756 //Veto denominators matching to clean leptons
757 Bool_t IsCleanLepton = false;
758 for (UInt_t l=0; l<CleanLeptons->GetEntries(); l++) {
759 if (MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
760 CleanLeptons->At(l)->Phi(),
761 CleanLeptons->At(l)->Eta()) < 0.1) {
762 IsCleanLepton = true;
763 }
764 }
765
766 //Veto on Trigger jet
767 Bool_t IsTriggerJet = false;
768 if (fVetoTriggerJet) {
769 for (UInt_t l=0; l<triggerObjects->GetEntries(); l++) {
770 Double_t deltaR = MathUtils::DeltaR(denominator->Phi(), denominator->Eta(),
771 triggerObjects->At(l)->Phi(), triggerObjects->At(l)->Eta());
772 if (triggerObjects->At(l)->TrigName() == fTriggerName.Data()
773 && triggerObjects->At(l)->Type() == TriggerObject::TriggerJet
774 && deltaR < 0.3
775 ) {
776 IsTriggerJet = true;
777 break;
778 }
779 }
780 }
781
782 //****************************************************************************************
783 // D0 Cut
784 //****************************************************************************************
785 double d0Min = 99999;
786 for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
787 double pD0 = denominator->Trk()->D0Corrected(*fVertices->At(i0));
788 if(TMath::Abs(pD0) < TMath::Abs(d0Min)) d0Min = TMath::Abs(pD0);
789 }
790
791 if (denominator->Pt() > 10.0 && totalIsolation < 10.0 && denominator->HasTrackerTrk()
792 && d0Min < 0.025
793 && !(fVetoGenLeptons && IsGenLepton)
794 && !(fVetoCleanLeptons && IsCleanLepton)
795 && !(fVetoTriggerJet && IsTriggerJet)
796 ) {
797 Muon* tmpMuon = MuFakeableObjs->AddNew();
798 tmpMuon->SetTrackerTrk(denominator->TrackerTrk());
799 }
800 }
801 }
802
803 //***********************************************************************************************
804 //Export the fakeable object collections for other modules to use
805 //***********************************************************************************************
806 ElFakeableObjs->SetName(fElFakeableObjsName);
807 AddObjThisEvt(ElFakeableObjs);
808 MuFakeableObjs->SetName(fMuFakeableObjsName);
809 AddObjThisEvt(MuFakeableObjs);
810
811 delete GenLeptonsAndTaus;
812 delete SuperClusters;
813 delete DuplicateRemovedElectrons;
814 }