ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonIDMod.cc
Revision: 1.21
Committed: Wed May 18 14:01:19 2011 UTC (13 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_023, Mit_022a, Mit_022, Mit_021
Changes since 1.20: +14 -9 lines
Log Message:
make fiducial cuts consistent

File Contents

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