1 |
//--------------------------------------------------------------------------------------------------
|
2 |
// M.Yang 2011/10/12
|
3 |
// $Id: PhotonPairSelector.h,v 1.37 2013/12/09 17:55:50 bendavid Exp $
|
4 |
//
|
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 |
#include "MitAna/DataTree/interface/JetCol.h"
|
26 |
#include "MitAna/DataTree/interface/PFMetCol.h"
|
27 |
|
28 |
#include "MitPhysics/Utils/interface/PhotonTools.h"
|
29 |
#include "MitPhysics/Utils/interface/EGEnergyCorrector.h"
|
30 |
|
31 |
#include "MitPhysics/Utils/interface/MVATools.h"
|
32 |
#include "MitPhysics/Utils/interface/VertexTools.h"
|
33 |
|
34 |
#include "MitPhysics/Utils/interface/MVAMet.h"
|
35 |
#include "MitPhysics/Utils/interface/RhoUtilities.h"
|
36 |
|
37 |
class TNtuple;
|
38 |
class TRandom3;
|
39 |
class TH1D;
|
40 |
|
41 |
namespace mithep
|
42 |
{
|
43 |
class PhotonPairSelector : public BaseMod
|
44 |
{
|
45 |
public:
|
46 |
PhotonPairSelector(const char *name = "PhotonPairSelector",
|
47 |
const char *title = "Selecting PhotonPairs");
|
48 |
|
49 |
~PhotonPairSelector();
|
50 |
|
51 |
enum PhotonSelection {
|
52 |
kNoPhSelection = 0,
|
53 |
kCiCPhSelection,
|
54 |
kCiCPFPhSelection,
|
55 |
kCiCPFPhSelectionNoPFChargedIso,
|
56 |
kMVAPhSelection, //MVA
|
57 |
kMITPhSelection,
|
58 |
kMITPFPhSelection,
|
59 |
kMITPFPhSelectionNoEcal,
|
60 |
kMITPFPhSelectionNoEcalNoPFChargedIso
|
61 |
};
|
62 |
enum VertexSelection {
|
63 |
kStdVtxSelection = 0,
|
64 |
kCiCVtxSelection,
|
65 |
kMITVtxSelection,
|
66 |
kCiCMVAVtxSelection,
|
67 |
kMetSigVtxSelection
|
68 |
};
|
69 |
|
70 |
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 |
// outsourced to MVATools (IdMVAType) (fab)
|
89 |
/* enum IdMVA { */
|
90 |
/* k2011IdMVA = 0, */
|
91 |
/* k2012IdMVA_globe */
|
92 |
/* }; */
|
93 |
|
94 |
|
95 |
// outsourced to PhotonTools (fab)
|
96 |
/* enum ShowerShape { */
|
97 |
/* k2011ShowerShape = 0, */
|
98 |
/* k2012ShowerShape */
|
99 |
/* }; */
|
100 |
|
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 |
void SetIdMVAType(const char *type) { fIdMVAType = type; }
|
119 |
void SetShowerShapeType(const char *type) { fShowerShapeType = type; }
|
120 |
|
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 |
const char *GetOutputVtxName() const { return fChosenVtxName; }
|
126 |
void SetOutputVtxName(const char* n) { fChosenVtxName = n; }
|
127 |
|
128 |
|
129 |
// 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 |
void SetTrailingPtMin(Double_t pt) { fTrailingPtMin = pt; }
|
135 |
|
136 |
// is Data Or Not?
|
137 |
void SetIsData (Bool_t b) { fIsData = b;}
|
138 |
|
139 |
|
140 |
void AddEnCorrFromFile(TString filename);
|
141 |
|
142 |
// methods to set the MC smearing/energy correction values
|
143 |
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 |
};
|
147 |
|
148 |
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 |
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 |
fMCSmear_EBlowEta_hR9 = _EBlowEta_hR9;
|
162 |
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 |
};
|
170 |
|
171 |
// special routine in ordetr to use different smearing to compute mass-error for di-photon MVA input
|
172 |
void SetMCSmearFactorsMVA(Double_t _EBlowEta_hR9,
|
173 |
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 |
fMCSmearMVA_EBlowEta_hR9 = _EBlowEta_hR9;
|
182 |
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 |
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 |
|
228 |
void SetApplyEleVeto(bool a) { fApplyEleVeto = a; }
|
229 |
void SetInvertElectronVeto(Bool_t b) { fInvertElectronVeto = b; }
|
230 |
void DoDataEneCorr(bool a) { fDoDataEneCorr = a; }
|
231 |
void DoMCSmear(bool a) { fDoMCSmear = a; }
|
232 |
void DoMCEneSmear(bool a) { fDoMCEneSmear = a; }
|
233 |
void DoEneErrSmear(bool a) { fDoEneErrSmear = a; }
|
234 |
void UseSpecialSmearForDPMVA(bool a) { fUseSpecialSmearForDPMVA = a; }
|
235 |
void SetStochasticSmear(bool a) { fStochasticSmear = a; }
|
236 |
|
237 |
void SetGoodElectronsFromBranch(Bool_t b) { fGoodElectronsFromBranch = b; }
|
238 |
void SetGoodElectronName(TString name) { fGoodElectronName = name; }
|
239 |
void SetUseSingleLegConversions(Bool_t b) { fUseSingleLegConversions = b; }
|
240 |
void SetDoRegression(Bool_t b) { fDoRegression = b; }
|
241 |
void SetEtaCorrections(const TH1D *h) { fEtaCorrections = h; }
|
242 |
void SetBdtCutBarrel(Float_t x) { fbdtCutBarrel = x; }
|
243 |
void SetBdtCutEndcap(Float_t x) { fbdtCutEndcap = x; }
|
244 |
|
245 |
void SetDoShowerShapeScaling(Bool_t b) { fDoShowerShapeScaling = b; }
|
246 |
|
247 |
void SetJetsName(const char *n) { fJetsName = n; }
|
248 |
|
249 |
void SetRhoType(RhoUtilities::RhoType type) { fRhoType = type ; }
|
250 |
|
251 |
void SetApplyLeptonTag(bool a) { fApplyLeptonTag = a; }
|
252 |
|
253 |
void SetLeptonTagElectronsName(TString name) { fLeptonTagElectronsName = name; }
|
254 |
void SetLeptonTagMuonsName (TString name) { fLeptonTagMuonsName = name; }
|
255 |
|
256 |
void SetR9Rescale(bool dor9rescale, double p0b, double p1b, double p0e, double p1e) {fdor9rescale = dor9rescale; fp0b = p0b; fp1b = p1b; fp0e = p0e; fp1e = p1e;}
|
257 |
|
258 |
protected:
|
259 |
void Process();
|
260 |
void SlaveBegin();
|
261 |
|
262 |
// private auxiliary methods...
|
263 |
void FindHiggsPtAndZ(Float_t& pt, Float_t& z, Float_t& mass);
|
264 |
Double_t GetDataEnCorr(UInt_t run, const Photon *p);
|
265 |
Double_t GetMCSmearFac(PhotonTools::eScaleCats cat, bool useSpecialSmear = false); // last flag in case of special smearing for error computation
|
266 |
|
267 |
Double_t GetMCSmearFacStochastic(const Photon *p) const;
|
268 |
|
269 |
Float_t GetEventCat(PhotonTools::CiCBaseLineCats cat1, PhotonTools::CiCBaseLineCats cat2);
|
270 |
|
271 |
// Names for the input Collections
|
272 |
TString fPhotonBranchName;
|
273 |
TString fElectronName;
|
274 |
TString fGoodElectronName;
|
275 |
TString fConversionName;
|
276 |
TString fPFConversionName;
|
277 |
TString fTrackBranchName;
|
278 |
TString fPileUpDenName;
|
279 |
TString fPVName;
|
280 |
TString fBeamspotName;
|
281 |
TString fPFCandName;
|
282 |
TString fMCParticleName;
|
283 |
TString fPileUpName;
|
284 |
TString fJetsName;
|
285 |
TString fPFMetName;
|
286 |
|
287 |
TString fGoodPhotonsName; //name of exported "good photon" collection
|
288 |
TString fChosenVtxName; //name of exported "chosen Vtx" collection
|
289 |
|
290 |
TString fLeptonTagElectronsName;
|
291 |
TString fLeptonTagMuonsName;
|
292 |
|
293 |
// Selection Types
|
294 |
TString fPhotonSelType;
|
295 |
TString fVertexSelType;
|
296 |
PhotonSelection fPhSelType;
|
297 |
VertexSelection fVtxSelType;
|
298 |
|
299 |
// Id Type
|
300 |
TString fIdMVAType;
|
301 |
MVATools::IdMVAType fIdType;
|
302 |
//IdMVA fIdType;
|
303 |
|
304 |
// showershape
|
305 |
TString fShowerShapeType;
|
306 |
PhotonTools::ShowerShapeScales fSSType;
|
307 |
|
308 |
// Basic Pre-Selection kinematics
|
309 |
Double_t fPhotonPtMin; // min pt cut fro PRE-SELECTION!
|
310 |
Double_t fPhotonEtaMax; // max eta cut for PRE-SELECTION!
|
311 |
|
312 |
Double_t fLeadingPtMin;
|
313 |
Double_t fTrailingPtMin;
|
314 |
|
315 |
// is it Data or MC?
|
316 |
Bool_t fIsData;
|
317 |
|
318 |
// in case there's some PV pre-selection
|
319 |
Bool_t fPhotonsFromBranch;
|
320 |
Bool_t fPVFromBranch;
|
321 |
Bool_t fGoodElectronsFromBranch;
|
322 |
Bool_t fUseSingleLegConversions;
|
323 |
|
324 |
Bool_t fStochasticSmear;
|
325 |
|
326 |
const PhotonCol *fPhotons;
|
327 |
const ElectronCol *fElectrons;
|
328 |
const ElectronCol *fGoodElectrons;
|
329 |
const DecayParticleCol *fConversions;
|
330 |
const DecayParticleCol *fPFConversions;
|
331 |
const TrackCol *fTracks;
|
332 |
const PileupEnergyDensityCol *fPileUpDen;
|
333 |
const VertexCol *fPV;
|
334 |
const BeamSpotCol *fBeamspot;
|
335 |
const PFCandidateCol *fPFCands;
|
336 |
const MCParticleCol *fMCParticles;
|
337 |
const PileupInfoCol *fPileUp;
|
338 |
const JetCol *fJets;
|
339 |
const PFMetCol *fPFMet;
|
340 |
const ElectronCol *fLeptonTagElectrons;
|
341 |
const MuonCol *fLeptonTagMuons;
|
342 |
|
343 |
//vector of energy scale corrections
|
344 |
//format of tuple is:
|
345 |
//category, minrun, maxrun, minet, maxet, correction
|
346 |
std::vector<EnergyCorrection> fDataEnCorr;
|
347 |
|
348 |
Double_t fMCSmear_EBlowEta_hR9;
|
349 |
Double_t fMCSmear_EBlowEta_lR9;
|
350 |
Double_t fMCSmear_EBhighEta_hR9;
|
351 |
Double_t fMCSmear_EBhighEta_lR9;
|
352 |
Double_t fMCSmear_EElowEta_hR9;
|
353 |
Double_t fMCSmear_EElowEta_lR9;
|
354 |
Double_t fMCSmear_EEhighEta_hR9;
|
355 |
Double_t fMCSmear_EEhighEta_lR9;
|
356 |
|
357 |
// special Smear factors for usage for diphoton MVA input, incase differrent from std smearing
|
358 |
Double_t fMCSmearMVA_EBlowEta_hR9;
|
359 |
Double_t fMCSmearMVA_EBlowEta_lR9;
|
360 |
Double_t fMCSmearMVA_EBhighEta_hR9;
|
361 |
Double_t fMCSmearMVA_EBhighEta_lR9;
|
362 |
Double_t fMCSmearMVA_EElowEta_hR9;
|
363 |
Double_t fMCSmearMVA_EElowEta_lR9;
|
364 |
Double_t fMCSmearMVA_EEhighEta_hR9;
|
365 |
Double_t fMCSmearMVA_EEhighEta_lR9;
|
366 |
|
367 |
Double_t fMCStochasticPivot_EBlowEta_hR9;
|
368 |
Double_t fMCStochasticPivot_EBlowEta_lR9;
|
369 |
Double_t fMCStochasticPivot_EBhighEta_hR9;
|
370 |
Double_t fMCStochasticPivot_EBhighEta_lR9;
|
371 |
|
372 |
Double_t fMCStochasticRho_EBlowEta_hR9;
|
373 |
Double_t fMCStochasticRho_EBlowEta_lR9;
|
374 |
Double_t fMCStochasticRho_EBhighEta_hR9;
|
375 |
Double_t fMCStochasticRho_EBhighEta_lR9;
|
376 |
|
377 |
Double_t fMCStochasticPhi_EBlowEta_hR9;
|
378 |
Double_t fMCStochasticPhi_EBlowEta_lR9;
|
379 |
Double_t fMCStochasticPhi_EBhighEta_hR9;
|
380 |
Double_t fMCStochasticPhi_EBhighEta_lR9;
|
381 |
|
382 |
|
383 |
// pointer to RNG ionstance for smearing
|
384 |
TRandom3* fRng;
|
385 |
EGEnergyCorrector fEgCor;
|
386 |
Bool_t fDoRegression;
|
387 |
TString fPhFixString;
|
388 |
TString fPhFixFile;
|
389 |
TString fRegWeights;
|
390 |
|
391 |
const TH1D *fEtaCorrections;
|
392 |
|
393 |
// --------------------------------
|
394 |
// some streagin flags, not adjustable yet (FIX-ME)
|
395 |
bool fDoDataEneCorr;
|
396 |
bool fDoMCSmear;
|
397 |
bool fDoMCEneSmear;
|
398 |
bool fDoEneErrSmear;
|
399 |
bool fUseSpecialSmearForDPMVA; // if set to true, the special smearing numbers set in fMCSmearMVA_* are used to compute the mass-errors (input to diphoton MVA)
|
400 |
bool fDoVtxSelection;
|
401 |
bool fApplyEleVeto;
|
402 |
Bool_t fInvertElectronVeto; //=true (invert ele veto, for cic sel only atm)
|
403 |
|
404 |
// --------------------------------
|
405 |
bool fApplyLeptonTag;
|
406 |
|
407 |
//MVA
|
408 |
int fVariableType_2011;
|
409 |
TString fEndcapWeights_2011;
|
410 |
TString fBarrelWeights_2011;
|
411 |
int fVariableType_2012_globe;
|
412 |
TString fEndcapWeights_2012_globe;
|
413 |
TString fBarrelWeights_2012_globe;
|
414 |
MVATools fTool;
|
415 |
Float_t fbdtCutBarrel;
|
416 |
Float_t fbdtCutEndcap;
|
417 |
|
418 |
VertexTools fVtxTools;
|
419 |
|
420 |
Bool_t fDoShowerShapeScaling;
|
421 |
|
422 |
Bool_t fDoMCErrScaling;
|
423 |
Double_t fMCErrScaleEB;
|
424 |
Double_t fMCErrScaleEE;
|
425 |
UInt_t fRegressionVersion;
|
426 |
|
427 |
Bool_t fRelativePtCuts;
|
428 |
|
429 |
MVAMet fMVAMet;
|
430 |
|
431 |
//R9 rescale
|
432 |
bool fdor9rescale;
|
433 |
double fp0b;
|
434 |
double fp1b;
|
435 |
double fp0e;
|
436 |
double fp1e;
|
437 |
|
438 |
RhoUtilities::RhoType fRhoType;
|
439 |
|
440 |
ClassDef(PhotonPairSelector, 1) // Photon identification module
|
441 |
};
|
442 |
}
|
443 |
#endif
|