ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/interface/PhotonIDMod.h
Revision: 1.34
Committed: Mon Dec 9 17:55:50 2013 UTC (11 years, 5 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.33: +7 -69 lines
Log Message:
Implement energy scales from dat files including Et dependence, update 8TeV scale and smearing numbers

File Contents

# User Rev Content
1 sixie 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.34 // $Id: PhotonIDMod.h,v 1.33 2013/06/26 21:44:21 mingyang Exp $
3 sixie 1.1 //
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 loizides 1.10 #include "MitAna/DataTree/interface/PhotonFwd.h"
17 fabstoec 1.15 #include "MitAna/DataTree/interface/TrackCol.h"
18     #include "MitAna/DataTree/interface/BeamSpotCol.h"
19     #include "MitAna/DataTree/interface/PileupEnergyDensityCol.h"
20 bendavid 1.16 #include "MitAna/DataTree/interface/DecayParticleCol.h"
21     #include "MitAna/DataTree/interface/ElectronCol.h"
22 fabstoec 1.20 #include "MitAna/DataTree/interface/VertexCol.h"
23 bendavid 1.22 #include "MitAna/DataTree/interface/DecayParticleCol.h"
24     #include "MitAna/DataTree/interface/PileupInfoCol.h"
25     #include "MitAna/DataTree/interface/MCParticleCol.h"
26 bendavid 1.26 #include "MitAna/DataTree/interface/PFCandidateCol.h"
27 sixie 1.1
28 fabstoec 1.23 #include "MitPhysics/Utils/interface/MVATools.h"
29 fabstoec 1.27 #include "MitPhysics/Utils/interface/PhotonTools.h"
30 fabstoec 1.30 #include "MitPhysics/Utils/interface/RhoUtilities.h"
31 fabstoec 1.27
32     class TRandom3;
33 fabstoec 1.23
34 sixie 1.1 namespace mithep
35     {
36     class PhotonIDMod : public BaseMod
37     {
38     public:
39     PhotonIDMod(const char *name="PhotonIDMod",
40 loizides 1.3 const char *title="Photon identification module");
41 sixie 1.1
42 sixie 1.13 Bool_t GetApplySpikeRemoval() const { return fApplySpikeRemoval; }
43 loizides 1.6 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 ceballos 1.11 Bool_t GetApplyFiduciality() const { return fFiduciality; }
53     Double_t GetEtaWidthEB() const { return fEtaWidthEB; }
54     Double_t GetEtaWidthEE() const { return fEtaWidthEE; }
55 ceballos 1.12 Double_t GetAbsEtaMax() const { return fAbsEtaMax; }
56 sixie 1.13 void SetApplySpikeRemoval(Bool_t b) { fApplySpikeRemoval = b; }
57 loizides 1.6 void SetApplyPixelSeed(Bool_t b) { fApplyPixelSeed = b; }
58 bendavid 1.16 void SetApplyElectronVeto(Bool_t b) { fApplyElectronVeto = b; }
59 bendavid 1.22 void SetInvertElectronVeto(Bool_t b) { fInvertElectronVeto = b; }
60 bendavid 1.16 void SetApplyElectronVetoConvRecovery(Bool_t b) { fApplyElectronVetoConvRecovery = b; }
61     void SetApplyConversionId(Bool_t b) { fApplyConversionId = b; }
62     void SetApplyTriggerMatching(Bool_t b) { fApplyTriggerMatching = b; }
63 loizides 1.6 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 fabstoec 1.15 void SetTrackName(const char *n) { fTrackBranchName = n; }
69     void SetBeamspotName(const char *n) { fBeamspotBranchName = n; }
70 loizides 1.6 void SetIsoType(const char *type) { fPhotonIsoType = type; }
71     void SetOutputName(const char *n) { SetGoodPhotonsName(n); }
72     void SetPtMin(Double_t pt) { fPhotonPtMin = pt; }
73 ceballos 1.11 void SetR9Min(Double_t x) { fPhotonR9Min = x; }
74     void SetEtaWidthEB(Double_t x) { fEtaWidthEB = x; }
75     void SetEtaWidthEE(Double_t x) { fEtaWidthEE = x; }
76 ceballos 1.12 void SetAbsEtaMax(Double_t x) { fAbsEtaMax = x; }
77 bendavid 1.14 void SetApplyR9Min(Bool_t b) { fApplyR9Min = b; }
78 bendavid 1.18 void SetApplyFiduciality(Bool_t b) { fFiduciality = b; }
79 fabstoec 1.15 void SetEffAreas(Double_t ecal, Double_t hcal, Double_t track) {
80 fabstoec 1.17 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 bendavid 1.16 void SetTriggerObjectsName(const char *n) { fTrigObjectsName = n; }
89 fabstoec 1.15
90 fabstoec 1.25
91     void SetPhotonsFromBranch(bool b) { fPhotonsFromBranch = b; }
92    
93 fabstoec 1.20 void SetPVName(const char *n) { fPVName = n; }
94     void SetPVFromBranch(bool b) { fPVFromBranch = b; }
95 mingyang 1.32 void SetIsData (Bool_t b) { fIsData = b;}
96 fabstoec 1.27
97     void SetShowerShapeType(const char *type) { fShowerShapeType = type; }
98    
99     // methods to set the MC smearing/energy correction values
100     void AddEnCorrPerRun( UInt_t sRun, UInt_t eRun,
101 bendavid 1.34 Double_t corr_EBlowEta_hR9,
102 fabstoec 1.27 Double_t corr_EBlowEta_lR9,
103     Double_t corr_EBhighEta_hR9,
104     Double_t corr_EBhighEta_lR9,
105     Double_t corr_EElowEta_hR9,
106     Double_t corr_EElowEta_lR9,
107     Double_t corr_EEhighEta_hR9,
108     Double_t corr_EEhighEta_lR9) {
109    
110 bendavid 1.34 fDataEnCorr_EBlowEta_hR9.push_back(corr_EBlowEta_hR9);
111 fabstoec 1.27 fDataEnCorr_EBlowEta_lR9.push_back(corr_EBlowEta_lR9);
112     fDataEnCorr_EBhighEta_hR9.push_back(corr_EBhighEta_hR9);
113     fDataEnCorr_EBhighEta_lR9.push_back(corr_EBhighEta_lR9);
114     fDataEnCorr_EElowEta_hR9.push_back(corr_EElowEta_hR9);
115     fDataEnCorr_EElowEta_lR9.push_back(corr_EElowEta_lR9);
116     fDataEnCorr_EEhighEta_hR9.push_back(corr_EEhighEta_hR9);
117     fDataEnCorr_EEhighEta_lR9.push_back(corr_EEhighEta_lR9);
118     fRunStart.push_back (sRun);
119     fRunEnd.push_back (eRun);
120     };
121    
122 bendavid 1.34 void SetMCSmearFactors(Double_t _EBlowEta_hR9,
123 fabstoec 1.27 Double_t _EBlowEta_lR9,
124     Double_t _EBhighEta_hR9,
125     Double_t _EBhighEta_lR9,
126     Double_t _EElowEta_hR9,
127     Double_t _EElowEta_lR9,
128     Double_t _EEhighEta_hR9,
129     Double_t _EEhighEta_lR9) {
130 bendavid 1.34 fMCSmear_EBlowEta_hR9 = _EBlowEta_hR9;
131 fabstoec 1.27 fMCSmear_EBlowEta_lR9 = _EBlowEta_lR9;
132     fMCSmear_EBhighEta_hR9 = _EBhighEta_hR9;
133     fMCSmear_EBhighEta_lR9 = _EBhighEta_lR9;
134     fMCSmear_EElowEta_hR9 = _EElowEta_hR9;
135     fMCSmear_EElowEta_lR9 = _EElowEta_lR9;
136     fMCSmear_EEhighEta_hR9 = _EEhighEta_hR9;
137     fMCSmear_EEhighEta_lR9 = _EEhighEta_lR9;
138     };
139    
140 mingyang 1.32
141    
142    
143 bendavid 1.22 void SetGoodElectronsFromBranch(Bool_t b) { fGoodElectronsFromBranch = b; }
144     void SetGoodElectronName(TString name) { fGoodElectronName = name; }
145 fabstoec 1.20
146 fabstoec 1.23 void SetBdtCutBarrel(double a) {fbdtCutBarrel = a; }
147     void SetBdtCutEndcap(double a) {fbdtCutEndcap = a; }
148    
149 fabstoec 1.27
150     void DoDataEneCorr(bool a) { fDoDataEneCorr = a; }
151     void DoMCSmear(bool a) { fDoMCSmear = a; }
152     void SetDoShowerShapeScaling(Bool_t b) { fDoShowerShapeScaling = b; }
153    
154     // replaced by ShowerShapeScaling (fab)
155     /* void SetDoMCR9Scaling(Bool_t b) { fDoMCR9Scaling = b; } */
156     /* void SetMCR9Scale(Double_t ebscale, Double_t eescale) { fMCR9ScaleEB = ebscale; fMCR9ScaleEE = eescale; } */
157     /* void SetDoMCSigIEtaIEtaScaling(Bool_t b) { fDoMCSigIEtaIEtaScaling = b; } */
158     /* void SetDoMCWidthScaling(Bool_t b) { fDoMCWidthScaling = b; } */
159    
160 fabstoec 1.25 void SetDoMCErrScaling(Bool_t b) { fDoMCErrScaling = b; }
161     void SetMCErrScale(Double_t ebscale, Double_t eescale) { fMCErrScaleEB = ebscale; fMCErrScaleEE = eescale; }
162 fabstoec 1.23
163 fabstoec 1.29 void SetIdMVAType(const char *type) { fIdMVATypeName = type; }
164    
165 fabstoec 1.30 void SetRhoType(RhoUtilities::RhoType type) { fRhoType = type ; }
166 mingyang 1.33
167     enum EPhIdType {
168 sixie 1.1 kIdUndef = 0, //not defined
169     kTight, //"Tight"
170     kLoose, //"Loose"
171 ceballos 1.2 kLooseEM, //"LooseEM"
172 fabstoec 1.28 kBaseLineCiC, //"2011" Hgg BaseLine CiC
173     kBaseLineCiCPF, //"2012" Hgg BaseLine CiC
174 mingyang 1.31 kBaseLineCiCPFNoPresel, //"2012" Hgg BaseLine CiC plus eleveto -- for mono photon
175 fabstoec 1.28 kMITMVAId, // MingMing MVA ID
176     kMITPhSelection, //MIT loose preselection (for mva)
177 bendavid 1.26 kMITPFPhSelection, //MIT loose preselection (for mva)
178 mingyang 1.33 kMITPFPhSelectionNoEcal,
179 fabstoec 1.29 kMITPFPhSelection_NoTrigger, //MIT loose preselection (for mva, no Trigger)
180 fabstoec 1.28 kVgamma2011Selection, // Vgamma 2011 Photon ID
181 fabstoec 1.29 kTrivialSelection, // only pt & eta cuts
182 fabstoec 1.28 kCustomId //"Custom"
183 sixie 1.1 };
184 fabstoec 1.19
185 sixie 1.1 enum EPhIsoType {
186     kIsoUndef = 0, //not defined
187     kNoIso, //"NoIso"
188 ceballos 1.2 kCombinedIso, //"CombinedIso"
189 fabstoec 1.15 kCustomIso, //"Custom"
190     kMITPUCorrected //PileUp Corrected Hgg Isolation
191 sixie 1.1 };
192    
193     protected:
194 loizides 1.5 void Process();
195     void SlaveBegin();
196    
197 fabstoec 1.27 Int_t FindRunRangeIdx(UInt_t run);
198     Double_t GetDataEnCorr(Int_t runRange, PhotonTools::eScaleCats cat);
199 mingyang 1.32 Double_t GetMCSmearFac(PhotonTools::eScaleCats cat); // last flag in case of special smearing for error computation
200    
201 loizides 1.6 TString fPhotonBranchName; //name of photon collection (input)
202     TString fGoodPhotonsName; //name of exported "good photon" collection
203 fabstoec 1.15 TString fTrackBranchName; // name of the track collection (only needed for PU corrected isolation)
204     TString fBeamspotBranchName; //name of the Beamspot collection (only needed for PU corrected isolation)
205 bendavid 1.16 TString fPileUpDenName; //name of the PU density collection
206     TString fConversionName; //name of conversion branch
207     TString fElectronName;
208 bendavid 1.22 TString fGoodElectronName;
209 fabstoec 1.20 TString fTrigObjectsName; //name of trigger object collection
210     TString fPVName;
211 bendavid 1.21 TString fMCParticleName;
212     TString fPileUpName;
213 bendavid 1.26 TString fPFCandsName;
214 loizides 1.6 TString fPhotonIDType; //type of photon identification we impose
215     TString fPhotonIsoType; //type of photon isolation we impose
216 loizides 1.4 Double_t fPhotonPtMin; //min pt cut
217 loizides 1.6 Double_t fHadOverEmMax; //maximum of hadronic/em energy
218 sixie 1.13 Bool_t fApplySpikeRemoval; //whether apply spike removal
219 loizides 1.6 Bool_t fApplyPixelSeed; //=true then apply pixel seed constraint
220 bendavid 1.16 Bool_t fApplyElectronVeto; //=true then apply electron veto (with no conversion recovery)
221 bendavid 1.22 Bool_t fInvertElectronVeto; //=true then invert electron veto (for cic selection only atm)
222 bendavid 1.16 Bool_t fApplyElectronVetoConvRecovery; //=true then apply electron veto with conversion recovery
223     Bool_t fApplyConversionId; //=true then apply conversion id cuts
224     Bool_t fApplyTriggerMatching; //match to hlt photon (default=0)
225 ceballos 1.8 Double_t fPhotonR9Min; //min R9 value
226 loizides 1.4 EPhIdType fPhIdType; //!identification scheme
227     EPhIsoType fPhIsoType; //!isolation scheme
228 ceballos 1.11 Bool_t fFiduciality; //=true then apply fiducual requirement
229 fabstoec 1.27
230 ceballos 1.11 Double_t fEtaWidthEB; //max Eta Width in ECAL Barrel
231     Double_t fEtaWidthEE; //max Eta Width in ECAL End Cap
232 ceballos 1.12 Double_t fAbsEtaMax; //max Abs Eta
233 bendavid 1.14 Bool_t fApplyR9Min; //apply R9 min
234 fabstoec 1.17 Double_t fEffAreaEcalEE;
235     Double_t fEffAreaHcalEE;
236     Double_t fEffAreaTrackEE;
237     Double_t fEffAreaEcalEB;
238     Double_t fEffAreaHcalEB;
239     Double_t fEffAreaTrackEB;
240 loizides 1.10 const PhotonCol *fPhotons; //!photon branch
241 fabstoec 1.15 const TrackCol *fTracks; //!track branch
242     const BeamSpotCol *fBeamspots; //!beamspot branch
243 bendavid 1.16 const PileupEnergyDensityCol *fPileUpDen; //!rho branch
244     const DecayParticleCol *fConversions; //!conversion branch
245     const ElectronCol *fElectrons; //!electron branch
246 bendavid 1.22 const ElectronCol *fGoodElectrons; //!electron branch
247 bendavid 1.21 const VertexCol* fPV; //!
248     const MCParticleCol *fMCParticles;//!
249     const PileupInfoCol *fPileUp; //!
250 bendavid 1.26 const PFCandidateCol *fPFCands; //!
251 fabstoec 1.23
252     Double_t fbdtCutBarrel;
253     Double_t fbdtCutEndcap;
254 fabstoec 1.29
255     // ----------------------------------------------------------------
256     // these guys should go away.... (let MVATools handle this) (fab)
257 fabstoec 1.23 int fVariableType;
258     TString fEndcapWeights;
259     TString fBarrelWeights;
260 fabstoec 1.29 // ----------------------------------------------------------------
261 fabstoec 1.23 MVATools fTool;
262 fabstoec 1.29 TString fIdMVATypeName;
263     MVATools::IdMVAType fIdMVAType;
264     // ----------------------------------------------------------------
265 fabstoec 1.23
266 fabstoec 1.25 Bool_t fDoMCR9Scaling;
267     Double_t fMCR9ScaleEB;
268     Double_t fMCR9ScaleEE;
269    
270     Bool_t fDoMCSigIEtaIEtaScaling;
271     Bool_t fDoMCWidthScaling;
272    
273     Bool_t fDoMCErrScaling;
274     Double_t fMCErrScaleEB;
275     Double_t fMCErrScaleEE;
276    
277     Bool_t fPhotonsFromBranch;
278     Bool_t fPVFromBranch;
279 bendavid 1.22 Bool_t fGoodElectronsFromBranch;
280 bendavid 1.21 Bool_t fIsData;
281    
282 fabstoec 1.27 // showershape
283     TString fShowerShapeType;
284     PhotonTools::ShowerShapeScales fSSType;
285    
286     bool fDoDataEneCorr;
287     bool fDoMCSmear;
288     Bool_t fDoShowerShapeScaling;
289    
290    
291     // Vectroes to hols smeraring/correction factors
292 bendavid 1.34 std::vector<Double_t> fDataEnCorr_EBlowEta_hR9;
293 fabstoec 1.27 std::vector<Double_t> fDataEnCorr_EBlowEta_lR9;
294     std::vector<Double_t> fDataEnCorr_EBhighEta_hR9;
295     std::vector<Double_t> fDataEnCorr_EBhighEta_lR9;
296     std::vector<Double_t> fDataEnCorr_EElowEta_hR9;
297     std::vector<Double_t> fDataEnCorr_EElowEta_lR9;
298     std::vector<Double_t> fDataEnCorr_EEhighEta_hR9;
299     std::vector<Double_t> fDataEnCorr_EEhighEta_lR9;
300 mingyang 1.32
301 fabstoec 1.27 std::vector<UInt_t> fRunStart;
302     std::vector<UInt_t> fRunEnd;
303    
304 bendavid 1.34 Double_t fMCSmear_EBlowEta_hR9;
305 fabstoec 1.27 Double_t fMCSmear_EBlowEta_lR9;
306     Double_t fMCSmear_EBhighEta_hR9;
307     Double_t fMCSmear_EBhighEta_lR9;
308     Double_t fMCSmear_EElowEta_hR9;
309     Double_t fMCSmear_EElowEta_lR9;
310     Double_t fMCSmear_EEhighEta_hR9;
311     Double_t fMCSmear_EEhighEta_lR9;
312 mingyang 1.32
313 fabstoec 1.27 TRandom3* fRng;
314    
315 fabstoec 1.30 RhoUtilities::RhoType fRhoType;
316 fabstoec 1.15
317 loizides 1.6 ClassDef(PhotonIDMod, 1) // Photon identification module
318 sixie 1.1 };
319     }
320     #endif