34 if (
argc>1&&
string(
argv[1])==
"--help") {
35 cout<<
"USAGE: JetResolution_t --era <era> --alg <alg> --nevts <n> --gaussian"<<endl;
39 string era(
"Spring10");
40 string alg(
"AK5Calo");
41 unsigned nevts(10000);
42 bool doGaussian(
false);
45 if (
string(
argv[
i])==
"--era") { era =
argv[i+1]; i++; }
46 else if (
string(
argv[i])==
"--alg") { alg =
argv[i+1]; i++; }
47 else if (
string(
argv[i])==
"--nevts") { stringstream ss; ss<<argv[i+1]; ss>>nevts; i++; }
48 else if (
string(
argv[i])==
"--gaussian") { doGaussian =
true; }
50 cerr<<
"ERROR: unknown option '"<<
argv[
i]<<
"'"<<endl;
55 cout<<
"era: "<<era<<endl;
56 cout<<
"alg: "<<alg<<endl;
57 cout<<
"nevts: "<<nevts<<endl;
58 cout<<
"gaussian: "<<doGaussian<<endl<<endl;
65 if (
stat(path.c_str(),&st)!=0)
67 if (
stat(path.c_str(),&st)!=0) {
68 cerr<<
"ERROR: tried to set path but failed, abort."<<endl;
73 string ptFileName = path +
"/" + era +
"_PtResolution_" +alg+
".txt";
74 string etaFileName = path +
"/" + era +
"_EtaResolution_"+alg+
".txt";
75 string phiFileName = path +
"/" + era +
"_PhiResolution_"+alg+
".txt";
77 cout<<ptFileName<<endl;
78 cout<<etaFileName<<endl;
79 cout<<phiFileName<<endl;
88 float pt = 200.*gRandom->Exp(0.1);
89 float eta = gRandom->Uniform(-5.0,5.0);
92 cout<<
"pT="<<pt<<
" eta="<<eta<<
" phi="<<phi<<endl;
94 TF1* fPtResol = ptResol.resolutionEtaPt(eta,pt);
95 TF1* fEtaResol = etaResol.resolutionEtaPt(eta,pt);
96 TF1* fPhiResol = phiResol.resolutionEtaPt(eta,pt);
98 fPtResol ->Print();
cout<<endl;
99 fEtaResol->Print();
cout<<endl;
100 fPhiResol->Print();
cout<<endl;
104 TH1F* hRndPt =
new TH1F(
"RndPt",
";random number",200,0.0,5.0);
105 TH1F* hGenPt =
new TH1F(
"GenPt",
";p_{T} [GeV]",100,0.,250.);
106 TH1F* hJetPt =
new TH1F(
"JetPt",
";p_{T} [GeV]",100,0.,250.);
108 TH1F* hRndEta =
new TH1F(
"RndEta",
";random number",200,-5.0,5.0);
109 TH1F* hGenEta =
new TH1F(
"GenEta",
";#eta",51,-5.,5.);
110 TH1F* hJetEta =
new TH1F(
"JetEta",
";#eta",51,-5.,5.);
112 TH1F* hRndPhi =
new TH1F(
"RndPhi",
";random number",200,-3.15,3.15);
113 TH1F* hGenPhi =
new TH1F(
"GenPhi",
";#varphi",41,-3.15,3.15);
114 TH1F* hJetPhi =
new TH1F(
"JetPhi",
";#varphi",41,-3.15,3.15);
116 for (
unsigned ievt=0;ievt<nevts;ievt++) {
118 if ((ievt+1)%1000==0)
cout<<ievt+1<<
" events processed."<<endl;
120 float genpt = 200.*gRandom->Exp(0.1);
if (genpt<1.0)
continue;
121 float geneta = gRandom->Uniform(-5.0,5.0);
124 fPtResol = ptResol.resolutionEtaPt(geneta,genpt);
125 fEtaResol = etaResol.resolutionEtaPt(geneta,genpt);
126 fPhiResol = phiResol.resolutionEtaPt(geneta,genpt);
128 float rndpt = fPtResol ->GetRandom();
129 float rndeta = fEtaResol->GetRandom();
130 float rndphi = fPhiResol->GetRandom();
132 float jetpt = rndpt*genpt;
133 float jeteta = rndeta+geneta;
134 float jetphi = rndphi+genphi;
140 hRndEta->Fill(rndeta);
141 hGenEta->Fill(geneta);
142 hJetEta->Fill(jeteta);
144 hRndPhi->Fill(rndphi);
145 hGenPhi->Fill(genphi);
146 hJetPhi->Fill(jetphi);
151 TApplication* app =
new TApplication(
"JetResolution_t",&argc,
argv);
152 gROOT->SetStyle(
"Plain");
156 TCanvas* cResolution =
new TCanvas(
"Resolution",
"Resolution",0,0,1000,400);
157 cResolution->Divide(3,1);
162 TF1* fPtEta1 = ptResol.parameterEta(
"sigma",0.25);
163 TF1* fPtEta2 = ptResol.parameterEta(
"sigma",1.75);
164 TF1* fPtEta3 = ptResol.parameterEta(
"sigma",2.75);
166 fPtEta1->SetLineWidth(1); fPtEta2->SetLineWidth(1); fPtEta3->SetLineWidth(1);
167 fPtEta1->SetNpx(500); fPtEta2->SetNpx(500); fPtEta3->SetNpx(500);
168 fPtEta1->SetLineColor(kRed); fPtEta2->SetLineColor(kBlue); fPtEta3->SetLineColor(kGreen);
169 fPtEta1->SetRange(5.0,500.); fPtEta2->SetRange(5.0,500.); fPtEta3->SetRange(5.0,500.);
170 fPtEta1->Draw(); fPtEta2->Draw(
"SAME"); fPtEta3->Draw(
"SAME");
172 fPtEta1->SetTitle(
"p_{T} - Resolution");
173 fPtEta1->GetHistogram()->SetXTitle(
"p_{T} [GeV]");
174 fPtEta1->GetHistogram()->SetYTitle(
"#sigma(p_{T})/p_{T}");
175 fPtEta1->GetHistogram()->GetYaxis()->CenterTitle();
176 fPtEta1->GetHistogram()->GetYaxis()->SetTitleOffset(1.33);
178 TLegend* legPtRes =
new TLegend(0.6,0.85,0.85,0.6);
179 legPtRes->SetFillColor(10);
180 legPtRes->AddEntry(fPtEta1,
"#eta=0.25",
"l");
181 legPtRes->AddEntry(fPtEta2,
"#eta=1.75",
"l");
182 legPtRes->AddEntry(fPtEta3,
"#eta=2.75",
"l");
189 TF1* fEtaEta1 = etaResol.parameterEta(
"sigma",0.25);
190 TF1* fEtaEta2 = etaResol.parameterEta(
"sigma",1.75);
191 TF1* fEtaEta3 = etaResol.parameterEta(
"sigma",2.75);
193 fEtaEta1->SetLineWidth(1); fEtaEta2->SetLineWidth(1); fEtaEta3->SetLineWidth(1);
194 fEtaEta1->SetNpx(500); fEtaEta2->SetNpx(500); fEtaEta3->SetNpx(500);
195 fEtaEta1->SetLineColor(kRed); fEtaEta2->SetLineColor(kBlue); fEtaEta3->SetLineColor(kGreen);
196 fEtaEta1->SetRange(5.0,500.); fEtaEta2->SetRange(5.0,500.); fEtaEta3->SetRange(5.0,500.);
197 fEtaEta1->Draw(); fEtaEta2->Draw(
"SAME"); fEtaEta3->Draw(
"SAME");
199 fEtaEta1->SetTitle(
"#eta - Resolution");
200 fEtaEta1->GetHistogram()->SetXTitle(
"p_{T} [GeV]");
201 fEtaEta1->GetHistogram()->SetYTitle(
"#sigma(#eta)");
202 fEtaEta1->GetHistogram()->GetYaxis()->CenterTitle();
203 fEtaEta1->GetHistogram()->GetYaxis()->SetTitleOffset(1.33);
205 TLegend* legEtaRes =
new TLegend(0.6,0.85,0.85,0.6);
206 legEtaRes->SetFillColor(10);
207 legEtaRes->AddEntry(fEtaEta1,
"#eta=0.25",
"l");
208 legEtaRes->AddEntry(fEtaEta2,
"#eta=1.75",
"l");
209 legEtaRes->AddEntry(fEtaEta3,
"#eta=2.75",
"l");
216 TF1* fPhiEta1 = phiResol.parameterEta(
"sigma",0.25);
217 TF1* fPhiEta2 = phiResol.parameterEta(
"sigma",1.75);
218 TF1* fPhiEta3 = phiResol.parameterEta(
"sigma",2.75);
220 fPhiEta1->SetLineWidth(1); fPhiEta2->SetLineWidth(1); fPhiEta3->SetLineWidth(1);
221 fPhiEta1->SetNpx(500); fPhiEta2->SetNpx(500); fPhiEta3->SetNpx(500);
222 fPhiEta1->SetLineColor(kRed); fPhiEta2->SetLineColor(kBlue); fPhiEta3->SetLineColor(kGreen);
223 fPhiEta1->SetRange(5.0,500.); fPhiEta2->SetRange(5.0,500.); fPhiEta3->SetRange(5.0,500.);
224 fPhiEta1->Draw(); fPhiEta2->Draw(
"SAME"); fPhiEta3->Draw(
"SAME");
226 fPhiEta1->SetTitle(
"#varphi - Resolution");
227 fPhiEta1->GetHistogram()->SetXTitle(
"p_{T} [GeV]");
228 fPhiEta1->GetHistogram()->SetYTitle(
"#sigma(#varphi)");
229 fPhiEta1->GetHistogram()->GetYaxis()->CenterTitle();
230 fPhiEta1->GetHistogram()->GetYaxis()->SetTitleOffset(1.33);
232 TLegend* legPhiRes =
new TLegend(0.6,0.85,0.85,0.6);
233 legPhiRes->SetFillColor(10);
234 legPhiRes->AddEntry(fPhiEta1,
"#eta=0.25",
"l");
235 legPhiRes->AddEntry(fPhiEta2,
"#eta=1.75",
"l");
236 legPhiRes->AddEntry(fPhiEta3,
"#eta=2.75",
"l");
242 TCanvas* cSmearing =
new TCanvas(
"Smearing",
"Smearing",100,100,1000,600);
243 cSmearing->Divide(3,2);
260 hJetPt->Draw(
"SAME");
261 hJetPt->SetLineColor(kRed);
262 if (hGenPt->GetMaximum()<hJetPt->GetMaximum())
263 hGenPt->SetMaximum(1.1*hJetPt->GetMaximum());
264 TLegend* legPt =
new TLegend(0.6,0.8,0.85,0.65);
265 legPt->SetFillColor(10);
266 legPt->AddEntry(hGenPt,
"generated",
"l");
267 legPt->AddEntry(hJetPt,
"smeared",
"l");
272 hJetEta->Draw(
"SAME");
273 hJetEta->SetLineColor(kRed);
274 if (hGenEta->GetMaximum()<hJetEta->GetMaximum())
275 hGenEta->SetMaximum(1.1*hJetEta->GetMaximum());
276 hGenEta->SetMinimum(0.0);
277 hGenEta->SetMaximum(1.5*hGenEta->GetMaximum());
278 TLegend* legEta =
new TLegend(0.6,0.8,0.85,0.65);
279 legEta->SetFillColor(10);
280 legEta->AddEntry(hGenEta,
"generated",
"l");
281 legEta->AddEntry(hJetEta,
"smeared",
"l");
286 hJetPhi->Draw(
"SAME");
287 hJetPhi->SetLineColor(kRed);
288 if (hGenPhi->GetMaximum()<hJetPhi->GetMaximum())
289 hGenPhi->SetMaximum(1.1*hJetPhi->GetMaximum());
290 hGenPhi->SetMinimum(0.0);
291 hGenPhi->SetMaximum(1.5*hGenPhi->GetMaximum());
292 TLegend* legPhi =
new TLegend(0.6,0.8,0.85,0.65);
293 legPhi->SetFillColor(10);
294 legPhi->AddEntry(hGenPhi,
"generated",
"l");
295 legPhi->AddEntry(hJetPhi,
"smeared",
"l");