ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/src/SFWeight.cc
Revision: 1.4
Committed: Tue May 14 19:42:26 2013 UTC (12 years ago) by ahart
Content type: text/plain
Branch: MAIN
CVS Tags: V02-03-01, V02-03-00, V02-02-00, V02-01-01, V02-01-00
Changes since 1.3: +1 -1 lines
Log Message:
Commented out the cout statement for the mvaNonTrig scale factors.

File Contents

# Content
1 #include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
2
3 MuonSFWeight::MuonSFWeight (const string &sfFile, const string &dataOverMC)
4 {
5
6 TFile *fin = TFile::Open (sfFile.c_str ());
7 TGraphAsymmErrors *data = (TGraphAsymmErrors *) fin->Get (dataOverMC.c_str ());
8
9 double bins[data->GetN () + 1];
10 for (int i = 0; i < data->GetN (); i++)
11 {
12 double x, y, exl, exh;
13
14 data->GetPoint (i, x, y);
15 exl = data->GetErrorXlow (i);
16 exh = data->GetErrorXhigh (i);
17 if (i == 0)
18 bins[i] = x - exl;
19 bins[i + 1] = x + exh;
20 }
21
22 muonSFWeight_ = new TH1D ("muonSFWeight", "", data->GetN (), bins);
23 muonSFWeight_->SetDirectory (0);
24 for (int i = 0; i < data->GetN (); i++)
25 {
26 double dataX, dataY;
27
28 data->GetPoint (i, dataX, dataY);
29 muonSFWeight_->SetBinContent (i + 1, dataY);
30 }
31
32 fin->Close ();
33 delete data;
34 }
35
36 MuonSFWeight::MuonSFWeight (const string &sfFile, const string &dataEff, const string &mcEff)
37 {
38 TFile *fin = TFile::Open (sfFile.c_str ());
39 TGraphAsymmErrors *mc = (TGraphAsymmErrors *) fin->Get (mcEff.c_str ());
40 TGraphAsymmErrors *data = (TGraphAsymmErrors *) fin->Get (dataEff.c_str ());
41
42 double bins[mc->GetN () + 1];
43 for (int i = 0; i < mc->GetN (); i++)
44 {
45 double x, y, exl, exh;
46
47 mc->GetPoint (i, x, y);
48 exl = mc->GetErrorXlow (i);
49 exh = mc->GetErrorXhigh (i);
50 if (i == 0)
51 bins[i] = x - exl;
52 bins[i + 1] = x + exh;
53 }
54
55 muonSFWeight_ = new TH1D ("muonSFWeight", "", mc->GetN (), bins);
56 muonSFWeight_->SetDirectory (0);
57 for (int i = 0; i < mc->GetN (); i++)
58 {
59 double mcX, mcY, dataX, dataY;
60
61 mc->GetPoint (i, mcX, mcY);
62 data->GetPoint (i, dataX, dataY);
63 muonSFWeight_->SetBinContent (i + 1, dataY / mcY);
64 }
65
66 fin->Close ();
67 delete mc;
68 delete data;
69 }
70
71 MuonSFWeight::~MuonSFWeight ()
72 {
73 delete muonSFWeight_;
74 }
75
76 ElectronSFWeight::ElectronSFWeight (const string &cmsswRelease, const string &id) :
77 cmsswRelease_ (cmsswRelease),
78 id_ (id)
79 {
80 }
81
82 double
83 ElectronSFWeight::at (const double &eta, const double &pt)
84 {
85 //cout << eta << " " << pt << endl;
86 //cout << "doing it\n";
87 if (cmsswRelease_ == "53X")
88 {
89 if (id_ == "tight")
90 {
91 if (fabs (eta) < 0.8)
92 {
93 if (pt < 15.0 && pt >= 10.0)
94 return 0.818;
95 if (pt < 20.0 && pt >= 15.0)
96 return 0.928;
97 if (pt < 30.0 && pt >= 20.0)
98 return 0.973;
99 if (pt < 40.0 && pt >= 30.0)
100 return 0.979;
101 if (pt < 50.0 && pt >= 40.0)
102 return 0.984;
103 if (pt < 200.0 && pt >= 50.0)
104 return 0.983;
105 }
106 if (fabs (eta) < 1.442 && fabs (eta) >= 0.8)
107 {
108 if (pt < 15.0 && pt >= 10.0)
109 return 0.840;
110 if (pt < 20.0 && pt >= 15.0)
111 return 0.914;
112 if (pt < 30.0 && pt >= 20.0)
113 return 0.948;
114 if (pt < 40.0 && pt >= 30.0)
115 return 0.961;
116 if (pt < 50.0 && pt >= 40.0)
117 return 0.972;
118 if (pt < 200.0 && pt >= 50.0)
119 return 0.977;
120 }
121 if (fabs (eta) < 1.556 && fabs (eta) >= 1.442)
122 {
123 if (pt < 15.0 && pt >= 10.0)
124 return 1.008;
125 if (pt < 20.0 && pt >= 15.0)
126 return 0.877;
127 if (pt < 30.0 && pt >= 20.0)
128 return 0.983;
129 if (pt < 40.0 && pt >= 30.0)
130 return 0.983;
131 if (pt < 50.0 && pt >= 40.0)
132 return 0.957;
133 if (pt < 200.0 && pt >= 50.0)
134 return 0.978;
135 }
136 if (fabs (eta) < 2.0 && fabs (eta) >= 1.556)
137 {
138 if (pt < 15.0 && pt >= 10.0)
139 return 0.906;
140 if (pt < 20.0 && pt >= 15.0)
141 return 0.907;
142 if (pt < 30.0 && pt >= 20.0)
143 return 0.957;
144 if (pt < 40.0 && pt >= 30.0)
145 return 0.962;
146 if (pt < 50.0 && pt >= 40.0)
147 return 0.985;
148 if (pt < 200.0 && pt >= 50.0)
149 return 0.986;
150 }
151 if (fabs (eta) < 2.5 && fabs (eta) >= 2.0)
152 {
153 if (pt < 15.0 && pt >= 10.0)
154 return 0.991;
155 if (pt < 20.0 && pt >= 15.0)
156 return 0.939;
157 if (pt < 30.0 && pt >= 20.0)
158 return 1.001;
159 if (pt < 40.0 && pt >= 30.0)
160 return 1.002;
161 if (pt < 50.0 && pt >= 40.0)
162 return 0.999;
163 if (pt < 200.0 && pt >= 50.0)
164 return 0.995;
165 }
166 }
167 if (id_ == "mvaNonTrig")
168 {
169 //cout << "mvaNonTrig\n";
170 if (fabs (eta) < 0.8)
171 {
172 if (pt < 20.0)
173 return 1.0;
174 if (pt < 30.0 && pt >= 20.0)
175 return 0.994;
176 if (pt < 40.0 && pt >= 30.0)
177 return 0.974;
178 if (pt < 50.0 && pt >= 40.0)
179 return 0.988;
180 if (pt < 200.0 && pt >= 50.0)
181 return 0.999;
182 }
183 if (fabs (eta) < 1.478 && fabs (eta) >= 0.8)
184 {
185 if (pt < 20.0)
186 return 1.0;
187 if (pt < 30.0 && pt >= 20.0)
188 return 0.971;
189 if (pt < 40.0 && pt >= 30.0)
190 return 0.967;
191 if (pt < 50.0 && pt >= 40.0)
192 return 0.984;
193 if (pt < 200.0 && pt >= 50.0)
194 return 0.998;
195 }
196 if (fabs (eta) <= 2.5 && fabs (eta) >= 1.478)
197 {
198 if (pt < 20.0)
199 return 1.0;
200 if (pt < 30.0 && pt >= 20.0)
201 return 0.921;
202 if (pt < 40.0 && pt >= 30.0)
203 return 0.932;
204 if (pt < 50.0 && pt >= 40.0)
205 return 0.968;
206 if (pt < 200.0 && pt >= 50.0)
207 return 0.983;
208 }
209 }
210 }
211
212 return 0.0;
213 }
214
215 ElectronSFWeight::~ElectronSFWeight ()
216 {
217 }