1 |
peiffer |
1.1 |
#ifndef MCDataScaleFactors_H
|
2 |
|
|
#define MCDataScaleFactors_H
|
3 |
|
|
|
4 |
bazterra |
1.4 |
#include "TF1.h"
|
5 |
rkogler |
1.7 |
#include <TGraphAsymmErrors.h>
|
6 |
bazterra |
1.4 |
|
7 |
peiffer |
1.1 |
#include "include/Utils.h"
|
8 |
|
|
#include "include/EventCalc.h"
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* @short module to apply data-MC lepton scale factors for trigger and ID
|
12 |
|
|
*
|
13 |
bazterra |
1.4 |
*
|
14 |
peiffer |
1.1 |
*/
|
15 |
bazterra |
1.4 |
class LeptonScaleFactors {
|
16 |
|
|
public:
|
17 |
|
|
/**
|
18 |
|
|
* constructor
|
19 |
|
|
*
|
20 |
|
|
* first argument: list of corrections to be applied together with weight factors for luminosity, example: "MuonRunA 1.5 MuonRunB 2.6 MuonRunC 7.8"
|
21 |
|
|
*
|
22 |
|
|
* second argument: systematic shift
|
23 |
|
|
* @see E_SystShift
|
24 |
|
|
*/
|
25 |
rkogler |
1.8 |
LeptonScaleFactors(std::vector<std::string> correctionlist);
|
26 |
bazterra |
1.4 |
///Default destructor
|
27 |
|
|
~LeptonScaleFactors() {};
|
28 |
|
|
|
29 |
rkogler |
1.6 |
///browse configuration and fill all requested correction factors
|
30 |
|
|
void FillWeights();
|
31 |
|
|
|
32 |
|
|
///return the total weight (muon*electron)
|
33 |
|
|
///derived from the weighted correction factor for muons (ID, trigger and isolation)
|
34 |
|
|
///and all electron weights
|
35 |
bazterra |
1.4 |
double GetWeight();
|
36 |
|
|
|
37 |
rkogler |
1.6 |
///return the weighted correction factor for muon ID
|
38 |
|
|
double GetMuonIDWeight();
|
39 |
|
|
|
40 |
|
|
///return the weighted correction factor for muon trigger
|
41 |
|
|
double GetMuonTrigWeight();
|
42 |
|
|
|
43 |
|
|
///return the weighted correction factor for muon isolation
|
44 |
|
|
double GetMuonIsoWeight();
|
45 |
|
|
|
46 |
|
|
///return the weighted correction factor for muons (ID, trigger and isolation)
|
47 |
|
|
double GetMuonWeight();
|
48 |
|
|
|
49 |
|
|
///return the weighted correction factor for electron trigger
|
50 |
|
|
double GetElectronTrigWeight();
|
51 |
|
|
|
52 |
|
|
///return the weighted correction factor for electrons (right now: only trigger)
|
53 |
|
|
double GetElectronWeight();
|
54 |
|
|
|
55 |
|
|
///check if the scale factors are up-to-date, fill them only once per run
|
56 |
|
|
///implemented for run-dependent scale factors
|
57 |
|
|
bool IsUpToDate();
|
58 |
|
|
|
59 |
|
|
/// return the bin number of the muon eta bin
|
60 |
|
|
int GetMuonEtaBin(double eta);
|
61 |
|
|
|
62 |
rkogler |
1.7 |
/// return the bin number of a graph corresponding to a certain value of the x coordinate
|
63 |
|
|
int GetBin(double x, TGraphAsymmErrors* graph);
|
64 |
rkogler |
1.8 |
|
65 |
|
|
void DoUpVarMuonSF(bool f=true){m_muon_unc=true; m_syst_shift=e_Up;}
|
66 |
|
|
void DoDownVarMuonSF(bool f=true){m_muon_unc=true; m_syst_shift=e_Down;}
|
67 |
|
|
|
68 |
|
|
void DoUpVarEleSF(bool f=true){m_ele_unc=true; m_syst_shift=e_Up;}
|
69 |
|
|
void DoDownVarEleSF(bool f=true){m_ele_unc=true; m_syst_shift=e_Down;}
|
70 |
|
|
|
71 |
|
|
void DoUpVarTauSF(bool f=true){m_tau_unc=true; m_syst_shift=e_Up;}
|
72 |
|
|
void DoDownVarTauSF(bool f=true){m_tau_unc=true; m_syst_shift=e_Down;}
|
73 |
|
|
|
74 |
rkogler |
1.7 |
|
75 |
bazterra |
1.4 |
private:
|
76 |
|
|
E_SystShift m_syst_shift;
|
77 |
|
|
std::vector<std::pair<std::string, double> > m_correctionlist;
|
78 |
rkogler |
1.6 |
bool m_apply; // should any scale factors be applied?
|
79 |
rkogler |
1.8 |
bool m_muon_unc; // do shift of muon scale factors
|
80 |
|
|
bool m_ele_unc; // do shift of electron scale factors
|
81 |
|
|
bool m_tau_unc; // do shift of tau scale factors
|
82 |
rkogler |
1.6 |
int m_current_run; // run for which the scale factors are valid
|
83 |
rkogler |
1.7 |
std::vector< std::vector<TGraphAsymmErrors*> > m_mu_id; // two arrays: first index stands for eta bin, second for run period
|
84 |
|
|
std::vector< std::vector<TGraphAsymmErrors*> > m_mu_trig; // two arrays: first index stands for eta bin, second for run period
|
85 |
|
|
std::vector< std::vector<TGraphAsymmErrors*> > m_mu_iso; // two arrays: first index stands for eta bin, second for run period
|
86 |
|
|
std::vector<double> m_weights; // weights for different runs
|
87 |
rkogler |
1.6 |
std::vector<double> m_ele_trig; // two-parameter function of relative isolation times additional weight
|
88 |
|
|
|
89 |
bazterra |
1.4 |
};
|
90 |
|
|
|
91 |
peiffer |
1.1 |
|
92 |
bazterra |
1.4 |
/**
|
93 |
|
|
* @short modules to apply data-MC btagging corrections
|
94 |
|
|
*
|
95 |
|
|
*
|
96 |
|
|
*/
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
class BtagFunction {
|
100 |
|
|
public:
|
101 |
|
|
BtagFunction(E_BtagType btagtype) {
|
102 |
|
|
m_btagtype = btagtype;
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
virtual ~BtagFunction() {
|
106 |
|
|
};
|
107 |
|
|
|
108 |
|
|
virtual float value(const float &x) const = 0;
|
109 |
|
|
virtual float value_plus(const float &x) const = 0;
|
110 |
|
|
virtual float value_minus(const float &x) const = 0;
|
111 |
|
|
|
112 |
|
|
protected:
|
113 |
|
|
E_BtagType m_btagtype;
|
114 |
peiffer |
1.1 |
};
|
115 |
|
|
|
116 |
|
|
|
117 |
bazterra |
1.4 |
class BtagScale: public BtagFunction {
|
118 |
|
|
public:
|
119 |
|
|
|
120 |
|
|
BtagScale(E_BtagType);
|
121 |
|
|
|
122 |
|
|
virtual float value(const float &jet_pt) const;
|
123 |
|
|
virtual float value_plus(const float &jet_pt) const {
|
124 |
|
|
return value(jet_pt) + error(jet_pt);
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
virtual float value_minus(const float &jet_pt) const {
|
128 |
|
|
const float value_ = value(jet_pt) - error(jet_pt);
|
129 |
|
|
return value_ > 0 ? value_ : 0;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
protected:
|
133 |
|
|
|
134 |
|
|
virtual float error(const float &jet_pt) const;
|
135 |
|
|
|
136 |
|
|
private:
|
137 |
|
|
|
138 |
|
|
TF1 * _scale;
|
139 |
|
|
std::vector<float> _errors;
|
140 |
|
|
std::vector<float> _bins;
|
141 |
|
|
const unsigned int find_bin(const float &jet_pt) const;
|
142 |
|
|
};
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
class CtagScale: public BtagScale {
|
146 |
|
|
public:
|
147 |
|
|
|
148 |
|
|
CtagScale(E_BtagType btagtype) : BtagScale(btagtype) {}
|
149 |
|
|
|
150 |
|
|
protected:
|
151 |
|
|
|
152 |
|
|
virtual float error(const float &jet_pt) const;
|
153 |
|
|
|
154 |
|
|
};
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
class LtagScale: public BtagFunction {
|
158 |
|
|
public:
|
159 |
|
|
|
160 |
|
|
LtagScale(E_BtagType btagtype);
|
161 |
|
|
|
162 |
|
|
virtual float value(const float &jet_pt) const;
|
163 |
|
|
virtual float value_plus(const float &jet_pt) const;
|
164 |
|
|
virtual float value_minus(const float &jet_pt) const;
|
165 |
|
|
|
166 |
|
|
private:
|
167 |
|
|
|
168 |
|
|
TF1 * _scale;
|
169 |
|
|
TF1 * _scale_plus;
|
170 |
|
|
TF1 * _scale_minus;
|
171 |
|
|
|
172 |
|
|
};
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
class BtagEfficiency: public BtagFunction {
|
176 |
|
|
public:
|
177 |
|
|
|
178 |
|
|
BtagEfficiency(E_BtagType, E_LeptonSelection);
|
179 |
|
|
|
180 |
|
|
virtual float value(const float &jet_pt) const;
|
181 |
|
|
virtual float value_plus(const float &jet_pt) const {
|
182 |
|
|
return value(jet_pt);
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
virtual float value_minus(const float &jet_pt) const {
|
186 |
|
|
return value(jet_pt);
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
protected:
|
190 |
|
|
|
191 |
|
|
const unsigned int find_bin(const float &jet_pt) const;
|
192 |
|
|
std::vector<float> _values;
|
193 |
|
|
std::vector<float> _bins;
|
194 |
|
|
|
195 |
|
|
};
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
class CtagEfficiency: public BtagEfficiency {
|
199 |
|
|
public:
|
200 |
|
|
|
201 |
|
|
CtagEfficiency(E_BtagType, E_LeptonSelection);
|
202 |
peiffer |
1.2 |
|
203 |
|
|
};
|
204 |
|
|
|
205 |
|
|
|
206 |
bazterra |
1.4 |
class LtagEfficiency: public BtagEfficiency {
|
207 |
|
|
public:
|
208 |
|
|
|
209 |
|
|
LtagEfficiency(E_BtagType, E_LeptonSelection);
|
210 |
|
|
|
211 |
|
|
};
|
212 |
peiffer |
1.2 |
|
213 |
|
|
|
214 |
|
|
/**
|
215 |
|
|
* @short module to apply data-MC scale factors for b tagging
|
216 |
|
|
*
|
217 |
bazterra |
1.4 |
*
|
218 |
peiffer |
1.2 |
*/
|
219 |
bazterra |
1.4 |
class BTaggingScaleFactors {
|
220 |
|
|
public:
|
221 |
|
|
/**
|
222 |
|
|
* constructor
|
223 |
|
|
*
|
224 |
|
|
* second argument: systematic shift
|
225 |
|
|
* @see E_SystShift
|
226 |
|
|
*/
|
227 |
bazterra |
1.5 |
BTaggingScaleFactors(
|
228 |
|
|
E_BtagType, E_LeptonSelection, E_SystShift sys_bjets=e_Default, E_SystShift sys_ljets=e_Default
|
229 |
|
|
);
|
230 |
bazterra |
1.4 |
///Default destructor
|
231 |
|
|
~BTaggingScaleFactors() {};
|
232 |
|
|
|
233 |
|
|
///return the weighted correction factor
|
234 |
|
|
double GetWeight();
|
235 |
|
|
|
236 |
|
|
private:
|
237 |
|
|
|
238 |
bazterra |
1.5 |
E_SystShift m_sys_bjets;
|
239 |
|
|
E_SystShift m_sys_ljets;
|
240 |
bazterra |
1.4 |
E_BtagType m_btagtype;
|
241 |
|
|
E_LeptonSelection m_lepton_selection;
|
242 |
|
|
|
243 |
|
|
float scale(const bool &is_tagged,
|
244 |
|
|
const float &jet_pt,
|
245 |
|
|
const BtagFunction* sf,
|
246 |
|
|
const BtagFunction* eff,
|
247 |
|
|
const E_SystShift &sytematic);
|
248 |
|
|
|
249 |
|
|
float scale_data(const bool &is_tagged,
|
250 |
|
|
const float &jet_pt,
|
251 |
|
|
const BtagFunction* sf,
|
252 |
|
|
const BtagFunction* eff,
|
253 |
|
|
const E_SystShift &sytematic);
|
254 |
peiffer |
1.2 |
|
255 |
bazterra |
1.4 |
BtagFunction* _scale_btag;
|
256 |
|
|
BtagFunction* _eff_btag;
|
257 |
peiffer |
1.2 |
|
258 |
bazterra |
1.4 |
BtagFunction* _scale_ctag;
|
259 |
|
|
BtagFunction* _eff_ctag;
|
260 |
peiffer |
1.2 |
|
261 |
bazterra |
1.4 |
BtagFunction* _scale_light;
|
262 |
|
|
BtagFunction* _eff_light;
|
263 |
|
|
};
|
264 |
peiffer |
1.2 |
|
265 |
peiffer |
1.1 |
#endif
|