ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/Plotting_Functions.C
Revision: 1.69
Committed: Mon Sep 19 15:37:13 2011 UTC (13 years, 7 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.68: +9 -2 lines
Log Message:
Adapted ratio plot so the axes are legible and the ratio plot doesn't cover the mll histo anymore

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