ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/FSRStudy.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/FSRStudy.C (file contents):
Revision 1.3 by buchmann, Mon Oct 15 22:12:14 2012 UTC vs.
Revision 1.6 by buchmann, Tue Nov 6 17:00:04 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines