ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonIDMod.cc
Revision: 1.22
Committed: Fri Jul 15 17:24:37 2011 UTC (13 years, 9 months ago) by fabstoec
Content type: text/plain
Branch: MAIN
Changes since 1.21: +54 -38 lines
Log Message:
added/improved stuff for CiC Selection

File Contents

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