ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonIDMod.cc
Revision: 1.20
Committed: Tue Apr 19 09:13:36 2011 UTC (14 years ago) by fabstoec
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_020d, TMit_020d, Mit_020c, Mit_021pre2, Mit_021pre1, Mit_020b
Changes since 1.19: +17 -4 lines
Log Message:
EE/EB effective areas for iso

File Contents

# User Rev Content
1 fabstoec 1.20 // $Id: PhotonIDMod.cc,v 1.19 2011/04/12 22:14:21 bendavid 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 ceballos 1.11 fAbsEtaMax(2.5),
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     LoadEventObject(fPileUpDenName, fPileUpDen);
72     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.19 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 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 sixie 1.1
100 sixie 1.13 Bool_t passSpikeRemovalFilter = kTRUE;
101 sixie 1.15
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 sixie 1.13 }
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 ceballos 1.2 if (ph->HadOverEm() >= fHadOverEmMax)
121     continue;
122 ceballos 1.14
123 ceballos 1.2 if (fApplyPixelSeed == kTRUE &&
124     ph->HasPixelSeed() == kTRUE)
125     continue;
126 ceballos 1.14
127 bendavid 1.19 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 sixie 1.1 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 ceballos 1.5 idcut = kTRUE;
148 sixie 1.1 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 ceballos 1.2 case kCombinedIso:
161 bendavid 1.12 {
162     Double_t totalIso = ph->HollowConeTrkIsoDr04()+
163     ph->EcalRecHitIsoDr04() +
164     ph->HcalTowerSumEtDr04();
165     if (totalIso/ph->Pt() < 0.25)
166     isocut = kTRUE;
167     }
168 ceballos 1.2 break;
169 sixie 1.1 case kCustomIso:
170 bendavid 1.16 {
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 fabstoec 1.17 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 fabstoec 1.20 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 fabstoec 1.17 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 sixie 1.1 }
210 fabstoec 1.17
211 sixie 1.1 if (!isocut)
212     continue;
213 fabstoec 1.17
214 bendavid 1.16 if ( fApplyR9Min && ph->R9() <= fPhotonR9Min)
215 ceballos 1.5 continue;
216    
217 ceballos 1.10 if (fFiduciality == kTRUE &&
218     ph->IsEB() == kFALSE && ph->IsEE() == kFALSE)
219     continue;
220    
221 bendavid 1.16 if ((ph->IsEB() == kTRUE && ph->CoviEtaiEta() >= fEtaWidthEB) ||
222     (ph->IsEE() == kTRUE && ph->CoviEtaiEta() >= fEtaWidthEE))
223 ceballos 1.10 continue;
224    
225 ceballos 1.11 if (ph->AbsEta() >= fAbsEtaMax)
226     continue;
227 ceballos 1.14
228 sixie 1.1 // add good electron
229     GoodPhotons->Add(fPhotons->At(i));
230     }
231    
232 loizides 1.4 // sort according to pt
233     GoodPhotons->Sort();
234    
235 sixie 1.1 // 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 loizides 1.3 // we just request the photon collection branch.
244 sixie 1.1
245 fabstoec 1.17 ReqEventObject(fPhotonBranchName, fPhotons, kTRUE);
246     ReqEventObject(fTrackBranchName, fTracks, kTRUE);
247     ReqEventObject(fBeamspotBranchName, fBeamspots, kTRUE);
248     ReqEventObject(fPileUpDenName, fPileUpDen, kTRUE);
249 bendavid 1.19 ReqEventObject(fConversionName, fConversions, kTRUE);
250     ReqEventObject(fElectronName, fElectrons, kTRUE);
251    
252 sixie 1.1
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 ceballos 1.2 "The specified photon identification %s is not defined.",
264 sixie 1.1 fPhotonIDType.Data());
265     return;
266     }
267    
268     if (fPhotonIsoType.CompareTo("NoIso") == 0 )
269     fPhIsoType = kNoIso;
270 ceballos 1.2 else if (fPhotonIsoType.CompareTo("CombinedIso") == 0 )
271     fPhIsoType = kCombinedIso;
272 fabstoec 1.17 else if (fPhotonIsoType.CompareTo("Custom") == 0 )
273 sixie 1.1 fPhIsoType = kCustomIso;
274 fabstoec 1.17 else if (fPhotonIsoType.CompareTo("MITPUCorrected") == 0 )
275     fPhIsoType = kMITPUCorrected;
276     else {
277 sixie 1.1 SendError(kAbortAnalysis, "SlaveBegin",
278 ceballos 1.2 "The specified photon isolation %s is not defined.",
279 sixie 1.1 fPhotonIsoType.Data());
280     return;
281     }
282     }