1 |
peveraer |
1.29 |
// $Id: ElectronIDMod.cc,v 1.28 2009/07/21 16:35:12 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 |
loizides |
1.1 |
fElectronIDType("Tight"),
|
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 |
loizides |
1.14 |
fElectrons(0),
|
37 |
|
|
fConversions(0),
|
38 |
loizides |
1.25 |
fVertices(0)
|
39 |
loizides |
1.1 |
{
|
40 |
|
|
// Constructor.
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
//--------------------------------------------------------------------------------------------------
|
44 |
|
|
void ElectronIDMod::Process()
|
45 |
|
|
{
|
46 |
|
|
// Process entries of the tree.
|
47 |
|
|
|
48 |
loizides |
1.23 |
LoadEventObject(fElectronBranchName, fElectrons);
|
49 |
loizides |
1.1 |
|
50 |
loizides |
1.6 |
ElectronOArr *GoodElectrons = new ElectronOArr;
|
51 |
|
|
GoodElectrons->SetName(fGoodElectronsName);
|
52 |
loizides |
1.1 |
|
53 |
ceballos |
1.18 |
for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
|
54 |
loizides |
1.5 |
const Electron *e = fElectrons->At(i);
|
55 |
loizides |
1.1 |
|
56 |
loizides |
1.5 |
if (e->Pt() <= fElectronPtMin)
|
57 |
|
|
continue;
|
58 |
loizides |
1.1 |
|
59 |
loizides |
1.5 |
Bool_t idcut = kFALSE;
|
60 |
|
|
switch (fElIdType) {
|
61 |
|
|
case kTight:
|
62 |
|
|
idcut = e->PassTightID();
|
63 |
|
|
break;
|
64 |
|
|
case kLoose:
|
65 |
|
|
idcut = e->PassLooseID();
|
66 |
|
|
break;
|
67 |
|
|
case kLikelihood:
|
68 |
|
|
idcut = (e->IDLikelihood() > fIDLikelihoodCut);
|
69 |
|
|
break;
|
70 |
loizides |
1.11 |
case kNoId:
|
71 |
|
|
idcut = kTRUE;
|
72 |
|
|
break;
|
73 |
peveraer |
1.29 |
case kCustomIdLoose:
|
74 |
|
|
idcut = ElectronIDMod::PassCustomID(e,kLooseCustom);
|
75 |
|
|
break;
|
76 |
|
|
case kCustomIdTight:
|
77 |
|
|
idcut = ElectronIDMod::PassCustomID(e,kTightCustom);
|
78 |
loizides |
1.5 |
break;
|
79 |
loizides |
1.1 |
}
|
80 |
|
|
|
81 |
loizides |
1.5 |
if (!idcut)
|
82 |
|
|
continue;
|
83 |
|
|
|
84 |
|
|
Bool_t isocut = kFALSE;
|
85 |
|
|
switch (fElIsoType) {
|
86 |
|
|
case kTrackCalo:
|
87 |
bendavid |
1.28 |
isocut = (e->TrackIsolationDr03() < fTrackIsolationCut) &&
|
88 |
loizides |
1.5 |
(e->CaloIsolation() < fCaloIsolationCut);
|
89 |
|
|
break;
|
90 |
|
|
case kTrackJura:
|
91 |
bendavid |
1.28 |
isocut = (e->TrackIsolationDr03() < fTrackIsolationCut) &&
|
92 |
|
|
(e->EcalRecHitIsoDr04() < fEcalJuraIsoCut) &&
|
93 |
loizides |
1.5 |
(e->HcalIsolation() < fHcalIsolationCut);
|
94 |
|
|
break;
|
95 |
|
|
case kTrackJuraSliding:
|
96 |
ceballos |
1.18 |
{
|
97 |
bendavid |
1.28 |
Double_t totalIso = e->TrackIsolationDr03() + e->EcalRecHitIsoDr04() - 1.5;
|
98 |
ceballos |
1.12 |
if ((totalIso < (e->Pt()-10.0)*5.0/15.0 && e->Pt() <= 25) ||
|
99 |
|
|
(totalIso < 5.0 && e->Pt() > 25) ||
|
100 |
ceballos |
1.7 |
totalIso <= 0)
|
101 |
loizides |
1.5 |
isocut = kTRUE;
|
102 |
ceballos |
1.24 |
|
103 |
|
|
if (fReverseIsoCut == kTRUE &&
|
104 |
|
|
isocut == kFALSE && totalIso < 10)
|
105 |
|
|
isocut = kTRUE;
|
106 |
|
|
else if(fReverseIsoCut == kTRUE)
|
107 |
|
|
isocut = kFALSE;
|
108 |
loizides |
1.5 |
}
|
109 |
|
|
break;
|
110 |
|
|
case kNoIso:
|
111 |
|
|
isocut = kTRUE;
|
112 |
|
|
break;
|
113 |
|
|
case kCustomIso:
|
114 |
|
|
default:
|
115 |
|
|
break;
|
116 |
loizides |
1.1 |
}
|
117 |
|
|
|
118 |
ceballos |
1.24 |
if (isocut == kFALSE)
|
119 |
loizides |
1.5 |
continue;
|
120 |
|
|
|
121 |
loizides |
1.14 |
// apply conversion filter
|
122 |
ceballos |
1.12 |
Bool_t isGoodConversion = kFALSE;
|
123 |
loizides |
1.14 |
if (fApplyConvFilter) {
|
124 |
ceballos |
1.12 |
LoadBranch(fConversionBranchName);
|
125 |
|
|
for (UInt_t ifc=0; ifc<fConversions->GetEntries(); ifc++) {
|
126 |
|
|
|
127 |
|
|
Bool_t ConversionMatchFound = kFALSE;
|
128 |
|
|
for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
|
129 |
|
|
const Track *trk = dynamic_cast<const ChargedParticle*>
|
130 |
|
|
(fConversions->At(ifc)->Daughter(d))->Trk();
|
131 |
ceballos |
1.13 |
if (e->GsfTrk() == trk) {
|
132 |
ceballos |
1.12 |
ConversionMatchFound = kTRUE;
|
133 |
|
|
break;
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
// if match between the e-track and one of the conversion legs
|
138 |
|
|
if (ConversionMatchFound == kTRUE){
|
139 |
ceballos |
1.19 |
isGoodConversion = (fConversions->At(ifc)->Prob() > 0.0005) &&
|
140 |
ceballos |
1.12 |
(fConversions->At(ifc)->Lxy() > 0) &&
|
141 |
|
|
(fConversions->At(ifc)->Lz() > 0);
|
142 |
|
|
|
143 |
|
|
if (isGoodConversion == kTRUE) {
|
144 |
|
|
for (UInt_t d=0; d<fConversions->At(ifc)->NDaughters(); d++) {
|
145 |
|
|
const Track *trk = dynamic_cast<const ChargedParticle*>
|
146 |
|
|
(fConversions->At(ifc)->Daughter(d))->Trk();
|
147 |
|
|
|
148 |
|
|
if (trk) {
|
149 |
bendavid |
1.27 |
// These requirements are not used for the GSF track
|
150 |
|
|
if (!(trk->NHits() > 8 && trk->Prob() > 0.005) && trk!=e->GsfTrk())
|
151 |
ceballos |
1.12 |
isGoodConversion = kFALSE;
|
152 |
|
|
|
153 |
|
|
const StableData *sd = dynamic_cast<const StableData*>
|
154 |
|
|
(fConversions->At(ifc)->DaughterDat(d));
|
155 |
|
|
if (sd->NWrongHits() != 0)
|
156 |
|
|
isGoodConversion = kFALSE;
|
157 |
|
|
|
158 |
|
|
} else {
|
159 |
|
|
isGoodConversion = kFALSE;
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
if (isGoodConversion == kTRUE) break;
|
166 |
|
|
|
167 |
|
|
} // loop over all conversions
|
168 |
|
|
|
169 |
|
|
}
|
170 |
|
|
if (isGoodConversion == kTRUE) continue;
|
171 |
|
|
|
172 |
ceballos |
1.15 |
if (fApplyD0Cut) {
|
173 |
ceballos |
1.24 |
Bool_t d0cut = kFALSE;
|
174 |
ceballos |
1.15 |
LoadBranch(fVertexName);
|
175 |
|
|
// d0 cut
|
176 |
|
|
double d0_real = 99999;
|
177 |
|
|
for(uint i0 = 0; i0 < fVertices->GetEntries(); i0++) {
|
178 |
|
|
double pD0 = e->GsfTrk()->D0Corrected(*fVertices->At(i0));
|
179 |
|
|
if(TMath::Abs(pD0) < TMath::Abs(d0_real)) d0_real = TMath::Abs(pD0);
|
180 |
|
|
}
|
181 |
ceballos |
1.24 |
if(d0_real < fD0Cut) d0cut = kTRUE;
|
182 |
|
|
|
183 |
|
|
if (fReverseD0Cut == kTRUE &&
|
184 |
|
|
d0cut == kFALSE && d0_real < 0.05)
|
185 |
|
|
d0cut = kTRUE;
|
186 |
|
|
else if(fReverseD0Cut == kTRUE)
|
187 |
|
|
d0cut = kFALSE;
|
188 |
|
|
|
189 |
|
|
if (d0cut == kFALSE)
|
190 |
|
|
continue;
|
191 |
ceballos |
1.12 |
}
|
192 |
|
|
|
193 |
loizides |
1.5 |
// add good electron
|
194 |
ceballos |
1.12 |
GoodElectrons->Add(e);
|
195 |
loizides |
1.5 |
}
|
196 |
loizides |
1.1 |
|
197 |
loizides |
1.9 |
// sort according to pt
|
198 |
|
|
GoodElectrons->Sort();
|
199 |
|
|
|
200 |
loizides |
1.5 |
// add to event for other modules to use
|
201 |
loizides |
1.6 |
AddObjThisEvt(GoodElectrons);
|
202 |
loizides |
1.1 |
}
|
203 |
|
|
|
204 |
peveraer |
1.29 |
Bool_t ElectronIDMod::PassCustomID(const Electron *ele, EElIdCustomType CustomIDName){
|
205 |
|
|
|
206 |
|
|
double tightcuts[6][8]={
|
207 |
|
|
{0.056, 0.0221, 0.037, 0.0, 0.0268, 0.0102, 0.0104, 0.0}, //hovere
|
208 |
|
|
{0.0095, 0.0094, 0.0094, 0.0, 0.029, 0.029, 0.029, 0.0}, //sigmaetaeta
|
209 |
|
|
{0.0225, 0.0114, 0.0234, 0.039, 0.0215, 0.0095, 0.0148, 0.0167}, //deltaphiin
|
210 |
|
|
{0.0043, 0.00282, 0.0036, 0.0, 0.0066, 0.0049, 0.0041, 0.0}, //deltaetain
|
211 |
|
|
{0.32, 0.94, 0.221, 0.0, 0.74, 0.89, 0.66, 0.0}, //eoverp
|
212 |
|
|
{0.8,0.2,0.9,0,0,0,0,0}}; //extra cuts fbrem and E_Over_P
|
213 |
|
|
double loosecuts[6][8]={
|
214 |
|
|
{0.076, 0.033, 0.07, 0.0, 0.083,0.148, 0.033, 0.0}, //hovere
|
215 |
|
|
{0.0101, 0.0095, 0.0097, 0.0, 0.03, 0.03, 0.03, 0.0}, //sigmaetaeta
|
216 |
|
|
{0.053, 0.0189, 0.059, 0.099, 0.0278,0.0157, 0.042, 0.080}, //deltaphiin
|
217 |
|
|
{0.0078, 0.00259, 0.0062, 0.0, 0.0078,0.0061, 0.0061, 0.0}, //deltaetain
|
218 |
|
|
{0.3, 0.92, 0.211, 0.0, 0.42, 0.88, 0.68, 0.0}, //eoverp
|
219 |
|
|
{0.8,0.2,0,0,0,0,0,0}}; //extra cuts fbrem and E_Over_P
|
220 |
|
|
|
221 |
|
|
double cuts[6][8];
|
222 |
|
|
|
223 |
|
|
switch (CustomIDName) {
|
224 |
|
|
case kTightCustom:
|
225 |
|
|
for (int i=0;i<6;i++){
|
226 |
|
|
for (int j=0;j<8;j++){
|
227 |
|
|
cuts[i][j]=tightcuts[i][j];
|
228 |
|
|
}
|
229 |
|
|
}
|
230 |
|
|
break;
|
231 |
|
|
case kLooseCustom:
|
232 |
|
|
for (int i=0;i<6;i++){
|
233 |
|
|
for (int j=0;j<8;j++){
|
234 |
|
|
cuts[i][j]=loosecuts[i][j];
|
235 |
|
|
}
|
236 |
|
|
}
|
237 |
|
|
break;
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
double eOverP = ele->ESuperClusterOverP();
|
241 |
|
|
double pin = ele->PIn();
|
242 |
|
|
double pout = ele->POut();
|
243 |
|
|
double fBrem = (pin-pout)/pin;
|
244 |
|
|
if ((eOverP < cuts[5][0]) && (fBrem < cuts[5][1])) {
|
245 |
|
|
return false; }
|
246 |
|
|
if (eOverP < cuts[5][2]*(1-fBrem)){
|
247 |
|
|
return false; }
|
248 |
|
|
int cat = ElectronIDMod::Categories(ele);
|
249 |
|
|
double eSeedOverPin = ele->ESeedClusterOverPIn();
|
250 |
|
|
double hOverE = ele->HadronicOverEm();
|
251 |
|
|
double sigmaee = ele->CoviEtaiEta();
|
252 |
|
|
double deltaPhiIn = fabs(ele->DeltaPhiSuperClusterTrackAtVtx());
|
253 |
|
|
double deltaEtaIn = fabs(ele->DeltaEtaSuperClusterTrackAtVtx());
|
254 |
|
|
|
255 |
|
|
int eb;
|
256 |
|
|
if (ele->IsEB())
|
257 |
|
|
eb = 0;
|
258 |
|
|
else {
|
259 |
|
|
eb = 1;
|
260 |
|
|
}
|
261 |
|
|
|
262 |
|
|
if(hOverE>cuts[0][cat+4*eb]) { return false; }
|
263 |
|
|
if(sigmaee>cuts[1][cat+4*eb]){ return false; }
|
264 |
|
|
if(eOverP<1.5){
|
265 |
|
|
if(deltaPhiIn>cuts[2][cat+4*eb]){ return false;} }
|
266 |
|
|
else{
|
267 |
|
|
if(deltaPhiIn>cuts[2][3+4*eb]){ return false;} }
|
268 |
|
|
if(deltaEtaIn>cuts[3][cat+4*eb]){ return false;}
|
269 |
|
|
if(eSeedOverPin<cuts[4][cat+4*eb]){ return false;}
|
270 |
|
|
return true;
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
Int_t ElectronIDMod::Categories(const Electron *electron){
|
275 |
|
|
double eOverP = electron->ESuperClusterOverP();
|
276 |
|
|
double pin = electron->PIn();
|
277 |
|
|
double pout = electron->POut();
|
278 |
|
|
double fBrem = (pin-pout)/pin;
|
279 |
|
|
|
280 |
|
|
int cat;
|
281 |
|
|
|
282 |
|
|
if( (electron->IsEB() && fBrem<0.06) || (electron->IsEE() && fBrem<0.1))
|
283 |
|
|
cat=1;
|
284 |
|
|
else if (eOverP < 1.2 && eOverP > 0.8)
|
285 |
|
|
cat=0;
|
286 |
|
|
else
|
287 |
|
|
cat=2;
|
288 |
|
|
|
289 |
|
|
return cat;
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
|
297 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
298 |
|
|
void ElectronIDMod::SlaveBegin()
|
299 |
|
|
{
|
300 |
|
|
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
301 |
loizides |
1.5 |
// we just request the electron collection branch.
|
302 |
loizides |
1.1 |
|
303 |
loizides |
1.23 |
ReqEventObject(fElectronBranchName, fElectrons, kTRUE);
|
304 |
loizides |
1.17 |
|
305 |
ceballos |
1.16 |
if (fApplyConvFilter)
|
306 |
loizides |
1.23 |
ReqEventObject(fConversionBranchName, fConversions, kTRUE);
|
307 |
loizides |
1.17 |
|
308 |
ceballos |
1.15 |
if (fApplyD0Cut)
|
309 |
loizides |
1.23 |
ReqEventObject(fVertexName, fVertices, kTRUE);
|
310 |
loizides |
1.1 |
|
311 |
loizides |
1.5 |
if (fElectronIDType.CompareTo("Tight") == 0)
|
312 |
|
|
fElIdType = kTight;
|
313 |
|
|
else if (fElectronIDType.CompareTo("Loose") == 0)
|
314 |
|
|
fElIdType = kLoose;
|
315 |
|
|
else if (fElectronIDType.CompareTo("Likelihood") == 0)
|
316 |
|
|
fElIdType = kLikelihood;
|
317 |
loizides |
1.10 |
else if (fElectronIDType.CompareTo("NoId") == 0)
|
318 |
|
|
fElIdType = kNoId;
|
319 |
peveraer |
1.29 |
else if (fElectronIDType.CompareTo("CustomLoose") == 0)
|
320 |
|
|
fElIdType = kCustomIdLoose;
|
321 |
|
|
else if (fElectronIDType.CompareTo("CustomTight") == 0)
|
322 |
|
|
fElIdType = kCustomIdTight;
|
323 |
|
|
else {
|
324 |
loizides |
1.5 |
SendError(kAbortAnalysis, "SlaveBegin",
|
325 |
|
|
"The specified electron identification %s is not defined.",
|
326 |
|
|
fElectronIDType.Data());
|
327 |
|
|
return;
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
if (fElectronIsoType.CompareTo("TrackCalo") == 0 )
|
331 |
|
|
fElIsoType = kTrackCalo;
|
332 |
|
|
else if (fElectronIsoType.CompareTo("TrackJura") == 0)
|
333 |
|
|
fElIsoType = kTrackJura;
|
334 |
|
|
else if(fElectronIsoType.CompareTo("TrackJuraSliding") == 0)
|
335 |
|
|
fElIsoType = kTrackJuraSliding;
|
336 |
|
|
else if (fElectronIsoType.CompareTo("NoIso") == 0 )
|
337 |
|
|
fElIsoType = kNoIso;
|
338 |
|
|
else if (fElectronIsoType.CompareTo("Custom") == 0 ) {
|
339 |
|
|
fElIsoType = kCustomIso;
|
340 |
|
|
SendError(kWarning, "SlaveBegin",
|
341 |
|
|
"Custom electron isolation is not yet implemented.");
|
342 |
|
|
} else {
|
343 |
|
|
SendError(kAbortAnalysis, "SlaveBegin",
|
344 |
|
|
"The specified electron isolation %s is not defined.",
|
345 |
|
|
fElectronIsoType.Data());
|
346 |
|
|
return;
|
347 |
|
|
}
|
348 |
loizides |
1.1 |
}
|