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

File Contents

# User Rev Content
1 fabstoec 1.1 //--------------------------------------------------------------------------------------------------
2 mingyang 1.10 // M.Yang 2011/10/12
3 bendavid 1.37 // $Id: PhotonPairSelector.h,v 1.36 2013/11/27 23:41:21 bendavid Exp $
4 fabstoec 1.1 //
5     // PhotonPairSelector
6     //
7     // Authors: F. Stoeckli
8     //--------------------------------------------------------------------------------------------------
9    
10     #ifndef MITPHYSICS_MODS_PHOTONPAIRSELECTOR_H
11     #define MITPHYSICS_MODS_PHOTONPAIRSELECTOR_H
12    
13     #include "MitAna/TreeMod/interface/BaseMod.h"
14     #include "MitAna/DataTree/interface/PhotonFwd.h"
15     #include "MitAna/DataTree/interface/TrackCol.h"
16     #include "MitAna/DataTree/interface/VertexCol.h"
17     #include "MitAna/DataTree/interface/BeamSpotCol.h"
18     #include "MitAna/DataTree/interface/PFCandidateCol.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/DecayParticleCol.h"
23     #include "MitAna/DataTree/interface/PileupInfoCol.h"
24     #include "MitAna/DataTree/interface/MCParticleCol.h"
25 bendavid 1.20 #include "MitAna/DataTree/interface/JetCol.h"
26     #include "MitAna/DataTree/interface/PFMetCol.h"
27 fabstoec 1.1
28     #include "MitPhysics/Utils/interface/PhotonTools.h"
29 bendavid 1.8 #include "MitPhysics/Utils/interface/EGEnergyCorrector.h"
30 fabstoec 1.1
31 mingyang 1.10 #include "MitPhysics/Utils/interface/MVATools.h"
32 bendavid 1.13 #include "MitPhysics/Utils/interface/VertexTools.h"
33 mingyang 1.10
34 bendavid 1.20 #include "MitPhysics/Utils/interface/MVAMet.h"
35 fabstoec 1.30 #include "MitPhysics/Utils/interface/RhoUtilities.h"
36    
37 fabstoec 1.1 class TNtuple;
38     class TRandom3;
39 bendavid 1.8 class TH1D;
40 fabstoec 1.1
41     namespace mithep
42 bendavid 1.7 {
43 fabstoec 1.1 class PhotonPairSelector : public BaseMod
44     {
45     public:
46 paus 1.18 PhotonPairSelector(const char *name = "PhotonPairSelector",
47     const char *title = "Selecting PhotonPairs");
48 fabstoec 1.1
49     ~PhotonPairSelector();
50    
51     enum PhotonSelection {
52     kNoPhSelection = 0,
53     kCiCPhSelection,
54 mingyang 1.34 kCiCPFPhSelection,
55     kCiCPFPhSelectionNoPFChargedIso,
56 mingyang 1.10 kMVAPhSelection, //MVA
57 bendavid 1.21 kMITPhSelection,
58 mingyang 1.33 kMITPFPhSelection,
59 mingyang 1.34 kMITPFPhSelectionNoEcal,
60     kMITPFPhSelectionNoEcalNoPFChargedIso
61 fabstoec 1.1 };
62     enum VertexSelection {
63     kStdVtxSelection = 0,
64     kCiCVtxSelection,
65 bendavid 1.13 kMITVtxSelection,
66 bendavid 1.20 kCiCMVAVtxSelection,
67     kMetSigVtxSelection
68 fabstoec 1.1 };
69 fabstoec 1.29
70 bendavid 1.37 class EnergyCorrection {
71    
72     public:
73    
74     EnergyCorrection() : fCat(PhotonTools::kEBlowEtaGold), fMinRun(0), fMaxRun(0), fMinEt(-99.), fMaxEt(-99.), fCorr(1.) {}
75     EnergyCorrection(PhotonTools::eScaleCats cat, UInt_t minrun, UInt_t maxrun, Double_t minet, Double_t maxet, Double_t corr) :
76     fCat(cat), fMinRun(minrun), fMaxRun(maxrun), fMinEt(minet), fMaxEt(maxet), fCorr(corr) {}
77    
78     PhotonTools::eScaleCats fCat;
79     UInt_t fMinRun;
80     UInt_t fMaxRun;
81     Double_t fMinEt;
82     Double_t fMaxEt;
83     Double_t fCorr;
84    
85     };
86    
87    
88 fabstoec 1.29 // outsourced to MVATools (IdMVAType) (fab)
89     /* enum IdMVA { */
90     /* k2011IdMVA = 0, */
91     /* k2012IdMVA_globe */
92     /* }; */
93 fabstoec 1.27
94    
95     // outsourced to PhotonTools (fab)
96     /* enum ShowerShape { */
97     /* k2011ShowerShape = 0, */
98     /* k2012ShowerShape */
99     /* }; */
100 fabstoec 1.1
101     // setting all the input Names
102     void SetInputPhotonsName(const char *n){ fPhotonBranchName= n; }
103     void SetPhotonsFromBranch(bool b) { fPhotonsFromBranch = b; }
104     void SetTrackName(const char *n) { fTrackBranchName = n; }
105     void SetElectronName(const char *n) { fElectronName = n; }
106     void SetConversionName(const char *n) { fConversionName = n; }
107     void SetPUDensityName(const char *n) { fPileUpDenName = n; }
108     void SetPVName(const char *n) { fPVName = n; }
109     void SetPVFromBranch(bool b) { fPVFromBranch = b; }
110     void SetMCParticle(const char *n) { fMCParticleName = n; }
111     void SetPUInfoName(const char *n) { fPileUpName = n; }
112     void SetBeamspotName(const char *n) { fBeamspotName = n; }
113     void SetPFCandName(const char *n) { fPFCandName = n; }
114    
115     // set the type of selection
116     void SetPhotonSelType(const char *type){ fPhotonSelType = type; }
117     void SetVertexSelType(const char *type){ fVertexSelType = type; }
118 mingyang 1.22 void SetIdMVAType(const char *type) { fIdMVAType = type; }
119 mingyang 1.26 void SetShowerShapeType(const char *type) { fShowerShapeType = type; }
120 fabstoec 1.1
121     // get/set the Names for the output Photon Collection
122     const char *GetOutputName() const { return fGoodPhotonsName; }
123     void SetOutputName(const char *n) { fGoodPhotonsName=n; }
124    
125 fabstoec 1.19 const char *GetOutputVtxName() const { return fChosenVtxName; }
126     void SetOutputVtxName(const char* n) { fChosenVtxName = n; }
127    
128    
129 fabstoec 1.1 // set basic Cut variables (FOR PRE-SELECTION)
130     void SetPtMin(Double_t pt) { fPhotonPtMin = pt; }
131     void SetAbsEtaMax(Double_t eta) { fPhotonEtaMax = eta; }
132    
133     void SetLeadingPtMin(Double_t pt) { fLeadingPtMin = pt; }
134 fabstoec 1.6 void SetTrailingPtMin(Double_t pt) { fTrailingPtMin = pt; }
135 fabstoec 1.1
136     // is Data Or Not?
137 mingyang 1.31 void SetIsData (Bool_t b) { fIsData = b;}
138    
139 bendavid 1.37
140     void AddEnCorrFromFile(TString filename);
141 fabstoec 1.1
142     // methods to set the MC smearing/energy correction values
143 bendavid 1.37 void AddEnCorrPerRun( PhotonTools::eScaleCats cat, UInt_t sRun, UInt_t eRun, Double_t corr) {
144    
145     fDataEnCorr.push_back(EnergyCorrection(cat,sRun,eRun,-99.,-99.,corr));
146 fabstoec 1.1 };
147    
148 bendavid 1.37 void AddEnCorrPerRunEtDep( PhotonTools::eScaleCats cat, UInt_t sRun, UInt_t eRun, Double_t minet, Double_t maxet, Double_t corr) {
149    
150     fDataEnCorr.push_back(EnergyCorrection(cat,sRun,eRun,minet,maxet,corr));
151     };
152    
153     void SetMCSmearFactors(Double_t _EBlowEta_hR9,
154 bendavid 1.13 Double_t _EBlowEta_lR9,
155     Double_t _EBhighEta_hR9,
156     Double_t _EBhighEta_lR9,
157     Double_t _EElowEta_hR9,
158     Double_t _EElowEta_lR9,
159     Double_t _EEhighEta_hR9,
160     Double_t _EEhighEta_lR9) {
161 bendavid 1.37 fMCSmear_EBlowEta_hR9 = _EBlowEta_hR9;
162 bendavid 1.13 fMCSmear_EBlowEta_lR9 = _EBlowEta_lR9;
163     fMCSmear_EBhighEta_hR9 = _EBhighEta_hR9;
164     fMCSmear_EBhighEta_lR9 = _EBhighEta_lR9;
165     fMCSmear_EElowEta_hR9 = _EElowEta_hR9;
166     fMCSmear_EElowEta_lR9 = _EElowEta_lR9;
167     fMCSmear_EEhighEta_hR9 = _EEhighEta_hR9;
168     fMCSmear_EEhighEta_lR9 = _EEhighEta_lR9;
169 fabstoec 1.1 };
170 fabstoec 1.2
171 fabstoec 1.32 // special routine in ordetr to use different smearing to compute mass-error for di-photon MVA input
172 bendavid 1.37 void SetMCSmearFactorsMVA(Double_t _EBlowEta_hR9,
173 fabstoec 1.32 Double_t _EBlowEta_lR9,
174     Double_t _EBhighEta_hR9,
175     Double_t _EBhighEta_lR9,
176     Double_t _EElowEta_hR9,
177     Double_t _EElowEta_lR9,
178     Double_t _EEhighEta_hR9,
179     Double_t _EEhighEta_lR9) {
180    
181 bendavid 1.37 fMCSmearMVA_EBlowEta_hR9 = _EBlowEta_hR9;
182 fabstoec 1.32 fMCSmearMVA_EBlowEta_lR9 = _EBlowEta_lR9;
183     fMCSmearMVA_EBhighEta_hR9 = _EBhighEta_hR9;
184     fMCSmearMVA_EBhighEta_lR9 = _EBhighEta_lR9;
185     fMCSmearMVA_EElowEta_hR9 = _EElowEta_hR9;
186     fMCSmearMVA_EElowEta_lR9 = _EElowEta_lR9;
187     fMCSmearMVA_EEhighEta_hR9 = _EEhighEta_hR9;
188     fMCSmearMVA_EEhighEta_lR9 = _EEhighEta_lR9;
189     };
190    
191 bendavid 1.36 void SetMCStochasticPivot(Double_t pivot_lowEta_hR9,
192     Double_t pivot_lowEta_lR9,
193     Double_t pivot_highEta_hR9,
194     Double_t pivot_highEta_lR9) {
195    
196     fMCStochasticPivot_EBlowEta_hR9 = pivot_lowEta_hR9;
197     fMCStochasticPivot_EBlowEta_lR9 = pivot_lowEta_lR9;
198     fMCStochasticPivot_EBhighEta_hR9 = pivot_highEta_hR9;
199     fMCStochasticPivot_EBhighEta_lR9 = pivot_highEta_lR9;
200    
201     }
202    
203     void SetMCStochasticRho(Double_t rho_lowEta_hR9,
204     Double_t rho_lowEta_lR9,
205     Double_t rho_highEta_hR9,
206     Double_t rho_highEta_lR9) {
207    
208     fMCStochasticRho_EBlowEta_hR9 = rho_lowEta_hR9;
209     fMCStochasticRho_EBlowEta_lR9 = rho_lowEta_lR9;
210     fMCStochasticRho_EBhighEta_hR9 = rho_highEta_hR9;
211     fMCStochasticRho_EBhighEta_lR9 = rho_highEta_lR9;
212    
213     }
214    
215     void SetMCStochasticPhi(Double_t phi_lowEta_hR9,
216     Double_t phi_lowEta_lR9,
217     Double_t phi_highEta_hR9,
218     Double_t phi_highEta_lR9) {
219    
220     fMCStochasticPhi_EBlowEta_hR9 = phi_lowEta_hR9;
221     fMCStochasticPhi_EBlowEta_lR9 = phi_lowEta_lR9;
222     fMCStochasticPhi_EBhighEta_hR9 = phi_highEta_hR9;
223     fMCStochasticPhi_EBhighEta_lR9 = phi_highEta_lR9;
224    
225     }
226    
227 fabstoec 1.32
228 bendavid 1.15 void SetApplyEleVeto(bool a) { fApplyEleVeto = a; }
229 bendavid 1.7 void SetInvertElectronVeto(Bool_t b) { fInvertElectronVeto = b; }
230 fabstoec 1.2 void DoDataEneCorr(bool a) { fDoDataEneCorr = a; }
231     void DoMCSmear(bool a) { fDoMCSmear = a; }
232 veverka 1.35 void DoMCEneSmear(bool a) { fDoMCEneSmear = a; }
233     void DoEneErrSmear(bool a) { fDoEneErrSmear = a; }
234 fabstoec 1.32 void UseSpecialSmearForDPMVA(bool a) { fUseSpecialSmearForDPMVA = a; }
235 bendavid 1.36 void SetStochasticSmear(bool a) { fStochasticSmear = a; }
236    
237 bendavid 1.7 void SetGoodElectronsFromBranch(Bool_t b) { fGoodElectronsFromBranch = b; }
238     void SetGoodElectronName(TString name) { fGoodElectronName = name; }
239 bendavid 1.24 void SetUseSingleLegConversions(Bool_t b) { fUseSingleLegConversions = b; }
240 bendavid 1.8 void SetDoRegression(Bool_t b) { fDoRegression = b; }
241     void SetEtaCorrections(const TH1D *h) { fEtaCorrections = h; }
242 mingyang 1.12 void SetBdtCutBarrel(Float_t x) { fbdtCutBarrel = x; }
243     void SetBdtCutEndcap(Float_t x) { fbdtCutEndcap = x; }
244 mingyang 1.26
245     void SetDoShowerShapeScaling(Bool_t b) { fDoShowerShapeScaling = b; }
246 bendavid 1.13
247 bendavid 1.20 void SetJetsName(const char *n) { fJetsName = n; }
248 bendavid 1.28
249 fabstoec 1.30 void SetRhoType(RhoUtilities::RhoType type) { fRhoType = type ; }
250    
251 mingyang 1.31 void SetApplyLeptonTag(bool a) { fApplyLeptonTag = a; }
252    
253     void SetLeptonTagElectronsName(TString name) { fLeptonTagElectronsName = name; }
254     void SetLeptonTagMuonsName (TString name) { fLeptonTagMuonsName = name; }
255    
256 fabstoec 1.1 protected:
257     void Process();
258     void SlaveBegin();
259    
260     // private auxiliary methods...
261 bendavid 1.7 void FindHiggsPtAndZ(Float_t& pt, Float_t& z, Float_t& mass);
262 bendavid 1.37 Double_t GetDataEnCorr(UInt_t run, const Photon *p);
263 fabstoec 1.32 Double_t GetMCSmearFac(PhotonTools::eScaleCats cat, bool useSpecialSmear = false); // last flag in case of special smearing for error computation
264 bendavid 1.36
265     Double_t GetMCSmearFacStochastic(const Photon *p) const;
266    
267 fabstoec 1.1 Float_t GetEventCat(PhotonTools::CiCBaseLineCats cat1, PhotonTools::CiCBaseLineCats cat2);
268    
269     // Names for the input Collections
270     TString fPhotonBranchName;
271     TString fElectronName;
272 bendavid 1.7 TString fGoodElectronName;
273 fabstoec 1.1 TString fConversionName;
274 bendavid 1.24 TString fPFConversionName;
275 fabstoec 1.1 TString fTrackBranchName;
276     TString fPileUpDenName;
277     TString fPVName;
278     TString fBeamspotName;
279     TString fPFCandName;
280     TString fMCParticleName;
281     TString fPileUpName;
282 bendavid 1.20 TString fJetsName;
283     TString fPFMetName;
284 fabstoec 1.1
285     TString fGoodPhotonsName; //name of exported "good photon" collection
286 fabstoec 1.19 TString fChosenVtxName; //name of exported "chosen Vtx" collection
287 mingyang 1.31
288     TString fLeptonTagElectronsName;
289     TString fLeptonTagMuonsName;
290 fabstoec 1.1
291     // Selection Types
292     TString fPhotonSelType;
293     TString fVertexSelType;
294     PhotonSelection fPhSelType;
295     VertexSelection fVtxSelType;
296    
297 mingyang 1.22 // Id Type
298     TString fIdMVAType;
299 fabstoec 1.29 MVATools::IdMVAType fIdType;
300     //IdMVA fIdType;
301 mingyang 1.22
302 mingyang 1.26 // showershape
303 fabstoec 1.27 TString fShowerShapeType;
304     PhotonTools::ShowerShapeScales fSSType;
305 mingyang 1.26
306 fabstoec 1.1 // Basic Pre-Selection kinematics
307     Double_t fPhotonPtMin; // min pt cut fro PRE-SELECTION!
308     Double_t fPhotonEtaMax; // max eta cut for PRE-SELECTION!
309    
310     Double_t fLeadingPtMin;
311     Double_t fTrailingPtMin;
312    
313     // is it Data or MC?
314     Bool_t fIsData;
315    
316     // in case there's some PV pre-selection
317     Bool_t fPhotonsFromBranch;
318     Bool_t fPVFromBranch;
319 bendavid 1.7 Bool_t fGoodElectronsFromBranch;
320 bendavid 1.24 Bool_t fUseSingleLegConversions;
321 fabstoec 1.1
322 bendavid 1.36 Bool_t fStochasticSmear;
323 mingyang 1.31
324 fabstoec 1.1 const PhotonCol *fPhotons;
325     const ElectronCol *fElectrons;
326 bendavid 1.7 const ElectronCol *fGoodElectrons;
327 fabstoec 1.1 const DecayParticleCol *fConversions;
328 bendavid 1.24 const DecayParticleCol *fPFConversions;
329 fabstoec 1.1 const TrackCol *fTracks;
330     const PileupEnergyDensityCol *fPileUpDen;
331     const VertexCol *fPV;
332     const BeamSpotCol *fBeamspot;
333     const PFCandidateCol *fPFCands;
334     const MCParticleCol *fMCParticles;
335     const PileupInfoCol *fPileUp;
336 bendavid 1.20 const JetCol *fJets;
337     const PFMetCol *fPFMet;
338 mingyang 1.31 const ElectronCol *fLeptonTagElectrons;
339     const MuonCol *fLeptonTagMuons;
340 bendavid 1.37
341     //vector of energy scale corrections
342     //format of tuple is:
343     //category, minrun, maxrun, minet, maxet, correction
344     std::vector<EnergyCorrection> fDataEnCorr;
345 bendavid 1.20
346 bendavid 1.37 Double_t fMCSmear_EBlowEta_hR9;
347 paus 1.18 Double_t fMCSmear_EBlowEta_lR9;
348     Double_t fMCSmear_EBhighEta_hR9;
349     Double_t fMCSmear_EBhighEta_lR9;
350     Double_t fMCSmear_EElowEta_hR9;
351     Double_t fMCSmear_EElowEta_lR9;
352     Double_t fMCSmear_EEhighEta_hR9;
353     Double_t fMCSmear_EEhighEta_lR9;
354 fabstoec 1.1
355 fabstoec 1.32 // special Smear factors for usage for diphoton MVA input, incase differrent from std smearing
356 bendavid 1.37 Double_t fMCSmearMVA_EBlowEta_hR9;
357 fabstoec 1.32 Double_t fMCSmearMVA_EBlowEta_lR9;
358     Double_t fMCSmearMVA_EBhighEta_hR9;
359     Double_t fMCSmearMVA_EBhighEta_lR9;
360     Double_t fMCSmearMVA_EElowEta_hR9;
361     Double_t fMCSmearMVA_EElowEta_lR9;
362     Double_t fMCSmearMVA_EEhighEta_hR9;
363     Double_t fMCSmearMVA_EEhighEta_lR9;
364 bendavid 1.36
365     Double_t fMCStochasticPivot_EBlowEta_hR9;
366     Double_t fMCStochasticPivot_EBlowEta_lR9;
367     Double_t fMCStochasticPivot_EBhighEta_hR9;
368     Double_t fMCStochasticPivot_EBhighEta_lR9;
369    
370     Double_t fMCStochasticRho_EBlowEta_hR9;
371     Double_t fMCStochasticRho_EBlowEta_lR9;
372     Double_t fMCStochasticRho_EBhighEta_hR9;
373     Double_t fMCStochasticRho_EBhighEta_lR9;
374    
375     Double_t fMCStochasticPhi_EBlowEta_hR9;
376     Double_t fMCStochasticPhi_EBlowEta_lR9;
377     Double_t fMCStochasticPhi_EBhighEta_hR9;
378     Double_t fMCStochasticPhi_EBhighEta_lR9;
379 fabstoec 1.32
380    
381 fabstoec 1.1 // pointer to RNG ionstance for smearing
382 paus 1.18 TRandom3* fRng;
383     EGEnergyCorrector fEgCor;
384     Bool_t fDoRegression;
385     TString fPhFixString;
386     TString fPhFixFile;
387     TString fRegWeights;
388    
389     const TH1D *fEtaCorrections;
390 bendavid 1.8
391 fabstoec 1.1 // --------------------------------
392     // some streagin flags, not adjustable yet (FIX-ME)
393 paus 1.18 bool fDoDataEneCorr;
394     bool fDoMCSmear;
395 veverka 1.35 bool fDoMCEneSmear;
396     bool fDoEneErrSmear;
397 fabstoec 1.32 bool fUseSpecialSmearForDPMVA; // if set to true, the special smearing numbers set in fMCSmearMVA_* are used to compute the mass-errors (input to diphoton MVA)
398 paus 1.18 bool fDoVtxSelection;
399     bool fApplyEleVeto;
400     Bool_t fInvertElectronVeto; //=true (invert ele veto, for cic sel only atm)
401 mingyang 1.31
402     // --------------------------------
403     bool fApplyLeptonTag;
404    
405 mingyang 1.10 //MVA
406 mingyang 1.22 int fVariableType_2011;
407     TString fEndcapWeights_2011;
408     TString fBarrelWeights_2011;
409     int fVariableType_2012_globe;
410     TString fEndcapWeights_2012_globe;
411     TString fBarrelWeights_2012_globe;
412 paus 1.18 MVATools fTool;
413     Float_t fbdtCutBarrel;
414     Float_t fbdtCutEndcap;
415    
416     VertexTools fVtxTools;
417    
418 mingyang 1.26 Bool_t fDoShowerShapeScaling;
419 fabstoec 1.27
420 paus 1.18 Bool_t fDoMCErrScaling;
421     Double_t fMCErrScaleEB;
422     Double_t fMCErrScaleEE;
423     UInt_t fRegressionVersion;
424    
425     Bool_t fRelativePtCuts;
426 bendavid 1.13
427 bendavid 1.20 MVAMet fMVAMet;
428    
429 fabstoec 1.30 RhoUtilities::RhoType fRhoType;
430    
431 fabstoec 1.1 ClassDef(PhotonPairSelector, 1) // Photon identification module
432     };
433     }
434     #endif