ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/Plotting_Functions.C
Revision: 1.68
Committed: Mon Sep 19 14:03:20 2011 UTC (13 years, 7 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.67: +20 -2 lines
Log Message:
Saving the y scale for the mll (ossf) plot, and reusing it for the osof mll plot

File Contents

# User Rev Content
1 buchmann 1.1 #include <iostream>
2     #include <vector>
3     #include <sys/stat.h>
4    
5     #include <TCut.h>
6     #include <TROOT.h>
7     #include <TCanvas.h>
8     #include <TMath.h>
9     #include <TColor.h>
10     #include <TPaveText.h>
11     #include <TRandom.h>
12     #include <TH1.h>
13     #include <TH2.h>
14     #include <TF1.h>
15     #include <TSQLResult.h>
16 buchmann 1.13 #include <TProfile.h>
17 fronga 1.24 #include <TLegendEntry.h>
18 buchmann 1.1
19 buchmann 1.9 //#include "TTbar_stuff.C"
20 buchmann 1.1 using namespace std;
21    
22     using namespace PlottingSetup;
23    
24 buchmann 1.22 void todo() {
25     dout << "My to do list: " << endl;
26 buchmann 1.38 dout << " - ExperimentalModule::Poisson_ratio_plot : Get the second part to work!" << endl;
27 buchmann 1.22 dout << " - update script for limits " << endl;
28     dout << " - get expected and observed limits, get sigma (edit the current table)" << endl;
29 buchmann 1.64 dout << " - Finish up saving to root file (currently deactivated)" << endl;
30     dout << " - Exclusion plots" << endl;
31 buchmann 1.22 }
32    
33 buchmann 1.1 void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result)
34     {
35 buchmann 1.21 TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
36 buchmann 1.17 TH1F *rawJZBeemmMC = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
37     TH1F *rawJZBeemmData = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
38     TH1F *rawJZBemMC = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
39     TH1F *rawJZBemData = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
40 buchmann 1.1 TH1F *rawttbarjzbeemmMC;
41    
42     if(method==doKM) {
43     //we only need this histo for the KM fitting...
44 buchmann 1.17 rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
45 buchmann 1.1 MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
46     DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
47     }
48     else {
49     TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
50     TH1F *reducedData = (TH1F*)rawJZBeemmData->Clone();
51     reducedMC->Add(rawJZBemMC,-1);
52     reducedData->Add(rawJZBemData,-1);
53     //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
54     MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
55     DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
56 buchmann 1.11
57 buchmann 1.1 }
58 buchmann 1.11
59 buchmann 1.1
60     // MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
61     // DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
62 buchmann 1.21 dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
63 buchmann 1.1 result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
64 buchmann 1.21 dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
65 buchmann 1.1 result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
66     }
67    
68     void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
69    
70     TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
71    
72     TH1F *datahistoOSSF = allsamples.Draw("datahistoOSSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&cutnJets&&basiccut,data,luminosity);
73     THStack mcstackOSSF = allsamples.DrawStack("mcstackOSSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&cutnJets&&basiccut,mc,luminosity);
74 fronga 1.24 TH1F *datahistoOSOF = allsamples.Draw("datahistoOSOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&cutnJets&&basiccut,data,luminosity);
75 buchmann 1.1
76     if(logscale) ckin->SetLogy(1);
77 buchmann 1.17 datahistoOSSF->SetMarkerSize(DataMarkerSize);
78 buchmann 1.1 datahistoOSSF->GetXaxis()->SetTitle(xlabel.c_str());
79     datahistoOSSF->GetXaxis()->CenterTitle();
80     datahistoOSSF->GetYaxis()->SetTitle("events");
81     datahistoOSSF->GetYaxis()->CenterTitle();
82 buchmann 1.17 datahistoOSOF->SetMarkerSize(DataMarkerSize);
83     datahistoOSSF->SetMarkerSize(DataMarkerSize);
84 buchmann 1.1 datahistoOSSF->Draw();
85 fronga 1.24
86 buchmann 1.1 mcstackOSSF.Draw("same");
87     datahistoOSSF->Draw("same");
88 fronga 1.24
89 buchmann 1.49 datahistoOSOF->SetMarkerColor(TColor::GetColor("#FE642E"));
90 fronga 1.24 datahistoOSOF->SetLineColor(kRed);
91 buchmann 1.17 datahistoOSOF->SetMarkerStyle(21);
92 buchmann 1.1 datahistoOSOF->Draw("same");
93 fronga 1.24
94     // Try to re-arrange legend...
95     TLegend *bgleg = allsamples.allbglegend("",datahistoOSSF);
96     TLegend *kinleg = make_legend();
97 fronga 1.41 kinleg->AddEntry(datahistoOSSF,"SF (data)","p");
98     kinleg->AddEntry(datahistoOSOF,"OF (data)","p");\
99 fronga 1.24 TIter next(bgleg->GetListOfPrimitives());
100     TObject* obj;
101     // Copy the nice bkgd legend skipping the "data"
102     while ( obj = next() )
103     if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
104     kinleg->GetListOfPrimitives()->Add(obj);
105    
106 buchmann 1.1 kinleg->Draw();
107     CompleteSave(ckin,"kin/mll_ossf_osof_distribution");
108 buchmann 1.18
109     delete datahistoOSOF;
110     delete datahistoOSSF;
111 buchmann 1.34 delete ckin;
112 buchmann 1.1 }
113    
114    
115 fronga 1.35 void draw_ratio_plot(TH1* hdata, THStack& hmc, float ymin=0.5, float ymax=1.5) {
116    
117     // Make a histogram from stack
118     TIter next(hmc.GetHists());
119     TObject* obj;
120     TH1* hratio = NULL;
121     while ( obj = next() ) {
122     if ( !hratio ) {
123     hratio = (TH1*)obj->Clone();
124     hratio->SetName("hratio");
125     } else hratio->Add( (TH1*)obj );
126     }
127     hratio->Divide(hdata);
128     hratio->SetMaximum(ymax);
129     hratio->SetMinimum(ymin);
130     hratio->SetMarkerStyle(2);
131     hratio->SetLineWidth(1);
132    
133     TPad* rpad = new TPad("rpad","",0.15,0.7,0.4,0.9);
134     rpad->Draw();
135     rpad->cd();
136     hratio->Draw("e1x0");
137    
138     TF1* oneline = new TF1("","1.0",0,1000);
139     oneline->SetLineColor(kBlue);
140     oneline->SetLineStyle(1);
141     oneline->SetLineWidth(1);
142     oneline->Draw("same");
143    
144     }
145    
146 buchmann 1.68 float lastrange_min=0;
147     float lastrange_max=0;
148    
149 fronga 1.25 void make_kin_plot(string variable, int nbins, float min, float max, bool logscale,
150 buchmann 1.68 string xlabel, string filename, bool isPF=true, bool plotratio=false, bool loadlastminmax=false ) {
151 buchmann 1.1 // TCut basiccut("(pfJetGoodNum>=2&&pfJetGoodID[0])&&(pfJetGoodNum>=2&&pfJetGoodID[1])&&(passed_triggers||!is_data)");
152     TCut ibasiccut=basiccut;
153    
154     if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
155     //Step 1: Adapt the variable (if we're dealing with PF we need to adapt the variable!)
156     if(isPF) {
157     if(variable=="mll") variable="pfmll[0]";
158     if(variable=="jetpt[0]") variable="pfJetGoodPt[0]";
159     if(variable=="jeteta[0]") variable="pfJetGoodEta[0]";
160     if(variable=="pt") variable="pfpt[0]";
161     if(variable=="pt1") variable="pfpt1[0]";
162 buchmann 1.19 if(variable=="pt2") variable="pfpt2[0]";
163 buchmann 1.1 if(variable=="eta1") variable="pfeta1[0]";
164     if(variable=="jzb[1]") variable="pfjzb[0]";
165     //if(variable=="pfJetGoodNum") variable="pfJetGoodNum"; // pointless.
166     }
167    
168     //Step 2: Refine the cut
169     TCut cut;
170     cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
171     if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
172     if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
173     if(filename=="mll") cut=cutOSSF&&cutnJets&&ibasiccut;
174 buchmann 1.18 if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
175 buchmann 1.63 if(filename=="mll_osof") cut=cutOSOF&&cutnJets&&ibasiccut;
176 buchmann 1.18 if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
177 buchmann 1.17 if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
178 buchmann 1.18 if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
179     if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
180 buchmann 1.59 if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
181     if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
182 buchmann 1.1
183 fronga 1.25 TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
184     ckin->SetLogy(logscale);
185 buchmann 1.1 TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
186 buchmann 1.17 datahisto->SetMarkerSize(DataMarkerSize);
187 buchmann 1.1 THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
188     if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
189     if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
190     if(filename=="mll_inclusive") datahisto->SetMinimum(1);
191 buchmann 1.67 if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
192     if(filename=="mll_osof") datahisto->SetMinimum(9);
193 buchmann 1.68
194 buchmann 1.1 datahisto->Draw("e1");
195 buchmann 1.68 ckin->Update();
196     if(loadlastminmax) {
197     datahisto->SetMinimum(lastrange_min);
198     datahisto->SetMaximum(lastrange_max);
199     if(logscale) {
200     datahisto->SetMinimum(pow(10,lastrange_min));
201     datahisto->SetMaximum(pow(10,lastrange_max));
202     }
203     }
204     lastrange_min=ckin->GetUymin();
205     lastrange_max=ckin->GetUymax();
206    
207 buchmann 1.1 mcstack.Draw("same");
208     datahisto->Draw("same,e1");
209     TLegend *kinleg = allsamples.allbglegend();
210     kinleg->Draw();
211 buchmann 1.68 if(filename=="mll_osof") kinleg->SetHeader("OSOF");
212     if(filename=="mll") kinleg->SetHeader("OSSF");
213 buchmann 1.16 TText* write_cut = write_cut_on_canvas(decipher_cut(cut,basicqualitycut));
214 buchmann 1.1 write_cut->Draw();
215     TText* write_variable = write_text(0.99,0.01,variable);
216     write_variable->SetTextAlign(31);
217     write_variable->SetTextSize(0.02);
218 fronga 1.35
219 buchmann 1.1 if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF");
220     else CompleteSave(ckin,"kin/"+filename);
221 buchmann 1.67 if ( plotratio ) {
222     draw_ratio_plot( datahisto, mcstack );
223     if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF_withratio");
224     else CompleteSave(ckin,"kin/"+filename+"_withratio");
225     }
226 buchmann 1.1 datahisto->Delete();
227 buchmann 1.47 delete ckin;
228 buchmann 1.1 }
229    
230     void do_kinematic_plots(bool doPF=false)
231     {
232     bool dolog=true;
233     bool nolog=false;
234 buchmann 1.65 make_kin_plot("mll",21,55,160,dolog,"m_{ll} [GeV]","mll",doPF,true);
235 buchmann 1.68 make_kin_plot("mll",21,55,160,dolog,"m_{ll} [GeV]","mll_osof",doPF,false,true);
236 buchmann 1.65 make_kin_plot("mll",21,55,160,dolog,"m_{ll} [GeV]","mll_ee",doPF);
237     make_kin_plot("mll",21,55,160,dolog,"m_{ll} [GeV]","mll_mm",doPF);
238     make_kin_plot("mll",105,55,160,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
239     make_kin_plot("mll",105,55,160,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
240     make_kin_plot("mll",105,55,160,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
241     make_kin_plot("mll",305,55,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
242 fronga 1.25 make_kin_plot("jetpt[0]",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
243     make_kin_plot("jeteta[0]",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
244     make_kin_plot("pt",50,0,200,dolog,"Z p_{T} [GeV]","Zpt",doPF);
245     make_kin_plot("pt1",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
246     make_kin_plot("pt2",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
247     make_kin_plot("eta1",40,-5,5,nolog,"#eta_{l}","eta",doPF);
248     make_kin_plot("jzb[1]",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
249     make_kin_plot("pfJetGoodNum",8,0.5,8.5,dolog,"nJets","nJets",doPF);
250     make_kin_plot("pfJetGoodNum",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
251 buchmann 1.65 make_special_mll_plot(21,55,160,dolog,"m_{ll} [GeV]");
252 buchmann 1.1 }
253    
254 fronga 1.25 void make_comp_plot( string var, string xlabel, string filename, string mcjzb, string datajzb,
255     int nbins, float xmin, float xmax, bool log,
256 fronga 1.26 float ymin=0, float ymax=0, bool leftJustified=false ) {
257 buchmann 1.60 TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
258     if(weightbackup==TCut("1.0")||weightbackup==TCut("1")) write_warning(__FUNCTION__,"WATCH OUT THE WEIGHT HAS POSSIBLY NOT BEEN RESET!!!! PLEASE CHANGE LINE "+any2string(__LINE__));
259     if(var=="numVtx") cutWeight=TCut("1.0");
260 fronga 1.25 TCut jzbData[]= { TCut(TString(datajzb+">100")),TCut(TString(datajzb+"<-100")) };
261     TCut jzbMC[] = { TCut(TString(mcjzb+">100")),TCut(TString(mcjzb+"<-100")) };
262    
263 buchmann 1.64 if(!RestrictToMassPeak) write_warning(__FUNCTION__,"Watch out, once we go offpeak this function needs rewriting!");//need to redefine the regions: only SF and OF remain
264 fronga 1.25 string sRegions[] = { "SFZP","OFZP","SFSB","OFSB" };
265     TCut kRegions[] = { cutOSSF&&cutnJets&&cutmass, cutOSOF&&cutnJets&&cutmass,
266     cutOSSF&&cutnJets&&sidebandcut, cutOSOF&&cutnJets&&sidebandcut };
267    
268     for ( int iregion=0; iregion<4; ++iregion )
269     for ( int ijzb=0; ijzb<2; ++ijzb ) {
270     TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
271     ccomp->SetLogy(log);
272     TH1F *datahisto = allsamples.Draw("datahisto", var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
273 buchmann 1.56 TH1F *lm4histo = signalsamples.Draw("lm4histo", var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
274 fronga 1.25 THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb], mc, luminosity);
275     datahisto->SetMarkerSize(DataMarkerSize);
276     if (ymax>ymin) datahisto->SetMaximum(ymax);
277 buchmann 1.56 lm4histo->SetLineStyle(2);
278 fronga 1.25 datahisto->Draw("e1");
279     mcstack.Draw("same");
280     datahisto->Draw("same,e1");
281 buchmann 1.57 // lm4histo->Draw("hist,same");
282 fronga 1.25 TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
283 fronga 1.26 if ( leftJustified ) {
284     Float_t w = kinleg->GetX2()-kinleg->GetX1();
285     kinleg->SetX1(0.2);
286     kinleg->SetX2(0.2+w);
287     }
288 buchmann 1.57 // kinleg->AddEntry(lm4histo,"LM4","l");
289 fronga 1.25 kinleg->Draw();
290     TText* write_variable = write_text(0.99,0.01,var);
291     write_variable->SetTextAlign(31);
292     write_variable->SetTextSize(0.02);
293     ccomp->RedrawAxis();
294 buchmann 1.52 CompleteSave(ccomp,"compare/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
295 buchmann 1.27 delete datahisto;
296 buchmann 1.34 delete ccomp;
297 buchmann 1.56 delete lm4histo;
298 fronga 1.25 }
299 buchmann 1.60 cutWeight=weightbackup;
300 fronga 1.25 }
301    
302    
303     void region_comparison_plots(string mcjzb, string datajzb) {
304     dout << "Creating comparison plots for signal and control regions" << endl;
305     // Compare a few quantities in the signal region and all 7 control regions
306 buchmann 1.55
307     switch_overunderflow(true); // switching overflow/underflow bins on
308    
309 buchmann 1.52 make_comp_plot("mll","m_{ll} [GeV]","mll",mcjzb,datajzb,30,50,170,false,0,16.);
310     make_comp_plot("met[4]","pfMET [GeV]","pfmet",mcjzb,datajzb,18,0,360,false,0,16.);
311     make_comp_plot("pfJetGoodNum","#(jets)","njets",mcjzb,datajzb,10,0,10, false,0,35.);
312     make_comp_plot("pt","Z p_{T} [GeV]","Zpt",mcjzb,datajzb,26,0,525,false,0.,21.);
313 buchmann 1.60 make_comp_plot("numVtx","#(prim. vertices)","nvtx",mcjzb,datajzb,20,0.,20.,false,0,16.);
314 buchmann 1.52 make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
315     make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
316 fronga 1.25
317 buchmann 1.55 switch_overunderflow(false); // switching overflow/underflow bins off
318 fronga 1.25 }
319    
320 buchmann 1.1 void do_kinematic_PF_plots()
321     {
322     do_kinematic_plots(true);
323     }
324    
325 buchmann 1.11 void signal_bg_comparison()
326 buchmann 1.1 {
327 buchmann 1.11 TCanvas *can = new TCanvas("can","Signal Background Comparison Canvas");
328 fronga 1.45 can->SetLogy(1);
329    
330     int sbg_nbins=130;
331     float sbg_min=-500; //-110;
332     float sbg_max=800; //jzbHigh;
333 buchmann 1.44
334 buchmann 1.58 float simulatedlumi=luminosity;//in pb please - adjust to your likings
335 buchmann 1.44
336     TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
337     TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
338     TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
339 buchmann 1.1
340     JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
341     JZBplotZJETs->SetFillColor(allsamples.GetColor("DY"));
342     JZBplotZJETs->SetLineColor(kBlack);
343     JZBplotLM4->SetLineStyle(2);
344 fronga 1.45 JZBplotZJETs->SetMaximum(JZBplotZJETs->GetMaximum()*5);
345     JZBplotZJETs->SetMinimum(1);
346    
347     JZBplotTtbar->SetMaximum(JZBplotZJETs->GetMaximum());
348     JZBplotTtbar->SetMinimum(0.01);
349     JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
350     JZBplotTtbar->DrawClone("histo");
351     JZBplotZJETs->Draw("histo,same");
352     JZBplotTtbar->SetFillColor(0);
353     JZBplotTtbar->DrawClone("histo,same");
354     JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
355 buchmann 1.44 JZBplotLM4->Draw("histo,same");
356 fronga 1.45
357    
358     TLegend *signal_bg_comparison_leg2 = make_legend("",0.55,0.75,false);
359 buchmann 1.1 signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
360     signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
361     signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
362     signal_bg_comparison_leg2->Draw();
363 fronga 1.53 DrawMCPrelim(simulatedlumi);
364 buchmann 1.39 CompleteSave(can,"jzb_bg_vs_signal_distribution");
365 buchmann 1.31
366 fronga 1.45 // Define illustrative set of SMS points
367     TCut kSMS1("MassGlu==250&&MassLSP==75");
368     TCut kSMS2("MassGlu==800&&MassLSP==200");
369     TCut kSMS3("MassGlu==1050&&MassLSP==850");
370     TCut kSMS4("MassGlu==1200&&MassLSP==100");
371 buchmann 1.47 TH1F *JZBplotSMS1 = scansample.Draw("JZBplotSMS1",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS1,mc,simulatedlumi,scansample.FindSample("t"));
372 fronga 1.45 JZBplotSMS1->Scale(JZBplotLM4->Integral()/JZBplotSMS1->Integral());
373 buchmann 1.47
374     TH1F *JZBplotSMS2 = scansample.Draw("JZBplotSMS2",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS2,mc,simulatedlumi,scansample.FindSample("t"));
375 buchmann 1.31 JZBplotSMS2->Scale(JZBplotLM4->Integral()/JZBplotSMS2->Integral());
376 buchmann 1.47
377     TH1F *JZBplotSMS3 = scansample.Draw("JZBplotSMS3",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS3,mc,simulatedlumi,scansample.FindSample("t"));
378 buchmann 1.31 JZBplotSMS3->Scale(JZBplotLM4->Integral()/JZBplotSMS3->Integral());
379    
380 buchmann 1.47 TH1F *JZBplotSMS4 = scansample.Draw("JZBplotSMS4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS4,mc,simulatedlumi,scansample.FindSample("t"));
381 buchmann 1.31 JZBplotSMS4->Scale(JZBplotLM4->Integral()/JZBplotSMS4->Integral());
382 fronga 1.45
383     // Draw all plots overlaid
384     JZBplotTtbar->SetMaximum(JZBplotZJETs->GetMaximum());
385     JZBplotTtbar->SetMinimum(0.01);
386     JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
387     JZBplotTtbar->DrawClone("histo");
388     JZBplotZJETs->Draw("histo,same");
389     JZBplotTtbar->SetFillColor(0);
390     JZBplotTtbar->DrawClone("histo,same");
391     JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
392    
393     JZBplotSMS1->SetLineColor(kRed+1);
394     JZBplotSMS2->SetLineColor(kBlue+1);
395     JZBplotSMS3->SetLineColor(kRed+1);
396     JZBplotSMS4->SetLineColor(kBlue+1);
397 buchmann 1.31 JZBplotSMS3->SetLineStyle(2);
398     JZBplotSMS4->SetLineStyle(2);
399    
400     JZBplotSMS1->Draw("histo,same");
401     JZBplotSMS2->Draw("histo,same");
402     JZBplotSMS3->Draw("histo,same");
403     JZBplotSMS4->Draw("histo,same");
404 buchmann 1.50 JZBplotLM4->SetLineColor(kGreen);JZBplotLM4->Draw("histo,same");
405 fronga 1.45 TLegend *signal_bg_comparison_leg6 = make_legend("",0.55,0.55,false);
406 buchmann 1.31 signal_bg_comparison_leg6->AddEntry(JZBplotZJETs,"Z+Jets","f");
407     signal_bg_comparison_leg6->AddEntry(JZBplotTtbar,"t#bar{t}","f");
408     signal_bg_comparison_leg6->AddEntry(JZBplotSMS1,"","");
409 fronga 1.45 signal_bg_comparison_leg6->AddEntry(JZBplotSMS1,"SMS parameters","");
410     signal_bg_comparison_leg6->AddEntry(JZBplotSMS1,"(250,75) [GeV]","f");
411     signal_bg_comparison_leg6->AddEntry(JZBplotSMS2,"(800,200) [GeV]","f");
412     signal_bg_comparison_leg6->AddEntry(JZBplotSMS3,"(1050,850) [GeV]","f");
413     signal_bg_comparison_leg6->AddEntry(JZBplotSMS4,"(1200,100) [GeV]","f");
414 buchmann 1.49 signal_bg_comparison_leg6->AddEntry(JZBplotLM4,"LM4","f");
415 buchmann 1.31 signal_bg_comparison_leg6->Draw();
416 buchmann 1.47 DrawMCPrelim(simulatedlumi);
417 buchmann 1.31 CompleteSave(can,"jzb_bg_vs_signal_distribution_SMS__summary");
418 buchmann 1.1 }
419    
420 buchmann 1.9 vector<TF1*> do_cb_fit_to_plot(TH1F *histo, float Sigma, float doingfitacrosstheboard=false) {
421     TF1 *BpredFunc = new TF1("BpredFunc",InvCrystalBall,0,1000,5);
422 buchmann 1.1 BpredFunc->SetParameter(0,histo->GetBinContent(1));
423 buchmann 1.6 if(doingfitacrosstheboard) BpredFunc->SetParameter(0,histo->GetMaximum());
424 buchmann 1.1 BpredFunc->SetParameter(1,0.);
425     if(method==1) BpredFunc->SetParameter(2,10*Sigma);//KM
426     else BpredFunc->SetParameter(2,Sigma);//Gaussian based methods
427     if(method==-99) BpredFunc->SetParameter(2,2.0*Sigma);//Kostas
428     BpredFunc->SetParameter(3,1.8);
429     BpredFunc->SetParameter(4,2.5);
430 buchmann 1.11 histo->Fit(BpredFunc,"QN0");
431 buchmann 1.1 BpredFunc->SetLineColor(kBlue);
432    
433 buchmann 1.9 TF1 *BpredFuncP = new TF1("BpredFuncP",InvCrystalBallP,-1000,histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()),5);
434     TF1 *BpredFuncN = new TF1("BpredFuncN",InvCrystalBallN,-1000,histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()),5);
435 buchmann 1.1
436     BpredFuncP->SetParameters(BpredFunc->GetParameters());
437     BpredFuncP->SetLineColor(kBlue);
438     BpredFuncP->SetLineStyle(2);
439    
440     BpredFuncN->SetParameters(BpredFunc->GetParameters());
441     BpredFuncN->SetLineColor(kBlue);
442     BpredFuncN->SetLineStyle(2);
443 buchmann 1.9
444     vector<TF1*> functions;
445     functions.push_back(BpredFuncN);
446     functions.push_back(BpredFunc);
447     functions.push_back(BpredFuncP);
448     return functions;
449 buchmann 1.1 }
450 buchmann 1.38
451    
452     TF1* do_logpar_fit_to_plot(TH1F *osof) {
453     TCanvas *logpar_fit_can = new TCanvas("logpar_fit_can","Fit canvas for LogPar");
454 buchmann 1.39 TF1 *logparfunc = new TF1("logparfunc",LogParabola,0,300,3);
455 buchmann 1.38 TF1 *logparfunc2 = new TF1("logparfunc2",LogParabola,0,(osof->GetXaxis()->GetBinLowEdge(osof->GetNbinsX())+osof->GetXaxis()->GetBinWidth(osof->GetNbinsX())),3);
456     TF1 *logparfuncN = new TF1("logparfuncN",LogParabolaN,0,(osof->GetXaxis()->GetBinLowEdge(osof->GetNbinsX())+osof->GetXaxis()->GetBinWidth(osof->GetNbinsX())),3);
457     TF1 *logparfuncP = new TF1("logparfuncP",LogParabolaP,0,(osof->GetXaxis()->GetBinLowEdge(osof->GetNbinsX())+osof->GetXaxis()->GetBinWidth(osof->GetNbinsX())),3);
458     osof->SetMinimum(0);
459     osof->Fit(logparfunc,"QR");
460     osof->Draw();
461     logparfunc->SetLineWidth(2);
462     logparfunc2->SetParameters(logparfunc->GetParameters());
463     logparfuncN->SetParameters(logparfunc->GetParameters());
464     logparfuncP->SetParameters(logparfunc->GetParameters());
465     stringstream fitinfo;
466     fitinfo << "#Chi^{2} / NDF : " << logparfunc->GetChisquare() << " / " << logparfunc->GetNDF();
467     TText *writefitinfo = write_text(0.8,0.8,fitinfo.str());
468     writefitinfo->SetTextSize(0.03);
469     DrawPrelim();
470     writefitinfo->Draw();
471     logparfunc->Draw("same");
472     logparfunc2->Draw("same");
473     logparfuncN->SetLineStyle(2);
474     logparfuncP->SetLineStyle(2);
475     logparfuncN->Draw("same");
476     logparfuncP->Draw("same");
477 buchmann 1.39 CompleteSave(logpar_fit_can,"Bpred_Data_LogPar_Fit_To_TTbarPred");
478 buchmann 1.38 delete logpar_fit_can;
479     return logparfunc2;
480     }
481    
482 buchmann 1.42 vector<TF1*> do_extended_fit_to_plot(TH1F *prediction, TH1F *Tprediction, TH1F *ossf, TH1F *osof,int isdata) {
483 buchmann 1.38 /* there are mainly two background contributions: Z+Jets (a) and ttbar (b). So:
484     a) The case is clear - we take the OSSF prediction - OSOF prediction, and fit a crystal ball function to it. We then extract the CB parameters.
485     b) For ttbar, we use the OSOF distribution and look at the [10,100] GeV JZB range, and fit our log parabola. We then extract the LP parameters.
486     Once we have these two components, we use the combined parameters to get the final function and we're done.
487     */
488     //Step 1: take the OSSF prediction - OSOF prediction, and fit a crystal ball function to it
489     TH1F *step1cb = (TH1F*)ossf->Clone("step1cb");
490     step1cb->Add(osof,-1);
491     vector<TF1*> functions = do_cb_fit_to_plot(step1cb,PlottingSetup::JZBPeakWidthData);
492     TF1 *zjetscrystalball = functions[1];
493    
494     //Step 2: use the OSOF distribution and look at the [10,100] GeV JZB range, and fit our log parabola
495 buchmann 1.39 // TH1F *ttbarprediction=(TH1F*)prediction->Clone("ttbarprediction");
496     // ttbarprediction->Add(ossf,-1);//without the Z+Jets estimate, this is really just the ttbar estimate!
497     // the line above is not necessary anymore as we're now looking at a prediction without Z+Jets, and not multiplied with (1.0/3)
498     TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
499     ttbarlogpar->SetParameter(0,1.0/3*ttbarlogpar->GetParameter(0));//correcting for the fact that we didn't multiply with (1.0/3);
500    
501 buchmann 1.38 TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
502     TF1 *ttbarlogparN = new TF1("ttbarlogparN",LogParabolaN,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
503    
504     //and now fuse the two!
505     TF1 *kmlp = new TF1("kmlp", CrystalBallPlusLogParabola, 0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
506     TF1 *kmlpP= new TF1("kmlpP",CrystalBallPlusLogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
507     TF1 *kmlpN= new TF1("kmlpN",CrystalBallPlusLogParabolaN,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
508     double kmlp_pars[10];
509     for(int i=0;i<5;i++) kmlp_pars[i]=zjetscrystalball->GetParameter(i);
510     for(int i=0;i<3;i++) kmlp_pars[5+i]=ttbarlogpar->GetParameter(i);
511     ttbarlogparP->SetParameters(ttbarlogpar->GetParameters());
512     ttbarlogparN->SetParameters(ttbarlogpar->GetParameters());
513     kmlp->SetParameters(kmlp_pars);
514 buchmann 1.39 prediction->Fit(kmlp,"Q");//fitting the final result (done this in the past but kicked it)
515 buchmann 1.62 /*
516     if you want to start from scratch (without the partial fitting and only fitting the whole thing, some good start values could be :
517     // kmlp_pars[0]=2579.38 // get this from the maximum !!!!
518     kmlp_pars[0]=kmlp->GetParameter(0);
519     kmlp_pars[1]=3.6198;
520     kmlp_pars[2]=16.4664;
521     kmlp_pars[3]=1.92253;
522     kmlp_pars[4]=3.56099;
523     kmlp_pars[5]=5.83;
524     kmlp_pars[6]=0.000757479;
525     kmlp_pars[7]=95.6157;
526     kmlp_pars[8]=0;
527     kmlp_pars[9]=0;
528     kmlp->SetParameters(kmlp_pars);
529     */
530    
531 buchmann 1.39 kmlpP->SetParameters(kmlp->GetParameters());
532     kmlpN->SetParameters(kmlp->GetParameters());
533 buchmann 1.38
534     // now that we're done, let's save all of this so we can have a look at it afterwards.
535     TCanvas *can = new TCanvas("can","Prediction Fit Canvas");
536     can->SetLogy(1);
537     prediction->SetMarkerColor(kRed);
538     prediction->Draw();
539    
540     kmlp->SetLineColor(TColor::GetColor("#04B404"));
541     kmlpP->SetLineColor(TColor::GetColor("#04B404"));
542     kmlpN->SetLineColor(TColor::GetColor("#04B404"));
543     kmlp->Draw("same");
544     kmlpN->SetLineStyle(2);
545     kmlpP->SetLineStyle(2);
546     kmlpN->Draw("same");
547     kmlpP->Draw("same");
548    
549     ttbarlogpar->SetLineColor(TColor::GetColor("#CC2EFA"));//purple
550     ttbarlogpar->Draw("same");
551     ttbarlogparP->SetLineColor(TColor::GetColor("#CC2EFA"));//purple
552     ttbarlogparN->SetLineColor(TColor::GetColor("#CC2EFA"));//purple
553     ttbarlogparP->SetLineStyle(2);
554     ttbarlogparN->SetLineStyle(2);
555     ttbarlogparP->Draw("same");
556     ttbarlogparN->Draw("same");
557    
558     functions[0]->Draw("same");functions[1]->Draw("same");functions[2]->Draw("same");
559 buchmann 1.62
560 buchmann 1.38 TLegend *analyticalBpredLEG = make_legend("",0.5,0.55);
561     analyticalBpredLEG->AddEntry(prediction,"predicted","p");
562     analyticalBpredLEG->AddEntry(functions[1],"Crystal Ball fit","l");
563     analyticalBpredLEG->AddEntry(functions[0],"1#sigma Crystal Ball fit","l");
564     analyticalBpredLEG->AddEntry(ttbarlogparN,"TTbar fit","l");
565     analyticalBpredLEG->AddEntry(ttbarlogpar,"1#sigma TTbar fit","l");
566     analyticalBpredLEG->AddEntry(kmlp,"Combined function","l");
567     analyticalBpredLEG->AddEntry(kmlpN,"1#sigma combined function","l");
568     analyticalBpredLEG->Draw("same");
569    
570 buchmann 1.42 if(isdata==0) CompleteSave(can,"MakingOfBpredFunction/Bpred_MC_Analytical_Function_Composition");
571     if(isdata==1) CompleteSave(can,"MakingOfBpredFunction/Bpred_data_Analytical_Function_Composition");
572     if(isdata==2) CompleteSave(can,"MakingOfBpredFunction/Bpred_MCBnS_Analytical_Function_Composition");
573 buchmann 1.38 delete can;
574    
575     //and finally: prep return functions
576     vector<TF1*> return_functions;
577     return_functions.push_back(kmlpN);
578     return_functions.push_back(kmlp);
579     return_functions.push_back(kmlpP);
580    
581     return_functions.push_back(ttbarlogparN);
582     return_functions.push_back(ttbarlogpar);
583     return_functions.push_back(ttbarlogparP);
584    
585     return_functions.push_back(functions[0]);
586     return_functions.push_back(functions[1]);
587     return_functions.push_back(functions[2]);
588    
589     return return_functions;
590     }
591    
592 fronga 1.24 void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, bool is_data, bool overlay_signal = false )
593 buchmann 1.1 {
594     int nbins=100;
595     if(is_data) nbins=50;
596     float low=0;
597     float hi=500;
598    
599 buchmann 1.17 TH1F *RcorrJZBeemm = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity);
600     TH1F *LcorrJZBeemm = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity);
601     TH1F *RcorrJZBem = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity);
602     TH1F *LcorrJZBem = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity);
603 buchmann 1.1
604 buchmann 1.17 TH1F *RcorrJZBSBem = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity);
605     TH1F *LcorrJZBSBem = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity);
606 buchmann 1.13
607 buchmann 1.17 TH1F *RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity);
608     TH1F *LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity);
609 buchmann 1.13
610 buchmann 1.17 TH1F *lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM4"));
611 buchmann 1.13
612 buchmann 1.64 if(!RestrictToMassPeak) write_warning(__FUNCTION__,"Watch out, once we go offpeak this function needs rewriting!"); // the TH1F Bpred below needs to be adapted (remove "1/3" and SBs)
613    
614 buchmann 1.17 TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
615 fronga 1.24 Bpred->Add(RcorrJZBem,1.0/3.);
616     Bpred->Add(LcorrJZBem,-1.0/3.);
617     Bpred->Add(RcorrJZBSBem,1.0/3.);
618     Bpred->Add(LcorrJZBSBem,-1.0/3.);
619     Bpred->Add(RcorrJZBSBeemm,1.0/3.);
620     Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
621 buchmann 1.39
622     TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
623     Tpred->Add(LcorrJZBem,-1.0);
624     Tpred->Add(RcorrJZBSBem,1.0);
625     Tpred->Add(LcorrJZBSBem,-1.0);
626     Tpred->Add(RcorrJZBSBeemm,1.0);
627     Tpred->Add(LcorrJZBSBeemm,-1.0);
628    
629 buchmann 1.1 globalcanvas->cd();
630     globalcanvas->SetLogy(1);
631 fronga 1.24
632     RcorrJZBeemm->SetMarkerStyle(20);
633     RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
634 fronga 1.46 RcorrJZBeemm->SetMinimum(0.1);
635 fronga 1.24 RcorrJZBeemm->Draw("e1x0");
636    
637 buchmann 1.1 Bpred->SetLineColor(kRed);
638     Bpred->SetStats(0);
639 fronga 1.24 Bpred->Draw("hist,same");
640    
641     if ( overlay_signal ) {
642     lm4RcorrJZBeemm->SetLineColor(TColor::GetColor("#088A08"));
643     lm4RcorrJZBeemm->Draw("histo,same");
644     }
645 buchmann 1.17 RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
646 buchmann 1.13
647 fronga 1.24 TLegend *legBpred = make_legend("",0.6,0.55);
648 buchmann 1.1 if(is_data)
649     {
650 buchmann 1.42 vector<TF1*> analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
651 buchmann 1.38 globalcanvas->cd();
652     analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
653 buchmann 1.47 RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
654 fronga 1.24 legBpred->AddEntry(RcorrJZBeemm,"observed","p");
655     legBpred->AddEntry(Bpred,"predicted","l");
656 buchmann 1.38 legBpred->AddEntry(analytical_function[1],"predicted fit","l");
657     legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
658 fronga 1.24 if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
659 buchmann 1.1 legBpred->Draw();
660     CompleteSave(globalcanvas,"Bpred_Data");
661     }
662     else {
663 buchmann 1.47 RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
664 fronga 1.24 legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
665     legBpred->AddEntry(Bpred,"MC predicted","l");
666 buchmann 1.29 legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
667 buchmann 1.28 // legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
668 fronga 1.24 if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
669 buchmann 1.1 legBpred->Draw();
670 buchmann 1.13
671 buchmann 1.1 CompleteSave(globalcanvas,"Bpred_MC");
672     }
673 buchmann 1.64 if(!RestrictToMassPeak) write_warning(__FUNCTION__,"Watch out, once we go offpeak this second part is superfluous (comparison of SB estimates and OF estimate)!");
674 buchmann 1.28 TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
675 buchmann 1.13 Bpredem->Add(RcorrJZBem);
676     Bpredem->Add(LcorrJZBem,-1);
677 buchmann 1.28 TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
678 buchmann 1.13 BpredSBem->Add(RcorrJZBSBem);
679     Bpred->Add(LcorrJZBSBem,-1);
680 buchmann 1.28 TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");
681 buchmann 1.17 BpredSBeemm->Add(RcorrJZBSBeemm);
682     BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
683 buchmann 1.13 globalcanvas->cd();
684     globalcanvas->SetLogy(1);
685 fronga 1.24
686     RcorrJZBeemm->SetMarkerStyle(20);
687     RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
688     RcorrJZBeemm->Draw("e1x0");
689     RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
690    
691     Bpredem->SetLineColor(kRed+1);
692 buchmann 1.13 Bpredem->SetStats(0);
693 fronga 1.24 Bpredem->Draw("hist,same");
694    
695     BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
696     BpredSBem->SetLineStyle(2);
697 buchmann 1.13 BpredSBem->Draw("hist,same");
698 fronga 1.24
699     BpredSBeemm->SetLineColor(kBlue+1);
700     BpredSBeemm->SetLineStyle(3);
701 buchmann 1.13 BpredSBeemm->Draw("hist,same");
702 buchmann 1.47 RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
703 fronga 1.24
704 fronga 1.46
705 fronga 1.24 TLegend *legBpredc = make_legend("",0.6,0.55);
706 buchmann 1.13 if(is_data)
707     {
708 fronga 1.24 legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
709     legBpredc->AddEntry(Bpredem,"OFZP","l");
710     legBpredc->AddEntry(BpredSBem,"OFSB","l");
711     legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
712 buchmann 1.13 legBpredc->Draw();
713     CompleteSave(globalcanvas,"Bpred_Data_comparison");
714     }
715     else {
716 fronga 1.24 legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
717     legBpredc->AddEntry(Bpredem,"MC OFZP","l");
718     legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
719     legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
720 buchmann 1.13 legBpredc->Draw();
721     legBpredc->Draw();
722     CompleteSave(globalcanvas,"Bpred_MC_comparison");
723     }
724     delete RcorrJZBeemm;
725     delete LcorrJZBeemm;
726     delete RcorrJZBem;
727     delete LcorrJZBem;
728     delete RcorrJZBSBem;
729     delete LcorrJZBSBem;
730     delete RcorrJZBSBeemm;
731     delete LcorrJZBSBeemm;
732     delete lm4RcorrJZBeemm;
733 buchmann 1.1 }
734    
735 fronga 1.24 void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
736 buchmann 1.11 TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
737 fronga 1.24 do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
738     do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
739 buchmann 1.1 }
740    
741     void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
742     bool do_data=0;
743     bool dosignal=0;
744     if(is_data==1) do_data=1;
745     if(is_data==2) dosignal=1;
746 buchmann 1.17 TH1F *RcorrJZBeemm = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
747     TH1F *LcorrJZBeemm = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
748     TH1F *RcorrJZBem = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
749     TH1F *LcorrJZBem = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
750    
751     TH1F *RcorrJZBSBem = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
752     TH1F *LcorrJZBSBem = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
753     TH1F *RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
754     TH1F *LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
755 buchmann 1.13
756 buchmann 1.64 if(!RestrictToMassPeak) write_warning(__FUNCTION__,"Watch out, once we go offpeak this function needs rewriting!");//the bpred below needs to be adapted
757 buchmann 1.17 TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
758 buchmann 1.13 Bpred->Add(RcorrJZBem,1.0/3);
759     Bpred->Add(LcorrJZBem,-1.0/3);
760     Bpred->Add(RcorrJZBSBem,1.0/3);
761     Bpred->Add(LcorrJZBSBem,-1.0/3);
762     Bpred->Add(RcorrJZBSBeemm,1.0/3);
763     Bpred->Add(LcorrJZBSbeemm,-1.0/3);
764 buchmann 1.1 can->cd();
765     can->SetLogy(0);
766     Bpred->SetLineColor(kRed);
767     Bpred->SetStats(0);
768     if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
769 buchmann 1.17 TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
770     JZBratioforfitting->Divide(Bpred);
771 buchmann 1.36 TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
772 buchmann 1.17
773 buchmann 1.1
774     JZBratio->SetTitle("");
775     JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
776 fronga 1.24 // if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
777 buchmann 1.1
778     TF1 *pol0 = new TF1("pol0","[0]",0,1000);
779     TF1 *pol0d = new TF1("pol0","[0]",0,1000);
780     // straightline_fit->SetParameter(0,1);
781     JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
782     pol0d->SetParameter(0,pol0->GetParameter(0));
783    
784     JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
785 buchmann 1.17 JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
786 fronga 1.24 if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
787 buchmann 1.1 JZBratio->GetYaxis()->SetNdivisions(519);
788 buchmann 1.59 JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
789 buchmann 1.17 JZBratio->GetYaxis()->CenterTitle();
790     JZBratio->GetXaxis()->CenterTitle();
791     JZBratio->SetMarkerSize(DataMarkerSize);
792 buchmann 1.1 JZBratio->Draw("AP");
793     /////----------------------------
794 fronga 1.24 TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
795 buchmann 1.1 writeresult->SetFillStyle(4000);
796     writeresult->SetFillColor(kWhite);
797     writeresult->SetTextFont(42);
798 fronga 1.24 writeresult->SetTextSize(0.03);
799     writeresult->SetTextAlign(12);
800 buchmann 1.1 ostringstream jzb_agreement_data_text;
801     jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) << pol0->GetParError(0);
802     if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
803     if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
804     /* if(is_data) writeresult->AddText("Data closure test");
805     else writeresult->AddText("MC closure test");
806     */
807     writeresult->AddText(jzb_agreement_data_text.str().c_str());
808 buchmann 1.60 // writeresult->Draw("same");
809 buchmann 1.59 // pol0d->Draw("same");
810 fronga 1.24 TF1 *topline = new TF1("","1.5",0,1000);
811     TF1 *bottomline = new TF1("","0.5",0,1000);
812 buchmann 1.1 topline->SetLineColor(kBlue);
813     topline->SetLineStyle(2);
814     bottomline->SetLineColor(kBlue);
815     bottomline->SetLineStyle(2);
816 buchmann 1.59 // topline->Draw("same");
817     // bottomline->Draw("same");
818 buchmann 1.1 TF1 *oneline = new TF1("","1.0",0,1000);
819     oneline->SetLineColor(kBlue);
820     oneline->SetLineStyle(1);
821     oneline->Draw("same");
822 buchmann 1.63 TLegend *phony_leg = make_legend("ratio",0.6,0.55,false);//this line is just to have the default CMS Preliminary (...) on the canvas as well.
823     if(is_data==1) DrawPrelim();
824     else DrawMCPrelim();
825 buchmann 1.61 TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
826 buchmann 1.1 leg->SetTextFont(42);
827 fronga 1.24 leg->SetTextSize(0.04);
828     // if(is_data==1) leg->SetHeader("Ratio (data)");
829     // else leg->SetHeader("Ratio (MC)");
830    
831     TString MCtitle("MC ");
832     if (is_data==1) MCtitle = "";
833    
834 buchmann 1.1 leg->SetFillStyle(4000);
835     leg->SetFillColor(kWhite);
836     leg->SetTextFont(42);
837     // leg->AddEntry(topline,"+20\% sys envelope","l");
838 fronga 1.24 leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
839 buchmann 1.1 leg->AddEntry(oneline,"ratio = 1","l");
840 buchmann 1.59 // leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
841     // leg->AddEntry(bottomline,"#pm50% envelope","l");
842 buchmann 1.61
843    
844     //leg->Draw("same"); // no longer drawing legend
845    
846 buchmann 1.1 if(is_data==1) CompleteSave(can, "jzb_ratio_data");
847     if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
848     if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
849 buchmann 1.17
850 buchmann 1.1 delete RcorrJZBeemm;
851     delete LcorrJZBeemm;
852     delete RcorrJZBem;
853     delete LcorrJZBem;
854 buchmann 1.17
855     delete RcorrJZBSBem;
856     delete LcorrJZBSBem;
857     delete RcorrJZBSBeemm;
858     delete LcorrJZBSbeemm;
859 buchmann 1.1 }
860    
861 buchmann 1.23 void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
862 buchmann 1.11 TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
863 buchmann 1.1 globalc->SetLogy(0);
864    
865 fronga 1.24 do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh );
866     do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh );
867     do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh );
868 buchmann 1.1 }
869    
870 buchmann 1.8 string give_jzb_expression(float peak, int type) {
871 buchmann 1.1 stringstream val;
872 buchmann 1.8 if(type==data) {
873     if(peak<0) val << jzbvariabledata << "+" << TMath::Abs(peak);
874     if(peak>0) val << jzbvariabledata << "-" << TMath::Abs(peak);
875     if(peak==0) val << jzbvariabledata;
876     }
877     if(type==mc) {
878     if(peak<0) val << jzbvariablemc << "+" << TMath::Abs(peak);
879     if(peak>0) val << jzbvariablemc << "-" << TMath::Abs(peak);
880     if(peak==0) val << jzbvariablemc;
881     }
882 buchmann 1.1 return val.str();
883     }
884    
885    
886 buchmann 1.11 void lepton_comparison_plots() {
887 fronga 1.24 Float_t ymin = 1.e-5, ymax = 0.25;
888 buchmann 1.11 TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
889 buchmann 1.1 can->SetLogy(1);
890 buchmann 1.17 TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
891     TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
892 buchmann 1.1 eemc->SetLineColor(kBlue);
893     mmmc->SetLineColor(kRed);
894     eemc->SetMinimum(0.1);
895     eemc->SetMaximum(10*eemc->GetMaximum());
896     eemc->Draw("histo");
897     mmmc->Draw("histo,same");
898     TLegend *leg = make_legend();
899 buchmann 1.17 leg->AddEntry(eemc,"ZJets->ee (MC)","l");
900     leg->AddEntry(mmmc,"ZJets->#mu#mu (MC)","l");
901 buchmann 1.11 leg->Draw("same");
902 buchmann 1.1 CompleteSave(can, "mll_effratio_mc");
903    
904 buchmann 1.17 TH1F *eed = allsamples.Draw("eed","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",data, luminosity);
905     TH1F *mmd = allsamples.Draw("mmd","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",data, luminosity);
906 buchmann 1.1 eed->SetLineColor(kBlue);
907     mmd->SetLineColor(kRed);
908     eed->SetMinimum(0.1);
909     eed->SetMaximum(10*eed->GetMaximum());
910     eed->Draw("histo");
911     mmd->Draw("histo,same");
912     TLegend *leg2 = make_legend();
913 buchmann 1.17 leg2->AddEntry(eed,"ZJets->ee (data)","l");
914     leg2->AddEntry(mmd,"ZJets->#mu#mu (data)","l");
915 buchmann 1.1 leg2->Draw();
916     CompleteSave(can, "mll_effratio_data");
917    
918 fronga 1.24 TH1F *jeed = allsamples.Draw("jeed",jzbvariabledata, 100,-150,jzbHigh , "JZB [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",data, luminosity);
919     TH1F *jmmd = allsamples.Draw("jmmd",jzbvariabledata, 100,-150,jzbHigh , "JZB [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",data, luminosity);
920     TH1F *jeemmd = allsamples.Draw("jeemmd",jzbvariabledata,100,-150,jzbHigh , "JZB [GeV]", "events", cutOSSF&&cutnJets,data, luminosity);
921 buchmann 1.21 dout << "ee : " << jeed->GetMean() << "+/-" << jeed->GetMeanError() << endl;
922     dout << "ee : " << jmmd->GetMean() << "+/-" << jmmd->GetMeanError() << endl;
923     dout << "eemd : " << jeemmd->GetMean() << "+/-" << jeemmd->GetMeanError() << endl;
924 buchmann 1.1 jeemmd->SetLineColor(kBlack);
925     jeemmd->SetMarkerStyle(25);
926     jeed->SetLineColor(kBlue);
927     jmmd->SetLineColor(kRed);
928     jeed->SetMinimum(0.1);
929     jeed->SetMaximum(10*eed->GetMaximum());
930 fronga 1.24 TH1* njeemmd = jeemmd->DrawNormalized();
931     njeemmd->SetMinimum(ymin);
932     njeemmd->SetMaximum(ymax);
933    
934 buchmann 1.1 jeed->DrawNormalized("histo,same");
935     jmmd->DrawNormalized("histo,same");
936     jeemmd->DrawNormalized("same");
937 fronga 1.24 TLegend *jleg2 = make_legend(" ");
938 buchmann 1.1 jleg2->AddEntry(jeemmd,"ee and #mu#mu","p");
939     jleg2->AddEntry(jeed,"ee","l");
940     jleg2->AddEntry(jmmd,"#mu#mu","l");
941     jleg2->Draw();
942     CompleteSave(can,"jzb_effratio_data");
943    
944 fronga 1.24 TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc, 100,-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJets"));
945     TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc, 100,-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJets"));
946     TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,100,-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets, mc, luminosity,allsamples.FindSample("DYJets"));
947 buchmann 1.21 dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
948     dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
949     dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
950 buchmann 1.11 zjeemmd->SetLineColor(kBlack);
951     zjeemmd->SetMarkerStyle(25);
952     zjeed->SetLineColor(kBlue);
953     zjmmd->SetLineColor(kRed);
954     zjeed->SetMinimum(0.1);
955     zjeed->SetMaximum(10*eed->GetMaximum());
956 fronga 1.24
957     TH1* nzjeemmd = zjeemmd->DrawNormalized();
958     nzjeemmd->SetMinimum(ymin);
959     nzjeemmd->SetMaximum(ymax);
960 buchmann 1.11 zjeed->DrawNormalized("histo,same");
961     zjmmd->DrawNormalized("histo,same");
962     zjeemmd->DrawNormalized("same");
963 fronga 1.24 TLegend *zjleg2 = make_legend("Z+jets MC");
964 buchmann 1.11 zjleg2->AddEntry(jeemmd,"ee and #mu#mu","p");
965     zjleg2->AddEntry(jeed,"ee","l");
966     zjleg2->AddEntry(jmmd,"#mu#mu","l");
967     zjleg2->Draw();
968     CompleteSave(can,"jzb_effratio_ZJets");
969    
970 buchmann 1.17 TH1F *ld = allsamples.Draw("ld","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets,data, luminosity);
971 buchmann 1.1 ld->DrawNormalized("e1");
972     eed->DrawNormalized("histo,same");
973     mmd->DrawNormalized("histo,same");
974     TLegend *leg3 = make_legend();
975     leg3->AddEntry(ld,"ZJets->ll (data)","p");
976 buchmann 1.17 leg3->AddEntry(eed,"ZJets->ee (data)","l");
977     leg3->AddEntry(mmd,"ZJets->#mu#mu (data)","l");
978 buchmann 1.1 leg3->Draw();
979     CompleteSave(can,"mll_effratio_data__all_compared");
980     /*
981 buchmann 1.17 TH1F *jzbld = allsamples.Draw("jzbld",jzbvariable,75,-150,150, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
982     TH1F *jzbemd = allsamples.Draw("jzbemd",jzbvariable,75,-150,150, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
983 buchmann 1.1 */
984 fronga 1.24 TH1F *jzbld = allsamples.Draw("jzbld",jzbvariabledata,92,-110,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
985     TH1F *jzbemd = allsamples.Draw("jzbemd",jzbvariabledata,92,-110,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
986 buchmann 1.1 jzbld->SetMarkerColor(kBlack);
987     jzbld->SetMarkerStyle(26);
988     jzbemd->SetMarkerStyle(25);
989     jzbemd->SetMarkerColor(kRed);
990     jzbemd->SetLineColor(kRed);
991     jzbld->SetMinimum(0.35);
992     jzbld->Draw("e1");
993     jzbemd->Draw("e1,same");
994 fronga 1.24 TLegend *leg4 = make_legend();
995     leg4->AddEntry(jzbld,"SFZP","p");
996     leg4->AddEntry(jzbemd,"OFZP","p");
997 buchmann 1.29 leg4->AddEntry((TObject*)0,"",""); //causes segmentation violation
998     leg4->AddEntry((TObject*)0,"",""); //causes segmentation violation
999 buchmann 1.1 leg4->Draw();
1000     CompleteSave(can,"jzb_eemumu_emu_data");
1001    
1002 buchmann 1.17 TH1F *ttbarjzbld = allsamples.Draw("ttbarjzbld",jzbvariablemc,110,-150,400, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity,allsamples.FindSample("TTJet"));
1003     TH1F *ttbarjzbemd = allsamples.Draw("ttbarjzbemd",jzbvariablemc,110,-150,400, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity,allsamples.FindSample("TTJet"));
1004 buchmann 1.1 ttbarjzbld->SetLineColor(allsamples.GetColor("TTJet"));
1005     ttbarjzbemd->SetLineColor(allsamples.GetColor("TTJet"));
1006     ttbarjzbld->Draw("histo");
1007     ttbarjzbemd->SetLineStyle(2);
1008     ttbarjzbemd->Draw("histo,same");
1009     TLegend *leg5 = make_legend();
1010 buchmann 1.17 leg5->AddEntry(ttbarjzbld,"t#bar{t}->(ee or #mu#mu)","l");
1011     leg5->AddEntry(ttbarjzbemd,"t#bar{t}->e#mu","l");
1012 buchmann 1.1 leg5->Draw();
1013     CompleteSave(can,"ttbar_emu_mc");
1014    
1015    
1016    
1017     }
1018    
1019     bool is_OF(TCut cut) {
1020     string scut = (const char*) cut;
1021     if((int)scut.find("id1!=id2")>-1) return true;
1022     if((int)scut.find("id1==id2")>-1) return false;
1023     return false;
1024     }
1025    
1026 fronga 1.24 bool is_ZP(TCut cut) {
1027     string scut = (const char*) cut;
1028     if((int)scut.find("91")>-1) return true;
1029     return false;
1030     }
1031    
1032    
1033 buchmann 1.23 void draw_pure_jzb_histo(TCut cut,string variable,string savename, TCanvas *can,vector<float> binning) {
1034 buchmann 1.1 can->cd();
1035     can->SetLogy(1);
1036 buchmann 1.17 string xlabel="JZB [GeV]";
1037 buchmann 1.1
1038 buchmann 1.23 TH1F *datahisto = allsamples.Draw("datahisto",variable,binning, xlabel, "events",cut,data,luminosity);
1039     THStack mcstack = allsamples.DrawStack("mcstack",variable,binning, xlabel, "events",cut,mc,luminosity);
1040 buchmann 1.1
1041     datahisto->SetMinimum(0.1);
1042 buchmann 1.12 //if(savename=="jzb_OSOF") datahisto->SetMaximum(10);
1043 buchmann 1.17 datahisto->SetMarkerSize(DataMarkerSize);
1044 buchmann 1.1 datahisto->Draw("e1");
1045     mcstack.Draw("same");
1046     datahisto->Draw("same,e1");
1047    
1048     TLegend *leg;
1049 fronga 1.24 if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1050     else if(!is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1051     else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1052     else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1053     else {
1054     std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1055     exit(-1);
1056     }
1057 buchmann 1.1 leg->Draw();
1058     string write_cut = decipher_cut(cut,"");
1059 buchmann 1.16 TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1060 buchmann 1.1 writeline1->SetTextSize(0.035);
1061     writeline1->Draw();
1062     CompleteSave(can, ("jzb/"+savename));
1063    
1064     datahisto->Delete();
1065     mcstack.Delete();
1066     }
1067    
1068     Double_t GausR(Double_t *x, Double_t *par) {
1069     return gRandom->Gaus(x[0],par[0]);
1070     }
1071    
1072 buchmann 1.23 void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1073 buchmann 1.11 TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1074 fronga 1.24 float max=jzbHigh ;
1075 buchmann 1.1 float min=-120;
1076     int nbins=(max-min)/5.0; // we want 5 GeV/bin
1077 buchmann 1.23 int coarserbins=int(nbins/2.0);
1078     int rebinnedbins=int(nbins/4.0);
1079 buchmann 1.1
1080 buchmann 1.23 // stringstream ss;
1081 buchmann 1.1 // ss << "GausRandom(" << datajzb << ",0)";
1082 buchmann 1.23 vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1083     for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1084     for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1085     for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1086    
1087     /* draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,"jzb_OSSF_altbins",can,ratio_binning);
1088     draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,"jzb_OSOF_altbins",can,ratio_binning);
1089     draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,"jzb_OSSF_SB_altbins",can,ratio_binning);
1090     draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,"jzb_OSOF_SB_altbins",can,ratio_binning);*/
1091 fronga 1.24 draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,"jzb_OS_SFZP",can,binning);
1092     draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,"jzb_OS_OFZP",can,binning);
1093     draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,"jzb_OS_SFSB",can,binning);
1094     draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,"jzb_OS_OFSB",can,binning);
1095    
1096     draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
1097     draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1098     draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1099     draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1100    
1101     draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1102     draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1103     draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1104     draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
1105 buchmann 1.1 }
1106    
1107     void calculate_all_yields(string mcdrawcommand,vector<float> jzb_cuts) {
1108 buchmann 1.21 dout << "Calculating background yields in MC:" << endl;
1109 buchmann 1.1 jzb_cuts.push_back(14000);
1110 buchmann 1.17 TH1F *allbgs = allsamples.Draw("allbgs",jzbvariablemc,jzb_cuts, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc,luminosity);
1111 buchmann 1.1 float cumulative=0;
1112     for(int i=allbgs->GetNbinsX();i>=1;i--) {
1113     cumulative+=allbgs->GetBinContent(i);
1114 buchmann 1.21 dout << "Above " << allbgs->GetBinLowEdge(i) << " GeV/c : " << cumulative << endl;
1115 buchmann 1.1 }
1116     }
1117    
1118 buchmann 1.4 void draw_ttbar_and_zjets_shape_for_one_configuration(string mcjzb, string datajzb, int leptontype=-1, int scenario=0,bool floating=false) {
1119 buchmann 1.10 //Step 1: Establishing cuts
1120 buchmann 1.3 stringstream jetcutstring;
1121 buchmann 1.10 string writescenario="";
1122    
1123 buchmann 1.3 if(scenario==0) jetcutstring << "(pfJetGoodNum>=3)&&"<<(const char*) basicqualitycut;
1124     if(scenario==1) jetcutstring << "(pfJetPt[0]>50&&pfJetPt[1]>50)&&"<<(const char*)basicqualitycut;
1125     TCut jetcut(jetcutstring.str().c_str());
1126     string leptoncut="mll>0";
1127     if(leptontype==0||leptontype==1) {
1128 buchmann 1.10 if(leptontype==0) {
1129     leptoncut="id1==0";
1130     writescenario="__ee";
1131     }
1132     else {
1133     leptoncut="id1==1";
1134     writescenario="__ee";
1135     }
1136 buchmann 1.3 }
1137     TCut lepcut(leptoncut.c_str());
1138    
1139 buchmann 1.6 TCanvas *c5 = new TCanvas("c5","c5",1500,500);
1140 buchmann 1.10 TCanvas *c6 = new TCanvas("c6","c6");
1141 buchmann 1.3 c5->Divide(3,1);
1142 buchmann 1.10
1143     //STEP 2: Extract Zjets shape in data
1144     c5->cd(1);
1145 buchmann 1.3 c5->cd(1)->SetLogy(1);
1146     TCut massat40("mll>40");
1147 buchmann 1.17 TH1F *ossfleft = allsamples.Draw("ossfleft", "-"+datajzb,40,0,200, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,data,luminosity);
1148     TH1F *osofleft = allsamples.Draw("osofleft", "-"+datajzb,40,0,200, "JZB [GeV]", "events", massat40&&cutOSOF&&jetcut&&lepcut,data,luminosity);
1149 buchmann 1.3 ossfleft->SetLineColor(kRed);
1150     ossfleft->SetMarkerColor(kRed);
1151     ossfleft->Add(osofleft,-1);
1152 buchmann 1.9 vector<TF1*> functions = do_cb_fit_to_plot(ossfleft,10);
1153 buchmann 1.17 ossfleft->SetMarkerSize(DataMarkerSize);
1154 buchmann 1.3 ossfleft->Draw();
1155 buchmann 1.9 functions[0]->Draw("same");functions[1]->Draw("same");functions[2]->Draw("same");
1156     TF1 *zjetsfunc = (TF1*) functions[1]->Clone();
1157     TF1 *zjetsfuncN = (TF1*) functions[0]->Clone();
1158     TF1 *zjetsfuncP = (TF1*) functions[2]->Clone();
1159 buchmann 1.6 zjetsfunc->Draw("same");zjetsfuncN->Draw("same");zjetsfuncP->Draw("same");
1160 buchmann 1.3 TLegend *leg1 = new TLegend(0.6,0.6,0.89,0.80);
1161     leg1->SetFillColor(kWhite);
1162     leg1->SetLineColor(kWhite);
1163     leg1->AddEntry(ossfleft,"OSSF (sub),JZB<peak","p");
1164 buchmann 1.6 leg1->AddEntry(zjetsfunc,"OSSF fit ('zjets')","l");
1165 buchmann 1.3 leg1->Draw("same");
1166     TText *titleleft = write_title("Extracting Z+Jets shape");
1167     titleleft->Draw();
1168    
1169 buchmann 1.10 //Step 3: Extract ttbar shape (in data or MC?)
1170     c5->cd(2);
1171 buchmann 1.3 c5->cd(2)->SetLogy(1);
1172 buchmann 1.4 TH1F *osof;
1173     TText *titlecenter;
1174 buchmann 1.10 bool frommc=false;
1175     if(frommc) {
1176 buchmann 1.17 osof = allsamples.Draw("osof",datajzb,40,-200,200, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,mc,luminosity,allsamples.FindSample("TTJets"));
1177 buchmann 1.4 titlecenter = write_title("Extracting ttbar shape (from ossf MC)");
1178     }
1179     else {
1180 buchmann 1.17 osof = allsamples.Draw("osof",datajzb,40,-200,200, "JZB [GeV]", "events", massat40&&cutOSOF&&jetcut&&lepcut,data,luminosity);
1181 buchmann 1.4 titlecenter = write_title("Extracting ttbar shape (from osof data)");
1182     }
1183 buchmann 1.17 osof->SetMarkerSize(DataMarkerSize);
1184 buchmann 1.3 osof->Draw();
1185 buchmann 1.10 vector<TF1*> ttbarfunctions = do_cb_fit_to_plot(osof,35,true);
1186     ttbarfunctions[0]->SetLineColor(kRed); ttbarfunctions[0]->SetLineStyle(2); ttbarfunctions[0]->Draw("same");
1187     ttbarfunctions[1]->SetLineColor(kRed); ttbarfunctions[1]->Draw("same");
1188     ttbarfunctions[2]->SetLineColor(kRed); ttbarfunctions[2]->SetLineStyle(2); ttbarfunctions[2]->Draw("same");
1189    
1190 buchmann 1.3 TLegend *leg2 = new TLegend(0.15,0.8,0.4,0.89);
1191     leg2->SetFillColor(kWhite);
1192     leg2->SetLineColor(kWhite);
1193 buchmann 1.10 if(frommc) {
1194 buchmann 1.4 leg2->AddEntry(osof,"t#bar{t} OSSF, MC","p");
1195 buchmann 1.10 leg2->AddEntry(ttbarfunctions[1],"Fit to t#bar{t} OSSF,MC","l");
1196 buchmann 1.4 } else {
1197     leg2->AddEntry(osof,"OSOF","p");
1198 buchmann 1.10 leg2->AddEntry(ttbarfunctions[1],"Fit to OSOF","l");
1199 buchmann 1.4 }
1200 buchmann 1.3 leg2->Draw("same");
1201     titlecenter->Draw();
1202 buchmann 1.10
1203     //--------------------------------------------------------------------------------------------------------------------------------
1204 buchmann 1.4 //STEP 4: Present it!
1205     // actually: if we wanna let it float we need to do that first :-)
1206 buchmann 1.3 c5->cd(3);
1207     c5->cd(3)->SetLogy(1);
1208 buchmann 1.17 TH1F *observed = allsamples.Draw("observed",datajzb,100,0,500, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,data,luminosity);
1209     observed->SetMarkerSize(DataMarkerSize);
1210 buchmann 1.4
1211 buchmann 1.6 TF1 *logparc = new TF1("logparc",InvCrystalBall,0,1000,5); logparc->SetLineColor(kRed);
1212 buchmann 1.8 TF1 *logparcn = new TF1("logparcn",InvCrystalBallN,0,1000,5); logparcn->SetLineColor(kRed); logparcn->SetLineStyle(2);
1213     TF1 *logparcp = new TF1("logparcp",InvCrystalBallP,0,1000,5); logparcp->SetLineColor(kRed); logparcp->SetLineStyle(2);
1214 buchmann 1.6
1215     TF1 *zjetsc = new TF1("zjetsc",InvCrystalBall,0,1000,5); zjetsc->SetLineColor(kBlue);
1216     TF1 *zjetscn = new TF1("zjetscn",InvCrystalBallN,0,1000,5); zjetscn->SetLineColor(kBlue); zjetscn->SetLineStyle(2);
1217     TF1 *zjetscp = new TF1("zjetscp",InvCrystalBallP,0,1000,5); zjetscp->SetLineColor(kBlue); zjetscp->SetLineStyle(2);
1218    
1219 buchmann 1.10 TF1 *ZplusJetsplusTTbar = new TF1("ZplusJetsplusTTbar", DoubleInvCrystalBall,0,1000,10); ZplusJetsplusTTbar->SetLineColor(kBlue);
1220     TF1 *ZplusJetsplusTTbarP= new TF1("ZplusJetsplusTTbarP",DoubleInvCrystalBallP,0,1000,10); ZplusJetsplusTTbarP->SetLineColor(kBlue); ZplusJetsplusTTbarP->SetLineStyle(2);
1221     TF1 *ZplusJetsplusTTbarN= new TF1("ZplusJetsplusTTbarN",DoubleInvCrystalBallN,0,1000,10); ZplusJetsplusTTbarN->SetLineColor(kBlue); ZplusJetsplusTTbarN->SetLineStyle(2);
1222    
1223 buchmann 1.6 zjetsc->SetParameters(zjetsfunc->GetParameters());
1224     zjetscp->SetParameters(zjetsfunc->GetParameters());
1225     zjetscn->SetParameters(zjetsfunc->GetParameters());
1226 buchmann 1.10
1227 fronga 1.24 TH1F *observeda = allsamples.Draw("observeda",datajzb,53,80,jzbHigh, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,data,luminosity);
1228 buchmann 1.7 //blublu
1229 buchmann 1.10 logparc->SetParameters(ttbarfunctions[1]->GetParameters());
1230     logparcn->SetParameters(ttbarfunctions[1]->GetParameters());
1231     logparcp->SetParameters(ttbarfunctions[1]->GetParameters());
1232 buchmann 1.4 if(floating) {
1233 buchmann 1.21 dout << "TTbar contribution assumed (before fitting) : " << logparc->GetParameter(0) << endl;
1234 buchmann 1.10 logparc->SetParameters(ttbarfunctions[1]->GetParameters());
1235 buchmann 1.7 for(int i=0;i<10;i++) {
1236     if(i<5) ZplusJetsplusTTbar->FixParameter(i,zjetsfunc->GetParameter(i));
1237     if(i>=5) {
1238     if (i>5) ZplusJetsplusTTbar->FixParameter(i,logparc->GetParameter(i-5));
1239     if (i==5) ZplusJetsplusTTbar->SetParameter(i,logparc->GetParameter(i-5));
1240     }
1241     }//end of setting parameters
1242     observeda->Draw("same");
1243     ZplusJetsplusTTbar->Draw("same");
1244     observeda->Fit(ZplusJetsplusTTbar);
1245 buchmann 1.21 dout << "--> Quality of Z+Jets / TTbar fit : chi2/ndf = " << ZplusJetsplusTTbar->GetChisquare() << "/" << ZplusJetsplusTTbar->GetNDF() << endl;
1246 buchmann 1.7 ZplusJetsplusTTbar->Draw("same");
1247 buchmann 1.8 ZplusJetsplusTTbarP->SetParameters(ZplusJetsplusTTbar->GetParameters());
1248     ZplusJetsplusTTbarN->SetParameters(ZplusJetsplusTTbar->GetParameters());
1249 buchmann 1.21 dout << "TTbar contribution found (after fitting) : " << ZplusJetsplusTTbar->GetParameter(5) << endl;
1250 buchmann 1.7 float factor = ZplusJetsplusTTbar->GetParameter(5) / logparc->GetParameter(0);
1251 buchmann 1.21 dout << "FACTOR: " << factor << endl;
1252 buchmann 1.10 logparc->SetParameter(0,factor*ttbarfunctions[1]->GetParameter(0));
1253     logparcn->SetParameter(0,factor*ttbarfunctions[1]->GetParameter(0));
1254     logparcp->SetParameter(0,factor*ttbarfunctions[1]->GetParameter(0));
1255 buchmann 1.4 }
1256 buchmann 1.6
1257 buchmann 1.4 c5->cd(3);
1258 buchmann 1.6 c5->cd(3)->SetLogy(1);
1259     observed->Draw();
1260     zjetsc->Draw("same");zjetscn->Draw("same");zjetscp->Draw("same");
1261 buchmann 1.3 logparc->Draw("same");
1262 buchmann 1.6 logparcn->Draw("same");
1263     logparcp->Draw("same");
1264    
1265 buchmann 1.3 TLegend *leg3 = new TLegend(0.6,0.6,0.89,0.80);
1266     leg3->SetFillColor(kWhite);
1267     leg3->SetLineColor(kWhite);
1268     leg3->AddEntry(observed,"OSSF,JZB>peak","p");
1269 buchmann 1.10 leg3->AddEntry(ttbarfunctions[1],"OSOF fit ('ttbar')","l");
1270 buchmann 1.6 leg3->AddEntry(zjetsfunc,"OSSF,JZB<0 fit ('zjets')","l");
1271 buchmann 1.3 leg3->Draw("same");
1272     TText *titleright = write_title("Summary of shapes and observed shape");
1273     titleright->Draw();
1274    
1275     c6->cd()->SetLogy(1);
1276 buchmann 1.6 observed->Draw();
1277     zjetsc->Draw("same");zjetscn->Draw("same");zjetscp->Draw("same");
1278 buchmann 1.3 logparc->Draw("same");
1279 buchmann 1.6 logparcn->Draw("same");
1280     logparcp->Draw("same");
1281 buchmann 1.3 leg3->Draw("same");
1282     titleright->Draw();
1283    
1284     if(scenario==0) {
1285     CompleteSave(c5,"Shapes2/Making_of___3jetsabove30"+writescenario);
1286 buchmann 1.6 CompleteSave(c5->cd(1),"Shapes2/Making_of___3jetsabove30"+writescenario+"__cd1");
1287     CompleteSave(c5->cd(2),"Shapes2/Making_of___3jetsabove30"+writescenario+"__cd2");
1288     CompleteSave(c5->cd(3),"Shapes2/Making_of___3jetsabove30"+writescenario+"__cd3");
1289 buchmann 1.3 CompleteSave(c6,"Shapes2/Background_Shapes___3jetsabove30"+writescenario);
1290     } else {
1291     CompleteSave(c5,"Shapes2/Making_of___2jetsabove50"+writescenario);
1292 buchmann 1.6 CompleteSave(c5->cd(1),"Shapes2/Making_of___2jetsabove50"+writescenario+"__cd1");
1293     CompleteSave(c5->cd(2),"Shapes2/Making_of___2jetsabove50"+writescenario+"__cd2");
1294     CompleteSave(c5->cd(3),"Shapes2/Making_of___2jetsabove50"+writescenario+"__cd3");
1295 buchmann 1.3 CompleteSave(c6,"Shapes2/Background_Shapes___2jetsabove50"+writescenario);
1296     }
1297 buchmann 1.21 dout << "Statistics about our fits: " << endl;
1298     dout << "Z+Jets shape: Chi2/ndf = " << zjetsfunc->GetChisquare() << "/" << ossfleft->GetNbinsX() << endl;
1299     dout << "ttbar shape: Chi2/ndf = " << ttbarfunctions[1]->GetChisquare() << "/" << osof->GetNbinsX() << endl;
1300 buchmann 1.4
1301 buchmann 1.7 c6->cd();
1302 buchmann 1.8 TLegend *additionallegend = new TLegend(0.6,0.6,0.89,0.89);
1303     additionallegend->SetFillColor(kWhite);
1304     additionallegend->SetLineColor(kWhite);
1305     additionallegend->AddEntry(observed,"Data","p");
1306     additionallegend->AddEntry(ZplusJetsplusTTbar,"Fitted Z+jets & TTbar","l");
1307     additionallegend->AddEntry(zjetsc,"Z+jets","l");
1308     additionallegend->AddEntry(logparc,"TTbar","l");
1309 buchmann 1.7 observed->Draw();
1310     ZplusJetsplusTTbar->SetLineColor(kGreen);
1311 buchmann 1.8 ZplusJetsplusTTbarP->SetLineColor(kGreen);
1312     ZplusJetsplusTTbarN->SetLineColor(kGreen);
1313     ZplusJetsplusTTbarP->SetLineStyle(2);
1314     ZplusJetsplusTTbarN->SetLineStyle(2);
1315     TF1 *ZplusJetsplusTTbar2 = new TF1("ZplusJetsplusTTbar2",DoubleInvCrystalBall,0,1000,10);
1316     ZplusJetsplusTTbar2->SetParameters(ZplusJetsplusTTbar->GetParameters());
1317     ZplusJetsplusTTbar2->SetLineColor(kGreen);
1318     ZplusJetsplusTTbarP->SetFillColor(TColor::GetColor("#81F781"));
1319     ZplusJetsplusTTbarN->SetFillColor(kWhite);
1320     ZplusJetsplusTTbarP->Draw("fcsame");
1321     ZplusJetsplusTTbarN->Draw("fcsame");
1322     TH1F *hZplusJetsplusTTbar = (TH1F*)ZplusJetsplusTTbar2->GetHistogram();
1323     TH1F *hZplusJetsplusTTbarN = (TH1F*)ZplusJetsplusTTbarN->GetHistogram();
1324     TH1F *hZplusJetsplusTTbarP = (TH1F*)ZplusJetsplusTTbarP->GetHistogram();
1325     hZplusJetsplusTTbar->SetMarkerSize(0);
1326     hZplusJetsplusTTbarP->SetMarkerSize(0);
1327     hZplusJetsplusTTbarN->SetMarkerSize(0);
1328     for (int i=1;i<=hZplusJetsplusTTbar->GetNbinsX();i++) {
1329     float newerror=hZplusJetsplusTTbarP->GetBinContent(i)-hZplusJetsplusTTbar->GetBinContent(i);
1330     hZplusJetsplusTTbar->SetBinError(i,newerror);
1331     if(hZplusJetsplusTTbar->GetBinContent(i)<0.05) hZplusJetsplusTTbar->SetBinContent(i,0); //avoiding a displaying probolem
1332     }
1333     hZplusJetsplusTTbarP->SetFillColor(kGreen);
1334     hZplusJetsplusTTbarN->SetFillColor(kWhite);
1335     hZplusJetsplusTTbarN->Draw("same");
1336    
1337     ZplusJetsplusTTbar2->SetMarkerSize(0);
1338     ZplusJetsplusTTbar2->Draw("same");
1339    
1340 buchmann 1.7 zjetsc->Draw("same");zjetscn->Draw("same");zjetscp->Draw("same");
1341     logparc->Draw("same");
1342     logparcn->Draw("same");
1343     logparcp->Draw("same");
1344 buchmann 1.8 additionallegend->Draw("same");
1345     if(scenario==0) {
1346     CompleteSave(c6,"Shapes2/Background_Shapes___3jetsabove30__allfits__"+writescenario);
1347     } else {
1348     CompleteSave(c6,"Shapes2/Background_Shapes___2jetsabove50__allfits__"+writescenario);
1349     }
1350 buchmann 1.10 //--------------------------------------------------------------------------------------------------------------------------------
1351 buchmann 1.3 }
1352    
1353 buchmann 1.2 void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
1354 buchmann 1.3 int all_leptons=-1;
1355     int electrons_only=0;
1356     int mu_only=1;
1357     int twojetswith50gev=1;
1358     int threejetswith30gev=0;
1359 buchmann 1.4 /*
1360 buchmann 1.3 draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
1361     draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
1362    
1363     draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,electrons_only,twojetswith50gev);
1364     draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,electrons_only,threejetswith30gev);
1365    
1366     draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,mu_only,twojetswith50gev);
1367     draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,mu_only,threejetswith30gev);
1368 buchmann 1.4 */
1369 buchmann 1.2
1370 buchmann 1.10 draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
1371 buchmann 1.2 }
1372 buchmann 1.6
1373 buchmann 1.8 void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
1374 buchmann 1.13 //first: colorful plots
1375     TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
1376 buchmann 1.14 cancorr->SetLogz();
1377 fronga 1.26 cancorr->SetRightMargin(0.13);
1378 buchmann 1.13 TCut zptforresponsepresentation("pt<600&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)&&((sumJetPt[1]/pt)<5.0)");
1379 fronga 1.26 TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
1380 buchmann 1.48 (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
1381 buchmann 1.13 niceresponseplotd->SetStats(0);
1382 fronga 1.26 niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
1383 buchmann 1.13 niceresponseplotd->GetYaxis()->SetTitle("Response");
1384     niceresponseplotd->GetXaxis()->CenterTitle();
1385     niceresponseplotd->GetYaxis()->CenterTitle();
1386     niceresponseplotd->Draw("COLZ");
1387 fronga 1.26 TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
1388     profd->SetMarkerSize(DataMarkerSize);
1389     profd->Fit("pol0","","same,e1",30,400);
1390 buchmann 1.13 DrawPrelim();
1391 buchmann 1.32 TText* title = write_text(0.5,0.7,"Data");
1392     title->SetTextAlign(12);
1393 fronga 1.26 title->Draw();
1394 buchmann 1.32 TF1 *datapol=(TF1*)profd->GetFunction("pol0");
1395     float datacorrection=datapol->GetParameter(0);
1396     stringstream dataresstring;
1397     dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
1398     TText* restitle = write_text(0.5,0.65,dataresstring.str());
1399     restitle->SetTextAlign(12);
1400     restitle->SetTextSize(0.03);
1401     restitle->Draw();
1402 buchmann 1.13 CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
1403    
1404 fronga 1.26 TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
1405     (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
1406     niceresponseplotm->SetStats(0);
1407     niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
1408     niceresponseplotm->GetYaxis()->SetTitle("Response");
1409     niceresponseplotm->GetXaxis()->CenterTitle();
1410     niceresponseplotm->GetYaxis()->CenterTitle();
1411     niceresponseplotm->Draw("COLZ");
1412 buchmann 1.13 (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
1413 fronga 1.26 TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
1414     profm->SetMarkerSize(DataMarkerSize);
1415     profm->Fit("pol0","","same,e1",30,400);
1416 buchmann 1.13 DrawPrelim();
1417 buchmann 1.32 title = write_text(0.5,0.7,"MC simulation");
1418     title->SetTextAlign(12);
1419 fronga 1.26 title->Draw();
1420 buchmann 1.32 TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
1421     float mccorrection=mcpol->GetParameter(0);
1422     stringstream mcresstring;
1423     mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
1424     TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
1425     mcrestitle->SetTextAlign(12);
1426     mcrestitle->SetTextSize(0.03);
1427     mcrestitle->Draw();
1428 buchmann 1.13 CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
1429    
1430 buchmann 1.32
1431 buchmann 1.13 //Step 2: Getting the result
1432 buchmann 1.32 // TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
1433 buchmann 1.8 stringstream jzbvardatas;
1434 buchmann 1.9 if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
1435     if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
1436 buchmann 1.8 jzbvardata=jzbvardatas.str();
1437     stringstream jzbvarmcs;
1438 buchmann 1.33 if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
1439 buchmann 1.9 if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
1440 buchmann 1.8 jzbvarmc=jzbvarmcs.str();
1441 buchmann 1.21 dout << "JZB Z pt correction summary : " << endl;
1442 buchmann 1.32 dout << " Data: The response is " << datacorrection << " --> jzb variable is now : " << jzbvardata << endl;
1443     dout << " MC : The response is " << mccorrection << " --> jzb variable is now : " << jzbvarmc << endl;
1444 buchmann 1.8 }
1445 buchmann 1.11
1446 buchmann 1.12 void pick_up_events(string cut) {
1447 buchmann 1.21 dout << "Picking up events with cut " << cut << endl;
1448 buchmann 1.12 allsamples.PickUpEvents(cut);
1449 buchmann 1.11 }
1450    
1451 buchmann 1.38 void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
1452     cout << "Saving configuration template!" << endl;
1453 buchmann 1.30 ofstream configfile;
1454 buchmann 1.31 configfile.open("../DistributedModelCalculations/last_configuration.C");
1455 buchmann 1.30 configfile<<"#include <iostream>\n";
1456     configfile<<"#include <vector>\n";
1457     configfile<<"\nusing namespace std;\n\n";
1458 buchmann 1.31
1459     configfile<<"namespace PlottingSetup { \n";
1460     configfile<<"string datajzb=\"datajzb_ERROR\";\n";
1461     configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
1462     configfile<<"vector<float>jzb_cuts;\n";
1463     configfile<<"float MCPeakError=-999;\n";
1464     configfile<<"}\n\n";
1465    
1466    
1467    
1468 buchmann 1.30 configfile<<"void read_config() {\n";
1469     configfile<<"datajzb=\""<<datajzb<<"\";\n";
1470     configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
1471 buchmann 1.31 configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
1472 buchmann 1.30 for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<");\n";
1473     configfile<<"\n\n";
1474     for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<");\n";
1475     for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<");\n";
1476     for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<");\n";
1477 buchmann 1.37 configfile<<"\n\n";
1478 buchmann 1.38 configfile<<"luminosity="<<luminosity<<";\n";
1479 buchmann 1.30
1480     configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
1481    
1482     configfile.close();
1483    
1484     }
1485    
1486 buchmann 1.40 float get_nonzero_minimum(TH1F *histo) {
1487     float min=histo->GetMaximum();
1488     for(int ibin=1;ibin<=histo->GetNbinsX();ibin++) {
1489     float curcont=histo->GetBinContent(ibin);
1490     if(curcont<min&&curcont>0) min=curcont;
1491     }
1492     return min;
1493     }
1494    
1495     void draw_all_ttbar_histos(TCanvas *can, vector<TH1F*> histos, string drawoption="", float manualmin=-9) {
1496     can->cd();
1497     float min=1;
1498     float max=histos[0]->GetMaximum();
1499     if(manualmin>=0) min=manualmin;
1500     else {
1501     for(int i=1;i<histos.size();i++) {
1502     float curmin=get_nonzero_minimum(histos[i]);
1503     float curmax=histos[i]->GetMaximum();
1504     if(curmin<min) min=curmin;
1505     if(curmax>max) max=curmax;
1506     }
1507     }
1508     histos[0]->GetYaxis()->SetRangeUser(min,4*max);
1509     histos[0]->Draw(drawoption.c_str());
1510     stringstream drawopt;
1511     drawopt << drawoption << ",same";
1512     for(int i=1;i<histos.size();i++) {
1513     histos[i]->Draw(drawopt.str().c_str());
1514     }
1515     }
1516    
1517     void ttbar_sidebands_comparison(string mcjzb) {
1518 buchmann 1.64 if(!RestrictToMassPeak) write_warning(__FUNCTION__,"Watch out, once we go offpeak this function needs rewriting!");//need to build in a warning that this function is pointless for the off peak analysis
1519 buchmann 1.60 TCut weightbackup=cutWeight;
1520     cutWeight="1.0";
1521 buchmann 1.40 float sbg_min=-110;
1522     float sbg_max=jzbHigh;
1523 buchmann 1.63 int sbg_nbins=(sbg_max-sbg_min)/20.0;
1524 buchmann 1.58 float simulatedlumi = luminosity; //in pb please - adjust to your likings
1525 buchmann 1.40
1526 fronga 1.51 TH1F *TZem = allsamples.Draw("TZem",mcjzb,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
1527     TH1F *TSem = allsamples.Draw("TSem",mcjzb,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
1528     TH1F *TZeemm = allsamples.Draw("TZeemm",mcjzb,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
1529     TH1F *TSeemm = allsamples.Draw("TSeemm",mcjzb,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
1530 buchmann 1.40
1531     TCanvas *tcan = new TCanvas("tcan","tcan");
1532    
1533     tcan->SetLogy(1);
1534    
1535     TZeemm->SetLineColor(kBlack);
1536     TZem->SetLineColor(kRed);
1537     TSem->SetLineColor(kGreen);
1538     TSeemm->SetLineColor(kBlue);
1539    
1540     TZeemm->SetMarkerColor(kBlack);
1541     TZem->SetMarkerColor(kRed);
1542     TSem->SetMarkerColor(kGreen);
1543     TSeemm->SetMarkerColor(kBlue);
1544    
1545     TSem->SetLineStyle(2);
1546     TSeemm->SetLineStyle(2);
1547    
1548     vector<TH1F*> histos;
1549     histos.push_back(TZem);
1550     histos.push_back(TZeemm);
1551     histos.push_back(TSem);
1552     histos.push_back(TSeemm);
1553     draw_all_ttbar_histos(tcan,histos,"histo",0.04);
1554    
1555 fronga 1.51 TLegend *leg = make_legend("MC ttbar",0.55,0.65,false);
1556 buchmann 1.42 leg->AddEntry(TZeemm,"SFZP","l");
1557     leg->AddEntry(TZem,"OFZP","l");
1558     leg->AddEntry(TSeemm,"SFSB","l");
1559     leg->AddEntry(TSem,"OFSB","l");
1560 buchmann 1.40 leg->Draw("same");
1561 fronga 1.51 DrawMCPrelim(simulatedlumi);
1562 buchmann 1.40 CompleteSave(tcan,"ttbar_comparison");
1563    
1564     TZem->Divide(TZeemm);
1565     TSem->Divide(TZeemm);
1566     TSeemm->Divide(TZeemm);
1567    
1568 buchmann 1.62 TZem->SetMarkerStyle(21);
1569     TSem->SetMarkerStyle(24);
1570     TSeemm->SetMarkerStyle(30);
1571    
1572 buchmann 1.40 tcan->SetLogy(0);
1573     TZem->GetYaxis()->SetRangeUser(0,2.5);
1574     TZem->GetYaxis()->SetTitle("predicted/MC truth");
1575     TZem->Draw();
1576     TSem->Draw("same");
1577     TSeemm->Draw("same");
1578    
1579     TLine *top = new TLine(sbg_min,1.5,sbg_max,1.5);
1580     TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
1581     TLine *bottom = new TLine(sbg_min,0.5,sbg_max,0.5);
1582    
1583     top->SetLineColor(kBlue);top->SetLineStyle(2);
1584     bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
1585     center->SetLineColor(kBlue);
1586    
1587     top->Draw("same");
1588     center->Draw("same");
1589     bottom->Draw("same");
1590    
1591 fronga 1.51 TLegend *leg2 = make_legend("MC ttbar",0.55,0.75,false);
1592 buchmann 1.43 leg2->AddEntry(TZem,"OFZP / SFZP","ple");
1593     leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
1594     leg2->AddEntry(TSem,"OFSB / SFZP","ple");
1595 buchmann 1.40 leg2->AddEntry(bottom,"syst. envelope","l");
1596 buchmann 1.62 leg2->SetX1(0.25);leg2->SetX2(0.6);
1597 buchmann 1.40 leg2->SetY1(0.65);
1598    
1599     leg2->Draw("same");
1600    
1601 fronga 1.51 DrawMCPrelim(simulatedlumi);
1602 buchmann 1.40 CompleteSave(tcan,"ttbar_comparison_ratio");
1603    
1604     delete tcan;
1605 buchmann 1.60 cutWeight=weightbackup;
1606 buchmann 1.40 }
1607    
1608 fronga 1.45 void zjets_prediction_comparison(string mcjzb) {
1609 buchmann 1.64 if(!RestrictToMassPeak) write_warning(__FUNCTION__,"Watch out, once we go offpeak this function needs rewriting!");
1610 buchmann 1.60 TCut weightbackup=cutWeight;
1611     cutWeight="1.0";
1612 fronga 1.45 float sbg_min=0.;
1613     float sbg_max=100.;
1614     int sbg_nbins=5;
1615 buchmann 1.58 float simulatedlumi = luminosity;//in pb please - adjust to your likings
1616 fronga 1.45
1617     TCut kPos((mcjzb+">0").c_str());
1618     TCut kNeg((mcjzb+"<0").c_str());
1619     string var( "abs("+mcjzb+")" );
1620    
1621     TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
1622     TH1F *hJZBpos = allsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
1623 fronga 1.51 kcut&&kPos,mc,simulatedlumi,allsamples.FindSample("DYJets"));
1624 fronga 1.45 TH1F *hJZBneg = allsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
1625 fronga 1.51 kcut&&kNeg,mc,simulatedlumi,allsamples.FindSample("DYJets"));
1626 fronga 1.45 hJZBpos->SetLineColor(kBlack);
1627     hJZBneg->SetLineColor(kRed);
1628    
1629     Int_t nbins = 5;
1630     Float_t xmax = 100.;
1631    
1632    
1633     TCanvas *zcan = new TCanvas("zcan","zcan");
1634     zcan->SetLogy(1);
1635    
1636     hJZBpos->Draw("e1");
1637     hJZBneg->Draw("same,hist");
1638     hJZBpos->Draw("same,e1"); // So it's on top...
1639    
1640 fronga 1.51 TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
1641 fronga 1.45 leg->AddEntry(hJZBpos,"Observed","pe");
1642     leg->AddEntry(hJZBneg,"Predicted","l");
1643     leg->Draw("same");
1644 fronga 1.51 DrawMCPrelim(simulatedlumi);
1645 fronga 1.45 CompleteSave(zcan,"zjets_prediction");
1646    
1647     TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
1648     hratio->Divide(hJZBneg);
1649    
1650     zcan->SetLogy(0);
1651     hratio->GetYaxis()->SetRangeUser(0,2.5);
1652     hratio->GetYaxis()->SetTitle("Observed/Predicted");
1653     hratio->Draw("e1");
1654    
1655     TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
1656     TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
1657     TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
1658    
1659    
1660     top->SetLineColor(kBlue);top->SetLineStyle(2);
1661     bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
1662     center->SetLineColor(kBlue);
1663    
1664     top->Draw("same");
1665     center->Draw("same");
1666     bottom->Draw("same");
1667    
1668 fronga 1.51 TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
1669 fronga 1.45 leg2->AddEntry(hratio,"obs / pred","pe");
1670     leg2->AddEntry(bottom,"syst. envelope","l");
1671     leg2->Draw("same");
1672 fronga 1.51 DrawMCPrelim(simulatedlumi);
1673 fronga 1.45 CompleteSave(zcan,"zjets_prediction_ratio");
1674    
1675     delete zcan;
1676 buchmann 1.60 cutWeight=weightbackup;
1677    
1678 fronga 1.45 }
1679    
1680 buchmann 1.30
1681 buchmann 1.11 void test() {
1682 buchmann 1.19
1683 buchmann 1.11 TCanvas *testcanv = new TCanvas("testcanv","testcanv");
1684     testcanv->cd();
1685     switch_overunderflow(true);
1686 buchmann 1.17 TH1F *ptdistr = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
1687 buchmann 1.11 switch_overunderflow(false);
1688     ptdistr->Draw();
1689     testcanv->SaveAs("test.png");
1690 buchmann 1.21 dout << "HELLO there!" << endl;
1691 buchmann 1.19
1692 buchmann 1.11 }