ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/FSRStudy.C
Revision: 1.7
Committed: Tue Nov 20 16:51:55 2012 UTC (12 years, 5 months ago) by buchmann
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +35 -25 lines
Log Message:
Updated photon studies for final conclusions: mll predicted vs observed

File Contents

# Content
1 #include <iostream>
2
3
4 samplecollection PhotonSamples("PhotonSamples");
5
6 namespace GenPhotons {
7 void CompareZmassToFinalStateLeptons();
8 void GenLevelStudies();
9
10 void NumberOfPhotonsPerEvent();
11 void CharacterizingFSRPhotons();
12 void MakeCharacterizationPlot(string variable, int nbins, float min, float max, string label, string saveas);
13 void dR2DPlots();
14 void CompareGenJZBDistributions();
15 void EfficiencyPurity();
16
17 TCut FSRcut;
18 TCut NoFSRcut;
19 TCut BaseCut;
20 }
21
22 namespace RecoPhotons {
23 void RecoLevelStudies();
24
25 void NumberOfPhotonsPerEvent();
26 void CharacterizingFSRPhotons();
27 void MakeCharacterizationPlot(string variable, int nbins, float min, float max, string label, string saveas);
28 void dR2DPlots();
29 void CompareRecoJZBDistributions();
30 void EfficiencyPurity();
31 void FSRPhotonVsUnmatchedVsMatchedPhoton();
32 void FSRPhotonVsUnmatchedVsMatchedPhoton2D();
33 void JZBvsmllClosure();
34
35 TCut FSRcut;
36 TCut NoFSRcut;
37 TCut BaseCut;
38 }
39
40 void RecoPhotons::JZBvsmllClosure() {
41 TCanvas *can = new TCanvas("can","can",1000,1000);
42 can->Divide(2,2);
43 can->cd(1);
44
45 //we only want Z->ee and Z->mm for this (not Z->tautau)
46
47 TCut em("!EventZToTaus");
48
49 //no FSR recovery
50 TH1F *negmll_noFSR = PhotonSamples.Draw("negmll_noFSR", "genFSRmll", 36, 20, 200, "m_{ll}^{gen}", "events",BaseCut && TCut("genFSRjzb<-0.1") && em, mc,PlottingSetup::luminosity);
51 TH1F *posmll_noFSR = PhotonSamples.Draw("posmll_noFSR", "genFSRmll", 36, 20, 200, "m_{ll}^{gen}", "events",BaseCut && TCut("genFSRjzb>0.1") && em, mc,PlottingSetup::luminosity);
52
53
54 //with FSR recovery
55 TH1F *negmll_FSR = PhotonSamples.Draw("negmll_FSR", "genFSRmllg", 36, 20, 200, "m_{ll}^{gen}", "events",BaseCut && TCut("genFSRjzbG<-0.1") && em, mc,PlottingSetup::luminosity);
56 TH1F *posmll_FSR = PhotonSamples.Draw("posmll_FSR", "genFSRmllg", 36, 20, 200, "m_{ll}^{gen}", "events",BaseCut && TCut("genFSRjzbG>0.1") && em, mc,PlottingSetup::luminosity);
57
58 cout << "Integrals: " << endl;
59 cout << " no FSR: JZB<0 : " << negmll_noFSR->Integral() << endl;
60 cout << " no FSR: JZB>0 : " << posmll_noFSR->Integral() << endl;
61 cout << " with FSR: JZB<0 : " << negmll_FSR->Integral() << endl;
62 cout << " with FSR: JZB>0 : " << posmll_FSR->Integral() << endl;
63
64 can->cd(1)->SetLogy(1);
65 can->cd(2)->SetLogy(1);
66 // can->cd(3)->SetLogy(1);
67 // can->cd(4)->SetLogy(1);
68
69 negmll_noFSR->SetLineColor(kRed);
70 posmll_noFSR->SetLineColor(kBlack);
71
72 negmll_FSR->SetLineColor(kRed);
73 posmll_FSR->SetLineColor(kBlack);
74
75 TLegend *leg = make_legend();
76 leg->AddEntry(negmll_noFSR,"prediction","L");
77 leg->AddEntry(posmll_noFSR,"observation","P");
78 leg->SetHeader("#splitline{DY MC, gen level}{Only Z#rightarrow ee,mm}");
79
80 can->cd(1);
81 negmll_noFSR->Draw("histo");
82 posmll_noFSR->Draw("e1,same");
83 TText *noFSR = write_title("No FSR recovery");
84 noFSR->Draw();
85 leg->Draw();
86
87 can->cd(2);
88 negmll_FSR->Draw("histo");
89 posmll_FSR->Draw("e1,same");
90 TText *FSR = write_title("With FSR recovery");
91 FSR->Draw();
92 leg->Draw();
93
94 can->cd(3);
95 TH1F *ratioNoFSR = (TH1F*)posmll_noFSR->Clone("ratioNoFSR");
96 ratioNoFSR->Divide(negmll_noFSR);
97 ratioNoFSR->GetYaxis()->SetRangeUser(0,2);
98 ratioNoFSR->GetYaxis()->SetTitle("obs/pred");
99 ratioNoFSR->Draw("e1");
100 TLine *oneline = new TLine(ratioNoFSR->GetBinLowEdge(1),1.0,ratioNoFSR->GetBinLowEdge(ratioNoFSR->GetNbinsX())+ratioNoFSR->GetBinWidth(ratioNoFSR->GetNbinsX()),1.0);
101 oneline->SetLineColor(kBlue);
102 oneline->Draw();
103 noFSR->Draw();
104
105 can->cd(4);
106 TH1F *ratioFSR = (TH1F*)posmll_FSR->Clone("ratioFSR");
107 ratioFSR->Divide(negmll_FSR);
108 ratioFSR->GetYaxis()->SetTitle("obs/pred");
109 ratioFSR->GetYaxis()->SetRangeUser(0,2);
110 ratioFSR->Draw("e1");
111 oneline->Draw();
112 FSR->Draw();
113
114
115 CompleteSave(can,"PhotonStudies/Recophotons/ComparePredObsZmass_GEN");
116
117
118 cout << __FUNCTION__ << " : Still need to delete objects" << endl;
119 delete FSR;
120 delete ratioNoFSR;
121 delete ratioFSR;
122 delete negmll_noFSR;
123 delete negmll_FSR;
124 delete posmll_noFSR;
125 delete posmll_FSR;
126 delete can;
127 }
128
129 void RecoPhotons::FSRPhotonVsUnmatchedVsMatchedPhoton() {
130
131 TCanvas *can = new TCanvas("can","can");
132
133 can->SetLogy(1);
134 TH1F *MatchedFSR = PhotonSamples.Draw("MatchedFSR" ,"min(recoPhotonsDR1,recoPhotonsDR2)",20,0,2,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))" , "events", "recoPhotonGenIndex>=0 && genPhotonsIsFSR[recoPhotonGenIndex]",mc,PlottingSetup::luminosity);
135 TH1F *MatchednoFSR = PhotonSamples.Draw("MatchednoFSR" ,"min(recoPhotonsDR1,recoPhotonsDR2)",20,0,2,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))" , "events", "recoPhotonGenIndex>=0 && !genPhotonsIsFSR[recoPhotonGenIndex]",mc,PlottingSetup::luminosity);
136 TH1F *UnMatched = PhotonSamples.Draw("UnMatched" ,"min(recoPhotonsDR1,recoPhotonsDR2)",20,0,2,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))" , "events", "recoPhotonGenIndex<0",mc,PlottingSetup::luminosity);
137
138 MatchedFSR->SetLineColor(TColor::GetColor("#01DF01"));//green
139 MatchednoFSR->SetLineColor(TColor::GetColor("#FF4000"));//red
140 UnMatched->SetLineColor(TColor::GetColor("#194fff"));//blue
141
142 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
143 leg->SetFillColor(kWhite);
144 leg->AddEntry(MatchedFSR,"Matched: FSR","l");
145 leg->AddEntry(MatchednoFSR,"Matched: no FSR","l");
146 leg->AddEntry(UnMatched,"Unmatched #gamma","l");
147
148 MatchedFSR->DrawNormalized("histo");
149 MatchednoFSR->DrawNormalized("same,histo");
150 UnMatched->DrawNormalized("same,histo");
151 leg->SetHeader("DY MC:");
152 leg->Draw("same,histo");
153 DrawMCPrelim();
154
155 CompleteSave(can,"PhotonStudies/Recophotons/DeltaR_Comparison_Matched_Unmatched_FSR__Normalized");
156
157 MatchedFSR->Draw("histo");
158 MatchednoFSR->Draw("same,histo");
159 UnMatched->Draw("same,histo");
160 leg->SetHeader("DY MC:");
161 leg->Draw("same,histo");
162 DrawMCPrelim();
163 CompleteSave(can,"PhotonStudies/Recophotons/DeltaR_Comparison_Matched_Unmatched_FSR");
164 delete can;
165
166
167 }
168
169 void RecoPhotons::FSRPhotonVsUnmatchedVsMatchedPhoton2D() {
170
171 TCanvas *can = new TCanvas("can","can");
172 can->SetLogy(1);
173 TH1F *MatchedFSR = PhotonSamples.Draw("MatchedFSR" ,"min(recoPhotonsDR1,recoPhotonsDR2)",100,0,2,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))" , "events", "recoPhotonGenIndex>=0 && genPhotonsIsFSR[recoPhotonGenIndex]&&recoPhotonsDR1>0&&recoPhotonsDR2>0",mc,PlottingSetup::luminosity);
174 TH1F *MatchednoFSR = PhotonSamples.Draw("MatchednoFSR" ,"min(recoPhotonsDR1,recoPhotonsDR2)",100,0,2,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))" , "events", "recoPhotonGenIndex>=0 && !genPhotonsIsFSR[recoPhotonGenIndex]&&recoPhotonsDR1>0&&recoPhotonsDR2>0",mc,PlottingSetup::luminosity);
175 TH1F *UnMatched = PhotonSamples.Draw("UnMatched" ,"min(recoPhotonsDR1,recoPhotonsDR2)",100,0,2,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))" , "events", "recoPhotonGenIndex<0&&recoPhotonsDR1>0&&recoPhotonsDR2>0",mc,PlottingSetup::luminosity);
176
177 MatchedFSR->SetLineColor(TColor::GetColor("#01DF01"));//green
178 MatchednoFSR->SetLineColor(TColor::GetColor("#FF4000"));//red
179 UnMatched->SetLineColor(TColor::GetColor("#194fff"));//blue
180
181 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
182 leg->SetFillColor(kWhite);
183 leg->AddEntry(MatchedFSR,"Matched: FSR","l");
184 leg->AddEntry(MatchednoFSR,"Matched: no FSR","l");
185 leg->AddEntry(UnMatched,"Unmatched #gamma","l");
186
187 MatchedFSR->DrawNormalized("histo");
188 MatchednoFSR->DrawNormalized("same,histo");
189 UnMatched->DrawNormalized("same,histo");
190 leg->SetHeader("DY MC:");
191 leg->Draw("same,histo");
192 DrawMCPrelim();
193
194 CompleteSave(can,"PhotonStudies/Recophotons/DeltaR_Comparison_Matched_Unmatched_FSR");
195
196
197 delete can;
198
199 TCanvas *can2 = new TCanvas("can2","can2",1000,1000);
200 can2->Divide(2,2);
201 can2->cd(1);
202
203
204 vector<float> binX, binY;
205 int nBins=40;
206 for(int i=0;i<nBins;i++) {
207 binX.push_back(i*(3.0/nBins));
208 binY.push_back(i*(3.0/nBins));
209 }
210
211 cout << __LINE__ << endl;
212 TH2F *tMatchedFSR = PhotonSamples.Draw("tMatchedFSR", "recoPhotonsDR1:recoPhotonsDR2", binX,binY, "#Delta R (#gamma^{FSR},l_{1})","#Delta R (#gamma^{FSR},l_{2})",BaseCut&&TCut("recoPhotonGenIndex>=0 && genPhotonsIsFSR[recoPhotonGenIndex]&&recoPhotonsDR1>0&&recoPhotonsDR2>0"),mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
213 cout << __LINE__ << endl;
214 TH2F *tMatchednoFSR = PhotonSamples.Draw("tMatchednoFSR", "recoPhotonsDR1:recoPhotonsDR2", binX,binY, "#Delta R (#gamma^{FSR},l_{1})","#Delta R (#gamma^{FSR},l_{2})",BaseCut&&TCut("recoPhotonGenIndex>=0 && !genPhotonsIsFSR[recoPhotonGenIndex]&&recoPhotonsDR1>0&&recoPhotonsDR2>0"),mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
215 cout << __LINE__ << endl;
216 TH2F *tUnMatched = PhotonSamples.Draw("tUnMatched", "recoPhotonsDR1:recoPhotonsDR2", binX,binY, "#Delta R (#gamma^{FSR},l_{1})","#Delta R (#gamma^{FSR},l_{2})",BaseCut&&TCut("recoPhotonGenIndex<0&&recoPhotonsDR1>0&&recoPhotonsDR2>0"),mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
217 cout << __LINE__ << endl;
218
219
220
221
222 can2->cd(1);
223 can2->cd(1)->SetRightMargin(0.14);
224 tMatchedFSR->Draw("COLZ");
225 TText *ma = write_title("Matched FSR photons");
226 ma->Draw();
227 can2->cd(2);
228 can2->cd(2)->SetRightMargin(0.14);
229 cout << __LINE__ << endl;
230 tMatchednoFSR->Draw("COLZ");
231 TText *man = write_title("Matched non-FSR phtons");
232 man->Draw();
233 can2->cd(3);
234 can2->cd(3)->SetRightMargin(0.14);
235 cout << __LINE__ << endl;
236 TText *unm = write_title("Unmatched photons");
237 tUnMatched->Draw("COLZ");
238 unm->Draw();
239 can2->cd(4);
240 can2->cd(4)->SetLogy(1);
241 MatchedFSR->DrawNormalized("histo");
242 MatchednoFSR->DrawNormalized("same,histo");
243 UnMatched->DrawNormalized("same,histo");
244 leg->SetHeader("DY MC:");
245 leg->Draw("same,histo");
246 DrawMCPrelim();
247
248 cout << __LINE__ << endl;
249 CompleteSave(can2,"PhotonStudies/Recophotons/DeltaR_Comparison_Matched_Unmatched_FSR__2D");
250
251 delete can2;
252 }
253
254 void RecoPhotons::NumberOfPhotonsPerEvent() {
255 cout << __FUNCTION__ << " not implemented." << endl;
256 }
257
258 void RecoPhotons::CharacterizingFSRPhotons() {
259 cout << __FUNCTION__ << " not implemented." << endl;
260 }
261
262 void RecoPhotons::dR2DPlots() {
263 cout << __FUNCTION__ << " not implemented." << endl;
264 }
265
266 void RecoPhotons::MakeCharacterizationPlot(string variable, int nbins, float min, float max, string label, string saveas) {
267 cout << __FUNCTION__ << " not implemented." << endl;
268 }
269
270 void RecoPhotons::CompareRecoJZBDistributions() {
271 cout << __FUNCTION__ << " not implemented." << endl;
272 }
273
274 void RecoPhotons::EfficiencyPurity() {
275 cout << __FUNCTION__ << " not implemented." << endl;
276 }
277
278 void CompareZmassToFinalStateLeptons() {
279
280 TCanvas *can = new TCanvas("can","can");
281 can->SetLogy(1);
282
283 TH1F *FullZ = PhotonSamples.Draw("FullZ" ,"genFSRmllg",36,20,200,"m_{ll} [GeV]" , "events", "genFSRmllg>20&&genFSRmllg<200",mc,PlottingSetup::luminosity);
284 TH1F *RecoLL = PhotonSamples.Draw("RecoLL","mll", 36,20,200,"m_{ll} [GeV]" , "events","mll>20&&mll<200",mc,PlottingSetup::luminosity);
285 TH1F *FSRRll = PhotonSamples.Draw("FSRRll","mllg", 36,20,200,"m_{ll#gamma} [GeV]", "events","mllg>20&&mllg<200",mc,PlottingSetup::luminosity);
286
287 FullZ->SetLineColor(TColor::GetColor("#01DF01"));//green
288 RecoLL->SetLineColor(TColor::GetColor("#FF4000"));//red
289 FSRRll->SetLineColor(TColor::GetColor("#194fff"));//blue
290
291 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
292 leg->SetFillColor(kWhite);
293 leg->AddEntry(FullZ,"gen Z mass","l");
294 leg->AddEntry(RecoLL,"reco m_{ll}","l");
295 leg->AddEntry(FSRRll,"reco m_{ll} w/ FSR recovery","l");
296
297 FullZ->DrawNormalized("histo");
298 RecoLL->DrawNormalized("same,histo");
299 FSRRll->DrawNormalized("same,histo");
300 leg->SetHeader("DY MC:");
301 leg->Draw("same,histo");
302 DrawMCPrelim();
303
304 CompleteSave(can,"PhotonStudies/Recophotons/CompareZmassToFinalStateLeptons");
305
306
307 TH1F *RecoLL2 = PhotonSamples.Draw("RecoLL2","mll-genFSRmllg", 40,-100,100,"m_{ll}-m_{Z}^{gen} [GeV]", "events","mll>20&&genFSRmllg>20", mc,PlottingSetup::luminosity);
308 TH1F *FSRRll2 = PhotonSamples.Draw("FSRRll2","mllg-genFSRmllg", 40,-100,100,"m_{ll}-m_{Z}^{gen} [GeV]", "events","mllg>20&&genFSRmllg>20",mc,PlottingSetup::luminosity);
309
310 RecoLL2->SetLineColor(TColor::GetColor("#FF4000"));//red
311 FSRRll2->SetLineColor(TColor::GetColor("#194fff"));//blue
312
313 TH1F *phony = new TH1F("phony","",1,0,1);
314 phony->SetLineColor(kWhite);
315
316 stringstream summary;
317 summary << "#splitline{#splitline{Before: Mean : " << std::setprecision(3) << RecoLL2->GetMean() << "}{ RMS : " << std::setprecision(3) << RecoLL2->GetRMS() << "}";
318 summary << "}{#splitline{After: Mean : " << std::setprecision(3) << FSRRll2->GetMean() << "}{ RMS : " << std::setprecision(3) << FSRRll2->GetRMS() << "}}";
319
320 TLegend *leg2 = new TLegend(0.6,0.7,0.89,0.89);
321 leg2->SetFillColor(kWhite);
322 //leg2->AddEntry(FullZ,"gen Z mass","l");
323 leg2->AddEntry(RecoLL,"m_{ll}-m_{Z}^{gen}: no FSR recov","l");
324 leg2->AddEntry(FSRRll,"m_{ll}-m_{Z}^{gen}: with FSR recov","l");
325
326 RecoLL2->DrawNormalized("histo");
327 FSRRll2->DrawNormalized("same,histo");
328 leg2->SetHeader("DY MC:");
329 leg2->Draw("same,histo");
330 DrawMCPrelim();
331
332 TText *text = write_title(summary.str().c_str());
333 text->SetX(0.4);
334 text->SetY(0.8);
335 text->SetTextAlign(31);
336 text->SetTextSize(0.025);
337 text->Draw();
338
339 cout << "Mean (before recovery) : " << RecoLL2->GetMean() << " , RMS: " << RecoLL2->GetRMS() << endl;
340 cout << "Mean (after recovery) : " << FSRRll2->GetMean() << " , RMS: " << FSRRll2->GetRMS() << endl;
341
342
343 CompleteSave(can,"PhotonStudies/Recophotons/CompareZmassToFinalStateLeptons_MassDiff");
344
345
346
347 delete RecoLL;
348 delete RecoLL2;
349 delete FullZ;
350 delete FSRRll;
351 delete FSRRll2;
352 delete phony;
353 delete can;
354 }
355
356 void RecoPhotons::RecoLevelStudies() {
357 TCut essential_bkp = essentialcut;
358 essentialcut=TCut("");
359
360 JZBvsmllClosure();
361 CompareZmassToFinalStateLeptons();
362 FSRPhotonVsUnmatchedVsMatchedPhoton();/*
363 FSRPhotonVsUnmatchedVsMatchedPhoton2D();
364 NumberOfPhotonsPerEvent();
365 CharacterizingFSRPhotons();
366 CompareRecoJZBDistributions();
367
368 dR2DPlots();
369
370 EfficiencyPurity();*/
371
372 essentialcut=essential_bkp;
373 }
374
375
376 void GenPhotons::CompareZmassToFinalStateLeptons() {
377
378 TCanvas *can = new TCanvas("can","can");
379 can->SetLogy(1);
380
381 TH1F *FullZ = PhotonSamples.Draw("FullZ","genFSRmllg",36,20,200,"m_{Z}^{gen} [GeV]", "events", "genFSRmllg>20&&genFSRmllg<200",mc,PlottingSetup::luminosity);
382 TH1F *GenLL = PhotonSamples.Draw("GenLL","genFSRmll", 36,20,200,"m_{ll}^{gen} [GeV]", "events","genFSRmllg>20&&genFSRmllg<200",mc,PlottingSetup::luminosity);
383
384 FullZ->SetLineColor(TColor::GetColor("#01DF01"));
385 GenLL->SetLineColor(TColor::GetColor("#FF4000"));
386
387 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
388 leg->SetFillColor(kWhite);
389 leg->AddEntry(FullZ,"gen Z mass","l");
390 leg->AddEntry(GenLL,"gen m_{ll}","l");
391
392 FullZ->Draw("histo");
393 GenLL->Draw("same,histo");
394 leg->SetHeader("DY MC:");
395 leg->Draw("same,histo");
396 DrawMCPrelim();
397
398 CompleteSave(can,"PhotonStudies/GenPhotons/CompareZmassToFinalStateLeptons");
399 delete can;
400 }
401
402
403 void GenPhotons::NumberOfPhotonsPerEvent() {
404 TCanvas *can = new TCanvas("can","can");
405 can->SetLogy(1);
406
407 TH1F *FSR = PhotonSamples.Draw("FSR","genFSRNparticles" ,11,-0.5,10.5,"N(#gamma)", "events", BaseCut,mc,PlottingSetup::luminosity);
408 TH1F *all = PhotonSamples.Draw("all","genPhotonsNPhotons",11,-0.5,10.5,"N(#gamma)", "events", BaseCut,mc,PlottingSetup::luminosity);
409
410 FSR->SetLineColor(TColor::GetColor("#01DF01"));
411 all->SetLineColor(TColor::GetColor("#FF4000"));
412
413 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
414 leg->SetFillColor(kWhite);
415 leg->AddEntry(FSR,"FSR photons","l");
416 leg->AddEntry(all,"all photons","l");
417
418 FSR->Draw("histo");
419 all->Draw("same,histo");
420 leg->SetHeader("DY MC:");
421 leg->Draw("same,histo");
422 DrawMCPrelim();
423
424 CompleteSave(can,"PhotonStudies/GenPhotons/NPhotons");
425
426
427 TH1F *PhotonPt[10];
428 for(int i=0;i<10;i++) {
429 PhotonPt[i] = PhotonSamples.Draw("FSR","genPhotonsPt",25,0,100,"N(#gamma)", "events", FSRcut && TCut(("genFSRNparticles=="+any2string(i)).c_str()),mc,PlottingSetup::luminosity);
430 }
431
432 int DrawCounter=0;
433
434 TLegend *leg2 = make_legend();
435 for(int i=0;i<10;i++) {
436 if(PhotonPt[i]->Integral()>50) {
437 PhotonPt[i]->SetLineColor(DrawCounter+1);
438 leg2->AddEntry(PhotonPt[i],(any2string(i)+" FSR Photons").c_str(),"l");
439 if(DrawCounter) PhotonPt[i]->DrawNormalized("same,hist");
440 else PhotonPt[i]->DrawNormalized("hist");
441 DrawCounter++;
442 }
443 }
444
445 leg2->Draw();
446
447 leg2->SetHeader("DY MC (N_{jets} #geq 0):");
448 DrawMCPrelim();
449
450 CompleteSave(can,"PhotonStudies/GenPhotons/PhotonPtvsNPhotons");
451
452 delete can;
453 }
454
455 void GenPhotons::MakeCharacterizationPlot(string variable, int nbins, float min, float max, string label, string saveas) {
456 TCanvas *can = new TCanvas("can","can");
457 can->SetLogy(1);
458
459 TH1F *dR_FSR = PhotonSamples.Draw("dR_FSR", variable, nbins, min, max, label, "events",BaseCut && FSRcut, mc,PlottingSetup::luminosity);
460 TH1F *dR_nFSR = PhotonSamples.Draw("dR_nFSR", variable, nbins, min, max, label, "events",BaseCut && NoFSRcut, mc,PlottingSetup::luminosity);
461
462 dR_FSR->SetLineColor(TColor::GetColor("#01DF01"));
463 dR_nFSR->SetLineColor(TColor::GetColor("#FF4000"));
464
465 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
466 leg->SetFillColor(kWhite);
467 leg->AddEntry(dR_FSR,"FSR #gamma's","l");
468 leg->AddEntry(dR_nFSR,"non-FSR #gamma's","l");
469
470 if(dR_nFSR->GetMinimum()<dR_FSR->GetMinimum()) dR_FSR->SetMinimum(dR_nFSR->GetMinimum());
471 if(dR_nFSR->GetMaximum()>dR_FSR->GetMaximum()) dR_FSR->SetMaximum(dR_nFSR->GetMaximum());
472
473
474 dR_FSR->Draw("histo");
475 dR_nFSR->Draw("same,histo");
476 leg->SetHeader("DY MC:");
477 leg->Draw("same,histo");
478 DrawMCPrelim();
479
480 CompleteSave(can,"PhotonStudies/GenPhotons/CharacterizingFSRPhotons/"+saveas);
481 delete dR_FSR;
482 delete dR_nFSR;
483 delete can;
484 }
485
486
487 void GenPhotons::CharacterizingFSRPhotons() {
488 MakeCharacterizationPlot("min(genPhotonsdR1,genPhotonsdR2)",100,0,5,"min(#Delta R (#gamma,l_{1}), #Delta R (#gamma,l_{2}))", "MinDR");
489 MakeCharacterizationPlot("genPhotonsPt",100,0,100,"p_{T}^{#gamma}", "PhotonPt");
490 MakeCharacterizationPlot("genPhotonsEta",100,-5,5,"#eta^{#gamma}", "PhotonEta");
491 MakeCharacterizationPlot("genPhotonsPhi",40,-4,4,"#phi^{#gamma}", "PhotonPhi");
492 }
493
494 void GenPhotons::CompareGenJZBDistributions() {
495 TCanvas *can = new TCanvas("can","can");
496 can->SetLogy(1);
497
498 TH1F *dR_FSR = PhotonSamples.Draw("dR_FSR", "genFSRjzbG", 30, -30, 30, "JZB^{gen}", "events",BaseCut && TCut("abs(genFSRjzbG)>0.1"), mc,PlottingSetup::luminosity);
499 TH1F *dR_nFSR = PhotonSamples.Draw("dR_nFSR", "genFSRjzb", 30, -30, 30, "JZB^{gen}", "events",BaseCut && TCut("abs(genFSRjzb)>0.1") , mc,PlottingSetup::luminosity);
500
501 dR_FSR->SetLineColor(TColor::GetColor("#01DF01"));
502 dR_nFSR->SetLineColor(TColor::GetColor("#FF4000"));
503
504 TLegend *leg = new TLegend(0.7,0.7,0.89,0.89);
505 leg->SetFillColor(kWhite);
506 leg->AddEntry(dR_FSR,"With FSR recovery","l");
507 leg->AddEntry(dR_nFSR,"Without FSR recovery","l");
508
509 if(dR_nFSR->GetMinimum()<dR_FSR->GetMinimum()) dR_FSR->SetMinimum(dR_nFSR->GetMinimum());
510 if(dR_nFSR->GetMaximum()>dR_FSR->GetMaximum()) dR_FSR->SetMaximum(dR_nFSR->GetMaximum());
511
512
513 dR_FSR->Draw("histo");
514 dR_nFSR->Draw("same,histo");
515 leg->SetHeader("DY MC:");
516 leg->Draw("same,histo");
517 DrawMCPrelim();
518
519 CompleteSave(can,"PhotonStudies/GenPhotons/GenJZBDistributions");
520 delete dR_FSR;
521 delete dR_nFSR;
522 delete can;
523 }
524
525 void GenPhotons::dR2DPlots() {
526 TCanvas *can = new TCanvas("can","can",1000,500);
527 can->Divide(2,1);
528 can->cd(1);
529
530 vector<float> binX, binY;
531 for(int i=0;i<=31;i++) {
532 binX.push_back(i*0.1);
533 binY.push_back(i*0.1);
534 }
535
536 TH2F *dR_FSR = PhotonSamples.Draw("dR_FSR", "genPhotonsdR1:genPhotonsdR2", binX,binY, "#Delta R (#gamma^{FSR},l_{1})","#Delta R (#gamma^{FSR},l_{2})",BaseCut && FSRcut ,mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
537 TH2F *dR_nFSR = PhotonSamples.Draw("dR_nFSR", "genPhotonsdR1:genPhotonsdR2", binX,binY, "#Delta R (#gamma^{non-FSR},l_{1})","#Delta R (#gamma^{non-FSR},l_{2})",BaseCut && NoFSRcut ,mc,PlottingSetup::luminosity, PhotonSamples.FindSample("o"),false);
538
539 can->cd(1);
540 dR_FSR->Draw("COLZ");
541 DrawMCPrelim();
542
543 can->cd(2);
544 dR_nFSR->Draw("COLZ");
545 DrawMCPrelim();
546
547 CompleteSave(can,"PhotonStudies/GenPhotons/dR_in_2D");
548 delete dR_FSR;
549 delete dR_nFSR;
550 delete can;
551 }
552
553
554 void GenPhotons::EfficiencyPurity() {
555 TCanvas *can = new TCanvas("can","can");
556 vector<float> bindR, binPt;
557 for(int i=0;i<=100;i++) bindR.push_back(i*0.05);
558 binPt.push_back(0);binPt.push_back(10);binPt.push_back(50);binPt.push_back(100);binPt.push_back(1000);binPt.push_back(1010);
559 // binPt.push_back(0);binPt.push_back(1000);binPt.push_back(1001);
560
561
562 TGraph *purity[binPt.size()];
563 TGraph *efficiency[binPt.size()];
564 TGraph *purity_n_efficiency[binPt.size()];
565 TH1F *FSR[binPt.size()];
566 TH1F *Any[binPt.size()];
567 for(int i=1;i<binPt.size();i++) {
568 //do this for each pt range
569 float ptlow=binPt[i-1];
570 float pthi =binPt[i];
571 stringstream ptcut;
572 ptcut << "genPhotonsPt>" << ptlow << " && genPhotonsPt<" << pthi << " && min(genPhotonsdR1,genPhotonsdR2)<5";
573
574 FSR[i-1] = PhotonSamples.Draw("FSR", "min(genPhotonsdR1,genPhotonsdR2)", bindR,"min DR","events",TCut(ptcut.str().c_str()) && BaseCut && FSRcut ,mc,PlottingSetup::luminosity);
575 Any[i-1] = PhotonSamples.Draw("Any", "min(genPhotonsdR1,genPhotonsdR2)", bindR,"min DR","events",TCut(ptcut.str().c_str()) && BaseCut ,mc,PlottingSetup::luminosity);
576
577 float NPhotons=0;
578 float NFSRPhotons=0;
579 float totalNFSRphotons=0;
580
581 for(int k=1;k<FSR[i-1]->GetNbinsX();k++) totalNFSRphotons+=FSR[i-1]->GetBinContent(k);
582 purity[i-1]=new TGraph(FSR[i-1]->GetNbinsX());
583 efficiency[i-1]=new TGraph(FSR[i-1]->GetNbinsX());
584 purity_n_efficiency[i-1]=new TGraph(FSR[i-1]->GetNbinsX());
585 for(int j=1;j<=FSR[i-1]->GetNbinsX();j++) {
586 NPhotons+=(int)Any[i-1]->GetBinContent(j);
587 NFSRPhotons+=FSR[i-1]->GetBinContent(j);
588 // cout << " ::::::::" << j << " : " << NPhotons << " : " << NFSRPhotons << " : " << totalNFSRphotons << endl;
589 if(NPhotons>0) purity[i-1]->SetPoint(j-1,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),(float)NFSRPhotons/NPhotons);
590 else purity[i-1]->SetPoint(j-1,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),-1);
591 if(totalNFSRphotons>0) efficiency[i-1]->SetPoint(j,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),(float)NFSRPhotons/totalNFSRphotons);
592 else efficiency[i-1]->SetPoint(j-1,FSR[i-1]->GetXaxis()->GetBinCenter(j)+FSR[i-1]->GetBinWidth(j),-1);
593 if(totalNFSRphotons>0&&NPhotons>0) purity_n_efficiency[i-1]->SetPoint(j-1,(float)NFSRPhotons/totalNFSRphotons,(float)NFSRPhotons/NPhotons);
594 }
595 purity[i-1]->GetXaxis()->SetTitle("min(#Delta R(#gamma,l_{1}), #Delta R(#gamma,_{2}))");
596 purity[i-1]->GetXaxis()->CenterTitle();
597 purity[i-1]->GetYaxis()->SetTitle("purity");
598 purity[i-1]->GetYaxis()->CenterTitle();
599
600 efficiency[i-1]->GetXaxis()->SetTitle("min(#Delta R(#gamma,l_{1}), #Delta R(#gamma,_{2}))");
601 efficiency[i-1]->GetXaxis()->CenterTitle();
602 efficiency[i-1]->GetYaxis()->SetTitle("efficiency");
603 efficiency[i-1]->GetYaxis()->CenterTitle();
604
605 purity_n_efficiency[i-1]->GetXaxis()->SetTitle("efficiency");
606 purity_n_efficiency[i-1]->GetXaxis()->CenterTitle();
607 purity_n_efficiency[i-1]->GetYaxis()->SetTitle("purity");
608 purity_n_efficiency[i-1]->GetYaxis()->CenterTitle();
609 }
610
611 TLegend *leg = make_legend();
612
613
614 for(int i=0;i<binPt.size()-2;i++) {
615 stringstream description;
616 description << binPt[i] << " < p_{T}^{#gamma} < " << binPt[i+1];
617 purity[i]->SetLineColor(i+1);
618 purity_n_efficiency[i]->SetLineColor(i+1);
619 efficiency[i]->SetLineColor(i+1);
620 leg->AddEntry(purity[i],description.str().c_str(),"l");
621 }
622
623 for(int i=0;i<binPt.size()-2;i++) {
624 if(i==0) purity[i]->Draw("AC");
625 else purity[i]->Draw("C");
626 }
627 leg->Draw();
628 CompleteSave(can,"PhotonStudies/GenPhotons/Purity");
629
630 for(int i=0;i<binPt.size()-2;i++) {
631 if(i==0) efficiency[i]->Draw("AC");
632 else efficiency[i]->Draw("C");
633 }
634 leg->Draw();
635 CompleteSave(can,"PhotonStudies/GenPhotons/Efficiency");
636
637 for(int i=0;i<binPt.size()-1;i++) {
638 if(i==0) purity_n_efficiency[i]->Draw("AC");
639 else purity_n_efficiency[i]->Draw("C");
640 }
641 leg->SetX2(0.8);
642 leg->SetX1(0.65);
643 leg->SetY1(0.1);
644 leg->SetY2(0.6);
645 leg->Draw();
646 CompleteSave(can,"PhotonStudies/GenPhotons/Purity_n_efficiency");
647 }
648
649
650 void GenPhotons::GenLevelStudies() {
651 TCut essential_bkp = essentialcut;
652 essentialcut=TCut("");
653
654 CompareZmassToFinalStateLeptons();
655 NumberOfPhotonsPerEvent();
656 CharacterizingFSRPhotons();
657 CompareGenJZBDistributions();
658
659 dR2DPlots();
660
661 EfficiencyPurity();
662
663 essentialcut=essential_bkp;
664 }
665
666 void InitializePhotonSamples() {
667 float ZJetsCrossSection = 3532.8;
668 float LowZJetsCrossSection = 11050*0.069*1.15; // LO xs * filter eff * k-factor (same as ZJets)
669
670 PhotonSamples.AddSample("/shome/buchmann/ntuples/MC8tev/PhotonStudies/Skim3genJets_DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball-Summer12_DR53X-PU_S10_START53_V7A-v1.root","Z+Jets",-30346766,ZJetsCrossSection,false,false,1,kYellow);
671 PhotonSamples.AddSample("/shome/buchmann/ntuples/MC8tev/PhotonStudies/Skim3genJets_DYJetsToLL_M-10To50filter_8TeV-madgraph-Summer12_DR53X-PU_S10_START53_V7A-v1.root","Z+Jets",-6955271,LowZJetsCrossSection,false,false,1,kYellow);
672
673 write_info(__FUNCTION__,"Photon samples have been initialized!");
674 PhotonSamples.ListSamples();
675
676 GenPhotons::FSRcut = TCut("genPhotonsIsFSR");
677 GenPhotons::NoFSRcut = TCut("!genPhotonsIsFSR");
678 GenPhotons::BaseCut = TCut("genNjets>=3 && genPhotonsPt > 5 && NgenLeps>0");
679 }
680
681 void FSRstudy() {
682 InitializePhotonSamples();
683
684 // GenPhotons::GenLevelStudies();
685 RecoPhotons::RecoLevelStudies();
686 write_info(__FUNCTION__,"Please change JZBAnalysis photon dR cuts to 0.1 and 0.3 instead of 0.1 and 0.5 - there's too much crap coming in between .3 and .5");
687 }