ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFrameTools/include/MCDataScaleFactors.h
Revision: 1.7
Committed: Thu Feb 14 17:41:55 2013 UTC (12 years, 2 months ago) by rkogler
Content type: text/plain
Branch: MAIN
Changes since 1.6: +8 -3 lines
Log Message:
muon efficiencies as function of pt, using scale factors from muon POG

File Contents

# User Rev Content
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     LeptonScaleFactors(std::vector<std::string> correctionlist, E_SystShift syst_shift=e_Default);
26     ///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    
65 bazterra 1.4 private:
66     E_SystShift m_syst_shift;
67     std::vector<std::pair<std::string, double> > m_correctionlist;
68 rkogler 1.6 bool m_apply; // should any scale factors be applied?
69     int m_current_run; // run for which the scale factors are valid
70 rkogler 1.7 std::vector< std::vector<TGraphAsymmErrors*> > m_mu_id; // two arrays: first index stands for eta bin, second for run period
71     std::vector< std::vector<TGraphAsymmErrors*> > m_mu_trig; // two arrays: first index stands for eta bin, second for run period
72     std::vector< std::vector<TGraphAsymmErrors*> > m_mu_iso; // two arrays: first index stands for eta bin, second for run period
73     std::vector<double> m_weights; // weights for different runs
74 rkogler 1.6 std::vector<double> m_ele_trig; // two-parameter function of relative isolation times additional weight
75    
76 bazterra 1.4 };
77    
78 peiffer 1.1
79 bazterra 1.4 /**
80     * @short modules to apply data-MC btagging corrections
81     *
82     *
83     */
84    
85    
86     class BtagFunction {
87     public:
88     BtagFunction(E_BtagType btagtype) {
89     m_btagtype = btagtype;
90     }
91    
92     virtual ~BtagFunction() {
93     };
94    
95     virtual float value(const float &x) const = 0;
96     virtual float value_plus(const float &x) const = 0;
97     virtual float value_minus(const float &x) const = 0;
98    
99     protected:
100     E_BtagType m_btagtype;
101 peiffer 1.1 };
102    
103    
104 bazterra 1.4 class BtagScale: public BtagFunction {
105     public:
106    
107     BtagScale(E_BtagType);
108    
109     virtual float value(const float &jet_pt) const;
110     virtual float value_plus(const float &jet_pt) const {
111     return value(jet_pt) + error(jet_pt);
112     }
113    
114     virtual float value_minus(const float &jet_pt) const {
115     const float value_ = value(jet_pt) - error(jet_pt);
116     return value_ > 0 ? value_ : 0;
117     }
118    
119     protected:
120    
121     virtual float error(const float &jet_pt) const;
122    
123     private:
124    
125     TF1 * _scale;
126     std::vector<float> _errors;
127     std::vector<float> _bins;
128     const unsigned int find_bin(const float &jet_pt) const;
129     };
130    
131    
132     class CtagScale: public BtagScale {
133     public:
134    
135     CtagScale(E_BtagType btagtype) : BtagScale(btagtype) {}
136    
137     protected:
138    
139     virtual float error(const float &jet_pt) const;
140    
141     };
142    
143    
144     class LtagScale: public BtagFunction {
145     public:
146    
147     LtagScale(E_BtagType btagtype);
148    
149     virtual float value(const float &jet_pt) const;
150     virtual float value_plus(const float &jet_pt) const;
151     virtual float value_minus(const float &jet_pt) const;
152    
153     private:
154    
155     TF1 * _scale;
156     TF1 * _scale_plus;
157     TF1 * _scale_minus;
158    
159     };
160    
161    
162     class BtagEfficiency: public BtagFunction {
163     public:
164    
165     BtagEfficiency(E_BtagType, E_LeptonSelection);
166    
167     virtual float value(const float &jet_pt) const;
168     virtual float value_plus(const float &jet_pt) const {
169     return value(jet_pt);
170     }
171    
172     virtual float value_minus(const float &jet_pt) const {
173     return value(jet_pt);
174     }
175    
176     protected:
177    
178     const unsigned int find_bin(const float &jet_pt) const;
179     std::vector<float> _values;
180     std::vector<float> _bins;
181    
182     };
183    
184    
185     class CtagEfficiency: public BtagEfficiency {
186     public:
187    
188     CtagEfficiency(E_BtagType, E_LeptonSelection);
189 peiffer 1.2
190     };
191    
192    
193 bazterra 1.4 class LtagEfficiency: public BtagEfficiency {
194     public:
195    
196     LtagEfficiency(E_BtagType, E_LeptonSelection);
197    
198     };
199 peiffer 1.2
200    
201     /**
202     * @short module to apply data-MC scale factors for b tagging
203     *
204 bazterra 1.4 *
205 peiffer 1.2 */
206 bazterra 1.4 class BTaggingScaleFactors {
207     public:
208     /**
209     * constructor
210     *
211     * second argument: systematic shift
212     * @see E_SystShift
213     */
214 bazterra 1.5 BTaggingScaleFactors(
215     E_BtagType, E_LeptonSelection, E_SystShift sys_bjets=e_Default, E_SystShift sys_ljets=e_Default
216     );
217 bazterra 1.4 ///Default destructor
218     ~BTaggingScaleFactors() {};
219    
220     ///return the weighted correction factor
221     double GetWeight();
222    
223     private:
224    
225 bazterra 1.5 E_SystShift m_sys_bjets;
226     E_SystShift m_sys_ljets;
227 bazterra 1.4 E_BtagType m_btagtype;
228     E_LeptonSelection m_lepton_selection;
229    
230     float scale(const bool &is_tagged,
231     const float &jet_pt,
232     const BtagFunction* sf,
233     const BtagFunction* eff,
234     const E_SystShift &sytematic);
235    
236     float scale_data(const bool &is_tagged,
237     const float &jet_pt,
238     const BtagFunction* sf,
239     const BtagFunction* eff,
240     const E_SystShift &sytematic);
241 peiffer 1.2
242 bazterra 1.4 BtagFunction* _scale_btag;
243     BtagFunction* _eff_btag;
244 peiffer 1.2
245 bazterra 1.4 BtagFunction* _scale_ctag;
246     BtagFunction* _eff_ctag;
247 peiffer 1.2
248 bazterra 1.4 BtagFunction* _scale_light;
249     BtagFunction* _eff_light;
250     };
251 peiffer 1.2
252 peiffer 1.1 #endif