ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonIDMod.cc
Revision: 1.19
Committed: Tue Apr 12 22:14:21 2011 UTC (14 years ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.18: +44 -11 lines
Log Message:
Add PhotonTools with conversion id, trigger matching and diphoton categories, add functionality to PhotonIdMod

File Contents

# User Rev Content
1 bendavid 1.19 // $Id: PhotonIDMod.cc,v 1.18 2011/04/06 18:09:20 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 ceballos 1.11 fAbsEtaMax(2.5),
40 bendavid 1.16 fApplyR9Min(kFALSE),
41 fabstoec 1.17 fEffAreaEcal(0.139),
42     fEffAreaHcal(0.056),
43     fEffAreaTrack(0.296),
44     fPhotons(0),
45     fTracks(0),
46     fBeamspots(0),
47 bendavid 1.19 fPileUpDen(0),
48     fConversions(0),
49     fElectrons(0)
50 fabstoec 1.17
51 sixie 1.1 {
52     // Constructor.
53     }
54    
55     //--------------------------------------------------------------------------------------------------
56     void PhotonIDMod::Process()
57     {
58     // Process entries of the tree.
59    
60 fabstoec 1.17 LoadEventObject(fPhotonBranchName, fPhotons);
61 bendavid 1.19
62     const BaseVertex *bsp = NULL;
63     Double_t _tRho = -1.;
64     const TriggerObjectCol *trigObjs = 0;
65     if (fPhotons->GetEntries()>0) {
66     LoadEventObject(fTrackBranchName, fTracks);
67     LoadEventObject(fBeamspotBranchName, fBeamspots);
68     LoadEventObject(fPileUpDenName, fPileUpDen);
69     LoadEventObject(fConversionName, fConversions);
70     LoadEventObject(fElectronName, fElectrons);
71 fabstoec 1.17
72 bendavid 1.19
73     if(fBeamspots->GetEntries() > 0)
74     bsp = fBeamspots->At(0);
75 fabstoec 1.17
76 bendavid 1.19 if(fPileUpDen->GetEntries() > 0)
77     _tRho = (Double_t) fPileUpDen->At(0)->Rho();
78    
79     //get trigger object collection if trigger matching is enabled
80     if (fApplyTriggerMatching) {
81     trigObjs = GetHLTObjects(fTrigObjectsName);
82     }
83    
84     }
85 fabstoec 1.17
86 sixie 1.1 PhotonOArr *GoodPhotons = new PhotonOArr;
87     GoodPhotons->SetName(fGoodPhotonsName);
88    
89     for (UInt_t i=0; i<fPhotons->GetEntries(); ++i) {
90     const Photon *ph = fPhotons->At(i);
91    
92     if (ph->Pt() <= fPhotonPtMin)
93     continue;
94 sixie 1.13
95    
96 sixie 1.1
97 sixie 1.13 Bool_t passSpikeRemovalFilter = kTRUE;
98 sixie 1.15
99     if (ph->SCluster() && ph->SCluster()->Seed()) {
100     if(ph->SCluster()->Seed()->Energy() > 5.0 &&
101     ph->SCluster()->Seed()->EMax() / ph->SCluster()->Seed()->E3x3() > 0.95
102     ) {
103     passSpikeRemovalFilter = kFALSE;
104     }
105 sixie 1.13 }
106    
107     // For Now Only use the EMax/E3x3 prescription.
108     //if(ph->SCluster()->Seed()->Energy() > 5.0 &&
109     // (1 - (ph->SCluster()->Seed()->E1x3() + ph->SCluster()->Seed()->E3x1() - 2*ph->SCluster()->Seed()->EMax())) > 0.95
110     // ) {
111     // passSpikeRemovalFilter = kFALSE;
112     //}
113     if (fApplySpikeRemoval && !passSpikeRemovalFilter) continue;
114    
115    
116    
117 ceballos 1.2 if (ph->HadOverEm() >= fHadOverEmMax)
118     continue;
119 ceballos 1.14
120 ceballos 1.2 if (fApplyPixelSeed == kTRUE &&
121     ph->HasPixelSeed() == kTRUE)
122     continue;
123 ceballos 1.14
124 bendavid 1.19 if (fApplyElectronVeto && !PhotonTools::PassElectronVeto(ph,fElectrons) ) continue;
125    
126     if (fApplyElectronVetoConvRecovery && !PhotonTools::PassElectronVetoConvRecovery(ph,fElectrons,fConversions,bsp) ) continue;
127    
128     if (fApplyConversionId && !PhotonTools::PassConversionId(ph,PhotonTools::MatchedConversion(ph,fConversions,bsp))) continue;
129    
130     if (fApplyTriggerMatching && !PhotonTools::PassTriggerMatching(ph,trigObjs)) continue;
131    
132 sixie 1.1 Bool_t idcut = kFALSE;
133     switch (fPhIdType) {
134     case kTight:
135     idcut = ph->IsTightPhoton();
136     break;
137     case kLoose:
138     idcut = ph->IsLoosePhoton();
139     break;
140     case kLooseEM:
141     idcut = ph->IsLooseEM();
142     break;
143     case kCustomId:
144 ceballos 1.5 idcut = kTRUE;
145 sixie 1.1 default:
146     break;
147     }
148    
149     if (!idcut)
150     continue;
151    
152     Bool_t isocut = kFALSE;
153     switch (fPhIsoType) {
154     case kNoIso:
155     isocut = kTRUE;
156     break;
157 ceballos 1.2 case kCombinedIso:
158 bendavid 1.12 {
159     Double_t totalIso = ph->HollowConeTrkIsoDr04()+
160     ph->EcalRecHitIsoDr04() +
161     ph->HcalTowerSumEtDr04();
162     if (totalIso/ph->Pt() < 0.25)
163     isocut = kTRUE;
164     }
165 ceballos 1.2 break;
166 sixie 1.1 case kCustomIso:
167 bendavid 1.16 {
168     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()) )
169     isocut = kTRUE;
170     }
171 fabstoec 1.17 break;
172    
173     case kMITPUCorrected:
174     {
175     // compute the PU corrections only if Rho is available
176     // ... otherwise (_tRho = -1.0) it's the std isolation
177     isocut = kTRUE;
178     Double_t EcalCorrISO = ph->EcalRecHitIsoDr04();
179     if(_tRho > -0.5 ) EcalCorrISO -= _tRho * fEffAreaEcal;
180     if ( EcalCorrISO > (2.0+0.006*ph->Pt()) ) isocut = kFALSE;
181     if ( isocut ) {
182     Double_t HcalCorrISO = ph->HcalTowerSumEtDr04();
183     if(_tRho > -0.5 ) HcalCorrISO -= _tRho * fEffAreaHcal;
184     if ( HcalCorrISO > (2.0+0.0025*ph->Pt()) ) isocut = kFALSE;
185     }
186     if ( isocut ) {
187     Double_t TrackCorrISO = IsolationTools::TrackIsolationNoPV(ph, bsp, 0.4, 0.04, 0.0, 0.015, 0.1, TrackQuality::highPurity, fTracks);
188     if(_tRho > -0.5 )
189     TrackCorrISO -= _tRho * fEffAreaTrack;
190     if ( TrackCorrISO > (1.5 + 0.001*ph->Pt()) ) isocut = kFALSE;
191     }
192     break;
193     }
194     default:
195     break;
196 sixie 1.1 }
197 fabstoec 1.17
198 sixie 1.1 if (!isocut)
199     continue;
200 fabstoec 1.17
201 bendavid 1.16 if ( fApplyR9Min && ph->R9() <= fPhotonR9Min)
202 ceballos 1.5 continue;
203    
204 ceballos 1.10 if (fFiduciality == kTRUE &&
205     ph->IsEB() == kFALSE && ph->IsEE() == kFALSE)
206     continue;
207    
208 bendavid 1.16 if ((ph->IsEB() == kTRUE && ph->CoviEtaiEta() >= fEtaWidthEB) ||
209     (ph->IsEE() == kTRUE && ph->CoviEtaiEta() >= fEtaWidthEE))
210 ceballos 1.10 continue;
211    
212 ceballos 1.11 if (ph->AbsEta() >= fAbsEtaMax)
213     continue;
214 ceballos 1.14
215 sixie 1.1 // add good electron
216     GoodPhotons->Add(fPhotons->At(i));
217     }
218    
219 loizides 1.4 // sort according to pt
220     GoodPhotons->Sort();
221    
222 sixie 1.1 // add to event for other modules to use
223     AddObjThisEvt(GoodPhotons);
224     }
225    
226     //--------------------------------------------------------------------------------------------------
227     void PhotonIDMod::SlaveBegin()
228     {
229     // Run startup code on the computer (slave) doing the actual analysis. Here,
230 loizides 1.3 // we just request the photon collection branch.
231 sixie 1.1
232 fabstoec 1.17 ReqEventObject(fPhotonBranchName, fPhotons, kTRUE);
233     ReqEventObject(fTrackBranchName, fTracks, kTRUE);
234     ReqEventObject(fBeamspotBranchName, fBeamspots, kTRUE);
235     ReqEventObject(fPileUpDenName, fPileUpDen, kTRUE);
236 bendavid 1.19 ReqEventObject(fConversionName, fConversions, kTRUE);
237     ReqEventObject(fElectronName, fElectrons, kTRUE);
238    
239 sixie 1.1
240     if (fPhotonIDType.CompareTo("Tight") == 0)
241     fPhIdType = kTight;
242     else if (fPhotonIDType.CompareTo("Loose") == 0)
243     fPhIdType = kLoose;
244     else if (fPhotonIDType.CompareTo("LooseEM") == 0)
245     fPhIdType = kLooseEM;
246     else if (fPhotonIDType.CompareTo("Custom") == 0) {
247     fPhIdType = kCustomId;
248     } else {
249     SendError(kAbortAnalysis, "SlaveBegin",
250 ceballos 1.2 "The specified photon identification %s is not defined.",
251 sixie 1.1 fPhotonIDType.Data());
252     return;
253     }
254    
255     if (fPhotonIsoType.CompareTo("NoIso") == 0 )
256     fPhIsoType = kNoIso;
257 ceballos 1.2 else if (fPhotonIsoType.CompareTo("CombinedIso") == 0 )
258     fPhIsoType = kCombinedIso;
259 fabstoec 1.17 else if (fPhotonIsoType.CompareTo("Custom") == 0 )
260 sixie 1.1 fPhIsoType = kCustomIso;
261 fabstoec 1.17 else if (fPhotonIsoType.CompareTo("MITPUCorrected") == 0 )
262     fPhIsoType = kMITPUCorrected;
263     else {
264 sixie 1.1 SendError(kAbortAnalysis, "SlaveBegin",
265 ceballos 1.2 "The specified photon isolation %s is not defined.",
266 sixie 1.1 fPhotonIsoType.Data());
267     return;
268     }
269     }