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