ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/interface/PhotonIDMod.h
Revision: 1.32
Committed: Fri Jun 21 19:04:27 2013 UTC (11 years, 10 months ago) by mingyang
Content type: text/plain
Branch: MAIN
Changes since 1.31: +64 -7 lines
Log Message:
PhotonIDMod.h

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PhotonIDMod.h,v 1.31 2013/06/21 13:11:09 mingyang Exp $
3 //
4 // PhotonIDMod
5 //
6 // This module applies photon identification criteria and exports a pointer to a collection
7 // of "good photons" according to the specified identification scheme.
8 //
9 // Authors: S.Xie, C.Loizides
10 //--------------------------------------------------------------------------------------------------
11
12 #ifndef MITPHYSICS_MODS_PHOTONIDMOD_H
13 #define MITPHYSICS_MODS_PHOTONIDMOD_H
14
15 #include "MitAna/TreeMod/interface/BaseMod.h"
16 #include "MitAna/DataTree/interface/PhotonFwd.h"
17 #include "MitAna/DataTree/interface/TrackCol.h"
18 #include "MitAna/DataTree/interface/BeamSpotCol.h"
19 #include "MitAna/DataTree/interface/PileupEnergyDensityCol.h"
20 #include "MitAna/DataTree/interface/DecayParticleCol.h"
21 #include "MitAna/DataTree/interface/ElectronCol.h"
22 #include "MitAna/DataTree/interface/VertexCol.h"
23 #include "MitAna/DataTree/interface/DecayParticleCol.h"
24 #include "MitAna/DataTree/interface/PileupInfoCol.h"
25 #include "MitAna/DataTree/interface/MCParticleCol.h"
26 #include "MitAna/DataTree/interface/PFCandidateCol.h"
27
28 #include "MitPhysics/Utils/interface/MVATools.h"
29 #include "MitPhysics/Utils/interface/PhotonTools.h"
30 #include "MitPhysics/Utils/interface/RhoUtilities.h"
31
32 class TRandom3;
33
34 namespace mithep
35 {
36 class PhotonIDMod : public BaseMod
37 {
38 public:
39 PhotonIDMod(const char *name="PhotonIDMod",
40 const char *title="Photon identification module");
41
42 Bool_t GetApplySpikeRemoval() const { return fApplySpikeRemoval; }
43 Bool_t GetApplyPixelSeed() const { return fApplyPixelSeed; }
44 const char *GetGoodName() const { return GetGoodPhotonsName(); }
45 const char *GetGoodPhotonsName() const { return fGoodPhotonsName; }
46 Double_t GetHadOverEmMax() const { return fHadOverEmMax; }
47 const char *GetIDType() const { return fPhotonIDType; }
48 const char *GetInputName() const { return fPhotonBranchName; }
49 const char *GetIsoType() const { return fPhotonIsoType; }
50 const char *GetOutputName() const { return GetGoodPhotonsName(); }
51 Double_t GetPtMin() const { return fPhotonPtMin; }
52 Bool_t GetApplyFiduciality() const { return fFiduciality; }
53 Double_t GetEtaWidthEB() const { return fEtaWidthEB; }
54 Double_t GetEtaWidthEE() const { return fEtaWidthEE; }
55 Double_t GetAbsEtaMax() const { return fAbsEtaMax; }
56 void SetApplySpikeRemoval(Bool_t b) { fApplySpikeRemoval = b; }
57 void SetApplyPixelSeed(Bool_t b) { fApplyPixelSeed = b; }
58 void SetApplyElectronVeto(Bool_t b) { fApplyElectronVeto = b; }
59 void SetInvertElectronVeto(Bool_t b) { fInvertElectronVeto = b; }
60 void SetApplyElectronVetoConvRecovery(Bool_t b) { fApplyElectronVetoConvRecovery = b; }
61 void SetApplyConversionId(Bool_t b) { fApplyConversionId = b; }
62 void SetApplyTriggerMatching(Bool_t b) { fApplyTriggerMatching = b; }
63 void SetGoodName(const char *n) { SetGoodPhotonsName(n); }
64 void SetGoodPhotonsName(const char *n) { fGoodPhotonsName = n; }
65 void SetHadOverEmMax(Double_t hoe) { fHadOverEmMax = hoe; }
66 void SetIDType(const char *type) { fPhotonIDType = type; }
67 void SetInputName(const char *n) { fPhotonBranchName= n; }
68 void SetTrackName(const char *n) { fTrackBranchName = n; }
69 void SetBeamspotName(const char *n) { fBeamspotBranchName = n; }
70 void SetIsoType(const char *type) { fPhotonIsoType = type; }
71 void SetOutputName(const char *n) { SetGoodPhotonsName(n); }
72 void SetPtMin(Double_t pt) { fPhotonPtMin = pt; }
73 void SetR9Min(Double_t x) { fPhotonR9Min = x; }
74 void SetEtaWidthEB(Double_t x) { fEtaWidthEB = x; }
75 void SetEtaWidthEE(Double_t x) { fEtaWidthEE = x; }
76 void SetAbsEtaMax(Double_t x) { fAbsEtaMax = x; }
77 void SetApplyR9Min(Bool_t b) { fApplyR9Min = b; }
78 void SetApplyFiduciality(Bool_t b) { fFiduciality = b; }
79 void SetEffAreas(Double_t ecal, Double_t hcal, Double_t track) {
80 fEffAreaEcalEE = ecal; fEffAreaHcalEE = hcal; fEffAreaTrackEE = track;
81 fEffAreaEcalEB = ecal; fEffAreaHcalEB = hcal; fEffAreaTrackEB = track;
82 }
83 void SetEffAreasEEEB(Double_t ecalEE, Double_t hcalEE, Double_t trackEE,
84 Double_t ecalEB, Double_t hcalEB, Double_t trackEB) {
85 fEffAreaEcalEE = ecalEE; fEffAreaHcalEE = hcalEE; fEffAreaTrackEE = trackEE;
86 fEffAreaEcalEB = ecalEB; fEffAreaHcalEB = hcalEB; fEffAreaTrackEB = trackEB;
87 }
88 void SetTriggerObjectsName(const char *n) { fTrigObjectsName = n; }
89
90
91 void SetPhotonsFromBranch(bool b) { fPhotonsFromBranch = b; }
92
93 void SetPVName(const char *n) { fPVName = n; }
94 void SetPVFromBranch(bool b) { fPVFromBranch = b; }
95 void SetIsData (Bool_t b) { fIsData = b;}
96 void Set2012HCP (Bool_t b) { f2012HCP = b;}
97
98 void SetShowerShapeType(const char *type) { fShowerShapeType = type; }
99
100 // methods to set the MC smearing/energy correction values
101 void AddEnCorrPerRun( UInt_t sRun, UInt_t eRun,
102 Double_t corr_EBlowEta_hR9central,
103 Double_t corr_EBlowEta_hR9gap,
104 Double_t corr_EBlowEta_lR9,
105 Double_t corr_EBhighEta_hR9,
106 Double_t corr_EBhighEta_lR9,
107 Double_t corr_EElowEta_hR9,
108 Double_t corr_EElowEta_lR9,
109 Double_t corr_EEhighEta_hR9,
110 Double_t corr_EEhighEta_lR9) {
111
112 fDataEnCorr_EBlowEta_hR9central.push_back(corr_EBlowEta_hR9central);
113 fDataEnCorr_EBlowEta_hR9gap.push_back(corr_EBlowEta_hR9gap);
114 fDataEnCorr_EBlowEta_lR9.push_back(corr_EBlowEta_lR9);
115 fDataEnCorr_EBhighEta_hR9.push_back(corr_EBhighEta_hR9);
116 fDataEnCorr_EBhighEta_lR9.push_back(corr_EBhighEta_lR9);
117 fDataEnCorr_EElowEta_hR9.push_back(corr_EElowEta_hR9);
118 fDataEnCorr_EElowEta_lR9.push_back(corr_EElowEta_lR9);
119 fDataEnCorr_EEhighEta_hR9.push_back(corr_EEhighEta_hR9);
120 fDataEnCorr_EEhighEta_lR9.push_back(corr_EEhighEta_lR9);
121 fRunStart.push_back (sRun);
122 fRunEnd.push_back (eRun);
123 };
124
125 void SetMCSmearFactors(Double_t _EBlowEta_hR9central,
126 Double_t _EBlowEta_hR9gap,
127 Double_t _EBlowEta_lR9,
128 Double_t _EBhighEta_hR9,
129 Double_t _EBhighEta_lR9,
130 Double_t _EElowEta_hR9,
131 Double_t _EElowEta_lR9,
132 Double_t _EEhighEta_hR9,
133 Double_t _EEhighEta_lR9) {
134 fMCSmear_EBlowEta_hR9central = _EBlowEta_hR9central;
135 fMCSmear_EBlowEta_hR9gap = _EBlowEta_hR9gap;
136 fMCSmear_EBlowEta_lR9 = _EBlowEta_lR9;
137 fMCSmear_EBhighEta_hR9 = _EBhighEta_hR9;
138 fMCSmear_EBhighEta_lR9 = _EBhighEta_lR9;
139 fMCSmear_EElowEta_hR9 = _EElowEta_hR9;
140 fMCSmear_EElowEta_lR9 = _EElowEta_lR9;
141 fMCSmear_EEhighEta_hR9 = _EEhighEta_hR9;
142 fMCSmear_EEhighEta_lR9 = _EEhighEta_lR9;
143 };
144
145
146 void AddEnCorrPerRun2012HCP( UInt_t sRun, UInt_t eRun,
147 Double_t corr_EBlowEta_hR9central,
148 Double_t corr_EBlowEta_hR9gap,
149 Double_t corr_EBlowEta_lR9central,
150 Double_t corr_EBlowEta_lR9gap,
151 Double_t corr_EBhighEta_hR9,
152 Double_t corr_EBhighEta_lR9,
153 Double_t corr_EElowEta_hR9,
154 Double_t corr_EElowEta_lR9,
155 Double_t corr_EEhighEta_hR9,
156 Double_t corr_EEhighEta_lR9) {
157 fDataEnCorr_EBlowEta_hR9central.push_back(corr_EBlowEta_hR9central);
158 fDataEnCorr_EBlowEta_hR9gap.push_back(corr_EBlowEta_hR9gap);
159 fDataEnCorr_EBlowEta_lR9central.push_back(corr_EBlowEta_lR9central);
160 fDataEnCorr_EBlowEta_lR9gap.push_back(corr_EBlowEta_lR9gap);
161 fDataEnCorr_EBhighEta_hR9.push_back(corr_EBhighEta_hR9);
162 fDataEnCorr_EBhighEta_lR9.push_back(corr_EBhighEta_lR9);
163 fDataEnCorr_EElowEta_hR9.push_back(corr_EElowEta_hR9);
164 fDataEnCorr_EElowEta_lR9.push_back(corr_EElowEta_lR9);
165 fDataEnCorr_EEhighEta_hR9.push_back(corr_EEhighEta_hR9);
166 fDataEnCorr_EEhighEta_lR9.push_back(corr_EEhighEta_lR9);
167 fRunStart.push_back (sRun);
168 fRunEnd.push_back (eRun);
169 };
170
171 void SetMCSmearFactors2012HCP(Double_t _EBlowEta_hR9central,
172 Double_t _EBlowEta_hR9gap,
173 Double_t _EBlowEta_lR9central,
174 Double_t _EBlowEta_lR9gap,
175 Double_t _EBhighEta_hR9,
176 Double_t _EBhighEta_lR9,
177 Double_t _EElowEta_hR9,
178 Double_t _EElowEta_lR9,
179 Double_t _EEhighEta_hR9,
180 Double_t _EEhighEta_lR9) {
181 fMCSmear_EBlowEta_hR9central = _EBlowEta_hR9central;
182 fMCSmear_EBlowEta_hR9gap = _EBlowEta_hR9gap;
183 fMCSmear_EBlowEta_lR9central = _EBlowEta_lR9central;
184 fMCSmear_EBlowEta_lR9gap = _EBlowEta_lR9gap;
185 fMCSmear_EBhighEta_hR9 = _EBhighEta_hR9;
186 fMCSmear_EBhighEta_lR9 = _EBhighEta_lR9;
187 fMCSmear_EElowEta_hR9 = _EElowEta_hR9;
188 fMCSmear_EElowEta_lR9 = _EElowEta_lR9;
189 fMCSmear_EEhighEta_hR9 = _EEhighEta_hR9;
190 fMCSmear_EEhighEta_lR9 = _EEhighEta_lR9;
191 };
192
193
194 void SetGoodElectronsFromBranch(Bool_t b) { fGoodElectronsFromBranch = b; }
195 void SetGoodElectronName(TString name) { fGoodElectronName = name; }
196
197 void SetBdtCutBarrel(double a) {fbdtCutBarrel = a; }
198 void SetBdtCutEndcap(double a) {fbdtCutEndcap = a; }
199
200
201 void DoDataEneCorr(bool a) { fDoDataEneCorr = a; }
202 void DoMCSmear(bool a) { fDoMCSmear = a; }
203 void SetDoShowerShapeScaling(Bool_t b) { fDoShowerShapeScaling = b; }
204
205 // replaced by ShowerShapeScaling (fab)
206 /* void SetDoMCR9Scaling(Bool_t b) { fDoMCR9Scaling = b; } */
207 /* void SetMCR9Scale(Double_t ebscale, Double_t eescale) { fMCR9ScaleEB = ebscale; fMCR9ScaleEE = eescale; } */
208 /* void SetDoMCSigIEtaIEtaScaling(Bool_t b) { fDoMCSigIEtaIEtaScaling = b; } */
209 /* void SetDoMCWidthScaling(Bool_t b) { fDoMCWidthScaling = b; } */
210
211 void SetDoMCErrScaling(Bool_t b) { fDoMCErrScaling = b; }
212 void SetMCErrScale(Double_t ebscale, Double_t eescale) { fMCErrScaleEB = ebscale; fMCErrScaleEE = eescale; }
213
214 void SetIdMVAType(const char *type) { fIdMVATypeName = type; }
215
216 void SetRhoType(RhoUtilities::RhoType type) { fRhoType = type ; }
217
218 enum EPhIdType {
219 kIdUndef = 0, //not defined
220 kTight, //"Tight"
221 kLoose, //"Loose"
222 kLooseEM, //"LooseEM"
223 kBaseLineCiC, //"2011" Hgg BaseLine CiC
224 kBaseLineCiCPF, //"2012" Hgg BaseLine CiC
225 kBaseLineCiCPFNoPresel, //"2012" Hgg BaseLine CiC plus eleveto -- for mono photon
226 kMITMVAId, // MingMing MVA ID
227 kMITPhSelection, //MIT loose preselection (for mva)
228 kMITPFPhSelection, //MIT loose preselection (for mva)
229 kMITPFPhSelection_NoTrigger, //MIT loose preselection (for mva, no Trigger)
230 kVgamma2011Selection, // Vgamma 2011 Photon ID
231 kTrivialSelection, // only pt & eta cuts
232 kCustomId //"Custom"
233 };
234
235 enum EPhIsoType {
236 kIsoUndef = 0, //not defined
237 kNoIso, //"NoIso"
238 kCombinedIso, //"CombinedIso"
239 kCustomIso, //"Custom"
240 kMITPUCorrected //PileUp Corrected Hgg Isolation
241 };
242
243 protected:
244 void Process();
245 void SlaveBegin();
246
247 Int_t FindRunRangeIdx(UInt_t run);
248 Double_t GetDataEnCorr(Int_t runRange, PhotonTools::eScaleCats cat);
249 Double_t GetMCSmearFac(PhotonTools::eScaleCats cat); // last flag in case of special smearing for error computation
250 Double_t GetDataEnCorrHCP(Int_t runRange, PhotonTools::eScaleCats cat);
251 Double_t GetMCSmearFacHCP(PhotonTools::eScaleCats cat); // last flag in case of special smearing for error computation
252
253 TString fPhotonBranchName; //name of photon collection (input)
254 TString fGoodPhotonsName; //name of exported "good photon" collection
255 TString fTrackBranchName; // name of the track collection (only needed for PU corrected isolation)
256 TString fBeamspotBranchName; //name of the Beamspot collection (only needed for PU corrected isolation)
257 TString fPileUpDenName; //name of the PU density collection
258 TString fConversionName; //name of conversion branch
259 TString fElectronName;
260 TString fGoodElectronName;
261 TString fTrigObjectsName; //name of trigger object collection
262 TString fPVName;
263 TString fMCParticleName;
264 TString fPileUpName;
265 TString fPFCandsName;
266 TString fPhotonIDType; //type of photon identification we impose
267 TString fPhotonIsoType; //type of photon isolation we impose
268 Double_t fPhotonPtMin; //min pt cut
269 Double_t fHadOverEmMax; //maximum of hadronic/em energy
270 Bool_t fApplySpikeRemoval; //whether apply spike removal
271 Bool_t fApplyPixelSeed; //=true then apply pixel seed constraint
272 Bool_t fApplyElectronVeto; //=true then apply electron veto (with no conversion recovery)
273 Bool_t fInvertElectronVeto; //=true then invert electron veto (for cic selection only atm)
274 Bool_t fApplyElectronVetoConvRecovery; //=true then apply electron veto with conversion recovery
275 Bool_t fApplyConversionId; //=true then apply conversion id cuts
276 Bool_t fApplyTriggerMatching; //match to hlt photon (default=0)
277 Double_t fPhotonR9Min; //min R9 value
278 EPhIdType fPhIdType; //!identification scheme
279 EPhIsoType fPhIsoType; //!isolation scheme
280 Bool_t fFiduciality; //=true then apply fiducual requirement
281
282 Double_t fEtaWidthEB; //max Eta Width in ECAL Barrel
283 Double_t fEtaWidthEE; //max Eta Width in ECAL End Cap
284 Double_t fAbsEtaMax; //max Abs Eta
285 Bool_t fApplyR9Min; //apply R9 min
286 Double_t fEffAreaEcalEE;
287 Double_t fEffAreaHcalEE;
288 Double_t fEffAreaTrackEE;
289 Double_t fEffAreaEcalEB;
290 Double_t fEffAreaHcalEB;
291 Double_t fEffAreaTrackEB;
292 const PhotonCol *fPhotons; //!photon branch
293 const TrackCol *fTracks; //!track branch
294 const BeamSpotCol *fBeamspots; //!beamspot branch
295 const PileupEnergyDensityCol *fPileUpDen; //!rho branch
296 const DecayParticleCol *fConversions; //!conversion branch
297 const ElectronCol *fElectrons; //!electron branch
298 const ElectronCol *fGoodElectrons; //!electron branch
299 const VertexCol* fPV; //!
300 const MCParticleCol *fMCParticles;//!
301 const PileupInfoCol *fPileUp; //!
302 const PFCandidateCol *fPFCands; //!
303
304 Double_t fbdtCutBarrel;
305 Double_t fbdtCutEndcap;
306
307 // ----------------------------------------------------------------
308 // these guys should go away.... (let MVATools handle this) (fab)
309 int fVariableType;
310 TString fEndcapWeights;
311 TString fBarrelWeights;
312 // ----------------------------------------------------------------
313 MVATools fTool;
314 TString fIdMVATypeName;
315 MVATools::IdMVAType fIdMVAType;
316 // ----------------------------------------------------------------
317
318 Bool_t fDoMCR9Scaling;
319 Double_t fMCR9ScaleEB;
320 Double_t fMCR9ScaleEE;
321
322 Bool_t fDoMCSigIEtaIEtaScaling;
323 Bool_t fDoMCWidthScaling;
324
325 Bool_t fDoMCErrScaling;
326 Double_t fMCErrScaleEB;
327 Double_t fMCErrScaleEE;
328
329 Bool_t fPhotonsFromBranch;
330 Bool_t fPVFromBranch;
331 Bool_t fGoodElectronsFromBranch;
332 Bool_t fIsData;
333
334 Bool_t f2012HCP;
335
336
337 // showershape
338 TString fShowerShapeType;
339 PhotonTools::ShowerShapeScales fSSType;
340
341 bool fDoDataEneCorr;
342 bool fDoMCSmear;
343 Bool_t fDoShowerShapeScaling;
344
345
346 // Vectroes to hols smeraring/correction factors
347 std::vector<Double_t> fDataEnCorr_EBlowEta_hR9central;
348 std::vector<Double_t> fDataEnCorr_EBlowEta_hR9gap;
349 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9;
350 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9central;
351 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9gap;
352 std::vector<Double_t> fDataEnCorr_EBhighEta_hR9;
353 std::vector<Double_t> fDataEnCorr_EBhighEta_lR9;
354 std::vector<Double_t> fDataEnCorr_EElowEta_hR9;
355 std::vector<Double_t> fDataEnCorr_EElowEta_lR9;
356 std::vector<Double_t> fDataEnCorr_EEhighEta_hR9;
357 std::vector<Double_t> fDataEnCorr_EEhighEta_lR9;
358
359 std::vector<UInt_t> fRunStart;
360 std::vector<UInt_t> fRunEnd;
361
362 Double_t fMCSmear_EBlowEta_hR9central;
363 Double_t fMCSmear_EBlowEta_hR9gap;
364 Double_t fMCSmear_EBlowEta_lR9;
365 Double_t fMCSmear_EBlowEta_lR9central;
366 Double_t fMCSmear_EBlowEta_lR9gap;
367 Double_t fMCSmear_EBhighEta_hR9;
368 Double_t fMCSmear_EBhighEta_lR9;
369 Double_t fMCSmear_EElowEta_hR9;
370 Double_t fMCSmear_EElowEta_lR9;
371 Double_t fMCSmear_EEhighEta_hR9;
372 Double_t fMCSmear_EEhighEta_lR9;
373
374 TRandom3* fRng;
375
376 RhoUtilities::RhoType fRhoType;
377
378 ClassDef(PhotonIDMod, 1) // Photon identification module
379 };
380 }
381 #endif