ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/interface/PhotonIDMod.h
Revision: 1.33
Committed: Wed Jun 26 21:44:21 2013 UTC (11 years, 10 months ago) by mingyang
Content type: text/plain
Branch: MAIN
Changes since 1.32: +4 -3 lines
Log Message:
PhotonIDMod.h

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PhotonIDMod.h,v 1.32 2013/06/21 19:04:27 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 kMITPFPhSelectionNoEcal,
230 kMITPFPhSelection_NoTrigger, //MIT loose preselection (for mva, no Trigger)
231 kVgamma2011Selection, // Vgamma 2011 Photon ID
232 kTrivialSelection, // only pt & eta cuts
233 kCustomId //"Custom"
234 };
235
236 enum EPhIsoType {
237 kIsoUndef = 0, //not defined
238 kNoIso, //"NoIso"
239 kCombinedIso, //"CombinedIso"
240 kCustomIso, //"Custom"
241 kMITPUCorrected //PileUp Corrected Hgg Isolation
242 };
243
244 protected:
245 void Process();
246 void SlaveBegin();
247
248 Int_t FindRunRangeIdx(UInt_t run);
249 Double_t GetDataEnCorr(Int_t runRange, PhotonTools::eScaleCats cat);
250 Double_t GetMCSmearFac(PhotonTools::eScaleCats cat); // last flag in case of special smearing for error computation
251 Double_t GetDataEnCorrHCP(Int_t runRange, PhotonTools::eScaleCats cat);
252 Double_t GetMCSmearFacHCP(PhotonTools::eScaleCats cat); // last flag in case of special smearing for error computation
253
254 TString fPhotonBranchName; //name of photon collection (input)
255 TString fGoodPhotonsName; //name of exported "good photon" collection
256 TString fTrackBranchName; // name of the track collection (only needed for PU corrected isolation)
257 TString fBeamspotBranchName; //name of the Beamspot collection (only needed for PU corrected isolation)
258 TString fPileUpDenName; //name of the PU density collection
259 TString fConversionName; //name of conversion branch
260 TString fElectronName;
261 TString fGoodElectronName;
262 TString fTrigObjectsName; //name of trigger object collection
263 TString fPVName;
264 TString fMCParticleName;
265 TString fPileUpName;
266 TString fPFCandsName;
267 TString fPhotonIDType; //type of photon identification we impose
268 TString fPhotonIsoType; //type of photon isolation we impose
269 Double_t fPhotonPtMin; //min pt cut
270 Double_t fHadOverEmMax; //maximum of hadronic/em energy
271 Bool_t fApplySpikeRemoval; //whether apply spike removal
272 Bool_t fApplyPixelSeed; //=true then apply pixel seed constraint
273 Bool_t fApplyElectronVeto; //=true then apply electron veto (with no conversion recovery)
274 Bool_t fInvertElectronVeto; //=true then invert electron veto (for cic selection only atm)
275 Bool_t fApplyElectronVetoConvRecovery; //=true then apply electron veto with conversion recovery
276 Bool_t fApplyConversionId; //=true then apply conversion id cuts
277 Bool_t fApplyTriggerMatching; //match to hlt photon (default=0)
278 Double_t fPhotonR9Min; //min R9 value
279 EPhIdType fPhIdType; //!identification scheme
280 EPhIsoType fPhIsoType; //!isolation scheme
281 Bool_t fFiduciality; //=true then apply fiducual requirement
282
283 Double_t fEtaWidthEB; //max Eta Width in ECAL Barrel
284 Double_t fEtaWidthEE; //max Eta Width in ECAL End Cap
285 Double_t fAbsEtaMax; //max Abs Eta
286 Bool_t fApplyR9Min; //apply R9 min
287 Double_t fEffAreaEcalEE;
288 Double_t fEffAreaHcalEE;
289 Double_t fEffAreaTrackEE;
290 Double_t fEffAreaEcalEB;
291 Double_t fEffAreaHcalEB;
292 Double_t fEffAreaTrackEB;
293 const PhotonCol *fPhotons; //!photon branch
294 const TrackCol *fTracks; //!track branch
295 const BeamSpotCol *fBeamspots; //!beamspot branch
296 const PileupEnergyDensityCol *fPileUpDen; //!rho branch
297 const DecayParticleCol *fConversions; //!conversion branch
298 const ElectronCol *fElectrons; //!electron branch
299 const ElectronCol *fGoodElectrons; //!electron branch
300 const VertexCol* fPV; //!
301 const MCParticleCol *fMCParticles;//!
302 const PileupInfoCol *fPileUp; //!
303 const PFCandidateCol *fPFCands; //!
304
305 Double_t fbdtCutBarrel;
306 Double_t fbdtCutEndcap;
307
308 // ----------------------------------------------------------------
309 // these guys should go away.... (let MVATools handle this) (fab)
310 int fVariableType;
311 TString fEndcapWeights;
312 TString fBarrelWeights;
313 // ----------------------------------------------------------------
314 MVATools fTool;
315 TString fIdMVATypeName;
316 MVATools::IdMVAType fIdMVAType;
317 // ----------------------------------------------------------------
318
319 Bool_t fDoMCR9Scaling;
320 Double_t fMCR9ScaleEB;
321 Double_t fMCR9ScaleEE;
322
323 Bool_t fDoMCSigIEtaIEtaScaling;
324 Bool_t fDoMCWidthScaling;
325
326 Bool_t fDoMCErrScaling;
327 Double_t fMCErrScaleEB;
328 Double_t fMCErrScaleEE;
329
330 Bool_t fPhotonsFromBranch;
331 Bool_t fPVFromBranch;
332 Bool_t fGoodElectronsFromBranch;
333 Bool_t fIsData;
334
335 Bool_t f2012HCP;
336
337
338 // showershape
339 TString fShowerShapeType;
340 PhotonTools::ShowerShapeScales fSSType;
341
342 bool fDoDataEneCorr;
343 bool fDoMCSmear;
344 Bool_t fDoShowerShapeScaling;
345
346
347 // Vectroes to hols smeraring/correction factors
348 std::vector<Double_t> fDataEnCorr_EBlowEta_hR9central;
349 std::vector<Double_t> fDataEnCorr_EBlowEta_hR9gap;
350 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9;
351 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9central;
352 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9gap;
353 std::vector<Double_t> fDataEnCorr_EBhighEta_hR9;
354 std::vector<Double_t> fDataEnCorr_EBhighEta_lR9;
355 std::vector<Double_t> fDataEnCorr_EElowEta_hR9;
356 std::vector<Double_t> fDataEnCorr_EElowEta_lR9;
357 std::vector<Double_t> fDataEnCorr_EEhighEta_hR9;
358 std::vector<Double_t> fDataEnCorr_EEhighEta_lR9;
359
360 std::vector<UInt_t> fRunStart;
361 std::vector<UInt_t> fRunEnd;
362
363 Double_t fMCSmear_EBlowEta_hR9central;
364 Double_t fMCSmear_EBlowEta_hR9gap;
365 Double_t fMCSmear_EBlowEta_lR9;
366 Double_t fMCSmear_EBlowEta_lR9central;
367 Double_t fMCSmear_EBlowEta_lR9gap;
368 Double_t fMCSmear_EBhighEta_hR9;
369 Double_t fMCSmear_EBhighEta_lR9;
370 Double_t fMCSmear_EElowEta_hR9;
371 Double_t fMCSmear_EElowEta_lR9;
372 Double_t fMCSmear_EEhighEta_hR9;
373 Double_t fMCSmear_EEhighEta_lR9;
374
375 TRandom3* fRng;
376
377 RhoUtilities::RhoType fRhoType;
378
379 ClassDef(PhotonIDMod, 1) // Photon identification module
380 };
381 }
382 #endif