1 |
bendavid |
1.37 |
// $Id: ElectronIDMod.cc,v 1.36 2009/09/21 15:43:46 bendavid Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitPhysics/Mods/interface/ElectronIDMod.h"
|
4 |
loizides |
1.26 |
#include "MitAna/DataTree/interface/StableData.h"
|
5 |
|
|
#include "MitAna/DataTree/interface/ElectronCol.h"
|
6 |
|
|
#include "MitAna/DataTree/interface/VertexCol.h"
|
7 |
|
|
#include "MitAna/DataTree/interface/DecayParticleCol.h"
|
8 |
loizides |
1.5 |
#include "MitPhysics/Init/interface/ModNames.h"
|
9 |
loizides |
1.1 |
|
10 |
|
|
using namespace mithep;
|
11 |
|
|
|
12 |
|
|
ClassImp(mithep::ElectronIDMod)
|
13 |
|
|
|
14 |
|
|
//--------------------------------------------------------------------------------------------------
|
15 |
loizides |
1.5 |
ElectronIDMod::ElectronIDMod(const char *name, const char *title) :
|
16 |
loizides |
1.1 |
BaseMod(name,title),
|
17 |
loizides |
1.5 |
fElectronBranchName(Names::gkElectronBrn),
|
18 |
ceballos |
1.12 |
fConversionBranchName(Names::gkMvfConversionBrn),
|
19 |
loizides |
1.5 |
fGoodElectronsName(ModNames::gkGoodElectronsName),
|
20 |
ceballos |
1.12 |
fVertexName(string("PrimaryVertexesBeamSpot").c_str()),
|
21 |
ceballos |
1.31 |
fElectronIDType("CustomTight"),
|
22 |
ceballos |
1.8 |
fElectronIsoType("TrackJuraSliding"),
|
23 |
loizides |
1.1 |
fElectronPtMin(10),
|
24 |
|
|
fIDLikelihoodCut(0.9),
|
25 |
|
|
fTrackIsolationCut(5.0),
|
26 |
|
|
fCaloIsolationCut(5.0),
|
27 |
loizides |
1.5 |
fEcalJuraIsoCut(5.0),
|
28 |
|
|
fHcalIsolationCut(5.0),
|
29 |
loizides |
1.14 |
fApplyConvFilter(kTRUE),
|
30 |
ceballos |
1.18 |
fApplyD0Cut(kTRUE),
|
31 |
loizides |
1.14 |
fD0Cut(0.025),
|
32 |
loizides |
1.25 |
fReverseIsoCut(kFALSE),
|
33 |
|
|
fReverseD0Cut(kFALSE),
|
34 |
loizides |
1.5 |
fElIdType(kIdUndef),
|
35 |
ceballos |
1.12 |
fElIsoType(kIsoUndef),
|
36 |
ceballos |
1.33 |
fChargeFilter(kTRUE),
|
37 |
loizides |
1.14 |
fElectrons(0),
|
38 |
|
|
fConversions(0),
|
39 |
loizides |
1.25 |
fVertices(0)
|
40 |
loizides |
1.1 |
{
|
41 |
|
|
// Constructor.
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
//--------------------------------------------------------------------------------------------------
|
45 |
loizides |
1.30 |
Bool_t ElectronIDMod::PassCustomID(const Electron *ele) const
|
46 |
|
|
{
|
47 |
loizides |
1.32 |
// Based on RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc.
|
48 |
loizides |
1.30 |
|
49 |
|
|
Double_t eOverP = ele->ESuperClusterOverP();
|
50 |
|
|
Double_t fBrem = ele->FBrem();
|
51 |
|
|
|
52 |
|
|
if ((eOverP < fCuts[5][0]) && (fBrem < fCuts[5][1]))
|
53 |
|
|
return kFALSE;
|
54 |
|
|
|
55 |
|
|
if (eOverP < fCuts[5][2]*(1-fBrem))
|
56 |
|
|
return kFALSE;
|
57 |
|
|
|
58 |
|
|
Int_t cat = 2;
|
59 |
|
|
if ((ele->IsEB() && fBrem<0.06) || (ele->IsEE() && fBrem<0.1))
|
60 |
|
|
cat=1;
|
61 |
|
|
else if (eOverP < 1.2 && eOverP > 0.8)
|
62 |
|
|
cat=0;
|
63 |
|
|
|
64 |
|
|
Double_t eSeedOverPin = ele->ESeedClusterOverPIn();
|
65 |
|
|
Double_t hOverE = ele->HadronicOverEm();
|
66 |
|
|
Double_t sigmaee = ele->CoviEtaiEta();
|
67 |
|
|
Double_t deltaPhiIn = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
|
68 |
|
|
Double_t deltaEtaIn = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
|
69 |
|
|
|
70 |
|
|
Int_t eb = 1;
|
71 |
|
|
if (ele->IsEB())
|
72 |
|
|
eb = 0;
|
73 |
|
|
|
74 |
|
|
if (hOverE>fCuts[0][cat+4*eb])
|
75 |
|
|
return kFALSE;
|
76 |
|
|
|
77 |
|
|
if (sigmaee>fCuts[1][cat+4*eb])
|
78 |
|
|
return kFALSE;
|
79 |
|
|
|
80 |
|
|
if (eOverP<1.5) {
|
81 |
|
|
if (deltaPhiIn>fCuts[2][cat+4*eb])
|
82 |
|
|
return kFALSE;
|
83 |
|
|
} else {
|
84 |
|
|
if(deltaPhiIn>fCuts[2][3+4*eb])
|
85 |
|
|
return kFALSE;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
if(deltaEtaIn>fCuts[3][cat+4*eb])
|
89 |
|
|
return kFALSE;
|
90 |
|
|
|
91 |
|
|
if(eSeedOverPin<fCuts[4][cat+4*eb])
|
92 |
|
|
return kFALSE;
|
93 |
|
|
|
94 |
|
|
return kTRUE;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
//--------------------------------------------------------------------------------------------------
|
98 |
loizides |
1.1 |
void ElectronIDMod::Process()
|
99 |
|
|
{
|
100 |
|
|
// Process entries of the tree.
|
101 |
|
|
|
102 |
loizides |
1.23 |
LoadEventObject(fElectronBranchName, fElectrons);
|
103 |
sixie |
1.34 |
if (fApplyD0Cut) {
|
104 |
|
|
LoadEventObject(fVertexName, fVertices);
|
105 |
|
|
}
|
106 |
loizides |
1.1 |
|
107 |
loizides |
1.6 |
ElectronOArr *GoodElectrons = new ElectronOArr;
|
108 |
|
|
GoodElectrons->SetName(fGoodElectronsName);
|
109 |
loizides |
1.1 |
|
110 |
ceballos |
1.18 |
for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
|
111 |
loizides |
1.5 |
const Electron *e = fElectrons->At(i);
|
112 |
loizides |
1.1 |
|
113 |
loizides |
1.5 |
if (e->Pt() <= fElectronPtMin)
|
114 |
|
|
continue;
|
115 |
loizides |
1.1 |
|
116 |
loizides |
1.5 |
Bool_t idcut = kFALSE;
|
117 |
|
|
switch (fElIdType) {
|
118 |
|
|
case kTight:
|
119 |
|
|
idcut = e->PassTightID();
|
120 |
|
|
break;
|
121 |
|
|
case kLoose:
|
122 |
|
|
idcut = e->PassLooseID();
|
123 |
|
|
break;
|
124 |
|
|
case kLikelihood:
|
125 |
|
|
idcut = (e->IDLikelihood() > fIDLikelihoodCut);
|
126 |
|
|
break;
|
127 |
loizides |
1.11 |
case kNoId:
|
128 |
|
|
idcut = kTRUE;
|
129 |
|
|
break;
|
130 |
peveraer |
1.29 |
case kCustomIdLoose:
|
131 |
loizides |
1.30 |
idcut = ElectronIDMod::PassCustomID(e);
|
132 |
peveraer |
1.29 |
break;
|
133 |
|
|
case kCustomIdTight:
|
134 |
loizides |
1.30 |
idcut = ElectronIDMod::PassCustomID(e);
|
135 |
|
|
break;
|
136 |
|
|
default:
|
137 |
loizides |
1.5 |
break;
|
138 |
loizides |
1.1 |
}
|
139 |
|
|
|
140 |
loizides |
1.5 |
if (!idcut)
|
141 |
|
|
continue;
|
142 |
|
|
|
143 |
|
|
Bool_t isocut = kFALSE;
|
144 |
|
|
switch (fElIsoType) {
|
145 |
|
|
case kTrackCalo:
|
146 |
bendavid |
1.28 |
isocut = (e->TrackIsolationDr03() < fTrackIsolationCut) &&
|
147 |
loizides |
1.5 |
(e->CaloIsolation() < fCaloIsolationCut);
|
148 |
|
|
break;
|
149 |
|
|
case kTrackJura:
|
150 |
bendavid |
1.28 |
isocut = (e->TrackIsolationDr03() < fTrackIsolationCut) &&
|
151 |
|
|
(e->EcalRecHitIsoDr04() < fEcalJuraIsoCut) &&
|
152 |
loizides |
1.5 |
(e->HcalIsolation() < fHcalIsolationCut);
|
153 |
|
|
break;
|
154 |
|
|
case kTrackJuraSliding:
|
155 |
ceballos |
1.18 |
{
|
156 |
bendavid |
1.28 |
Double_t totalIso = e->TrackIsolationDr03() + e->EcalRecHitIsoDr04() - 1.5;
|
157 |
ceballos |
1.35 |
if (totalIso < (e->Pt()-10.0)*4.5/20.0 ||
|
158 |
|
|
totalIso <= 0)
|
159 |
loizides |
1.5 |
isocut = kTRUE;
|
160 |
ceballos |
1.24 |
|
161 |
|
|
if (fReverseIsoCut == kTRUE &&
|
162 |
|
|
isocut == kFALSE && totalIso < 10)
|
163 |
|
|
isocut = kTRUE;
|
164 |
|
|
else if(fReverseIsoCut == kTRUE)
|
165 |
|
|
isocut = kFALSE;
|
166 |
loizides |
1.5 |
}
|
167 |
|
|
break;
|
168 |
|
|
case kNoIso:
|
169 |
|
|
isocut = kTRUE;
|
170 |
|
|
break;
|
171 |
|
|
case kCustomIso:
|
172 |
|
|
default:
|
173 |
|
|
break;
|
174 |
loizides |
1.1 |
}
|
175 |
|
|
|
176 |
ceballos |
1.24 |
if (isocut == kFALSE)
|
177 |
loizides |
1.5 |
continue;
|
178 |
|
|
|
179 |
loizides |
1.14 |
// apply conversion filter
|
180 |
ceballos |
1.12 |
Bool_t isGoodConversion = kFALSE;
|
181 |
loizides |
1.14 |
if (fApplyConvFilter) {
|
182 |
ceballos |
1.12 |
LoadBranch(fConversionBranchName);
|
183 |
|
|
for (UInt_t ifc=0; ifc<fConversions->GetEntries(); ifc++) {
|
184 |
|
|
|
185 |
|
|
Bool_t ConversionMatchFound = kFALSE;
|
186 |
|
|
for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
|
187 |
|
|
const Track *trk = dynamic_cast<const ChargedParticle*>
|
188 |
|
|
(fConversions->At(ifc)->Daughter(d))->Trk();
|
189 |
ceballos |
1.13 |
if (e->GsfTrk() == trk) {
|
190 |
ceballos |
1.12 |
ConversionMatchFound = kTRUE;
|
191 |
|
|
break;
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
// if match between the e-track and one of the conversion legs
|
196 |
|
|
if (ConversionMatchFound == kTRUE){
|
197 |
bendavid |
1.36 |
isGoodConversion = (fConversions->At(ifc)->Prob() > 1e-6) &&
|
198 |
ceballos |
1.12 |
(fConversions->At(ifc)->Lxy() > 0) &&
|
199 |
bendavid |
1.37 |
(fConversions->At(ifc)->Lz() > 0) &&
|
200 |
|
|
(fConversions->At(ifc)->Position().Rho() > 2.0);
|
201 |
ceballos |
1.12 |
|
202 |
|
|
if (isGoodConversion == kTRUE) {
|
203 |
|
|
for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
|
204 |
|
|
const Track *trk = dynamic_cast<const ChargedParticle*>
|
205 |
|
|
(fConversions->At(ifc)->Daughter(d))->Trk();
|
206 |
|
|
|
207 |
|
|
if (trk) {
|
208 |
bendavid |
1.27 |
// These requirements are not used for the GSF track
|
209 |
bendavid |
1.36 |
if (!(trk->NHits() >= 3 && trk->Prob() > 1e-6) && trk!=e->GsfTrk())
|
210 |
ceballos |
1.12 |
isGoodConversion = kFALSE;
|
211 |
|
|
|
212 |
|
|
const StableData *sd = dynamic_cast<const StableData*>
|
213 |
|
|
(fConversions->At(ifc)->DaughterDat(d));
|
214 |
|
|
if (sd->NWrongHits() != 0)
|
215 |
|
|
isGoodConversion = kFALSE;
|
216 |
|
|
|
217 |
|
|
} else {
|
218 |
|
|
isGoodConversion = kFALSE;
|
219 |
|
|
}
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
if (isGoodConversion == kTRUE) break;
|
225 |
|
|
|
226 |
|
|
} // loop over all conversions
|
227 |
|
|
|
228 |
|
|
}
|
229 |
|
|
if (isGoodConversion == kTRUE) continue;
|
230 |
|
|
|
231 |
ceballos |
1.15 |
if (fApplyD0Cut) {
|
232 |
ceballos |
1.24 |
Bool_t d0cut = kFALSE;
|
233 |
ceballos |
1.15 |
// d0 cut
|
234 |
loizides |
1.30 |
Double_t d0_real = 99999;
|
235 |
|
|
for(UInt_t i0 = 0; i0 < fVertices->GetEntries(); i0++) {
|
236 |
|
|
Double_t pD0 = e->GsfTrk()->D0Corrected(*fVertices->At(i0));
|
237 |
ceballos |
1.15 |
if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
|
238 |
|
|
}
|
239 |
ceballos |
1.24 |
if(d0_real < fD0Cut) d0cut = kTRUE;
|
240 |
|
|
|
241 |
|
|
if (fReverseD0Cut == kTRUE &&
|
242 |
|
|
d0cut == kFALSE && d0_real < 0.05)
|
243 |
|
|
d0cut = kTRUE;
|
244 |
|
|
else if(fReverseD0Cut == kTRUE)
|
245 |
|
|
d0cut = kFALSE;
|
246 |
|
|
|
247 |
|
|
if (d0cut == kFALSE)
|
248 |
|
|
continue;
|
249 |
ceballos |
1.12 |
}
|
250 |
ceballos |
1.33 |
if(fChargeFilter == kTRUE &&
|
251 |
|
|
e->TrackerTrk() &&
|
252 |
|
|
e->TrackerTrk()->Charge() != e->Charge()) continue;
|
253 |
ceballos |
1.12 |
|
254 |
loizides |
1.5 |
// add good electron
|
255 |
ceballos |
1.12 |
GoodElectrons->Add(e);
|
256 |
loizides |
1.5 |
}
|
257 |
loizides |
1.1 |
|
258 |
ceballos |
1.33 |
|
259 |
loizides |
1.9 |
// sort according to pt
|
260 |
|
|
GoodElectrons->Sort();
|
261 |
|
|
|
262 |
loizides |
1.5 |
// add to event for other modules to use
|
263 |
loizides |
1.6 |
AddObjThisEvt(GoodElectrons);
|
264 |
loizides |
1.1 |
}
|
265 |
|
|
|
266 |
|
|
//--------------------------------------------------------------------------------------------------
|
267 |
|
|
void ElectronIDMod::SlaveBegin()
|
268 |
|
|
{
|
269 |
|
|
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
270 |
loizides |
1.5 |
// we just request the electron collection branch.
|
271 |
loizides |
1.1 |
|
272 |
loizides |
1.23 |
ReqEventObject(fElectronBranchName, fElectrons, kTRUE);
|
273 |
loizides |
1.17 |
|
274 |
ceballos |
1.16 |
if (fApplyConvFilter)
|
275 |
loizides |
1.23 |
ReqEventObject(fConversionBranchName, fConversions, kTRUE);
|
276 |
loizides |
1.17 |
|
277 |
ceballos |
1.15 |
if (fApplyD0Cut)
|
278 |
loizides |
1.23 |
ReqEventObject(fVertexName, fVertices, kTRUE);
|
279 |
loizides |
1.1 |
|
280 |
loizides |
1.5 |
if (fElectronIDType.CompareTo("Tight") == 0)
|
281 |
|
|
fElIdType = kTight;
|
282 |
|
|
else if (fElectronIDType.CompareTo("Loose") == 0)
|
283 |
|
|
fElIdType = kLoose;
|
284 |
|
|
else if (fElectronIDType.CompareTo("Likelihood") == 0)
|
285 |
|
|
fElIdType = kLikelihood;
|
286 |
loizides |
1.10 |
else if (fElectronIDType.CompareTo("NoId") == 0)
|
287 |
|
|
fElIdType = kNoId;
|
288 |
loizides |
1.30 |
else if (fElectronIDType.CompareTo("CustomLoose") == 0) {
|
289 |
peveraer |
1.29 |
fElIdType = kCustomIdLoose;
|
290 |
loizides |
1.30 |
} else if (fElectronIDType.CompareTo("CustomTight") == 0) {
|
291 |
peveraer |
1.29 |
fElIdType = kCustomIdTight;
|
292 |
loizides |
1.30 |
}
|
293 |
peveraer |
1.29 |
else {
|
294 |
loizides |
1.5 |
SendError(kAbortAnalysis, "SlaveBegin",
|
295 |
|
|
"The specified electron identification %s is not defined.",
|
296 |
|
|
fElectronIDType.Data());
|
297 |
|
|
return;
|
298 |
|
|
}
|
299 |
|
|
|
300 |
loizides |
1.30 |
SetCustomIDCuts(fElIdType);
|
301 |
|
|
|
302 |
loizides |
1.5 |
if (fElectronIsoType.CompareTo("TrackCalo") == 0 )
|
303 |
|
|
fElIsoType = kTrackCalo;
|
304 |
|
|
else if (fElectronIsoType.CompareTo("TrackJura") == 0)
|
305 |
|
|
fElIsoType = kTrackJura;
|
306 |
|
|
else if(fElectronIsoType.CompareTo("TrackJuraSliding") == 0)
|
307 |
|
|
fElIsoType = kTrackJuraSliding;
|
308 |
|
|
else if (fElectronIsoType.CompareTo("NoIso") == 0 )
|
309 |
|
|
fElIsoType = kNoIso;
|
310 |
|
|
else if (fElectronIsoType.CompareTo("Custom") == 0 ) {
|
311 |
|
|
fElIsoType = kCustomIso;
|
312 |
|
|
SendError(kWarning, "SlaveBegin",
|
313 |
|
|
"Custom electron isolation is not yet implemented.");
|
314 |
|
|
} else {
|
315 |
|
|
SendError(kAbortAnalysis, "SlaveBegin",
|
316 |
|
|
"The specified electron isolation %s is not defined.",
|
317 |
|
|
fElectronIsoType.Data());
|
318 |
|
|
return;
|
319 |
|
|
}
|
320 |
loizides |
1.1 |
}
|
321 |
loizides |
1.30 |
|
322 |
|
|
//--------------------------------------------------------------------------------------------------
|
323 |
|
|
void ElectronIDMod::SetCustomIDCuts(EElIdType idt)
|
324 |
|
|
{
|
325 |
loizides |
1.32 |
// Set cut values based on RecoEgamma/ElectronIdentification/python/electronIdCutBasedExt_cfi.py.
|
326 |
|
|
// The following changes are in sigmaetaeta for endcups and deltaetain.
|
327 |
loizides |
1.30 |
|
328 |
|
|
Double_t tightcuts[6][8]={
|
329 |
ceballos |
1.31 |
{0.05, 0.042, 0.045, 0.0, 0.055, 0.037, 0.05, 0.0}, //hovere
|
330 |
|
|
{0.0125, 0.011, 0.01, 0.0, 0.0295, 0.0292, 0.0283, 0.0}, //sigmaetaeta
|
331 |
|
|
{0.032, 0.016, 0.0525, 0.09, 0.025, 0.035, 0.065, 0.092}, //deltaphiin
|
332 |
ceballos |
1.35 |
{0.0055, 0.0024, 0.0065, 0.0, 0.0070, 0.0055, 0.0085, 0.0}, //deltaetain
|
333 |
ceballos |
1.31 |
{0.24, 0.94, 0.11, 0.0, 0.32, 0.83, 0.0, 0.0}, //eoverp
|
334 |
|
|
{0.8,0.2,0.9,0,0,0,0,0}}; //extra cuts fbrem and E_Over_P
|
335 |
loizides |
1.30 |
|
336 |
|
|
Double_t loosecuts[6][8]={
|
337 |
|
|
{0.076, 0.033, 0.07, 0.0, 0.083,0.148, 0.033, 0.0}, //hovere
|
338 |
|
|
{0.0101, 0.0095, 0.0097, 0.0, 0.03, 0.03, 0.03, 0.0}, //sigmaetaeta
|
339 |
|
|
{0.053, 0.0189, 0.059, 0.099, 0.0278,0.0157, 0.042, 0.080}, //deltaphiin
|
340 |
|
|
{0.0078, 0.00259, 0.0062, 0.0, 0.0078,0.0061, 0.0061, 0.0}, //deltaetain
|
341 |
|
|
{0.3, 0.92, 0.211, 0.0, 0.42, 0.88, 0.68, 0.0}, //eoverp
|
342 |
|
|
{0.8,0.2,0,0,0,0,0,0}}; //extra cuts fbrem and E_Over_P
|
343 |
|
|
|
344 |
|
|
switch (idt) {
|
345 |
|
|
case kCustomIdTight:
|
346 |
|
|
memcpy(fCuts,tightcuts,sizeof(fCuts));
|
347 |
|
|
break;
|
348 |
|
|
case kCustomIdLoose:
|
349 |
|
|
memcpy(fCuts,loosecuts,sizeof(fCuts));
|
350 |
|
|
break;
|
351 |
|
|
default:
|
352 |
|
|
memset(fCuts,0,sizeof(fCuts));
|
353 |
|
|
break;
|
354 |
|
|
}
|
355 |
|
|
}
|
356 |
|
|
|