12 #include <TApplication.h> 29 if (
argc > 1 &&
string(
argv[1]) ==
"--help") {
30 cout <<
"USAGE: JetResolution_t --era <era> --alg <alg> --nevts <n> --gaussian" << endl;
34 string era(
"Spring10");
35 string alg(
"AK5Calo");
36 unsigned nevts(10000);
37 bool doGaussian(
false);
39 for (
int i = 1;
i <
argc;
i++) {
40 if (
string(
argv[
i]) ==
"--era") {
43 }
else if (
string(
argv[
i]) ==
"--alg") {
46 }
else if (
string(
argv[
i]) ==
"--nevts") {
51 }
else if (
string(
argv[
i]) ==
"--gaussian") {
54 cerr <<
"ERROR: unknown option '" <<
argv[
i] <<
"'" << endl;
59 cout <<
"era: " << era << endl;
60 cout <<
"alg: " << alg << endl;
62 cout <<
"gaussian: " << doGaussian << endl << endl;
65 string cmssw_release_base(std::getenv(
"CMSSW_RELEASE_BASE"));
69 path = cmssw_release_base +
"/src/CondFormats/JetMETObjects/data";
71 cerr <<
"ERROR: tried to set path but failed, abort." << endl;
75 string ptFileName =
path +
"/" + era +
"_PtResolution_" + alg +
".txt";
76 string etaFileName =
path +
"/" + era +
"_EtaResolution_" + alg +
".txt";
77 string phiFileName =
path +
"/" + era +
"_PhiResolution_" + alg +
".txt";
79 cout << ptFileName << endl;
80 cout << etaFileName << endl;
81 cout << phiFileName << endl;
89 float pt = 200. * gRandom->Exp(0.1);
90 float eta = gRandom->Uniform(-5.0, 5.0);
93 cout <<
"pT=" <<
pt <<
" eta=" <<
eta <<
" phi=" <<
phi << endl;
107 TH1F* hRndPt =
new TH1F(
"RndPt",
";random number", 200, 0.0, 5.0);
108 TH1F* hGenPt =
new TH1F(
"GenPt",
";p_{T} [GeV]", 100, 0., 250.);
109 TH1F* hJetPt =
new TH1F(
"JetPt",
";p_{T} [GeV]", 100, 0., 250.);
111 TH1F* hRndEta =
new TH1F(
"RndEta",
";random number", 200, -5.0, 5.0);
112 TH1F* hGenEta =
new TH1F(
"GenEta",
";#eta", 51, -5., 5.);
113 TH1F* hJetEta =
new TH1F(
"JetEta",
";#eta", 51, -5., 5.);
115 TH1F* hRndPhi =
new TH1F(
"RndPhi",
";random number", 200, -3.15, 3.15);
116 TH1F* hGenPhi =
new TH1F(
"GenPhi",
";#varphi", 41, -3.15, 3.15);
117 TH1F* hJetPhi =
new TH1F(
"JetPhi",
";#varphi", 41, -3.15, 3.15);
119 for (
unsigned ievt = 0; ievt <
nevts; ievt++) {
120 if ((ievt + 1) % 1000 == 0)
121 cout << ievt + 1 <<
" events processed." << endl;
123 float genpt = 200. * gRandom->Exp(0.1);
126 float geneta = gRandom->Uniform(-5.0, 5.0);
133 float rndpt = fPtResol->GetRandom();
134 float rndeta = fEtaResol->GetRandom();
135 float rndphi = fPhiResol->GetRandom();
137 float jetpt = rndpt * genpt;
138 float jeteta = rndeta + geneta;
139 float jetphi = rndphi + genphi;
145 hRndEta->Fill(rndeta);
146 hGenEta->Fill(geneta);
147 hJetEta->Fill(jeteta);
149 hRndPhi->Fill(rndphi);
150 hGenPhi->Fill(genphi);
151 hJetPhi->Fill(jetphi);
156 TApplication* app =
new TApplication(
"JetResolution_t", &
argc,
argv);
157 gROOT->SetStyle(
"Plain");
160 TCanvas* cResolution =
new TCanvas(
"Resolution",
"Resolution", 0, 0, 1000, 400);
161 cResolution->Divide(3, 1);
170 fPtEta1->SetLineWidth(1);
171 fPtEta2->SetLineWidth(1);
172 fPtEta3->SetLineWidth(1);
173 fPtEta1->SetNpx(500);
174 fPtEta2->SetNpx(500);
175 fPtEta3->SetNpx(500);
176 fPtEta1->SetLineColor(kRed);
177 fPtEta2->SetLineColor(kBlue);
178 fPtEta3->SetLineColor(kGreen);
179 fPtEta1->SetRange(5.0, 500.);
180 fPtEta2->SetRange(5.0, 500.);
181 fPtEta3->SetRange(5.0, 500.);
183 fPtEta2->Draw(
"SAME");
184 fPtEta3->Draw(
"SAME");
186 fPtEta1->SetTitle(
"p_{T} - Resolution");
187 fPtEta1->GetHistogram()->SetXTitle(
"p_{T} [GeV]");
188 fPtEta1->GetHistogram()->SetYTitle(
"#sigma(p_{T})/p_{T}");
189 fPtEta1->GetHistogram()->GetYaxis()->CenterTitle();
190 fPtEta1->GetHistogram()->GetYaxis()->SetTitleOffset(1.33);
192 TLegend* legPtRes =
new TLegend(0.6, 0.85, 0.85, 0.6);
193 legPtRes->SetFillColor(10);
194 legPtRes->AddEntry(fPtEta1,
"#eta=0.25",
"l");
195 legPtRes->AddEntry(fPtEta2,
"#eta=1.75",
"l");
196 legPtRes->AddEntry(fPtEta3,
"#eta=2.75",
"l");
206 fEtaEta1->SetLineWidth(1);
207 fEtaEta2->SetLineWidth(1);
208 fEtaEta3->SetLineWidth(1);
209 fEtaEta1->SetNpx(500);
210 fEtaEta2->SetNpx(500);
211 fEtaEta3->SetNpx(500);
212 fEtaEta1->SetLineColor(kRed);
213 fEtaEta2->SetLineColor(kBlue);
214 fEtaEta3->SetLineColor(kGreen);
215 fEtaEta1->SetRange(5.0, 500.);
216 fEtaEta2->SetRange(5.0, 500.);
217 fEtaEta3->SetRange(5.0, 500.);
219 fEtaEta2->Draw(
"SAME");
220 fEtaEta3->Draw(
"SAME");
222 fEtaEta1->SetTitle(
"#eta - Resolution");
223 fEtaEta1->GetHistogram()->SetXTitle(
"p_{T} [GeV]");
224 fEtaEta1->GetHistogram()->SetYTitle(
"#sigma(#eta)");
225 fEtaEta1->GetHistogram()->GetYaxis()->CenterTitle();
226 fEtaEta1->GetHistogram()->GetYaxis()->SetTitleOffset(1.33);
228 TLegend* legEtaRes =
new TLegend(0.6, 0.85, 0.85, 0.6);
229 legEtaRes->SetFillColor(10);
230 legEtaRes->AddEntry(fEtaEta1,
"#eta=0.25",
"l");
231 legEtaRes->AddEntry(fEtaEta2,
"#eta=1.75",
"l");
232 legEtaRes->AddEntry(fEtaEta3,
"#eta=2.75",
"l");
242 fPhiEta1->SetLineWidth(1);
243 fPhiEta2->SetLineWidth(1);
244 fPhiEta3->SetLineWidth(1);
245 fPhiEta1->SetNpx(500);
246 fPhiEta2->SetNpx(500);
247 fPhiEta3->SetNpx(500);
248 fPhiEta1->SetLineColor(kRed);
249 fPhiEta2->SetLineColor(kBlue);
250 fPhiEta3->SetLineColor(kGreen);
251 fPhiEta1->SetRange(5.0, 500.);
252 fPhiEta2->SetRange(5.0, 500.);
253 fPhiEta3->SetRange(5.0, 500.);
255 fPhiEta2->Draw(
"SAME");
256 fPhiEta3->Draw(
"SAME");
258 fPhiEta1->SetTitle(
"#varphi - Resolution");
259 fPhiEta1->GetHistogram()->SetXTitle(
"p_{T} [GeV]");
260 fPhiEta1->GetHistogram()->SetYTitle(
"#sigma(#varphi)");
261 fPhiEta1->GetHistogram()->GetYaxis()->CenterTitle();
262 fPhiEta1->GetHistogram()->GetYaxis()->SetTitleOffset(1.33);
264 TLegend* legPhiRes =
new TLegend(0.6, 0.85, 0.85, 0.6);
265 legPhiRes->SetFillColor(10);
266 legPhiRes->AddEntry(fPhiEta1,
"#eta=0.25",
"l");
267 legPhiRes->AddEntry(fPhiEta2,
"#eta=1.75",
"l");
268 legPhiRes->AddEntry(fPhiEta3,
"#eta=2.75",
"l");
272 TCanvas* cSmearing =
new TCanvas(
"Smearing",
"Smearing", 100, 100, 1000, 600);
273 cSmearing->Divide(3, 2);
290 hJetPt->Draw(
"SAME");
291 hJetPt->SetLineColor(kRed);
292 if (hGenPt->GetMaximum() < hJetPt->GetMaximum())
293 hGenPt->SetMaximum(1.1 * hJetPt->GetMaximum());
294 TLegend* legPt =
new TLegend(0.6, 0.8, 0.85, 0.65);
295 legPt->SetFillColor(10);
296 legPt->AddEntry(hGenPt,
"generated",
"l");
297 legPt->AddEntry(hJetPt,
"smeared",
"l");
302 hJetEta->Draw(
"SAME");
303 hJetEta->SetLineColor(kRed);
304 if (hGenEta->GetMaximum() < hJetEta->GetMaximum())
305 hGenEta->SetMaximum(1.1 * hJetEta->GetMaximum());
306 hGenEta->SetMinimum(0.0);
307 hGenEta->SetMaximum(1.5 * hGenEta->GetMaximum());
308 TLegend* legEta =
new TLegend(0.6, 0.8, 0.85, 0.65);
309 legEta->SetFillColor(10);
310 legEta->AddEntry(hGenEta,
"generated",
"l");
311 legEta->AddEntry(hJetEta,
"smeared",
"l");
316 hJetPhi->Draw(
"SAME");
317 hJetPhi->SetLineColor(kRed);
318 if (hGenPhi->GetMaximum() < hJetPhi->GetMaximum())
319 hGenPhi->SetMaximum(1.1 * hJetPhi->GetMaximum());
320 hGenPhi->SetMinimum(0.0);
321 hGenPhi->SetMaximum(1.5 * hGenPhi->GetMaximum());
322 TLegend* legPhi =
new TLegend(0.6, 0.8, 0.85, 0.65);
323 legPhi->SetFillColor(10);
324 legPhi->AddEntry(hGenPhi,
"generated",
"l");
325 legPhi->AddEntry(hJetPhi,
"smeared",
"l");
int main(int argc, char **argv)
TF1 * parameterEta(const std::string ¶meterName, float eta)
TF1 * resolutionEtaPt(float eta, float pt) const