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

Comparing UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C (file contents):
Revision 1.2 by buchmann, Thu Feb 9 16:02:21 2012 UTC vs.
Revision 1.25 by buchmann, Fri Jun 15 08:41:04 2012 UTC

# Line 23 | Line 23 | using namespace PlottingSetup;
23   void todo() {
24    dout << "My to do list: " << endl;
25    dout << "  - ExperimentalModule::Poisson_ratio_plot : Get the second part to work!" << endl;
26 +  dout << "  - compare_onpeak_offpeak_signal_distributions: Implement this function ... " << endl;
27    dout << "Info : The trigger requirement is currently set to " << (const char*) passtrig << endl;
28 +  dout << "Info : The pt requirement is currently set to " << (const char*) passtrig << endl;
29 +  dout << "Info : The mll requirement is currently set to " << (const char*) cutmass << endl;
30 +  dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
31   }  
32  
33   void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
# Line 31 | Line 35 | void find_peaks(float &MCPeak,float &MCP
35    // Temporarily switch off PU reweighting, if asked
36    TCut weightbackup=cutWeight;
37    if ( !doPUreweighting ) cutWeight="1.0";
38 <
38 >  
39 >  int nbins=100;
40 >  if(PlottingSetup::DoBTag) nbins=25;
41 >  
42    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
43 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
44 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
45 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
46 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
43 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
44 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
45 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
46 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
47    TH1F *rawttbarjzbeemmMC;
48  
49    if(method==doKM) {
50      //we only need this histo for the KM fitting...
51 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
51 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
52      MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
53      DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
54    }
# Line 68 | Line 75 | void find_peaks(float &MCPeak,float &MCP
75    delete tempcan;
76   }
77  
78 + void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
79 +  float min=70.0;
80 +  float max=115.0;
81 +  if(!PlottingSetup::RestrictToMassPeak) {
82 +    min=10;
83 +    max=150;
84 +  }
85 +  int nbins=int((max-min)/5);
86 +  
87 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
88 +  
89 +  stringstream largerzeroS;
90 +  largerzeroS << "(" << mcjzb << ">" << jzbthreshold << ")";
91 +  TCut largerzero(largerzeroS.str().c_str());
92 +  
93 +  stringstream smallerzeroS;
94 +  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
95 +  TCut smallerzero(smallerzeroS.str().c_str());
96 +  
97 +  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,data,luminosity);
98 +  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,mc,luminosity);
99 +  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,data,luminosity);
100 +  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,data,luminosity);
101 +  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,data,luminosity);
102 +
103 +  TH1F *RcorrJZBSBem;
104 +  TH1F *LcorrJZBSBem;
105 +  TH1F *RcorrJZBSBeemm;
106 +  TH1F *LcorrJZBSBeemm;
107 +  
108 + //  TH1F *RcorrJZBeemmNoS;
109 +
110 +  if(PlottingSetup::RestrictToMassPeak) {
111 +    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,data, luminosity);
112 +    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,data, luminosity);
113 +    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,data, luminosity);
114 +    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,data, luminosity);
115 +  }
116 +  
117 +  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
118 +  if(PlottingSetup::RestrictToMassPeak) {
119 +    Bpred->Add(RcorrJZBem,1.0/3.);
120 +    Bpred->Add(LcorrJZBem,-1.0/3.);
121 +    Bpred->Add(RcorrJZBSBem,1.0/3.);
122 +    Bpred->Add(LcorrJZBSBem,-1.0/3.);
123 +    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
124 +    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
125 +  } else {
126 +    Bpred->Add(RcorrJZBem,1.0);
127 +    Bpred->Add(LcorrJZBem,-1.0);
128 +  }
129 +  
130 +  Bpred->SetLineColor(kRed);
131 +  
132 +  RcorrJZBeemm->Draw();
133 +  mcRcorrJZBeemm.Draw("same");
134 +  Bpred->Draw("histo,same");
135 +  RcorrJZBeemm->Draw("same");
136 +  
137 +  TLegend *leg = allsamples.allbglegend();
138 +  leg->SetX1(0.58);
139 +  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
140 +  leg->AddEntry(Bpred,"predicted (data)","l");
141 +  leg->Draw("same");
142 +  
143 +  stringstream saveas;
144 +  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
145 +  CompleteSave(ckin,saveas.str());
146 +
147 +  delete RcorrJZBeemm;
148 +  delete LcorrJZBeemm;
149 +  delete RcorrJZBem;
150 +  delete LcorrJZBem;
151 +  if(PlottingSetup::RestrictToMassPeak) {
152 +    delete RcorrJZBSBeemm;
153 +    delete LcorrJZBSBeemm;
154 +    delete RcorrJZBSBem;
155 +    delete LcorrJZBSBem;
156 +  }
157 +  delete Bpred;
158 +  delete ckin;
159 + }
160 +
161   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
162    
163    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
# Line 102 | Line 192 | void make_special_mll_plot(int nbins, fl
192    TIter next(bgleg->GetListOfPrimitives());
193    TObject* obj;
194    // Copy the nice bkgd legend skipping the "data"
195 <  while ( obj = next() )
195 >  while ( (obj = next()) )
196      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
197        kinleg->GetListOfPrimitives()->Add(obj);
198  
# Line 121 | Line 211 | void draw_ratio_plot(TH1* hdata, THStack
211    TIter next(hmc.GetHists());
212    TObject* obj;
213    TH1* hratio = NULL;
214 <  while ( obj = next() ) {
214 >  while ( (obj = next()) ) {
215      if ( !hratio ) {
216        hratio = (TH1*)obj->Clone();
217        hratio->SetName("hratio");
# Line 182 | Line 272 | void make_kin_plot(string variable, stri
272    TCut cut;
273    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
274    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
275 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
276    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
277    if(filename=="mll") {
278          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 193 | Line 284 | void make_kin_plot(string variable, stri
284          draw_separation_lines=true;
285    }
286    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
287 <  if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
287 >  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
288 >  if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
289    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
290    if(filename=="mll_inclusive_osof") cut=cutOSOF;
291    if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
# Line 208 | Line 300 | void make_kin_plot(string variable, stri
300    THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
301    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
302    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
303 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
303 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
304    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
305    if(filename=="mll_osof") datahisto->SetMinimum(9);
214
306    datahisto->SetMaximum(5.3*datahisto->GetMaximum());
307    datahisto->Draw("e1");
308    ckin->Update();
# Line 291 | Line 382 | void make_kin_plot(string variable, stri
382    delete ckin;
383   }
384  
294
385   void make_JES_plot() {
386  
387    int nbins=10;
# Line 343 | Line 433 | void do_kinematic_plots(string mcjzb, st
433    bool dolog=true;
434    bool nolog=false;
435    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
436 <  float mll_low=40;
436 >  float mll_low=50;
437    float mll_hi=160;
438    if(!PlottingSetup::RestrictToMassPeak) {
439 <        mll_low=30;
440 <        mll_hi=180;
439 >        mll_low=iMllLow;
440 >        mll_hi=210;
441    }
442 +  
443 +  make_kin_plot("met[4]","",40,0,200,dolog,"MET [GeV]","met",doPF,true);
444    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
445    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
446    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
# Line 356 | Line 448 | void do_kinematic_plots(string mcjzb, st
448    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
449    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
450    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
451 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
451 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/2,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
452    make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
453 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
454 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
453 >  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
454 > //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
455 > //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
456    make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
457    make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
458    make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
459    make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
460    make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
461 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
462 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
461 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
462 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
463 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
464    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
465    stringstream jzbcut;
466    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
467    make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
468 +  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
469 +  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
470 +  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
471 +  stringstream jzbcut2;
472 +  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
473 +  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
474 +  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
475 +  stringstream jzbcut3;
476 +  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
477 +  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
478 +  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
479 +  
480 +  make_special_obs_pred_mll_plot(mcjzb,0);
481 +  make_special_obs_pred_mll_plot(mcjzb,50);
482 +  make_special_obs_pred_mll_plot(mcjzb,100);
483 +  make_special_obs_pred_mll_plot(mcjzb,150);
484 +  make_special_obs_pred_mll_plot(mcjzb,200);
485 +  make_special_obs_pred_mll_plot(mcjzb,250);
486   }
487  
488   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 442 | Line 554 | void region_comparison_plots(string mcjz
554      
555    
556      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
557 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
557 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
558      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
559      float mll_low=50;float mll_high=170;
560      if(!PlottingSetup::RestrictToMassPeak) {
# Line 479 | Line 591 | void signal_bg_comparison()
591    
592    float simulatedlumi=luminosity;//in pb please - adjust to your likings
593    
594 <  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
595 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
594 >  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
595 >  TH1F *JZBplotLM4;
596 >  if(PlottingSetup::RestrictToMassPeak) JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
597 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
598    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
599    
600    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 504 | Line 618 | void signal_bg_comparison()
618    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
619    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
620    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
621 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
621 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
622 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
623    signal_bg_comparison_leg2->Draw();
624    DrawMCPrelim(simulatedlumi);
625    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 746 | Line 861 | if you want to start from scratch (witho
861    return return_functions;
862   }
863  
864 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
864 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
865   {
866 +  // note: sigma is not used ATM
867 +  switch_overunderflow(true);
868    bool is_data=false;
869    bool use_signal=false;
870    if(use_data==1) is_data=true;
# Line 756 | Line 873 | void do_prediction_plot(string jzb, TCan
873    if(is_data) nbins=50;
874    float low=0;
875    float hi=500;
876 +  
877 +  stringstream largerzeroS;
878 +  largerzeroS << "("<<jzb<<">0)";
879 +  TCut largerzero(largerzeroS.str().c_str());
880 +  stringstream smallerzeroS;
881 +  smallerzeroS << "("<<jzb<<"<0)";
882 +  TCut smallerzero(smallerzeroS.str().c_str());
883 +  
884    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
885 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
886 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
887 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
888 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
885 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
886 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
887 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
888 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
889 >
890    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
891    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
892    blankback->GetXaxis()->CenterTitle();
# Line 775 | Line 901 | void do_prediction_plot(string jzb, TCan
901    TH1F *RcorrJZBeemmNoS;
902  
903      //these are for the ratio
904 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
905 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
906 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
907 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
904 >  
905 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
906 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
907 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
908 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
909    
910    TH1F *JRcorrJZBSBem;
911    TH1F *JLcorrJZBSBem;
912    TH1F *JRcorrJZBSBeemm;
913    TH1F *JLcorrJZBSBeemm;
914    
915 <  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
915 >  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,false);
916  
917    
918    if(PlottingSetup::RestrictToMassPeak) {
919 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
920 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
921 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
922 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
923 <
919 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
920 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
921 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
922 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
923 >    
924      //these are for the ratio
925 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
926 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
927 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
928 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
802 <
925 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
926 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
927 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
928 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
929    }
930    
931    TH1F *lm4RcorrJZBeemm;
932 <  if(overlay_signal || use_data == 2 ) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM4"));
932 >  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,allsamples.FindSample("LM"));
933    
934    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
935    
# Line 812 | Line 938 | void do_prediction_plot(string jzb, TCan
938      
939    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
940    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
941 +    
942 +  TH1F *BpredSys = (TH1F*)LcorrJZBeemm->Clone("Bpredsys");
943 +  ClearHisto(BpredSys);
944 +    write_error(__FUNCTION__,"Implemented systematic error but NOT drawing it yet. Need to still implement drawing, particularly in ratio.");
945 +    
946    if(PlottingSetup::RestrictToMassPeak) {
947      Bpred->Add(RcorrJZBem,1.0/3.);
948      Bpred->Add(LcorrJZBem,-1.0/3.);
# Line 834 | Line 965 | void do_prediction_plot(string jzb, TCan
965      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
966      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
967      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
968 +      
969 +    //Systematics:
970 +    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
971 +    AddSquared(BpredSys,RcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
972 +    AddSquared(BpredSys,LcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
973 +    AddSquared(BpredSys,RcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
974 +    AddSquared(BpredSys,LcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
975 +    AddSquared(BpredSys,RcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
976 +    AddSquared(BpredSys,LcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
977    } else {
978      Bpred->Add(RcorrJZBem,1.0);
979      Bpred->Add(LcorrJZBem,-1.0);
# Line 843 | Line 983 | void do_prediction_plot(string jzb, TCan
983      //these are for the ratio
984      JBpred->Add(JRcorrJZBem,1.0);
985      JBpred->Add(JLcorrJZBem,-1.0);
986 +      
987 +    //Systematics
988 +    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
989 +    AddSquared(BpredSys,RcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
990 +    AddSquared(BpredSys,LcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
991 +
992    }
993      
994 <  
994 >  SQRT(BpredSys);
995 >
996    
997    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
998    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
# Line 890 | Line 1037 | void do_prediction_plot(string jzb, TCan
1037    blankback->Draw();
1038    if(use_data==1)
1039    {
1040 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1041 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1042      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1043      kinpad->cd();//necessary because the extended fit function creates its own canvas
1044      RcorrJZBeemm->Draw("e1x0,same");
1045  
1046      Bpred->Draw("hist,same");
1047 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1047 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1048      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1049 +    lm4RcorrJZBeemm->Draw("hist,same");
1050      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1051      legBpred->AddEntry(Bpred,"predicted","l");
1052 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1053 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1054 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1052 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1053 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1054 >    legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1055      legBpred->Draw();
1056      DrawPrelim();
1057  
1058      //this plot shows what the prediction is composed of
1059 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1060 <    specialcanv->SetLogy(1);
1061 <    Zjetspred->SetFillColor(kYellow);
1062 <    Zjetspred->SetLineColor(kYellow);
1063 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1064 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1059 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1060 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1061 >    Bpred->SetLineWidth(2);
1062 >    predcomppad->cd();
1063 >    predcomppad->SetLogy(1);
1064 >    
1065 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1066 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1067 >    sidebandsemu->Add(jzbnegative,-1);
1068 >    
1069 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1070 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1071 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1072 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1073 >    
1074      THStack predcomposition("predcomposition","prediction composition");
1075 <    predcomposition.Add(TTbarpred);
1076 <    predcomposition.Add(Zjetspred);
1075 >    predcomposition.Add(sidebandsemu);
1076 >    predcomposition.Add(jzbnegative);
1077      blankback->Draw();
1078      RcorrJZBeemm->Draw("e1x0,same");
1079      predcomposition.Draw("histo,same");//
1080      Bpred->Draw("hist,same");
1081 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1081 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1082      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1083 <    legBpred->Draw();
1083 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1084 >    lm4RcorrJZBeemm->SetLineWidth(2);
1085 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1086 >    lm4RcorrJZBeemm->Draw("histo,same");
1087      DrawPrelim();
1088 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1089 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1090 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1091 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1092 <    specialleg->Draw("same");
1093 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1094 <
1088 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1089 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1090 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1091 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1092 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1093 >    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1094 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1095 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1096 >    speciallegBpred->Draw();
1097 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1098 >    
1099 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1100      THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1101      blankback->Draw();
1102      kostack.Draw("same");
# Line 938 | Line 1105 | void do_prediction_plot(string jzb, TCan
1105      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1106      legBpred->Draw();
1107      DrawPrelim();
1108 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1108 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1109 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1110      
1111 <    delete specialcanv;
944 <    delete specialleg;
1111 >    delete speciallegBpred;
1112      delete Zjetspred;
1113      delete TTbarpred;
1114      
# Line 949 | Line 1116 | void do_prediction_plot(string jzb, TCan
1116    }
1117    if(use_data==0) {
1118      RcorrJZBeemm->Draw("e1x0,same");
1119 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1120      Bpred->Draw("hist,same");
1121      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1122 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1123 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1122 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1123 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1124      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1125      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1126      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 963 | Line 1131 | void do_prediction_plot(string jzb, TCan
1131    }
1132    if(use_data==2) {
1133      RcorrJZBeemm->Draw("e1x0,same");
1134 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1135      Bpred->Draw("hist,same");
1136      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1137 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1137 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1138      legBpred->AddEntry(Bpred,"MC predicted","l");
1139 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1139 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1140      legBpred2->AddEntry(Bpred,"MC predicted","l");
1141      {
1142        if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
# Line 978 | Line 1147 | void do_prediction_plot(string jzb, TCan
1147   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1148      }
1149      {
1150 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1151 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1152 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1153 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1154 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1155 +      
1156        RcorrJZBeemmNoS->SetLineStyle(2);
1157        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1158        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 996 | Line 1171 | void do_prediction_plot(string jzb, TCan
1171    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1172    string ytitle("ratio");
1173    if ( use_data==1 ) ytitle = "data/pred";
1174 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1174 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1175 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle);//not extending the y range anymore up to 4
1176  
1177    
1178    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1179 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1180 <  if(!PlottingSetup::RestrictToMassPeak) return;
1181 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1182 <  Bpredem->Add(RcorrJZBem);
1183 <  Bpredem->Add(LcorrJZBem,-1);
1184 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1185 <  BpredSBem->Add(RcorrJZBSBem);
1186 <  Bpred->Add(LcorrJZBSBem,-1);
1187 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1188 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1189 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1190 <  globalcanvas->cd();
1191 <  globalcanvas->SetLogy(1);
1192 <
1193 <  RcorrJZBeemm->SetMarkerStyle(20);
1194 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1195 <  blankback->Draw();
1196 <  RcorrJZBeemm->Draw("e1x0,same");
1197 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1198 <  
1199 <  Bpredem->SetLineColor(kRed+1);
1200 <  Bpredem->SetStats(0);
1201 <  Bpredem->Draw("hist,same");
1202 <
1203 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1204 <  BpredSBem->SetLineStyle(2);
1205 <  BpredSBem->Draw("hist,same");
1206 <
1207 <  BpredSBeemm->SetLineColor(kBlue+1);
1208 <  BpredSBeemm->SetLineStyle(3);
1209 <  BpredSBeemm->Draw("hist,same");
1210 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1211 <
1212 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1213 <  if(use_data==1)
1214 <  {
1215 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1216 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1217 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1218 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1219 <    legBpredc->Draw();
1220 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1221 <  }
1222 <  if(use_data==0) {
1223 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1224 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1225 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1226 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1227 <    legBpredc->Draw();
1228 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1229 <  }
1230 <  if(use_data==2) {
1231 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1232 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1233 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1234 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1235 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1236 <    legBpredc->Draw();
1237 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1179 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1180 >  if(PlottingSetup::RestrictToMassPeak) {
1181 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1182 >    Bpredem->Add(RcorrJZBem);
1183 >    Bpredem->Add(LcorrJZBem,-1);
1184 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1185 >    BpredSBem->Add(RcorrJZBSBem);
1186 >    Bpred->Add(LcorrJZBSBem,-1);
1187 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1188 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1189 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1190 >    globalcanvas->cd();
1191 >    globalcanvas->SetLogy(1);
1192 >    
1193 >    RcorrJZBeemm->SetMarkerStyle(20);
1194 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1195 >    blankback->Draw();
1196 >    RcorrJZBeemm->Draw("e1x0,same");
1197 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1198 >    
1199 >    Bpredem->SetLineColor(kRed+1);
1200 >    Bpredem->SetStats(0);
1201 >    Bpredem->Draw("hist,same");
1202 >    
1203 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1204 >    BpredSBem->SetLineStyle(2);
1205 >    BpredSBem->Draw("hist,same");
1206 >    
1207 >    BpredSBeemm->SetLineColor(kBlue+1);
1208 >    BpredSBeemm->SetLineStyle(3);
1209 >    BpredSBeemm->Draw("hist,same");
1210 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1211 >    
1212 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1213 >    if(use_data==1)
1214 >    {
1215 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1216 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1217 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1218 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1219 >      legBpredc->Draw();
1220 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1221 >    }
1222 >    if(use_data==0) {
1223 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1224 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1225 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1226 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1227 >      legBpredc->Draw();
1228 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1229 >    }
1230 >    if(use_data==2) {
1231 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1232 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1233 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1234 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1235 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1236 >      legBpredc->Draw();
1237 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1238 >    }
1239    }
1240 +  
1241    delete RcorrJZBeemm;
1242    delete LcorrJZBeemm;
1243    delete RcorrJZBem;
# Line 1084 | Line 1262 | void do_prediction_plot(string jzb, TCan
1262      delete JLcorrJZBSBeemm;
1263    }
1264    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1265 +  switch_overunderflow(false);
1266   }
1267  
1268   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1269    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1270    do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1271 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1272 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1271 >  if ( !PlottingSetup::Approved ) {
1272 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1273 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1274 >  } else {
1275 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1276 >  }
1277   }
1278  
1279   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1258 | Line 1441 | void lepton_comparison_plots() {
1441    Float_t ymin = 1.e-5, ymax = 0.25;
1442    TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
1443    can->SetLogy(1);
1444 <  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
1445 <  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
1444 >  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
1445 >  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
1446    eemc->SetLineColor(kBlue);
1447    mmmc->SetLineColor(kRed);
1448    eemc->SetMinimum(0.1);
# Line 1324 | Line 1507 | void lepton_comparison_plots() {
1507    DrawPrelim();
1508    save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
1509    
1510 <  TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("DYJets"));
1511 <  TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("DYJets"));
1512 <  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("DYJets"));
1510 >  TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("/DY"));
1511 >  TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("/DY"));
1512 >  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("/DY"));
1513    dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
1514    dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
1515    dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
# Line 1440 | Line 1623 | void draw_pure_jzb_histo(TCut cut,string
1623    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1624    writeline1->SetTextSize(0.035);
1625    writeline1->Draw();
1626 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1626 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1627 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1628    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1629    jzbpad2->cd();
1630    jzbpad2->SetLogy(1);
# Line 1455 | Line 1639 | void draw_pure_jzb_histo(TCut cut,string
1639    writeline1->SetTextSize(0.035);
1640    writeline1->Draw();
1641    DrawPrelim();
1642 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1642 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1643 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1644    datahisto->Delete();
1645    mcstack.Delete();
1646   }
# Line 1463 | Line 1648 | void draw_pure_jzb_histo(TCut cut,string
1648   Double_t GausR(Double_t *x, Double_t *par) {
1649    return gRandom->Gaus(x[0],par[0]);
1650   }
1651 +
1652 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1653 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1654 +  float max=jzbHigh ;
1655 +  float min=-120;
1656 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1657 +  int coarserbins=int(nbins/2.0);
1658 +  int rebinnedbins=int(nbins/4.0);
1659 +  
1660 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1661 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1662 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1663 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1664 +
1665 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1666 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1667 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1668 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1669 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1670 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1671 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1672 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1673 +  
1674 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1675 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1676 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1677 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1678 +  
1679 +  delete dican;
1680 + }
1681    
1682 +
1683 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1684 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1685 +  
1686 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1687 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1688 +    return;
1689 +  }
1690 +  
1691 +  float stretchfactor = 100.0;
1692 +  vector<string> labels;
1693 +  
1694 +  
1695 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1696 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1697 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1698 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1699 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1700 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1701 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1702 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1703 +  }
1704 +  
1705 +  dout << "Going to produce JZB plots" << endl;
1706 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1707 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1708 +  float sigma=123456;
1709 +  
1710 +  dout << "Going to produce prediction plots" << endl;
1711 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1712 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1713 +  delete gloca;
1714 +
1715 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1716 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1717 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1718 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1719 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1720 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1721 +    dout << "     Reset xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " from " << Upxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ") and reset the correct name (from " << Upname << ")" << endl;
1722 +    
1723 +  }
1724 +  
1725 + }
1726   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1727    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1728    float max=jzbHigh ;
# Line 1477 | Line 1736 | void jzb_plots(string mcjzb, string data
1736    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1737    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1738  
1739 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1740 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1741 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1742 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1743 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1744 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1745 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1746 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1747 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1739 >  if ( !PlottingSetup::Approved ) {
1740 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1741 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1742 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1743 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1744 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1745 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1746 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1747 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1748 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1749 >  }
1750    
1751    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
1752 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1753 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1754 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1755 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1756 <
1757 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1758 < //  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1498 < //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1499 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1500 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
1752 >  if ( !PlottingSetup::Approved ) {
1753 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1754 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1755 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1756 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1757 >  }
1758 >  delete can;
1759   }
1760  
1761  
# Line 1552 | Line 1810 | void compute_MC_yields(string mcjzb,vect
1810    string posneg[] = {"pos","neg"};
1811    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
1812  
1813 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
1813 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
1814      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
1815      dout << "_________________________________________________________" << endl;
1816      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
1817 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
1817 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
1818        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
1819        else dout << "Sample & ";
1820        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1815 | Line 2073 | void draw_ttbar_and_zjets_shape_for_one_
2073  
2074   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2075    int all_leptons=-1;
1818  int electrons_only=0;
1819  int mu_only=1;
1820  int twojetswith50gev=1;
2076    int threejetswith30gev=0;
2077   /*  
2078 +  int twojetswith50gev=1;
2079 +  int electrons_only=0;
2080 +  int mu_only=1;
2081 +
2082    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2083    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2084    
# Line 1838 | Line 2097 | void find_correction_factors(string &jzb
2097    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2098    cancorr->SetLogz();
2099    cancorr->SetRightMargin(0.13);
2100 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2100 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2101    TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2102 +  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2103    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2104    (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2105    niceresponseplotd->SetStats(0);
# Line 1850 | Line 2110 | void find_correction_factors(string &jzb
2110    niceresponseplotd->Draw("COLZ");
2111    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2112    profd->SetMarkerSize(DataMarkerSize);
2113 <  profd->Fit("pol0","","same,e1",30,400);
2113 >  profd->Fit("pol0","","same,e1",100,400);
2114    DrawPrelim();
2115    TText* title = write_text(0.5,0.7,"Data");
2116    title->SetTextAlign(12);
# Line 1866 | Line 2126 | void find_correction_factors(string &jzb
2126    CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2127    
2128    TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2129 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2129 >  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation*cutWeight);
2130    niceresponseplotm->SetStats(0);
2131    niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2132    niceresponseplotm->GetYaxis()->SetTitle("Response");
# Line 1876 | Line 2136 | void find_correction_factors(string &jzb
2136    (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2137    TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2138    profm->SetMarkerSize(DataMarkerSize);
2139 <  profm->Fit("pol0","","same,e1",30,400);
2139 >  profm->Fit("pol0","","same,e1",100,400);
2140    DrawMCPrelim();
2141    title = write_text(0.5,0.7,"MC simulation");
2142    title->SetTextAlign(12);
# Line 1912 | Line 2172 | void pick_up_events(string cut) {
2172    allsamples.PickUpEvents(cut);
2173   }
2174  
2175 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2175 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2176    dout << "Saving configuration template!" << endl;
2177    ofstream configfile;
2178    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1932 | Line 2192 | void save_template(string mcjzb, string
2192    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2193    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2194    configfile<<"vector<float>jzb_cuts;\n";
2195 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2196    configfile<<"float MCPeakError=-999;\n";
2197 +  configfile<<"float DataPeakError=-999;\n";
2198    configfile<<"}\n\n";
2199  
2200    configfile<<"void read_config() {\n";
2201    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2202    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2203 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2204 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2203 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2204 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2205 >  for(int i=0;i<(int)jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2206    configfile<<"\n\n";
2207 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2208 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2209 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2207 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2208 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2209 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2210 >  configfile<<"\n\n";
2211 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2212 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2213 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2214 >  for(int i=0;i<(int)jzb_shape_limit_bins.size();i++) configfile<<"jzb_shape_limit_bins.push_back("<<jzb_shape_limit_bins[i]<<"); // JZB shape bin boundary at " << jzb_shape_limit_bins[i] << "\n";
2215    configfile<<"\n\n";
1948  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1949  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1950  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2216    configfile<<"\n\n";
2217    configfile<<"luminosity="<<luminosity<<";\n";
2218 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2219    
2220    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2221    
# Line 1972 | Line 2238 | void draw_all_ttbar_histos(TCanvas *can,
2238    float max=histos[0]->GetMaximum();
2239    if(manualmin>=0) min=manualmin;
2240    else {
2241 <    for(int i=1;i<histos.size();i++) {
2241 >    for(int i=1;i<(int)histos.size();i++) {
2242        float curmin=get_nonzero_minimum(histos[i]);
2243        float curmax=histos[i]->GetMaximum();
2244        if(curmin<min) min=curmin;
# Line 1983 | Line 2249 | void draw_all_ttbar_histos(TCanvas *can,
2249    histos[0]->Draw(drawoption.c_str());
2250    stringstream drawopt;
2251    drawopt << drawoption << ",same";
2252 <  for(int i=1;i<histos.size();i++) {
2252 >  for(int i=1;i<(int)histos.size();i++) {
2253      histos[i]->Draw(drawopt.str().c_str());
2254    }
2255   }
# Line 1992 | Line 2258 | void ttbar_sidebands_comparison(string m
2258    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2259    //in the case of the OFF peak analysis, we compare our control region to the real value
2260    TCut weightbackup=cutWeight;
2261 <  cutWeight="1.0";
2261 > //  cutWeight="1.0";
2262    float simulatedlumi = luminosity; //in pb please - adjust to your likings
2263    
2264  
# Line 2050 | Line 2316 | void ttbar_sidebands_comparison(string m
2316    leg->Draw("same");
2317    DrawMCPrelim(simulatedlumi);
2318    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2053  
2319    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2320    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2321 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2322 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2321 >  TH1F *TSeemmcopy;
2322 >  TH1F *TSemcopy;
2323 >  if(PlottingSetup::RestrictToMassPeak) {
2324 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2325 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2326 >  }
2327  
2328    TZem->Divide(TZeemm);
2329    TZem->SetMarkerStyle(21);
# Line 2076 | Line 2345 | void ttbar_sidebands_comparison(string m
2345    
2346    float linepos=0.25;
2347    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2348 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2349    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2350    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2351    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2352    
2353 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2354 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2355 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2356 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2357 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2358 +  topalt->Draw("same");bottomalt->Draw("same");*/
2359 +  
2360 +  
2361    top->SetLineColor(kBlue);top->SetLineStyle(2);
2362    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2363    center->SetLineColor(kBlue);
# Line 2104 | Line 2382 | void ttbar_sidebands_comparison(string m
2382    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2383    
2384  
2107
2385   ///-------------- second part: only look at the quantity we actually care about!
2386    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2387    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2231 | Line 2508 | void ttbar_sidebands_comparison(string m
2508   }
2509  
2510  
2511 < void zjets_prediction_comparison() {
2511 > void zjets_prediction_comparison(string mcjzbWithPU) {
2512 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2513 >  zcan->SetLogy(1);
2514 >  TCut weightbackup=cutWeight;
2515 >
2516 > /*
2517    // Do it without PU re-weighting
2518    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2519    stringstream resultsNoPU;
2520  
2521    stringstream mcjzbnoPU;
2522 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2522 >  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2523    if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2524    else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2525  
2526    string mcjzb = mcjzbnoPU.str();
2527    dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2528  
2247  TCut weightbackup=cutWeight;
2529    cutWeight="1.0";
2530 <  float sbg_min=0.;
2531 <  float sbg_max=100.;
2532 <  int sbg_nbins=5;
2530 > */
2531 >  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2532 >  
2533 >  vector<float> binning;
2534 >  binning.push_back(0);
2535 >  binning.push_back(20);
2536 >  binning.push_back(40);
2537 >  binning.push_back(60);
2538 >  binning.push_back(80);
2539 >  binning.push_back(100);
2540 > //  float sbg_min=0.;
2541 > //  float sbg_max=100.;
2542 > //  int sbg_nbins=5;
2543    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2544    
2545    TCut kPos((mcjzb+">0").c_str());
2546    TCut kNeg((mcjzb+"<0").c_str());
2547    string var( "abs("+mcjzb+")" );
2548  
2549 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2550 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2551 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("DYJets"));
2261 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2262 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("DYJets"));
2549 >  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2550 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2551 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2552    hJZBpos->SetLineColor(kBlack);
2553    hJZBneg->SetLineColor(kRed);
2554    
2555 <  Int_t nbins = 5;
2267 <  Float_t xmax = 100.;
2268 <
2269 <  
2270 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2271 <  zcan->SetLogy(1);
2272 <
2555 >  hJZBpos->SetMinimum(1.0);
2556    hJZBpos->Draw("e1");
2557    hJZBneg->Draw("same,hist");
2558    hJZBpos->Draw("same,e1"); // So it's on top...
# Line 2289 | Line 2572 | void zjets_prediction_comparison() {
2572    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2573    hratio->Draw("e1");
2574    
2575 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
2576 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
2577 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
2575 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
2576 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2577 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
2578    
2579  
2580    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2333 | Line 2616 | void sideband_assessment(string datajzb,
2616    tout << "\\begin{tabular}{l|cc}" << endl;
2617    tout << "\\hline" << endl;
2618    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
2619 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
2619 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
2620    tout << "\\end{tabular}" << endl;
2621    tout << "\\end{center}" << endl;
2622    tout << "\\end{table}" << endl;
# Line 2351 | Line 2634 | void make_table(samplecollection &coll,
2634    
2635    TCanvas *cannie = new TCanvas("cannie","cannie");
2636    
2637 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
2637 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
2638      float currcut=jzb_cuts[icut];
2639      int nbins=1;float low=currcut;
2640      vector<int> mysample;
# Line 2410 | Line 2693 | void make_table(samplecollection &coll,
2693    //prediction part
2694    if(is_data) cout << "Data prediction & ";
2695    if(subselection!="none") cout << subselection << " prediction &";
2696 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2696 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2697    
2698    cout << endl;
2699    //observation part
2700    if(is_data) cout << "Data observation & ";
2701    if(subselection!="none") cout << subselection << " observation &";
2702 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2702 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2703    cout << endl;
2704    cout << "_________________________________________________________________" << endl;
2705    delete cannie;
# Line 2451 | Line 2734 | void JZBSelEff(string mcjzb, TTree* even
2734    int nbins = sizeof(xbins)/sizeof(float)-1;
2735    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
2736  
2737 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2738 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2739 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2737 >  
2738 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
2739 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
2740 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
2741  
2742    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
2743    TCut kreco(cutmass);
# Line 2469 | Line 2753 | void JZBSelEff(string mcjzb, TTree* even
2753    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
2754    can->SetGridx(1);
2755    can->SetGridy(1);
2756 +  can->SetLeftMargin(0.16);
2757 +  can->SetRightMargin(0.05);
2758    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
2759 +  leg->SetBorderSize(1);
2760 +  leg->SetLineColor(kBlack);
2761 +  leg->SetTextFont(62);
2762  
2763 <  
2475 <
2476 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
2763 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
2764  
2765      ostringstream selection;
2766      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2489 | Line 2776 | void JZBSelEff(string mcjzb, TTree* even
2776      }
2777    
2778      heff->GetXaxis()->SetRangeUser(min, max);
2779 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
2780 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
2781 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
2782 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
2783      heff->SetMarkerStyle(markers[icut]);
2784      heff->Fit("func","Q+","same");
2785  
# Line 2500 | Line 2791 | void JZBSelEff(string mcjzb, TTree* even
2791  
2792      // Store plot
2793      TH1F* h = (TH1F*)heff->Clone(hname);
2794 +    h->SetNdivisions(505,"X");
2795      if ( icut) h->Draw("same");
2796      else h->Draw();
2797      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2520 | Line 2812 | void JZBSelEff(string mcjzb, TTree* even
2812   // Calls the above function for each signal sample
2813   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
2814   {  
2815 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
2815 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
2816      dout << "JZB selection efficiency curve: " << std::endl;
2817      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
2818    }
2819   }
2820 +
2821 + void qcd_plots(string datajzb, string mcjzb, vector<float> bins) {
2822 +  // What this function aims to do:
2823 +  // Illustrate cut flow for QCD (requiring only one lepton, requiring etc.)
2824 +  // Illustrate how little QCD is left over! i.e. make some pointless JZB plot with only QCD to visualize the fact that there's not much really.
2825 +  TCanvas *can = new TCanvas("can","can");
2826 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
2827 +  kinpad->cd();
2828 +  
2829 +  string jzb=mcjzb;
2830 +  
2831 +  float hi=400;
2832 +  bool use_signal=false;
2833 +  bool use_data=false;
2834 +  
2835 +  bool is_data=false;
2836 +  int nbins=50;//100;
2837 +  float low=0;
2838 +  float high=500;
2839 +  int versok=false;
2840 +  if(gROOT->GetVersionInt()>=53000) versok=true;
2841 +
2842 +  TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
2843 +  TH1F *RcorrJZBeemm   = qcdsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2844 +  TH1F *LcorrJZBeemm   = qcdsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2845 +  TH1F *RcorrJZBem     = qcdsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2846 +  TH1F *LcorrJZBem     = qcdsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2847 +  blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
2848 +  blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
2849 +  blankback->GetXaxis()->CenterTitle();
2850 +  blankback->GetYaxis()->CenterTitle();
2851 +  
2852 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
2853 +  TH1F *RcorrJZBSBem;
2854 +  TH1F *LcorrJZBSBem;
2855 +  TH1F *RcorrJZBSBeemm;
2856 +  TH1F *LcorrJZBSBeemm;
2857    
2858 + //  TH1F *RcorrJZBeemmNoS;
2859 +
2860 +    //these are for the ratio
2861 +  TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2862 +  TH1F *JLcorrJZBeemm   = qcdsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2863 +  TH1F *JRcorrJZBem     = qcdsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2864 +  TH1F *JLcorrJZBem     = qcdsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2865 +  
2866 +  TH1F *JRcorrJZBSBem;
2867 +  TH1F *JLcorrJZBSBem;
2868 +  TH1F *JRcorrJZBSBeemm;
2869 +  TH1F *JLcorrJZBSBeemm;
2870 +  
2871 +  if(PlottingSetup::RestrictToMassPeak) {
2872 +    RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2873 +    LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2874 +    RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2875 +    LcorrJZBSBeemm = qcdsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2876 +
2877 +    //these are for the ratio
2878 +    JRcorrJZBSBem   = qcdsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2879 +    JLcorrJZBSBem   = qcdsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2880 +    JRcorrJZBSBeemm = qcdsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2881 +    JLcorrJZBSBeemm = qcdsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2882 +
2883 +  }
2884 +  
2885 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
2886 +  
2887 +  TH1F *Zjetspred = (TH1F*)LcorrJZBeemm->Clone("Zjetspred");
2888 +  TH1F *TTbarpred = (TH1F*)RcorrJZBem->Clone("TTbarpred");
2889 +    
2890 +  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
2891 +  TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
2892 +  if(PlottingSetup::RestrictToMassPeak) {
2893 +    Bpred->Add(RcorrJZBem,1.0/3.);
2894 +    Bpred->Add(LcorrJZBem,-1.0/3.);
2895 +    Bpred->Add(RcorrJZBSBem,1.0/3.);
2896 +    Bpred->Add(LcorrJZBSBem,-1.0/3.);
2897 +    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
2898 +    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
2899 +    
2900 +    TTbarpred->Scale(1.0/3);
2901 +    Zjetspred->Add(LcorrJZBem,-1.0/3.);
2902 +    Zjetspred->Add(LcorrJZBSBem,-1.0/3.);
2903 +    TTbarpred->Add(RcorrJZBSBem,1.0/3.);
2904 +    Zjetspred->Add(LcorrJZBSBeemm,-1.0/3.);
2905 +    TTbarpred->Add(RcorrJZBSBeemm,1.0/3.);
2906 +    
2907 +    //these are for the ratio
2908 +    JBpred->Add(JRcorrJZBem,1.0/3.);
2909 +    JBpred->Add(JLcorrJZBem,-1.0/3.);
2910 +    JBpred->Add(JRcorrJZBSBem,1.0/3.);
2911 +    JBpred->Add(JLcorrJZBSBem,-1.0/3.);
2912 +    JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
2913 +    JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
2914 +  } else {
2915 +    Bpred->Add(RcorrJZBem,1.0);
2916 +    Bpred->Add(LcorrJZBem,-1.0);
2917 +    
2918 +    Zjetspred->Add(LcorrJZBem,-1.0);
2919 +    
2920 +    //these are for the ratio
2921 +    JBpred->Add(JRcorrJZBem,1.0);
2922 +    JBpred->Add(JLcorrJZBem,-1.0);
2923 +  }
2924 +    
2925 +  
2926 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
2927 +  
2928 +  TLegend *legBpred = make_legend("",0.6,0.55,false);
2929 +  RcorrJZBeemm->Draw("e1x0,same");
2930 +  Bpred->Draw("hist,same");
2931 +  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
2932 +  legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
2933 +  legBpred->AddEntry(Bpred,"MC predicted","l");
2934 +  if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
2935 +  if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
2936 +  legBpred->Draw();
2937 +  DrawMCPrelim();
2938 +
2939 +  //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
2940 +  string ytitle("ratio");
2941 +  if ( use_data==1 ) ytitle = "data/pred";
2942 +  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
2943 +  
2944 +  TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
2945 +  TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
2946 +  TH1F *osof = qcdsamples.Draw("osof","pfJetGoodNum",1,0,100, "internal code", "events", cutOSOF ,mc, luminosity);
2947 +  TH1F *njossf = qcdsamples.Draw("njossf","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSSF ,mc, luminosity);
2948 +  TH1F *njosof = qcdsamples.Draw("njosof","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSOF ,mc, luminosity);
2949 +  
2950 +  dout << "______________________________________________" << endl;
2951 +  dout << "QCD contribution: " << endl;
2952 +  dout << "Total number of events: " << allevents->Integral() << endl;
2953 +  dout << "OSSF events: " << ossf->Integral() << endl;
2954 +  dout << "OSOF events: " << osof->Integral() << endl;
2955 +  dout << "OSSF events with >=3 jets:" << njossf->Integral() << endl;
2956 +  dout << "OSOF events with >=3 jets:" << njosof->Integral() << endl;
2957 +  dout << "(note that no mass requirement has been imposed)" << endl;
2958 +  
2959 +  dout << "______________________________________________" << endl;
2960 +  dout << "How QCD shows up in the different regions: " << endl;
2961 +  dout << "OSSF: " << endl;
2962 +  if(PlottingSetup::RestrictToMassPeak) {
2963 +    dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
2964 +    dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
2965 +  } else {
2966 +    dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
2967 +  }
2968 +  dout << "OSOF: " << endl;
2969 +  if(PlottingSetup::RestrictToMassPeak) {
2970 +    dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
2971 +    dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
2972 +  } else {
2973 +    dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
2974 +  }
2975 +  dout << "Therefore: " << endl;
2976 +  if(PlottingSetup::RestrictToMassPeak) {
2977 +    dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
2978 +    dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
2979 +    dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
2980 +    dout << " = " << LcorrJZBeemm->Integral() + (1.0/3)*(RcorrJZBSBeemm->Integral() - LcorrJZBSBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() + RcorrJZBSBem->Integral() - LcorrJZBSBem->Integral()) << endl;
2981 +  } else {
2982 +    dout << "    Prediction increases by : " << LcorrJZBeemm->Integral();
2983 +    dout << " + (" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
2984 +    dout << " = " << LcorrJZBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() << endl;
2985 +  }
2986 +  dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
2987 +  
2988 +  dout << endl;
2989 +  for(int i=0;i<(int)bins.size();i++) {
2990 +    dout << " JZB > " << bins[i] << " : " << endl;
2991 +    dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
2992 +    if(PlottingSetup::RestrictToMassPeak) {
2993 +        dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + (1.0/3)*(RcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX())) << endl;
2994 +    } else {
2995 +        dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
2996 +    }
2997 +  }
2998 +      
2999 +  delete can;
3000 +  delete allevents;
3001 +  if(ossf) delete ossf;
3002 +  if(RcorrJZBem) delete RcorrJZBem;
3003 +  if(LcorrJZBem) delete LcorrJZBem;
3004 +  if(RcorrJZBeemm) delete RcorrJZBeemm;
3005 +  if(LcorrJZBeemm) delete LcorrJZBeemm;
3006 +  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3007 +  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3008 +  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3009 +  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3010 + }
3011 +
3012 + void check_ptsanity() {
3013 +  TCanvas *ptsancan = new TCanvas("ptsancan","ptsancan",600,1800);
3014 +  TH1F *individualpt1histos[allsamples.collection.size()];
3015 +  TH1F *individualpt2histos[allsamples.collection.size()];
3016 +  TH1F *fpt1 = new TH1F("fpt1","fpt1",50,0,50);
3017 +  fpt1->GetYaxis()->SetRangeUser(0,1);
3018 +  fpt1->GetXaxis()->SetTitle("p_{T,1}");
3019 +  fpt1->GetXaxis()->CenterTitle();
3020 +
3021 +  TH1F *fpt2 = new TH1F("fpt2","fpt2",50,0,50);
3022 +  fpt2->GetXaxis()->SetTitle("p_{T,2}");
3023 +  fpt2->GetXaxis()->CenterTitle();
3024 +  
3025 +  ptsancan->Divide(1,3);
3026 +  ptsancan->cd(1);
3027 +  float maxpt1entry=0;
3028 +  float maxpt2entry=0;
3029 +  
3030 +  TLegend *leg = make_legend();
3031 +  leg->SetX1(0.0);
3032 +  leg->SetY1(0.0);
3033 +  leg->SetX2(1.0);
3034 +  leg->SetY2(1.0);
3035 +  
3036 +  
3037 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3038 +    string nowname=(allsamples.collection)[isample].filename;
3039 +    cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3040 +    individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3041 +    individualpt2histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt2",50,0,50, "p_{T,2}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3042 +    individualpt1histos[isample]->SetLineColor(isample+1);
3043 +    individualpt2histos[isample]->SetLineColor(isample+1);
3044 +    float currmaxpt1entry=individualpt1histos[isample]->GetMaximum()/individualpt1histos[isample]->Integral();
3045 +    float currmaxpt2entry=individualpt2histos[isample]->GetMaximum()/individualpt2histos[isample]->Integral();
3046 +    cout << "      pt 1 histo contains; " << individualpt1histos[isample]->Integral() << endl;
3047 +    cout << "      pt 2 histo contains; " << individualpt2histos[isample]->Integral() << endl;
3048 +    if(currmaxpt1entry>maxpt1entry)maxpt1entry=currmaxpt1entry;
3049 +    if(currmaxpt2entry>maxpt2entry)maxpt2entry=currmaxpt2entry;
3050 +    leg->AddEntry(individualpt2histos[isample],((allsamples.collection)[isample].filename).c_str(),"f");
3051 +  }
3052 +
3053 +  fpt1->GetYaxis()->SetRangeUser(0,maxpt1entry);
3054 +  fpt2->GetYaxis()->SetRangeUser(0,maxpt2entry);
3055 +
3056 +  ptsancan->cd(1);
3057 +  fpt1->Draw();
3058 +  ptsancan->cd(2);
3059 +  fpt2->Draw();
3060 +
3061 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3062 +    ptsancan->cd(1);
3063 +    individualpt1histos[isample]->DrawNormalized("same,histo");
3064 +    ptsancan->cd(2);
3065 +    individualpt2histos[isample]->DrawNormalized("same,histo");
3066 +  }
3067 +  ptsancan->cd(3);
3068 +  leg->Draw();
3069 +  CompleteSave(ptsancan,"PtSanityCheck");
3070 +  
3071 +  delete ptsancan;
3072 + }
3073 +
3074 + void do_mlls_plot(string mcjzb) {
3075 +  cout << "At this point we'd plot the mll distribution" << endl;
3076 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3077 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3078 +    if(!(signalsamples.collection)[isig].events) continue;
3079 +    string nowname=(signalsamples.collection)[isig].filename;
3080 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3081 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3082 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3083 +    stringstream poscutS;
3084 +    poscutS << "((" << mcjzb <<")>50)";
3085 +    TCut poscut(poscutS.str().c_str());
3086 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3087 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3088 +    mll->Draw("histo");
3089 +    mllP->Draw("histo,same");
3090 +    TLegend *leg = make_legend();
3091 +    leg->SetY1(0.8);
3092 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3093 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3094 +    leg->Draw();
3095 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3096 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3097 +    lin->Draw("same");
3098 +    lin2->Draw("same");
3099 +    
3100 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3101 +    delete mll;
3102 +    delete mllP;
3103 +  }
3104 + }
3105 +
3106 + void met_vs_jzb_plots() {
3107 +  
3108 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3109 +  canmetjzb->SetRightMargin(0.16);
3110 +  
3111 +  vector<string> findme;
3112 +  findme.push_back("DY");
3113 +  findme.push_back("TTJets");
3114 +  findme.push_back("LM");
3115 +  
3116 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3117 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3118 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3119 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3120 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3121 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3122 +    }
3123 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3124 +    metvsjzb->SetStats(0);
3125 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3126 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3127 +    metvsjzb->GetXaxis()->CenterTitle();
3128 +    metvsjzb->GetYaxis()->CenterTitle();
3129 +    metvsjzb->Draw("COLZ");
3130 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3131 +    title->SetTextAlign(12);
3132 +    title->Draw();
3133 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3134 +  }
3135 + }
3136 +    
3137  
3138   void test() {
3139    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines