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.23 by buchmann, Thu Jun 7 08:16:28 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    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
40    TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
41    TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
# Line 68 | Line 72 | void find_peaks(float &MCPeak,float &MCP
72    delete tempcan;
73   }
74  
75 + void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
76 +  float min=70.0;
77 +  float max=115.0;
78 +  if(!PlottingSetup::RestrictToMassPeak) {
79 +    min=10;
80 +    max=150;
81 +  }
82 +  int nbins=int((max-min)/5);
83 +  
84 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
85 +  
86 +  stringstream largerzeroS;
87 +  largerzeroS << "(" << mcjzb << ">" << jzbthreshold << ")";
88 +  TCut largerzero(largerzeroS.str().c_str());
89 +  
90 +  stringstream smallerzeroS;
91 +  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
92 +  TCut smallerzero(smallerzeroS.str().c_str());
93 +  
94 +  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,data,luminosity);
95 +  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,mc,luminosity);
96 +  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,data,luminosity);
97 +  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,data,luminosity);
98 +  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,data,luminosity);
99 +
100 +  TH1F *RcorrJZBSBem;
101 +  TH1F *LcorrJZBSBem;
102 +  TH1F *RcorrJZBSBeemm;
103 +  TH1F *LcorrJZBSBeemm;
104 +  
105 + //  TH1F *RcorrJZBeemmNoS;
106 +
107 +  if(PlottingSetup::RestrictToMassPeak) {
108 +    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,data, luminosity);
109 +    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,data, luminosity);
110 +    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,data, luminosity);
111 +    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,data, luminosity);
112 +  }
113 +  
114 +  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
115 +  if(PlottingSetup::RestrictToMassPeak) {
116 +    Bpred->Add(RcorrJZBem,1.0/3.);
117 +    Bpred->Add(LcorrJZBem,-1.0/3.);
118 +    Bpred->Add(RcorrJZBSBem,1.0/3.);
119 +    Bpred->Add(LcorrJZBSBem,-1.0/3.);
120 +    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
121 +    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
122 +  } else {
123 +    Bpred->Add(RcorrJZBem,1.0);
124 +    Bpred->Add(LcorrJZBem,-1.0);
125 +  }
126 +  
127 +  Bpred->SetLineColor(kRed);
128 +  
129 +  RcorrJZBeemm->Draw();
130 +  mcRcorrJZBeemm.Draw("same");
131 +  Bpred->Draw("histo,same");
132 +  RcorrJZBeemm->Draw("same");
133 +  
134 +  TLegend *leg = allsamples.allbglegend();
135 +  leg->SetX1(0.58);
136 +  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
137 +  leg->AddEntry(Bpred,"predicted (data)","l");
138 +  leg->Draw("same");
139 +  
140 +  stringstream saveas;
141 +  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
142 +  CompleteSave(ckin,saveas.str());
143 +
144 +  delete RcorrJZBeemm;
145 +  delete LcorrJZBeemm;
146 +  delete RcorrJZBem;
147 +  delete LcorrJZBem;
148 +  if(PlottingSetup::RestrictToMassPeak) {
149 +    delete RcorrJZBSBeemm;
150 +    delete LcorrJZBSBeemm;
151 +    delete RcorrJZBSBem;
152 +    delete LcorrJZBSBem;
153 +  }
154 +  delete Bpred;
155 +  delete ckin;
156 + }
157 +
158   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
159    
160    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
# Line 102 | Line 189 | void make_special_mll_plot(int nbins, fl
189    TIter next(bgleg->GetListOfPrimitives());
190    TObject* obj;
191    // Copy the nice bkgd legend skipping the "data"
192 <  while ( obj = next() )
192 >  while ( (obj = next()) )
193      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
194        kinleg->GetListOfPrimitives()->Add(obj);
195  
# Line 121 | Line 208 | void draw_ratio_plot(TH1* hdata, THStack
208    TIter next(hmc.GetHists());
209    TObject* obj;
210    TH1* hratio = NULL;
211 <  while ( obj = next() ) {
211 >  while ( (obj = next()) ) {
212      if ( !hratio ) {
213        hratio = (TH1*)obj->Clone();
214        hratio->SetName("hratio");
# Line 182 | Line 269 | void make_kin_plot(string variable, stri
269    TCut cut;
270    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
271    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
272 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
273    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
274    if(filename=="mll") {
275          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 193 | Line 281 | void make_kin_plot(string variable, stri
281          draw_separation_lines=true;
282    }
283    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
284 <  if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
284 >  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
285 >  if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
286    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
287    if(filename=="mll_inclusive_osof") cut=cutOSOF;
288    if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
# Line 208 | Line 297 | void make_kin_plot(string variable, stri
297    THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
298    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
299    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
300 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
300 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
301    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
302    if(filename=="mll_osof") datahisto->SetMinimum(9);
214
303    datahisto->SetMaximum(5.3*datahisto->GetMaximum());
304    datahisto->Draw("e1");
305    ckin->Update();
# Line 291 | Line 379 | void make_kin_plot(string variable, stri
379    delete ckin;
380   }
381  
294
382   void make_JES_plot() {
383  
384    int nbins=10;
# Line 343 | Line 430 | void do_kinematic_plots(string mcjzb, st
430    bool dolog=true;
431    bool nolog=false;
432    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
433 <  float mll_low=40;
433 >  float mll_low=50;
434    float mll_hi=160;
435    if(!PlottingSetup::RestrictToMassPeak) {
436 <        mll_low=30;
437 <        mll_hi=180;
436 >        mll_low=20;
437 >        mll_hi=210;
438    }
439 +  
440 +  make_kin_plot("met[4]","",40,0,200,dolog,"MET [GeV]","met",doPF,true);
441    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
442    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
443    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 445 | void do_kinematic_plots(string mcjzb, st
445    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
446    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
447    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
448 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
448 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/2,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
449    make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
450 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
451 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
450 >  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
451 > //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
452 > //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
453    make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
454    make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
455    make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
456    make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
457    make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
458 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
459 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
458 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
459 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
460 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
461    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
462    stringstream jzbcut;
463    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
464    make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
465 +  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);
466 +  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
467 +  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);
468 +  stringstream jzbcut2;
469 +  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
470 +  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
471 +  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);
472 +  stringstream jzbcut3;
473 +  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
474 +  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);   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);
475 +  
476 +  make_special_obs_pred_mll_plot(mcjzb,0);
477 +  make_special_obs_pred_mll_plot(mcjzb,50);
478 +  make_special_obs_pred_mll_plot(mcjzb,100);
479 +  make_special_obs_pred_mll_plot(mcjzb,150);
480 +  make_special_obs_pred_mll_plot(mcjzb,200);
481 +  make_special_obs_pred_mll_plot(mcjzb,250);
482   }
483  
484   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 442 | Line 550 | void region_comparison_plots(string mcjz
550      
551    
552      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
553 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
553 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
554      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
555      float mll_low=50;float mll_high=170;
556      if(!PlottingSetup::RestrictToMassPeak) {
# Line 479 | Line 587 | void signal_bg_comparison()
587    
588    float simulatedlumi=luminosity;//in pb please - adjust to your likings
589    
590 <  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
591 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
590 >  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
591 >  TH1F *JZBplotLM4;
592 >  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"));
593 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
594    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
595    
596    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 504 | Line 614 | void signal_bg_comparison()
614    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
615    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
616    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
617 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
617 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
618 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
619    signal_bg_comparison_leg2->Draw();
620    DrawMCPrelim(simulatedlumi);
621    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 746 | Line 857 | if you want to start from scratch (witho
857    return return_functions;
858   }
859  
860 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
860 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
861   {
862 +  // note: sigma is not used ATM
863 +  switch_overunderflow(true);
864    bool is_data=false;
865    bool use_signal=false;
866    if(use_data==1) is_data=true;
# Line 756 | Line 869 | void do_prediction_plot(string jzb, TCan
869    if(is_data) nbins=50;
870    float low=0;
871    float hi=500;
872 +  
873 +  stringstream largerzeroS;
874 +  largerzeroS << "("<<jzb<<">0)";
875 +  TCut largerzero(largerzeroS.str().c_str());
876 +  stringstream smallerzeroS;
877 +  smallerzeroS << "("<<jzb<<"<0)";
878 +  TCut smallerzero(smallerzeroS.str().c_str());
879 +  
880    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
881 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
882 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
883 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
884 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
881 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
882 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
883 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
884 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
885 >
886    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
887    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
888    blankback->GetXaxis()->CenterTitle();
# Line 775 | Line 897 | void do_prediction_plot(string jzb, TCan
897    TH1F *RcorrJZBeemmNoS;
898  
899      //these are for the ratio
900 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
901 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
902 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
903 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
900 >  
901 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
902 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
903 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
904 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
905    
906    TH1F *JRcorrJZBSBem;
907    TH1F *JLcorrJZBSBem;
908    TH1F *JRcorrJZBSBeemm;
909    TH1F *JLcorrJZBSBeemm;
910    
911 <  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);
911 >  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);
912  
913    
914    if(PlottingSetup::RestrictToMassPeak) {
915 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
916 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
917 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
918 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
919 <
915 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
916 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
917 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
918 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
919 >    
920      //these are for the ratio
921 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
922 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
923 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
924 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
802 <
921 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
922 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
923 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
924 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
925    }
926    
927    TH1F *lm4RcorrJZBeemm;
928 <  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"));
928 >  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"));
929    
930    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
931    
# Line 812 | Line 934 | void do_prediction_plot(string jzb, TCan
934      
935    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
936    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
937 +    
938 +  TH1F *BpredSys = (TH1F*)LcorrJZBeemm->Clone("Bpredsys");
939 +  ClearHisto(BpredSys);
940 +    write_error(__FUNCTION__,"Implemented systematic error but NOT drawing it yet. Need to still implement drawing, particularly in ratio.");
941 +    
942    if(PlottingSetup::RestrictToMassPeak) {
943      Bpred->Add(RcorrJZBem,1.0/3.);
944      Bpred->Add(LcorrJZBem,-1.0/3.);
# Line 834 | Line 961 | void do_prediction_plot(string jzb, TCan
961      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
962      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
963      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
964 +      
965 +    //Systematics:
966 +    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
967 +    AddSquared(BpredSys,RcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
968 +    AddSquared(BpredSys,LcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
969 +    AddSquared(BpredSys,RcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
970 +    AddSquared(BpredSys,LcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
971 +    AddSquared(BpredSys,RcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
972 +    AddSquared(BpredSys,LcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
973    } else {
974      Bpred->Add(RcorrJZBem,1.0);
975      Bpred->Add(LcorrJZBem,-1.0);
# Line 843 | Line 979 | void do_prediction_plot(string jzb, TCan
979      //these are for the ratio
980      JBpred->Add(JRcorrJZBem,1.0);
981      JBpred->Add(JLcorrJZBem,-1.0);
982 +      
983 +    //Systematics
984 +    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
985 +    AddSquared(BpredSys,RcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
986 +    AddSquared(BpredSys,LcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
987 +
988    }
989      
990 <  
990 >  SQRT(BpredSys);
991 >
992    
993    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
994    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
# Line 890 | Line 1033 | void do_prediction_plot(string jzb, TCan
1033    blankback->Draw();
1034    if(use_data==1)
1035    {
1036 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1037 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1038      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1039      kinpad->cd();//necessary because the extended fit function creates its own canvas
1040      RcorrJZBeemm->Draw("e1x0,same");
1041  
1042      Bpred->Draw("hist,same");
1043 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1043 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1044      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1045 +    lm4RcorrJZBeemm->Draw("hist,same");
1046      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1047      legBpred->AddEntry(Bpred,"predicted","l");
1048      legBpred->AddEntry(analytical_function[1],"predicted fit","l");
# Line 906 | Line 1052 | void do_prediction_plot(string jzb, TCan
1052      DrawPrelim();
1053  
1054      //this plot shows what the prediction is composed of
1055 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1056 <    specialcanv->SetLogy(1);
1057 <    Zjetspred->SetFillColor(kYellow);
1058 <    Zjetspred->SetLineColor(kYellow);
1059 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1060 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1055 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1056 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1057 >    Bpred->SetLineWidth(2);
1058 >    predcomppad->cd();
1059 >    predcomppad->SetLogy(1);
1060 >    
1061 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1062 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1063 >    sidebandsemu->Add(jzbnegative,-1);
1064 >    
1065 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1066 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1067 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1068 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1069 >    
1070      THStack predcomposition("predcomposition","prediction composition");
1071 <    predcomposition.Add(TTbarpred);
1072 <    predcomposition.Add(Zjetspred);
1071 >    predcomposition.Add(sidebandsemu);
1072 >    predcomposition.Add(jzbnegative);
1073      blankback->Draw();
1074      RcorrJZBeemm->Draw("e1x0,same");
1075      predcomposition.Draw("histo,same");//
1076      Bpred->Draw("hist,same");
1077 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1077 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1078      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1079 <    legBpred->Draw();
1079 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1080 >    lm4RcorrJZBeemm->SetLineWidth(2);
1081 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1082 >    lm4RcorrJZBeemm->Draw("histo,same");
1083      DrawPrelim();
1084 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1085 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1086 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1087 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1088 <    specialleg->Draw("same");
1089 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1090 <
1084 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1085 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1086 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1087 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1088 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1089 >    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1090 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1091 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1092 >    speciallegBpred->Draw();
1093 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1094 >    
1095 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1096      THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1097      blankback->Draw();
1098      kostack.Draw("same");
# Line 938 | Line 1101 | void do_prediction_plot(string jzb, TCan
1101      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1102      legBpred->Draw();
1103      DrawPrelim();
1104 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1104 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1105 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1106      
1107 <    delete specialcanv;
944 <    delete specialleg;
1107 >    delete speciallegBpred;
1108      delete Zjetspred;
1109      delete TTbarpred;
1110      
# Line 949 | Line 1112 | void do_prediction_plot(string jzb, TCan
1112    }
1113    if(use_data==0) {
1114      RcorrJZBeemm->Draw("e1x0,same");
1115 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1116      Bpred->Draw("hist,same");
1117      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1118 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1119 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1118 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1119 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1120      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1121      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1122      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 963 | Line 1127 | void do_prediction_plot(string jzb, TCan
1127    }
1128    if(use_data==2) {
1129      RcorrJZBeemm->Draw("e1x0,same");
1130 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1131      Bpred->Draw("hist,same");
1132      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1133 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1133 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1134      legBpred->AddEntry(Bpred,"MC predicted","l");
1135 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1135 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1136      legBpred2->AddEntry(Bpred,"MC predicted","l");
1137      {
1138        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 1143 | void do_prediction_plot(string jzb, TCan
1143   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1144      }
1145      {
1146 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1147 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1148 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1149 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1150 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1151 +      
1152        RcorrJZBeemmNoS->SetLineStyle(2);
1153        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1154        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 996 | Line 1167 | void do_prediction_plot(string jzb, TCan
1167    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1168    string ytitle("ratio");
1169    if ( use_data==1 ) ytitle = "data/pred";
1170 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1170 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1171 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1172  
1173    
1174    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1175    /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1176 <  if(!PlottingSetup::RestrictToMassPeak) return;
1177 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1178 <  Bpredem->Add(RcorrJZBem);
1179 <  Bpredem->Add(LcorrJZBem,-1);
1180 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1181 <  BpredSBem->Add(RcorrJZBSBem);
1182 <  Bpred->Add(LcorrJZBSBem,-1);
1183 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1184 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1185 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1186 <  globalcanvas->cd();
1187 <  globalcanvas->SetLogy(1);
1188 <
1189 <  RcorrJZBeemm->SetMarkerStyle(20);
1190 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1191 <  blankback->Draw();
1192 <  RcorrJZBeemm->Draw("e1x0,same");
1193 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1194 <  
1195 <  Bpredem->SetLineColor(kRed+1);
1196 <  Bpredem->SetStats(0);
1197 <  Bpredem->Draw("hist,same");
1198 <
1199 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1200 <  BpredSBem->SetLineStyle(2);
1201 <  BpredSBem->Draw("hist,same");
1202 <
1203 <  BpredSBeemm->SetLineColor(kBlue+1);
1204 <  BpredSBeemm->SetLineStyle(3);
1205 <  BpredSBeemm->Draw("hist,same");
1206 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1207 <
1208 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1209 <  if(use_data==1)
1210 <  {
1211 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1212 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1213 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1214 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1215 <    legBpredc->Draw();
1216 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1217 <  }
1218 <  if(use_data==0) {
1219 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1220 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1221 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1222 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1223 <    legBpredc->Draw();
1224 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1225 <  }
1226 <  if(use_data==2) {
1227 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1228 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1229 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1230 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1231 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1232 <    legBpredc->Draw();
1233 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1176 >  if(PlottingSetup::RestrictToMassPeak) {
1177 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1178 >    Bpredem->Add(RcorrJZBem);
1179 >    Bpredem->Add(LcorrJZBem,-1);
1180 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1181 >    BpredSBem->Add(RcorrJZBSBem);
1182 >    Bpred->Add(LcorrJZBSBem,-1);
1183 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1184 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1185 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1186 >    globalcanvas->cd();
1187 >    globalcanvas->SetLogy(1);
1188 >    
1189 >    RcorrJZBeemm->SetMarkerStyle(20);
1190 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1191 >    blankback->Draw();
1192 >    RcorrJZBeemm->Draw("e1x0,same");
1193 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1194 >    
1195 >    Bpredem->SetLineColor(kRed+1);
1196 >    Bpredem->SetStats(0);
1197 >    Bpredem->Draw("hist,same");
1198 >    
1199 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1200 >    BpredSBem->SetLineStyle(2);
1201 >    BpredSBem->Draw("hist,same");
1202 >    
1203 >    BpredSBeemm->SetLineColor(kBlue+1);
1204 >    BpredSBeemm->SetLineStyle(3);
1205 >    BpredSBeemm->Draw("hist,same");
1206 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1207 >    
1208 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1209 >    if(use_data==1)
1210 >    {
1211 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1212 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1213 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1214 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1215 >      legBpredc->Draw();
1216 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1217 >    }
1218 >    if(use_data==0) {
1219 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1220 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1221 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1222 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1223 >      legBpredc->Draw();
1224 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1225 >    }
1226 >    if(use_data==2) {
1227 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1228 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1229 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1230 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1231 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1232 >      legBpredc->Draw();
1233 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1234 >    }
1235    }
1236 +  
1237    delete RcorrJZBeemm;
1238    delete LcorrJZBeemm;
1239    delete RcorrJZBem;
# Line 1084 | Line 1258 | void do_prediction_plot(string jzb, TCan
1258      delete JLcorrJZBSBeemm;
1259    }
1260    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1261 +  switch_overunderflow(false);
1262   }
1263  
1264   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1265    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1266    do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1267 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1268 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1267 >  if ( !PlottingSetup::Approved ) {
1268 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1269 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1270 >  } else {
1271 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1272 >  }
1273   }
1274  
1275   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1258 | Line 1437 | void lepton_comparison_plots() {
1437    Float_t ymin = 1.e-5, ymax = 0.25;
1438    TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
1439    can->SetLogy(1);
1440 <  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
1441 <  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
1440 >  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
1441 >  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
1442    eemc->SetLineColor(kBlue);
1443    mmmc->SetLineColor(kRed);
1444    eemc->SetMinimum(0.1);
# Line 1324 | Line 1503 | void lepton_comparison_plots() {
1503    DrawPrelim();
1504    save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
1505    
1506 <  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"));
1507 <  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"));
1508 <  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("DYJets"));
1506 >  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"));
1507 >  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"));
1508 >  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("/DY"));
1509    dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
1510    dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
1511    dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
# Line 1440 | Line 1619 | void draw_pure_jzb_histo(TCut cut,string
1619    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1620    writeline1->SetTextSize(0.035);
1621    writeline1->Draw();
1622 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1622 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1623 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1624    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1625    jzbpad2->cd();
1626    jzbpad2->SetLogy(1);
# Line 1455 | Line 1635 | void draw_pure_jzb_histo(TCut cut,string
1635    writeline1->SetTextSize(0.035);
1636    writeline1->Draw();
1637    DrawPrelim();
1638 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1638 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1639 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1640    datahisto->Delete();
1641    mcstack.Delete();
1642   }
# Line 1463 | Line 1644 | void draw_pure_jzb_histo(TCut cut,string
1644   Double_t GausR(Double_t *x, Double_t *par) {
1645    return gRandom->Gaus(x[0],par[0]);
1646   }
1647 +
1648 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1649 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1650 +  float max=jzbHigh ;
1651 +  float min=-120;
1652 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1653 +  int coarserbins=int(nbins/2.0);
1654 +  int rebinnedbins=int(nbins/4.0);
1655 +  
1656 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1657 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1658 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1659 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1660 +
1661 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1662 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1663 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1664 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1665 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1666 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1667 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1668 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1669 +  
1670 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1671 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1672 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1673 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1674 +  
1675 +  delete dican;
1676 + }
1677 +  
1678 +
1679 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1680 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1681 +  
1682 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1683 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1684 +    return;
1685 +  }
1686 +  
1687 +  float stretchfactor = 100.0;
1688 +  vector<string> labels;
1689 +  
1690 +  
1691 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1692 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1693 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1694 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1695 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1696 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1697 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1698 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1699 +  }
1700 +  
1701 +  dout << "Going to produce JZB plots" << endl;
1702 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1703 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1704 +  float sigma=123456;
1705 +  
1706 +  dout << "Going to produce prediction plots" << endl;
1707 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1708 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1709 +  delete gloca;
1710 +
1711 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1712 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1713 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1714 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1715 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1716 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1717 +    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;
1718 +    
1719 +  }
1720    
1721 + }
1722   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1723    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1724    float max=jzbHigh ;
# Line 1477 | Line 1732 | void jzb_plots(string mcjzb, string data
1732    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1733    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1734  
1735 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1736 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1737 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1738 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1739 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1740 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1741 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1742 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1743 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1735 >  if ( !PlottingSetup::Approved ) {
1736 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1737 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1738 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1739 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1740 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1741 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1742 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1743 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1744 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1745 >  }
1746    
1747    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
1748 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1749 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1750 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1751 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1752 <
1753 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1754 < //  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);
1748 >  if ( !PlottingSetup::Approved ) {
1749 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1750 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1751 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1752 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1753 >  }
1754 >  delete can;
1755   }
1756  
1757  
# Line 1552 | Line 1806 | void compute_MC_yields(string mcjzb,vect
1806    string posneg[] = {"pos","neg"};
1807    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
1808  
1809 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
1809 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
1810      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
1811      dout << "_________________________________________________________" << endl;
1812      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
1813 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
1813 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
1814        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
1815        else dout << "Sample & ";
1816        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1815 | Line 2069 | void draw_ttbar_and_zjets_shape_for_one_
2069  
2070   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2071    int all_leptons=-1;
1818  int electrons_only=0;
1819  int mu_only=1;
1820  int twojetswith50gev=1;
2072    int threejetswith30gev=0;
2073   /*  
2074 +  int twojetswith50gev=1;
2075 +  int electrons_only=0;
2076 +  int mu_only=1;
2077 +
2078    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2079    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2080    
# Line 1838 | Line 2093 | void find_correction_factors(string &jzb
2093    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2094    cancorr->SetLogz();
2095    cancorr->SetRightMargin(0.13);
2096 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2096 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2097    TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2098 +  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2099    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2100    (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2101    niceresponseplotd->SetStats(0);
# Line 1850 | Line 2106 | void find_correction_factors(string &jzb
2106    niceresponseplotd->Draw("COLZ");
2107    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2108    profd->SetMarkerSize(DataMarkerSize);
2109 <  profd->Fit("pol0","","same,e1",30,400);
2109 >  profd->Fit("pol0","","same,e1",100,400);
2110    DrawPrelim();
2111    TText* title = write_text(0.5,0.7,"Data");
2112    title->SetTextAlign(12);
# Line 1866 | Line 2122 | void find_correction_factors(string &jzb
2122    CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2123    
2124    TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2125 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2125 >  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation*cutWeight);
2126    niceresponseplotm->SetStats(0);
2127    niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2128    niceresponseplotm->GetYaxis()->SetTitle("Response");
# Line 1876 | Line 2132 | void find_correction_factors(string &jzb
2132    (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2133    TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2134    profm->SetMarkerSize(DataMarkerSize);
2135 <  profm->Fit("pol0","","same,e1",30,400);
2135 >  profm->Fit("pol0","","same,e1",100,400);
2136    DrawMCPrelim();
2137    title = write_text(0.5,0.7,"MC simulation");
2138    title->SetTextAlign(12);
# Line 1912 | Line 2168 | void pick_up_events(string cut) {
2168    allsamples.PickUpEvents(cut);
2169   }
2170  
2171 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2171 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2172    dout << "Saving configuration template!" << endl;
2173    ofstream configfile;
2174    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1932 | Line 2188 | void save_template(string mcjzb, string
2188    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2189    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2190    configfile<<"vector<float>jzb_cuts;\n";
2191 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2192    configfile<<"float MCPeakError=-999;\n";
2193 +  configfile<<"float DataPeakError=-999;\n";
2194    configfile<<"}\n\n";
2195  
2196    configfile<<"void read_config() {\n";
2197    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2198    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2199 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2200 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2199 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2200 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2201 >  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";
2202 >  configfile<<"\n\n";
2203 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2204 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2205 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[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)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2208 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2209 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2210 >  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";
2211    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";
2212    configfile<<"\n\n";
2213    configfile<<"luminosity="<<luminosity<<";\n";
2214 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2215    
2216    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2217    
# Line 1972 | Line 2234 | void draw_all_ttbar_histos(TCanvas *can,
2234    float max=histos[0]->GetMaximum();
2235    if(manualmin>=0) min=manualmin;
2236    else {
2237 <    for(int i=1;i<histos.size();i++) {
2237 >    for(int i=1;i<(int)histos.size();i++) {
2238        float curmin=get_nonzero_minimum(histos[i]);
2239        float curmax=histos[i]->GetMaximum();
2240        if(curmin<min) min=curmin;
# Line 1983 | Line 2245 | void draw_all_ttbar_histos(TCanvas *can,
2245    histos[0]->Draw(drawoption.c_str());
2246    stringstream drawopt;
2247    drawopt << drawoption << ",same";
2248 <  for(int i=1;i<histos.size();i++) {
2248 >  for(int i=1;i<(int)histos.size();i++) {
2249      histos[i]->Draw(drawopt.str().c_str());
2250    }
2251   }
# Line 1992 | Line 2254 | void ttbar_sidebands_comparison(string m
2254    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2255    //in the case of the OFF peak analysis, we compare our control region to the real value
2256    TCut weightbackup=cutWeight;
2257 <  cutWeight="1.0";
2257 > //  cutWeight="1.0";
2258    float simulatedlumi = luminosity; //in pb please - adjust to your likings
2259    
2260  
# Line 2050 | Line 2312 | void ttbar_sidebands_comparison(string m
2312    leg->Draw("same");
2313    DrawMCPrelim(simulatedlumi);
2314    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2053  
2315    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2316    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2317 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2318 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2317 >  TH1F *TSeemmcopy;
2318 >  TH1F *TSemcopy;
2319 >  if(PlottingSetup::RestrictToMassPeak) {
2320 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2321 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2322 >  }
2323  
2324    TZem->Divide(TZeemm);
2325    TZem->SetMarkerStyle(21);
# Line 2076 | Line 2341 | void ttbar_sidebands_comparison(string m
2341    
2342    float linepos=0.25;
2343    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2344 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2345    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2346    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2347    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2348    
2349 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2350 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2351 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2352 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2353 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2354 +  topalt->Draw("same");bottomalt->Draw("same");*/
2355 +  
2356 +  
2357    top->SetLineColor(kBlue);top->SetLineStyle(2);
2358    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2359    center->SetLineColor(kBlue);
# Line 2104 | Line 2378 | void ttbar_sidebands_comparison(string m
2378    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2379    
2380  
2107
2381   ///-------------- second part: only look at the quantity we actually care about!
2382    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2383    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2231 | Line 2504 | void ttbar_sidebands_comparison(string m
2504   }
2505  
2506  
2507 < void zjets_prediction_comparison() {
2507 > void zjets_prediction_comparison(string mcjzbWithPU) {
2508 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2509 >  zcan->SetLogy(1);
2510 >  TCut weightbackup=cutWeight;
2511 >
2512 > /*
2513    // Do it without PU re-weighting
2514    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2515    stringstream resultsNoPU;
2516  
2517    stringstream mcjzbnoPU;
2518 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2518 >  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2519    if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2520    else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2521  
2522    string mcjzb = mcjzbnoPU.str();
2523    dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2524  
2247  TCut weightbackup=cutWeight;
2525    cutWeight="1.0";
2526 + */
2527 +  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2528    float sbg_min=0.;
2529    float sbg_max=100.;
2530    int sbg_nbins=5;
# Line 2255 | Line 2534 | void zjets_prediction_comparison() {
2534    TCut kNeg((mcjzb+"<0").c_str());
2535    string var( "abs("+mcjzb+")" );
2536  
2537 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2538 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2539 <                                  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"));
2537 >  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2538 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2539 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2540    hJZBpos->SetLineColor(kBlack);
2541    hJZBneg->SetLineColor(kRed);
2542    
2266  Int_t nbins = 5;
2267  Float_t xmax = 100.;
2268
2269  
2270  TCanvas *zcan = new TCanvas("zcan","zcan");  
2271  zcan->SetLogy(1);
2543  
2544    hJZBpos->Draw("e1");
2545    hJZBneg->Draw("same,hist");
# Line 2351 | Line 2622 | void make_table(samplecollection &coll,
2622    
2623    TCanvas *cannie = new TCanvas("cannie","cannie");
2624    
2625 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
2625 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
2626      float currcut=jzb_cuts[icut];
2627      int nbins=1;float low=currcut;
2628      vector<int> mysample;
# Line 2410 | Line 2681 | void make_table(samplecollection &coll,
2681    //prediction part
2682    if(is_data) cout << "Data prediction & ";
2683    if(subselection!="none") cout << subselection << " prediction &";
2684 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2684 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2685    
2686    cout << endl;
2687    //observation part
2688    if(is_data) cout << "Data observation & ";
2689    if(subselection!="none") cout << subselection << " observation &";
2690 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2690 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2691    cout << endl;
2692    cout << "_________________________________________________________________" << endl;
2693    delete cannie;
# Line 2451 | Line 2722 | void JZBSelEff(string mcjzb, TTree* even
2722    int nbins = sizeof(xbins)/sizeof(float)-1;
2723    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
2724  
2725 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2726 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2727 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2725 >  
2726 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
2727 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
2728 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
2729  
2730    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
2731    TCut kreco(cutmass);
# Line 2469 | Line 2741 | void JZBSelEff(string mcjzb, TTree* even
2741    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
2742    can->SetGridx(1);
2743    can->SetGridy(1);
2744 +  can->SetLeftMargin(0.16);
2745 +  can->SetRightMargin(0.05);
2746    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
2747 +  leg->SetBorderSize(1);
2748 +  leg->SetLineColor(kBlack);
2749 +  leg->SetTextFont(62);
2750  
2751 <  
2475 <
2476 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
2751 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
2752  
2753      ostringstream selection;
2754      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2489 | Line 2764 | void JZBSelEff(string mcjzb, TTree* even
2764      }
2765    
2766      heff->GetXaxis()->SetRangeUser(min, max);
2767 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
2768 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
2769 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
2770 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
2771      heff->SetMarkerStyle(markers[icut]);
2772      heff->Fit("func","Q+","same");
2773  
# Line 2500 | Line 2779 | void JZBSelEff(string mcjzb, TTree* even
2779  
2780      // Store plot
2781      TH1F* h = (TH1F*)heff->Clone(hname);
2782 +    h->SetNdivisions(505,"X");
2783      if ( icut) h->Draw("same");
2784      else h->Draw();
2785      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2520 | Line 2800 | void JZBSelEff(string mcjzb, TTree* even
2800   // Calls the above function for each signal sample
2801   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
2802   {  
2803 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
2803 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
2804      dout << "JZB selection efficiency curve: " << std::endl;
2805      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
2806    }
2807   }
2808 +
2809 + void qcd_plots(string datajzb, string mcjzb, vector<float> bins) {
2810 +  // What this function aims to do:
2811 +  // Illustrate cut flow for QCD (requiring only one lepton, requiring etc.)
2812 +  // 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.
2813 +  TCanvas *can = new TCanvas("can","can");
2814 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
2815 +  kinpad->cd();
2816 +  
2817 +  string jzb=mcjzb;
2818 +  
2819 +  float hi=400;
2820 +  bool use_signal=false;
2821 +  bool use_data=false;
2822    
2823 +  bool is_data=false;
2824 +  int nbins=50;//100;
2825 +  float low=0;
2826 +  float high=500;
2827 +  int versok=false;
2828 +  if(gROOT->GetVersionInt()>=53000) versok=true;
2829 +
2830 +  TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
2831 +  TH1F *RcorrJZBeemm   = qcdsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2832 +  TH1F *LcorrJZBeemm   = qcdsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2833 +  TH1F *RcorrJZBem     = qcdsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2834 +  TH1F *LcorrJZBem     = qcdsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2835 +  blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
2836 +  blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
2837 +  blankback->GetXaxis()->CenterTitle();
2838 +  blankback->GetYaxis()->CenterTitle();
2839 +  
2840 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
2841 +  TH1F *RcorrJZBSBem;
2842 +  TH1F *LcorrJZBSBem;
2843 +  TH1F *RcorrJZBSBeemm;
2844 +  TH1F *LcorrJZBSBeemm;
2845 +  
2846 + //  TH1F *RcorrJZBeemmNoS;
2847 +
2848 +    //these are for the ratio
2849 +  TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2850 +  TH1F *JLcorrJZBeemm   = qcdsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2851 +  TH1F *JRcorrJZBem     = qcdsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2852 +  TH1F *JLcorrJZBem     = qcdsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2853 +  
2854 +  TH1F *JRcorrJZBSBem;
2855 +  TH1F *JLcorrJZBSBem;
2856 +  TH1F *JRcorrJZBSBeemm;
2857 +  TH1F *JLcorrJZBSBeemm;
2858 +  
2859 +  if(PlottingSetup::RestrictToMassPeak) {
2860 +    RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2861 +    LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2862 +    RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2863 +    LcorrJZBSBeemm = qcdsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2864 +
2865 +    //these are for the ratio
2866 +    JRcorrJZBSBem   = qcdsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2867 +    JLcorrJZBSBem   = qcdsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2868 +    JRcorrJZBSBeemm = qcdsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2869 +    JLcorrJZBSBeemm = qcdsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2870 +
2871 +  }
2872 +  
2873 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
2874 +  
2875 +  TH1F *Zjetspred = (TH1F*)LcorrJZBeemm->Clone("Zjetspred");
2876 +  TH1F *TTbarpred = (TH1F*)RcorrJZBem->Clone("TTbarpred");
2877 +    
2878 +  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
2879 +  TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
2880 +  if(PlottingSetup::RestrictToMassPeak) {
2881 +    Bpred->Add(RcorrJZBem,1.0/3.);
2882 +    Bpred->Add(LcorrJZBem,-1.0/3.);
2883 +    Bpred->Add(RcorrJZBSBem,1.0/3.);
2884 +    Bpred->Add(LcorrJZBSBem,-1.0/3.);
2885 +    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
2886 +    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
2887 +    
2888 +    TTbarpred->Scale(1.0/3);
2889 +    Zjetspred->Add(LcorrJZBem,-1.0/3.);
2890 +    Zjetspred->Add(LcorrJZBSBem,-1.0/3.);
2891 +    TTbarpred->Add(RcorrJZBSBem,1.0/3.);
2892 +    Zjetspred->Add(LcorrJZBSBeemm,-1.0/3.);
2893 +    TTbarpred->Add(RcorrJZBSBeemm,1.0/3.);
2894 +    
2895 +    //these are for the ratio
2896 +    JBpred->Add(JRcorrJZBem,1.0/3.);
2897 +    JBpred->Add(JLcorrJZBem,-1.0/3.);
2898 +    JBpred->Add(JRcorrJZBSBem,1.0/3.);
2899 +    JBpred->Add(JLcorrJZBSBem,-1.0/3.);
2900 +    JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
2901 +    JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
2902 +  } else {
2903 +    Bpred->Add(RcorrJZBem,1.0);
2904 +    Bpred->Add(LcorrJZBem,-1.0);
2905 +    
2906 +    Zjetspred->Add(LcorrJZBem,-1.0);
2907 +    
2908 +    //these are for the ratio
2909 +    JBpred->Add(JRcorrJZBem,1.0);
2910 +    JBpred->Add(JLcorrJZBem,-1.0);
2911 +  }
2912 +    
2913 +  
2914 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
2915 +  
2916 +  TLegend *legBpred = make_legend("",0.6,0.55,false);
2917 +  RcorrJZBeemm->Draw("e1x0,same");
2918 +  Bpred->Draw("hist,same");
2919 +  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
2920 +  legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
2921 +  legBpred->AddEntry(Bpred,"MC predicted","l");
2922 +  if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
2923 +  if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
2924 +  legBpred->Draw();
2925 +  DrawMCPrelim();
2926 +
2927 +  //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
2928 +  string ytitle("ratio");
2929 +  if ( use_data==1 ) ytitle = "data/pred";
2930 +  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
2931 +  
2932 +  TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
2933 +  TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
2934 +  TH1F *osof = qcdsamples.Draw("osof","pfJetGoodNum",1,0,100, "internal code", "events", cutOSOF ,mc, luminosity);
2935 +  TH1F *njossf = qcdsamples.Draw("njossf","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSSF ,mc, luminosity);
2936 +  TH1F *njosof = qcdsamples.Draw("njosof","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSOF ,mc, luminosity);
2937 +  
2938 +  dout << "______________________________________________" << endl;
2939 +  dout << "QCD contribution: " << endl;
2940 +  dout << "Total number of events: " << allevents->Integral() << endl;
2941 +  dout << "OSSF events: " << ossf->Integral() << endl;
2942 +  dout << "OSOF events: " << osof->Integral() << endl;
2943 +  dout << "OSSF events with >=3 jets:" << njossf->Integral() << endl;
2944 +  dout << "OSOF events with >=3 jets:" << njosof->Integral() << endl;
2945 +  dout << "(note that no mass requirement has been imposed)" << endl;
2946 +  
2947 +  dout << "______________________________________________" << endl;
2948 +  dout << "How QCD shows up in the different regions: " << endl;
2949 +  dout << "OSSF: " << endl;
2950 +  if(PlottingSetup::RestrictToMassPeak) {
2951 +    dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
2952 +    dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
2953 +  } else {
2954 +    dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
2955 +  }
2956 +  dout << "OSOF: " << endl;
2957 +  if(PlottingSetup::RestrictToMassPeak) {
2958 +    dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
2959 +    dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
2960 +  } else {
2961 +    dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
2962 +  }
2963 +  dout << "Therefore: " << endl;
2964 +  if(PlottingSetup::RestrictToMassPeak) {
2965 +    dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
2966 +    dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
2967 +    dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
2968 +    dout << " = " << LcorrJZBeemm->Integral() + (1.0/3)*(RcorrJZBSBeemm->Integral() - LcorrJZBSBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() + RcorrJZBSBem->Integral() - LcorrJZBSBem->Integral()) << endl;
2969 +  } else {
2970 +    dout << "    Prediction increases by : " << LcorrJZBeemm->Integral();
2971 +    dout << " + (" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
2972 +    dout << " = " << LcorrJZBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() << endl;
2973 +  }
2974 +  dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
2975 +  
2976 +  dout << endl;
2977 +  for(int i=0;i<(int)bins.size();i++) {
2978 +    dout << " JZB > " << bins[i] << " : " << endl;
2979 +    dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
2980 +    if(PlottingSetup::RestrictToMassPeak) {
2981 +        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;
2982 +    } else {
2983 +        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;
2984 +    }
2985 +  }
2986 +      
2987 +  delete can;
2988 +  delete allevents;
2989 +  if(ossf) delete ossf;
2990 +  if(RcorrJZBem) delete RcorrJZBem;
2991 +  if(LcorrJZBem) delete LcorrJZBem;
2992 +  if(RcorrJZBeemm) delete RcorrJZBeemm;
2993 +  if(LcorrJZBeemm) delete LcorrJZBeemm;
2994 +  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
2995 +  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
2996 +  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
2997 +  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
2998 + }
2999 +
3000 + void check_ptsanity() {
3001 +  TCanvas *ptsancan = new TCanvas("ptsancan","ptsancan",600,1800);
3002 +  TH1F *individualpt1histos[allsamples.collection.size()];
3003 +  TH1F *individualpt2histos[allsamples.collection.size()];
3004 +  TH1F *fpt1 = new TH1F("fpt1","fpt1",50,0,50);
3005 +  fpt1->GetYaxis()->SetRangeUser(0,1);
3006 +  fpt1->GetXaxis()->SetTitle("p_{T,1}");
3007 +  fpt1->GetXaxis()->CenterTitle();
3008 +
3009 +  TH1F *fpt2 = new TH1F("fpt2","fpt2",50,0,50);
3010 +  fpt2->GetXaxis()->SetTitle("p_{T,2}");
3011 +  fpt2->GetXaxis()->CenterTitle();
3012 +  
3013 +  ptsancan->Divide(1,3);
3014 +  ptsancan->cd(1);
3015 +  float maxpt1entry=0;
3016 +  float maxpt2entry=0;
3017 +  
3018 +  TLegend *leg = make_legend();
3019 +  leg->SetX1(0.0);
3020 +  leg->SetY1(0.0);
3021 +  leg->SetX2(1.0);
3022 +  leg->SetY2(1.0);
3023 +  
3024 +  
3025 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3026 +    string nowname=(allsamples.collection)[isample].filename;
3027 +    cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3028 +    individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3029 +    individualpt2histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt2",50,0,50, "p_{T,2}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3030 +    individualpt1histos[isample]->SetLineColor(isample+1);
3031 +    individualpt2histos[isample]->SetLineColor(isample+1);
3032 +    float currmaxpt1entry=individualpt1histos[isample]->GetMaximum()/individualpt1histos[isample]->Integral();
3033 +    float currmaxpt2entry=individualpt2histos[isample]->GetMaximum()/individualpt2histos[isample]->Integral();
3034 +    cout << "      pt 1 histo contains; " << individualpt1histos[isample]->Integral() << endl;
3035 +    cout << "      pt 2 histo contains; " << individualpt2histos[isample]->Integral() << endl;
3036 +    if(currmaxpt1entry>maxpt1entry)maxpt1entry=currmaxpt1entry;
3037 +    if(currmaxpt2entry>maxpt2entry)maxpt2entry=currmaxpt2entry;
3038 +    leg->AddEntry(individualpt2histos[isample],((allsamples.collection)[isample].filename).c_str(),"f");
3039 +  }
3040 +
3041 +  fpt1->GetYaxis()->SetRangeUser(0,maxpt1entry);
3042 +  fpt2->GetYaxis()->SetRangeUser(0,maxpt2entry);
3043 +
3044 +  ptsancan->cd(1);
3045 +  fpt1->Draw();
3046 +  ptsancan->cd(2);
3047 +  fpt2->Draw();
3048 +
3049 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3050 +    ptsancan->cd(1);
3051 +    individualpt1histos[isample]->DrawNormalized("same,histo");
3052 +    ptsancan->cd(2);
3053 +    individualpt2histos[isample]->DrawNormalized("same,histo");
3054 +  }
3055 +  ptsancan->cd(3);
3056 +  leg->Draw();
3057 +  CompleteSave(ptsancan,"PtSanityCheck");
3058 +  
3059 +  delete ptsancan;
3060 + }
3061 +
3062 + void do_mlls_plot(string mcjzb) {
3063 +  cout << "At this point we'd plot the mll distribution" << endl;
3064 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3065 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3066 +    if(!(signalsamples.collection)[isig].events) continue;
3067 +    string nowname=(signalsamples.collection)[isig].filename;
3068 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3069 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3070 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3071 +    stringstream poscutS;
3072 +    poscutS << "((" << mcjzb <<")>50)";
3073 +    TCut poscut(poscutS.str().c_str());
3074 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3075 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3076 +    mll->Draw("histo");
3077 +    mllP->Draw("histo,same");
3078 +    TLegend *leg = make_legend();
3079 +    leg->SetY1(0.8);
3080 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3081 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3082 +    leg->Draw();
3083 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3084 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3085 +    lin->Draw("same");
3086 +    lin2->Draw("same");
3087 +    
3088 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3089 +    delete mll;
3090 +    delete mllP;
3091 +  }
3092 + }
3093 +
3094 + void met_vs_jzb_plots() {
3095 +  
3096 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3097 +  canmetjzb->SetRightMargin(0.16);
3098 +  
3099 +  vector<string> findme;
3100 +  findme.push_back("DY");
3101 +  findme.push_back("TTJets");
3102 +  findme.push_back("LM");
3103 +  
3104 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3105 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3106 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3107 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3108 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3109 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3110 +    }
3111 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3112 +    metvsjzb->SetStats(0);
3113 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3114 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3115 +    metvsjzb->GetXaxis()->CenterTitle();
3116 +    metvsjzb->GetYaxis()->CenterTitle();
3117 +    metvsjzb->Draw("COLZ");
3118 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3119 +    title->SetTextAlign(12);
3120 +    title->Draw();
3121 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3122 +  }
3123 + }
3124 +    
3125  
3126   void test() {
3127    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines