1 |
// $Id: PhotonIDMod.cc,v 1.19 2011/04/12 22:14:21 bendavid Exp $
|
2 |
|
3 |
#include "MitPhysics/Mods/interface/PhotonIDMod.h"
|
4 |
#include "MitAna/DataTree/interface/PhotonCol.h"
|
5 |
#include "MitPhysics/Init/interface/ModNames.h"
|
6 |
#include "MitPhysics/Utils/interface/IsolationTools.h"
|
7 |
#include "MitPhysics/Utils/interface/PhotonTools.h"
|
8 |
|
9 |
using namespace mithep;
|
10 |
|
11 |
ClassImp(mithep::PhotonIDMod)
|
12 |
|
13 |
//--------------------------------------------------------------------------------------------------
|
14 |
PhotonIDMod::PhotonIDMod(const char *name, const char *title) :
|
15 |
BaseMod(name,title),
|
16 |
fPhotonBranchName (Names::gkPhotonBrn),
|
17 |
fGoodPhotonsName (ModNames::gkGoodPhotonsName),
|
18 |
fTrackBranchName (Names::gkTrackBrn),
|
19 |
fBeamspotBranchName(Names::gkBeamSpotBrn),
|
20 |
fPileUpDenName (Names::gkPileupEnergyDensityBrn),
|
21 |
fConversionName ("MergedConversions"),
|
22 |
fElectronName ("Electrons"),
|
23 |
fPhotonIDType("Custom"),
|
24 |
fPhotonIsoType("Custom"),
|
25 |
fPhotonPtMin(15.0),
|
26 |
fHadOverEmMax(0.02),
|
27 |
fApplySpikeRemoval(kFALSE),
|
28 |
fApplyPixelSeed(kTRUE),
|
29 |
fApplyElectronVeto(kFALSE),
|
30 |
fApplyElectronVetoConvRecovery(kFALSE),
|
31 |
fApplyConversionId(kFALSE),
|
32 |
fApplyTriggerMatching(kFALSE),
|
33 |
fPhotonR9Min(0.5),
|
34 |
fPhIdType(kIdUndef),
|
35 |
fPhIsoType(kIsoUndef),
|
36 |
fFiduciality(kTRUE),
|
37 |
fEtaWidthEB(0.01),
|
38 |
fEtaWidthEE(0.028),
|
39 |
fAbsEtaMax(2.5),
|
40 |
fApplyR9Min(kFALSE),
|
41 |
fEffAreaEcalEE(0.071),
|
42 |
fEffAreaHcalEE(0.095),
|
43 |
fEffAreaTrackEE(0.269),
|
44 |
fEffAreaEcalEB(0.162),
|
45 |
fEffAreaHcalEB(0.042),
|
46 |
fEffAreaTrackEB(0.317),
|
47 |
fPhotons(0),
|
48 |
fTracks(0),
|
49 |
fBeamspots(0),
|
50 |
fPileUpDen(0),
|
51 |
fConversions(0),
|
52 |
fElectrons(0)
|
53 |
|
54 |
{
|
55 |
// Constructor.
|
56 |
}
|
57 |
|
58 |
//--------------------------------------------------------------------------------------------------
|
59 |
void PhotonIDMod::Process()
|
60 |
{
|
61 |
// Process entries of the tree.
|
62 |
|
63 |
LoadEventObject(fPhotonBranchName, fPhotons);
|
64 |
|
65 |
const BaseVertex *bsp = NULL;
|
66 |
Double_t _tRho = -1.;
|
67 |
const TriggerObjectCol *trigObjs = 0;
|
68 |
if (fPhotons->GetEntries()>0) {
|
69 |
LoadEventObject(fTrackBranchName, fTracks);
|
70 |
LoadEventObject(fBeamspotBranchName, fBeamspots);
|
71 |
LoadEventObject(fPileUpDenName, fPileUpDen);
|
72 |
LoadEventObject(fConversionName, fConversions);
|
73 |
LoadEventObject(fElectronName, fElectrons);
|
74 |
|
75 |
|
76 |
if(fBeamspots->GetEntries() > 0)
|
77 |
bsp = fBeamspots->At(0);
|
78 |
|
79 |
if(fPileUpDen->GetEntries() > 0)
|
80 |
_tRho = (Double_t) fPileUpDen->At(0)->Rho();
|
81 |
|
82 |
//get trigger object collection if trigger matching is enabled
|
83 |
if (fApplyTriggerMatching) {
|
84 |
trigObjs = GetHLTObjects(fTrigObjectsName);
|
85 |
}
|
86 |
|
87 |
}
|
88 |
|
89 |
PhotonOArr *GoodPhotons = new PhotonOArr;
|
90 |
GoodPhotons->SetName(fGoodPhotonsName);
|
91 |
|
92 |
for (UInt_t i=0; i<fPhotons->GetEntries(); ++i) {
|
93 |
const Photon *ph = fPhotons->At(i);
|
94 |
|
95 |
if (ph->Pt() <= fPhotonPtMin)
|
96 |
continue;
|
97 |
|
98 |
|
99 |
|
100 |
Bool_t passSpikeRemovalFilter = kTRUE;
|
101 |
|
102 |
if (ph->SCluster() && ph->SCluster()->Seed()) {
|
103 |
if(ph->SCluster()->Seed()->Energy() > 5.0 &&
|
104 |
ph->SCluster()->Seed()->EMax() / ph->SCluster()->Seed()->E3x3() > 0.95
|
105 |
) {
|
106 |
passSpikeRemovalFilter = kFALSE;
|
107 |
}
|
108 |
}
|
109 |
|
110 |
// For Now Only use the EMax/E3x3 prescription.
|
111 |
//if(ph->SCluster()->Seed()->Energy() > 5.0 &&
|
112 |
// (1 - (ph->SCluster()->Seed()->E1x3() + ph->SCluster()->Seed()->E3x1() - 2*ph->SCluster()->Seed()->EMax())) > 0.95
|
113 |
// ) {
|
114 |
// passSpikeRemovalFilter = kFALSE;
|
115 |
//}
|
116 |
if (fApplySpikeRemoval && !passSpikeRemovalFilter) continue;
|
117 |
|
118 |
|
119 |
|
120 |
if (ph->HadOverEm() >= fHadOverEmMax)
|
121 |
continue;
|
122 |
|
123 |
if (fApplyPixelSeed == kTRUE &&
|
124 |
ph->HasPixelSeed() == kTRUE)
|
125 |
continue;
|
126 |
|
127 |
if (fApplyElectronVeto && !PhotonTools::PassElectronVeto(ph,fElectrons) ) continue;
|
128 |
|
129 |
if (fApplyElectronVetoConvRecovery && !PhotonTools::PassElectronVetoConvRecovery(ph,fElectrons,fConversions,bsp) ) continue;
|
130 |
|
131 |
if (fApplyConversionId && !PhotonTools::PassConversionId(ph,PhotonTools::MatchedConversion(ph,fConversions,bsp))) continue;
|
132 |
|
133 |
if (fApplyTriggerMatching && !PhotonTools::PassTriggerMatching(ph,trigObjs)) continue;
|
134 |
|
135 |
Bool_t idcut = kFALSE;
|
136 |
switch (fPhIdType) {
|
137 |
case kTight:
|
138 |
idcut = ph->IsTightPhoton();
|
139 |
break;
|
140 |
case kLoose:
|
141 |
idcut = ph->IsLoosePhoton();
|
142 |
break;
|
143 |
case kLooseEM:
|
144 |
idcut = ph->IsLooseEM();
|
145 |
break;
|
146 |
case kCustomId:
|
147 |
idcut = kTRUE;
|
148 |
default:
|
149 |
break;
|
150 |
}
|
151 |
|
152 |
if (!idcut)
|
153 |
continue;
|
154 |
|
155 |
Bool_t isocut = kFALSE;
|
156 |
switch (fPhIsoType) {
|
157 |
case kNoIso:
|
158 |
isocut = kTRUE;
|
159 |
break;
|
160 |
case kCombinedIso:
|
161 |
{
|
162 |
Double_t totalIso = ph->HollowConeTrkIsoDr04()+
|
163 |
ph->EcalRecHitIsoDr04() +
|
164 |
ph->HcalTowerSumEtDr04();
|
165 |
if (totalIso/ph->Pt() < 0.25)
|
166 |
isocut = kTRUE;
|
167 |
}
|
168 |
break;
|
169 |
case kCustomIso:
|
170 |
{
|
171 |
if ( ph->HollowConeTrkIsoDr04() < (1.5 + 0.001*ph->Pt()) && ph->EcalRecHitIsoDr04()<(2.0+0.006*ph->Pt()) && ph->HcalTowerSumEtDr04()<(2.0+0.0025*ph->Pt()) )
|
172 |
isocut = kTRUE;
|
173 |
}
|
174 |
break;
|
175 |
|
176 |
case kMITPUCorrected:
|
177 |
{
|
178 |
// compute the PU corrections only if Rho is available
|
179 |
// ... otherwise (_tRho = -1.0) it's the std isolation
|
180 |
isocut = kTRUE;
|
181 |
Double_t fEffAreaEcal = fEffAreaEcalEB;
|
182 |
Double_t fEffAreaHcal = fEffAreaHcalEB;
|
183 |
Double_t fEffAreaTrack = fEffAreaTrackEB;
|
184 |
|
185 |
if( abs(ph->Eta()) > 1.5 ) {
|
186 |
fEffAreaEcal = fEffAreaEcalEE;
|
187 |
fEffAreaHcal = fEffAreaHcalEE;
|
188 |
fEffAreaTrack = fEffAreaTrackEE;
|
189 |
}
|
190 |
|
191 |
Double_t EcalCorrISO = ph->EcalRecHitIsoDr04();
|
192 |
if(_tRho > -0.5 ) EcalCorrISO -= _tRho * fEffAreaEcal;
|
193 |
if ( EcalCorrISO > (2.0+0.006*ph->Pt()) ) isocut = kFALSE;
|
194 |
if ( isocut ) {
|
195 |
Double_t HcalCorrISO = ph->HcalTowerSumEtDr04();
|
196 |
if(_tRho > -0.5 ) HcalCorrISO -= _tRho * fEffAreaHcal;
|
197 |
if ( HcalCorrISO > (2.0+0.0025*ph->Pt()) ) isocut = kFALSE;
|
198 |
}
|
199 |
if ( isocut ) {
|
200 |
Double_t TrackCorrISO = IsolationTools::TrackIsolationNoPV(ph, bsp, 0.4, 0.04, 0.0, 0.015, 0.1, TrackQuality::highPurity, fTracks);
|
201 |
if(_tRho > -0.5 )
|
202 |
TrackCorrISO -= _tRho * fEffAreaTrack;
|
203 |
if ( TrackCorrISO > (1.5 + 0.001*ph->Pt()) ) isocut = kFALSE;
|
204 |
}
|
205 |
break;
|
206 |
}
|
207 |
default:
|
208 |
break;
|
209 |
}
|
210 |
|
211 |
if (!isocut)
|
212 |
continue;
|
213 |
|
214 |
if ( fApplyR9Min && ph->R9() <= fPhotonR9Min)
|
215 |
continue;
|
216 |
|
217 |
if (fFiduciality == kTRUE &&
|
218 |
ph->IsEB() == kFALSE && ph->IsEE() == kFALSE)
|
219 |
continue;
|
220 |
|
221 |
if ((ph->IsEB() == kTRUE && ph->CoviEtaiEta() >= fEtaWidthEB) ||
|
222 |
(ph->IsEE() == kTRUE && ph->CoviEtaiEta() >= fEtaWidthEE))
|
223 |
continue;
|
224 |
|
225 |
if (ph->AbsEta() >= fAbsEtaMax)
|
226 |
continue;
|
227 |
|
228 |
// add good electron
|
229 |
GoodPhotons->Add(fPhotons->At(i));
|
230 |
}
|
231 |
|
232 |
// sort according to pt
|
233 |
GoodPhotons->Sort();
|
234 |
|
235 |
// add to event for other modules to use
|
236 |
AddObjThisEvt(GoodPhotons);
|
237 |
}
|
238 |
|
239 |
//--------------------------------------------------------------------------------------------------
|
240 |
void PhotonIDMod::SlaveBegin()
|
241 |
{
|
242 |
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
243 |
// we just request the photon collection branch.
|
244 |
|
245 |
ReqEventObject(fPhotonBranchName, fPhotons, kTRUE);
|
246 |
ReqEventObject(fTrackBranchName, fTracks, kTRUE);
|
247 |
ReqEventObject(fBeamspotBranchName, fBeamspots, kTRUE);
|
248 |
ReqEventObject(fPileUpDenName, fPileUpDen, kTRUE);
|
249 |
ReqEventObject(fConversionName, fConversions, kTRUE);
|
250 |
ReqEventObject(fElectronName, fElectrons, kTRUE);
|
251 |
|
252 |
|
253 |
if (fPhotonIDType.CompareTo("Tight") == 0)
|
254 |
fPhIdType = kTight;
|
255 |
else if (fPhotonIDType.CompareTo("Loose") == 0)
|
256 |
fPhIdType = kLoose;
|
257 |
else if (fPhotonIDType.CompareTo("LooseEM") == 0)
|
258 |
fPhIdType = kLooseEM;
|
259 |
else if (fPhotonIDType.CompareTo("Custom") == 0) {
|
260 |
fPhIdType = kCustomId;
|
261 |
} else {
|
262 |
SendError(kAbortAnalysis, "SlaveBegin",
|
263 |
"The specified photon identification %s is not defined.",
|
264 |
fPhotonIDType.Data());
|
265 |
return;
|
266 |
}
|
267 |
|
268 |
if (fPhotonIsoType.CompareTo("NoIso") == 0 )
|
269 |
fPhIsoType = kNoIso;
|
270 |
else if (fPhotonIsoType.CompareTo("CombinedIso") == 0 )
|
271 |
fPhIsoType = kCombinedIso;
|
272 |
else if (fPhotonIsoType.CompareTo("Custom") == 0 )
|
273 |
fPhIsoType = kCustomIso;
|
274 |
else if (fPhotonIsoType.CompareTo("MITPUCorrected") == 0 )
|
275 |
fPhIsoType = kMITPUCorrected;
|
276 |
else {
|
277 |
SendError(kAbortAnalysis, "SlaveBegin",
|
278 |
"The specified photon isolation %s is not defined.",
|
279 |
fPhotonIsoType.Data());
|
280 |
return;
|
281 |
}
|
282 |
}
|