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.18 by buchmann, Tue May 22 16:28:11 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 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 193 | Line 280 | void make_kin_plot(string variable, stri
280          draw_separation_lines=true;
281    }
282    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
283 <  if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
283 >  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
284 >  if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
285    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
286    if(filename=="mll_inclusive_osof") cut=cutOSOF;
287    if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
# 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("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
441    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
442    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
# Line 358 | Line 446 | void do_kinematic_plots(string mcjzb, st
446    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
447    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)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
449 +  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",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);
452    make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
# Line 371 | Line 460 | void do_kinematic_plots(string mcjzb, st
460    stringstream jzbcut;
461    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
462    make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
463 +  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);
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 +  stringstream jzbcut2;
467 +  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
468 +  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
469 +  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);
470 +  stringstream jzbcut3;
471 +  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
472 +  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);
473 +  
474 +  make_special_obs_pred_mll_plot(mcjzb,0);
475 +  make_special_obs_pred_mll_plot(mcjzb,50);
476 +  make_special_obs_pred_mll_plot(mcjzb,100);
477 +  make_special_obs_pred_mll_plot(mcjzb,150);
478 +  make_special_obs_pred_mll_plot(mcjzb,200);
479 +  make_special_obs_pred_mll_plot(mcjzb,250);
480   }
481  
482   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 442 | Line 548 | void region_comparison_plots(string mcjz
548      
549    
550      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
551 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
551 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
552      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
553      float mll_low=50;float mll_high=170;
554      if(!PlottingSetup::RestrictToMassPeak) {
# Line 479 | Line 585 | void signal_bg_comparison()
585    
586    float simulatedlumi=luminosity;//in pb please - adjust to your likings
587    
588 <  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
589 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
588 >  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
589 >  TH1F *JZBplotLM4;
590 >  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"));
591 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
592    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
593    
594    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 504 | Line 612 | void signal_bg_comparison()
612    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
613    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
614    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
615 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
615 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
616 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
617    signal_bg_comparison_leg2->Draw();
618    DrawMCPrelim(simulatedlumi);
619    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 746 | Line 855 | if you want to start from scratch (witho
855    return return_functions;
856   }
857  
858 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
858 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
859   {
860 +  // note: sigma is not used ATM
861 +  switch_overunderflow(true);
862    bool is_data=false;
863    bool use_signal=false;
864    if(use_data==1) is_data=true;
# Line 756 | Line 867 | void do_prediction_plot(string jzb, TCan
867    if(is_data) nbins=50;
868    float low=0;
869    float hi=500;
870 +  
871 +  stringstream largerzeroS;
872 +  largerzeroS << "("<<jzb<<">0)";
873 +  TCut largerzero(largerzeroS.str().c_str());
874 +  stringstream smallerzeroS;
875 +  smallerzeroS << "("<<jzb<<"<0)";
876 +  TCut smallerzero(smallerzeroS.str().c_str());
877 +  
878    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
879 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
880 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
881 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
882 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
879 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
880 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
881 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
882 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
883 >
884    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
885    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
886    blankback->GetXaxis()->CenterTitle();
# Line 775 | Line 895 | void do_prediction_plot(string jzb, TCan
895    TH1F *RcorrJZBeemmNoS;
896  
897      //these are for the ratio
898 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
899 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
900 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
901 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
898 >  
899 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
900 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
901 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
902 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
903    
904    TH1F *JRcorrJZBSBem;
905    TH1F *JLcorrJZBSBem;
906    TH1F *JRcorrJZBSBeemm;
907    TH1F *JLcorrJZBSBeemm;
908    
909 <  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);
909 >  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);
910  
911    
912    if(PlottingSetup::RestrictToMassPeak) {
913 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
914 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
915 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
916 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
917 <
913 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
914 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
915 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
916 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
917 >    
918      //these are for the ratio
919 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
920 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
921 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
922 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
802 <
919 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
920 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
921 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
922 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
923    }
924    
925    TH1F *lm4RcorrJZBeemm;
926 <  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"));
926 >  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"));
927    
928    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
929    
# Line 890 | Line 1010 | void do_prediction_plot(string jzb, TCan
1010    blankback->Draw();
1011    if(use_data==1)
1012    {
1013 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1014 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1015      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1016      kinpad->cd();//necessary because the extended fit function creates its own canvas
1017      RcorrJZBeemm->Draw("e1x0,same");
1018  
1019      Bpred->Draw("hist,same");
1020 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1020 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1021      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1022 +    lm4RcorrJZBeemm->Draw("hist,same");
1023      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1024      legBpred->AddEntry(Bpred,"predicted","l");
1025      legBpred->AddEntry(analytical_function[1],"predicted fit","l");
# Line 906 | Line 1029 | void do_prediction_plot(string jzb, TCan
1029      DrawPrelim();
1030  
1031      //this plot shows what the prediction is composed of
1032 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1033 <    specialcanv->SetLogy(1);
1034 <    Zjetspred->SetFillColor(kYellow);
1035 <    Zjetspred->SetLineColor(kYellow);
1036 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1037 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1032 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1033 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1034 >    Bpred->SetLineWidth(2);
1035 >    predcomppad->cd();
1036 >    predcomppad->SetLogy(1);
1037 >    
1038 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1039 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1040 >    sidebandsemu->Add(jzbnegative,-1);
1041 >    
1042 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1043 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1044 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1045 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1046 >    
1047      THStack predcomposition("predcomposition","prediction composition");
1048 <    predcomposition.Add(TTbarpred);
1049 <    predcomposition.Add(Zjetspred);
1048 >    predcomposition.Add(sidebandsemu);
1049 >    predcomposition.Add(jzbnegative);
1050      blankback->Draw();
1051      RcorrJZBeemm->Draw("e1x0,same");
1052      predcomposition.Draw("histo,same");//
1053      Bpred->Draw("hist,same");
1054 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1054 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1055      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1056 <    legBpred->Draw();
1056 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1057 >    lm4RcorrJZBeemm->SetLineWidth(2);
1058 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1059 >    lm4RcorrJZBeemm->Draw("histo,same");
1060      DrawPrelim();
1061 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1062 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1063 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1064 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1065 <    specialleg->Draw("same");
1066 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1067 <
1061 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1062 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1063 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1064 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1065 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1066 >    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1067 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1068 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1069 >    speciallegBpred->Draw();
1070 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1071 >    
1072 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1073      THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1074      blankback->Draw();
1075      kostack.Draw("same");
# Line 938 | Line 1078 | void do_prediction_plot(string jzb, TCan
1078      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1079      legBpred->Draw();
1080      DrawPrelim();
1081 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1081 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1082 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1083      
1084 <    delete specialcanv;
944 <    delete specialleg;
1084 >    delete speciallegBpred;
1085      delete Zjetspred;
1086      delete TTbarpred;
1087      
# Line 949 | Line 1089 | void do_prediction_plot(string jzb, TCan
1089    }
1090    if(use_data==0) {
1091      RcorrJZBeemm->Draw("e1x0,same");
1092 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1093      Bpred->Draw("hist,same");
1094      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1095 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1096 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1095 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1096 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1097      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1098      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1099      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 963 | Line 1104 | void do_prediction_plot(string jzb, TCan
1104    }
1105    if(use_data==2) {
1106      RcorrJZBeemm->Draw("e1x0,same");
1107 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1108      Bpred->Draw("hist,same");
1109      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1110 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1110 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1111      legBpred->AddEntry(Bpred,"MC predicted","l");
1112 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1112 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1113      legBpred2->AddEntry(Bpred,"MC predicted","l");
1114      {
1115        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 1120 | void do_prediction_plot(string jzb, TCan
1120   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1121      }
1122      {
1123 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1124 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1125 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1126 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1127 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1128 +      
1129        RcorrJZBeemmNoS->SetLineStyle(2);
1130        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1131        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 996 | Line 1144 | void do_prediction_plot(string jzb, TCan
1144    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1145    string ytitle("ratio");
1146    if ( use_data==1 ) ytitle = "data/pred";
1147 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1147 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1148 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1149  
1150    
1151    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1152    /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1153 <  if(!PlottingSetup::RestrictToMassPeak) return;
1154 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1155 <  Bpredem->Add(RcorrJZBem);
1156 <  Bpredem->Add(LcorrJZBem,-1);
1157 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1158 <  BpredSBem->Add(RcorrJZBSBem);
1159 <  Bpred->Add(LcorrJZBSBem,-1);
1160 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1161 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1162 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1163 <  globalcanvas->cd();
1164 <  globalcanvas->SetLogy(1);
1165 <
1166 <  RcorrJZBeemm->SetMarkerStyle(20);
1167 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1168 <  blankback->Draw();
1169 <  RcorrJZBeemm->Draw("e1x0,same");
1170 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1171 <  
1172 <  Bpredem->SetLineColor(kRed+1);
1173 <  Bpredem->SetStats(0);
1174 <  Bpredem->Draw("hist,same");
1175 <
1176 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1177 <  BpredSBem->SetLineStyle(2);
1178 <  BpredSBem->Draw("hist,same");
1179 <
1180 <  BpredSBeemm->SetLineColor(kBlue+1);
1181 <  BpredSBeemm->SetLineStyle(3);
1182 <  BpredSBeemm->Draw("hist,same");
1183 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1184 <
1185 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1186 <  if(use_data==1)
1187 <  {
1188 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1189 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1190 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1191 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1192 <    legBpredc->Draw();
1193 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1194 <  }
1195 <  if(use_data==0) {
1196 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1197 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1198 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1199 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1200 <    legBpredc->Draw();
1201 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1202 <  }
1203 <  if(use_data==2) {
1204 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1205 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1206 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1207 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1208 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1209 <    legBpredc->Draw();
1210 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1153 >  if(PlottingSetup::RestrictToMassPeak) {
1154 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1155 >    Bpredem->Add(RcorrJZBem);
1156 >    Bpredem->Add(LcorrJZBem,-1);
1157 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1158 >    BpredSBem->Add(RcorrJZBSBem);
1159 >    Bpred->Add(LcorrJZBSBem,-1);
1160 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1161 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1162 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1163 >    globalcanvas->cd();
1164 >    globalcanvas->SetLogy(1);
1165 >    
1166 >    RcorrJZBeemm->SetMarkerStyle(20);
1167 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1168 >    blankback->Draw();
1169 >    RcorrJZBeemm->Draw("e1x0,same");
1170 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1171 >    
1172 >    Bpredem->SetLineColor(kRed+1);
1173 >    Bpredem->SetStats(0);
1174 >    Bpredem->Draw("hist,same");
1175 >    
1176 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1177 >    BpredSBem->SetLineStyle(2);
1178 >    BpredSBem->Draw("hist,same");
1179 >    
1180 >    BpredSBeemm->SetLineColor(kBlue+1);
1181 >    BpredSBeemm->SetLineStyle(3);
1182 >    BpredSBeemm->Draw("hist,same");
1183 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1184 >    
1185 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1186 >    if(use_data==1)
1187 >    {
1188 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1189 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1190 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1191 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1192 >      legBpredc->Draw();
1193 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1194 >    }
1195 >    if(use_data==0) {
1196 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1197 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1198 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1199 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1200 >      legBpredc->Draw();
1201 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1202 >    }
1203 >    if(use_data==2) {
1204 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1205 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1206 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1207 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1208 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1209 >      legBpredc->Draw();
1210 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1211 >    }
1212    }
1213 +  
1214    delete RcorrJZBeemm;
1215    delete LcorrJZBeemm;
1216    delete RcorrJZBem;
# Line 1084 | Line 1235 | void do_prediction_plot(string jzb, TCan
1235      delete JLcorrJZBSBeemm;
1236    }
1237    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1238 +  switch_overunderflow(false);
1239   }
1240  
1241   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1242    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1243    do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1244 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1245 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1244 >  if ( !PlottingSetup::Approved ) {
1245 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1246 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1247 >  } else {
1248 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1249 >  }
1250   }
1251  
1252   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1258 | Line 1414 | void lepton_comparison_plots() {
1414    Float_t ymin = 1.e-5, ymax = 0.25;
1415    TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
1416    can->SetLogy(1);
1417 <  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
1418 <  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
1417 >  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
1418 >  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
1419    eemc->SetLineColor(kBlue);
1420    mmmc->SetLineColor(kRed);
1421    eemc->SetMinimum(0.1);
# Line 1324 | Line 1480 | void lepton_comparison_plots() {
1480    DrawPrelim();
1481    save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
1482    
1483 <  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"));
1484 <  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"));
1485 <  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("DYJets"));
1483 >  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"));
1484 >  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"));
1485 >  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("/DY"));
1486    dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
1487    dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
1488    dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
# Line 1440 | Line 1596 | void draw_pure_jzb_histo(TCut cut,string
1596    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1597    writeline1->SetTextSize(0.035);
1598    writeline1->Draw();
1599 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1599 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1600 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1601    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1602    jzbpad2->cd();
1603    jzbpad2->SetLogy(1);
# Line 1455 | Line 1612 | void draw_pure_jzb_histo(TCut cut,string
1612    writeline1->SetTextSize(0.035);
1613    writeline1->Draw();
1614    DrawPrelim();
1615 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1615 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1616 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1617    datahisto->Delete();
1618    mcstack.Delete();
1619   }
# Line 1463 | Line 1621 | void draw_pure_jzb_histo(TCut cut,string
1621   Double_t GausR(Double_t *x, Double_t *par) {
1622    return gRandom->Gaus(x[0],par[0]);
1623   }
1624 +
1625 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1626 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1627 +  float max=jzbHigh ;
1628 +  float min=-120;
1629 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1630 +  int coarserbins=int(nbins/2.0);
1631 +  int rebinnedbins=int(nbins/4.0);
1632 +  
1633 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1634 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1635 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1636 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1637 +
1638 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1639 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1640 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1641 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1642 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1643 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1644 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1645 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1646 +  
1647 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1648 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1649 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1650 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1651 +  
1652 +  delete dican;
1653 + }
1654 +  
1655 +
1656 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1657 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1658 +  
1659 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1660 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1661 +    return;
1662 +  }
1663 +  
1664 +  float stretchfactor = 100.0;
1665 +  vector<string> labels;
1666 +  
1667 +  
1668 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1669 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1670 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1671 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1672 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1673 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1674 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1675 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1676 +  }
1677 +  
1678 +  dout << "Going to produce JZB plots" << endl;
1679 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1680 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1681 +  float sigma=123456;
1682 +  
1683 +  dout << "Going to produce prediction plots" << endl;
1684 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1685 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1686 +  delete gloca;
1687 +
1688 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1689 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1690 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1691 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1692 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1693 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1694 +    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;
1695 +    
1696 +  }
1697    
1698 + }
1699   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1700    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1701    float max=jzbHigh ;
# Line 1477 | Line 1709 | void jzb_plots(string mcjzb, string data
1709    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1710    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1711  
1712 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1713 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1714 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1715 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1716 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1717 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1718 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1719 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1720 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1712 >  if ( !PlottingSetup::Approved ) {
1713 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1714 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1715 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1716 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1717 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1718 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1719 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1720 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1721 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1722 >  }
1723    
1724    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
1725 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1726 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1727 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1728 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1729 <
1730 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1731 < //  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);
1725 >  if ( !PlottingSetup::Approved ) {
1726 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1727 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1728 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1729 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1730 >  }
1731 >  delete can;
1732   }
1733  
1734  
# Line 1552 | Line 1783 | void compute_MC_yields(string mcjzb,vect
1783    string posneg[] = {"pos","neg"};
1784    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
1785  
1786 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
1786 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
1787      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
1788      dout << "_________________________________________________________" << endl;
1789      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
1790 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
1790 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
1791        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
1792        else dout << "Sample & ";
1793        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1815 | Line 2046 | void draw_ttbar_and_zjets_shape_for_one_
2046  
2047   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2048    int all_leptons=-1;
1818  int electrons_only=0;
1819  int mu_only=1;
1820  int twojetswith50gev=1;
2049    int threejetswith30gev=0;
2050   /*  
2051 +  int twojetswith50gev=1;
2052 +  int electrons_only=0;
2053 +  int mu_only=1;
2054 +
2055    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2056    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2057    
# Line 1838 | Line 2070 | void find_correction_factors(string &jzb
2070    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2071    cancorr->SetLogz();
2072    cancorr->SetRightMargin(0.13);
2073 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2073 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2074    TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2075 +  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2076    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2077    (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2078    niceresponseplotd->SetStats(0);
# Line 1850 | Line 2083 | void find_correction_factors(string &jzb
2083    niceresponseplotd->Draw("COLZ");
2084    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2085    profd->SetMarkerSize(DataMarkerSize);
2086 <  profd->Fit("pol0","","same,e1",30,400);
2086 >  profd->Fit("pol0","","same,e1",100,400);
2087    DrawPrelim();
2088    TText* title = write_text(0.5,0.7,"Data");
2089    title->SetTextAlign(12);
# Line 1876 | Line 2109 | void find_correction_factors(string &jzb
2109    (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2110    TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2111    profm->SetMarkerSize(DataMarkerSize);
2112 <  profm->Fit("pol0","","same,e1",30,400);
2112 >  profm->Fit("pol0","","same,e1",100,400);
2113    DrawMCPrelim();
2114    title = write_text(0.5,0.7,"MC simulation");
2115    title->SetTextAlign(12);
# Line 1912 | Line 2145 | void pick_up_events(string cut) {
2145    allsamples.PickUpEvents(cut);
2146   }
2147  
2148 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2148 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2149    dout << "Saving configuration template!" << endl;
2150    ofstream configfile;
2151    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1932 | Line 2165 | void save_template(string mcjzb, string
2165    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2166    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2167    configfile<<"vector<float>jzb_cuts;\n";
2168 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2169    configfile<<"float MCPeakError=-999;\n";
2170 +  configfile<<"float DataPeakError=-999;\n";
2171    configfile<<"}\n\n";
2172  
2173    configfile<<"void read_config() {\n";
2174    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2175    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2176 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2177 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2176 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2177 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2178 >  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";
2179    configfile<<"\n\n";
2180 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2181 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2182 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2180 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2181 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2182 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2183 >  configfile<<"\n\n";
2184 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2185 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2186 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n\n";
2187 >  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";
2188    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";
2189    configfile<<"\n\n";
2190    configfile<<"luminosity="<<luminosity<<";\n";
2191 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2192    
2193    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2194    
# Line 1972 | Line 2211 | void draw_all_ttbar_histos(TCanvas *can,
2211    float max=histos[0]->GetMaximum();
2212    if(manualmin>=0) min=manualmin;
2213    else {
2214 <    for(int i=1;i<histos.size();i++) {
2214 >    for(int i=1;i<(int)histos.size();i++) {
2215        float curmin=get_nonzero_minimum(histos[i]);
2216        float curmax=histos[i]->GetMaximum();
2217        if(curmin<min) min=curmin;
# Line 1983 | Line 2222 | void draw_all_ttbar_histos(TCanvas *can,
2222    histos[0]->Draw(drawoption.c_str());
2223    stringstream drawopt;
2224    drawopt << drawoption << ",same";
2225 <  for(int i=1;i<histos.size();i++) {
2225 >  for(int i=1;i<(int)histos.size();i++) {
2226      histos[i]->Draw(drawopt.str().c_str());
2227    }
2228   }
# Line 2050 | Line 2289 | void ttbar_sidebands_comparison(string m
2289    leg->Draw("same");
2290    DrawMCPrelim(simulatedlumi);
2291    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2292 <  
2292 > cout << __LINE__ << endl;  
2293    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2294 + cout << __LINE__ << endl;  
2295    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2296 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2297 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2296 > cout << __LINE__ << endl;  
2297 >  TH1F *TSeemmcopy;
2298 >  TH1F *TSemcopy;
2299 >  if(PlottingSetup::RestrictToMassPeak) {
2300 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2301 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2302 >  }
2303  
2304    TZem->Divide(TZeemm);
2305    TZem->SetMarkerStyle(21);
# Line 2076 | Line 2321 | void ttbar_sidebands_comparison(string m
2321    
2322    float linepos=0.25;
2323    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2324 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2325    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2326    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2327    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2328    
2329 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2330 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2331 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2332 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2333 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2334 +  topalt->Draw("same");bottomalt->Draw("same");*/
2335 +  
2336 +  
2337    top->SetLineColor(kBlue);top->SetLineStyle(2);
2338    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2339    center->SetLineColor(kBlue);
# Line 2104 | Line 2358 | void ttbar_sidebands_comparison(string m
2358    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2359    
2360  
2107
2361   ///-------------- second part: only look at the quantity we actually care about!
2362    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2363    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2257 | Line 2510 | void zjets_prediction_comparison() {
2510  
2511    TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2512    TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2513 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("DYJets"));
2513 >                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2514    TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2515 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("DYJets"));
2515 >                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2516    hJZBpos->SetLineColor(kBlack);
2517    hJZBneg->SetLineColor(kRed);
2518    
2266  Int_t nbins = 5;
2267  Float_t xmax = 100.;
2268
2269  
2519    TCanvas *zcan = new TCanvas("zcan","zcan");  
2520    zcan->SetLogy(1);
2521  
# Line 2351 | Line 2600 | void make_table(samplecollection &coll,
2600    
2601    TCanvas *cannie = new TCanvas("cannie","cannie");
2602    
2603 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
2603 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
2604      float currcut=jzb_cuts[icut];
2605      int nbins=1;float low=currcut;
2606      vector<int> mysample;
# Line 2410 | Line 2659 | void make_table(samplecollection &coll,
2659    //prediction part
2660    if(is_data) cout << "Data prediction & ";
2661    if(subselection!="none") cout << subselection << " prediction &";
2662 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2662 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2663    
2664    cout << endl;
2665    //observation part
2666    if(is_data) cout << "Data observation & ";
2667    if(subselection!="none") cout << subselection << " observation &";
2668 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2668 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2669    cout << endl;
2670    cout << "_________________________________________________________________" << endl;
2671    delete cannie;
# Line 2451 | Line 2700 | void JZBSelEff(string mcjzb, TTree* even
2700    int nbins = sizeof(xbins)/sizeof(float)-1;
2701    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
2702  
2703 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2704 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2705 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2703 >  
2704 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
2705 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
2706 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
2707  
2708    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
2709    TCut kreco(cutmass);
# Line 2469 | Line 2719 | void JZBSelEff(string mcjzb, TTree* even
2719    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
2720    can->SetGridx(1);
2721    can->SetGridy(1);
2722 +  can->SetLeftMargin(0.16);
2723 +  can->SetRightMargin(0.05);
2724    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
2725 +  leg->SetBorderSize(1);
2726 +  leg->SetLineColor(kBlack);
2727 +  leg->SetTextFont(62);
2728  
2729 <  
2475 <
2476 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
2729 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
2730  
2731      ostringstream selection;
2732      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2489 | Line 2742 | void JZBSelEff(string mcjzb, TTree* even
2742      }
2743    
2744      heff->GetXaxis()->SetRangeUser(min, max);
2745 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
2746 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
2747 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
2748 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
2749      heff->SetMarkerStyle(markers[icut]);
2750      heff->Fit("func","Q+","same");
2751  
# Line 2500 | Line 2757 | void JZBSelEff(string mcjzb, TTree* even
2757  
2758      // Store plot
2759      TH1F* h = (TH1F*)heff->Clone(hname);
2760 +    h->SetNdivisions(505,"X");
2761      if ( icut) h->Draw("same");
2762      else h->Draw();
2763      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2520 | Line 2778 | void JZBSelEff(string mcjzb, TTree* even
2778   // Calls the above function for each signal sample
2779   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
2780   {  
2781 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
2781 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
2782      dout << "JZB selection efficiency curve: " << std::endl;
2783      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
2784    }
2785   }
2786 +
2787 + void qcd_plots(string datajzb, string mcjzb, vector<float> bins) {
2788 +  // What this function aims to do:
2789 +  // Illustrate cut flow for QCD (requiring only one lepton, requiring etc.)
2790 +  // 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.
2791 +  TCanvas *can = new TCanvas("can","can");
2792 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
2793 +  kinpad->cd();
2794 +  
2795 +  string jzb=mcjzb;
2796 +  
2797 +  float hi=400;
2798 +  bool use_signal=false;
2799 +  bool use_data=false;
2800 +  
2801 +  bool is_data=false;
2802 +  int nbins=50;//100;
2803 +  float low=0;
2804 +  float high=500;
2805 +  int versok=false;
2806 +  if(gROOT->GetVersionInt()>=53000) versok=true;
2807 +
2808 +  TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
2809 +  TH1F *RcorrJZBeemm   = qcdsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2810 +  TH1F *LcorrJZBeemm   = qcdsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2811 +  TH1F *RcorrJZBem     = qcdsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2812 +  TH1F *LcorrJZBem     = qcdsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2813 +  blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
2814 +  blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
2815 +  blankback->GetXaxis()->CenterTitle();
2816 +  blankback->GetYaxis()->CenterTitle();
2817 +  
2818 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
2819 +  TH1F *RcorrJZBSBem;
2820 +  TH1F *LcorrJZBSBem;
2821 +  TH1F *RcorrJZBSBeemm;
2822 +  TH1F *LcorrJZBSBeemm;
2823 +  
2824 + //  TH1F *RcorrJZBeemmNoS;
2825 +
2826 +    //these are for the ratio
2827 +  TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2828 +  TH1F *JLcorrJZBeemm   = qcdsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2829 +  TH1F *JRcorrJZBem     = qcdsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2830 +  TH1F *JLcorrJZBem     = qcdsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2831 +  
2832 +  TH1F *JRcorrJZBSBem;
2833 +  TH1F *JLcorrJZBSBem;
2834 +  TH1F *JRcorrJZBSBeemm;
2835 +  TH1F *JLcorrJZBSBeemm;
2836 +  
2837 +  if(PlottingSetup::RestrictToMassPeak) {
2838 +    RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2839 +    LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2840 +    RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2841 +    LcorrJZBSBeemm = qcdsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2842 +
2843 +    //these are for the ratio
2844 +    JRcorrJZBSBem   = qcdsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2845 +    JLcorrJZBSBem   = qcdsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
2846 +    JRcorrJZBSBeemm = qcdsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2847 +    JLcorrJZBSBeemm = qcdsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
2848 +
2849 +  }
2850 +  
2851 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
2852 +  
2853 +  TH1F *Zjetspred = (TH1F*)LcorrJZBeemm->Clone("Zjetspred");
2854 +  TH1F *TTbarpred = (TH1F*)RcorrJZBem->Clone("TTbarpred");
2855 +    
2856 +  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
2857 +  TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
2858 +  if(PlottingSetup::RestrictToMassPeak) {
2859 +    Bpred->Add(RcorrJZBem,1.0/3.);
2860 +    Bpred->Add(LcorrJZBem,-1.0/3.);
2861 +    Bpred->Add(RcorrJZBSBem,1.0/3.);
2862 +    Bpred->Add(LcorrJZBSBem,-1.0/3.);
2863 +    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
2864 +    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
2865 +    
2866 +    TTbarpred->Scale(1.0/3);
2867 +    Zjetspred->Add(LcorrJZBem,-1.0/3.);
2868 +    Zjetspred->Add(LcorrJZBSBem,-1.0/3.);
2869 +    TTbarpred->Add(RcorrJZBSBem,1.0/3.);
2870 +    Zjetspred->Add(LcorrJZBSBeemm,-1.0/3.);
2871 +    TTbarpred->Add(RcorrJZBSBeemm,1.0/3.);
2872 +    
2873 +    //these are for the ratio
2874 +    JBpred->Add(JRcorrJZBem,1.0/3.);
2875 +    JBpred->Add(JLcorrJZBem,-1.0/3.);
2876 +    JBpred->Add(JRcorrJZBSBem,1.0/3.);
2877 +    JBpred->Add(JLcorrJZBSBem,-1.0/3.);
2878 +    JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
2879 +    JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
2880 +  } else {
2881 +    Bpred->Add(RcorrJZBem,1.0);
2882 +    Bpred->Add(LcorrJZBem,-1.0);
2883 +    
2884 +    Zjetspred->Add(LcorrJZBem,-1.0);
2885 +    
2886 +    //these are for the ratio
2887 +    JBpred->Add(JRcorrJZBem,1.0);
2888 +    JBpred->Add(JLcorrJZBem,-1.0);
2889 +  }
2890 +    
2891 +  
2892 +  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
2893 +  
2894 +  TLegend *legBpred = make_legend("",0.6,0.55,false);
2895 +  RcorrJZBeemm->Draw("e1x0,same");
2896 +  Bpred->Draw("hist,same");
2897 +  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
2898 +  legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
2899 +  legBpred->AddEntry(Bpred,"MC predicted","l");
2900 +  if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
2901 +  if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
2902 +  legBpred->Draw();
2903 +  DrawMCPrelim();
2904 +
2905 +  //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
2906 +  string ytitle("ratio");
2907 +  if ( use_data==1 ) ytitle = "data/pred";
2908 +  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
2909 +  
2910 +  TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
2911 +  TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
2912 +  TH1F *osof = qcdsamples.Draw("osof","pfJetGoodNum",1,0,100, "internal code", "events", cutOSOF ,mc, luminosity);
2913 +  TH1F *njossf = qcdsamples.Draw("njossf","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSSF ,mc, luminosity);
2914 +  TH1F *njosof = qcdsamples.Draw("njosof","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSOF ,mc, luminosity);
2915 +  
2916 +  dout << "______________________________________________" << endl;
2917 +  dout << "QCD contribution: " << endl;
2918 +  dout << "Total number of events: " << allevents->Integral() << endl;
2919 +  dout << "OSSF events: " << ossf->Integral() << endl;
2920 +  dout << "OSOF events: " << osof->Integral() << endl;
2921 +  dout << "OSSF events with >=3 jets:" << njossf->Integral() << endl;
2922 +  dout << "OSOF events with >=3 jets:" << njosof->Integral() << endl;
2923 +  dout << "(note that no mass requirement has been imposed)" << endl;
2924 +  
2925 +  dout << "______________________________________________" << endl;
2926 +  dout << "How QCD shows up in the different regions: " << endl;
2927 +  dout << "OSSF: " << endl;
2928 +  if(PlottingSetup::RestrictToMassPeak) {
2929 +    dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
2930 +    dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
2931 +  } else {
2932 +    dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
2933 +  }
2934 +  dout << "OSOF: " << endl;
2935 +  if(PlottingSetup::RestrictToMassPeak) {
2936 +    dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
2937 +    dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
2938 +  } else {
2939 +    dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
2940 +  }
2941 +  dout << "Therefore: " << endl;
2942 +  if(PlottingSetup::RestrictToMassPeak) {
2943 +    dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
2944 +    dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
2945 +    dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
2946 +    dout << " = " << LcorrJZBeemm->Integral() + (1.0/3)*(RcorrJZBSBeemm->Integral() - LcorrJZBSBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() + RcorrJZBSBem->Integral() - LcorrJZBSBem->Integral()) << endl;
2947 +  } else {
2948 +    dout << "    Prediction increases by : " << LcorrJZBeemm->Integral();
2949 +    dout << " + (" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
2950 +    dout << " = " << LcorrJZBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() << endl;
2951 +  }
2952 +  dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
2953 +  
2954 +  dout << endl;
2955 +  for(int i=0;i<(int)bins.size();i++) {
2956 +    dout << " JZB > " << bins[i] << " : " << endl;
2957 +    dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
2958 +    if(PlottingSetup::RestrictToMassPeak) {
2959 +        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;
2960 +    } else {
2961 +        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;
2962 +    }
2963 +  }
2964 +      
2965 +  delete can;
2966 +  delete allevents;
2967 +  if(ossf) delete ossf;
2968 +  if(RcorrJZBem) delete RcorrJZBem;
2969 +  if(LcorrJZBem) delete LcorrJZBem;
2970 +  if(RcorrJZBeemm) delete RcorrJZBeemm;
2971 +  if(LcorrJZBeemm) delete LcorrJZBeemm;
2972 +  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
2973 +  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
2974 +  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
2975 +  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
2976 + }
2977 +
2978 + void check_ptsanity() {
2979 +  TCanvas *ptsancan = new TCanvas("ptsancan","ptsancan",600,1800);
2980 +  TH1F *individualpt1histos[allsamples.collection.size()];
2981 +  TH1F *individualpt2histos[allsamples.collection.size()];
2982 +  TH1F *fpt1 = new TH1F("fpt1","fpt1",50,0,50);
2983 +  fpt1->GetYaxis()->SetRangeUser(0,1);
2984 +  fpt1->GetXaxis()->SetTitle("p_{T,1}");
2985 +  fpt1->GetXaxis()->CenterTitle();
2986 +
2987 +  TH1F *fpt2 = new TH1F("fpt2","fpt2",50,0,50);
2988 +  fpt2->GetXaxis()->SetTitle("p_{T,2}");
2989 +  fpt2->GetXaxis()->CenterTitle();
2990 +  
2991 +  ptsancan->Divide(1,3);
2992 +  ptsancan->cd(1);
2993 +  float maxpt1entry=0;
2994 +  float maxpt2entry=0;
2995 +  
2996 +  TLegend *leg = make_legend();
2997 +  leg->SetX1(0.0);
2998 +  leg->SetY1(0.0);
2999 +  leg->SetX2(1.0);
3000 +  leg->SetY2(1.0);
3001 +  
3002 +  
3003 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3004 +    string nowname=(allsamples.collection)[isample].filename;
3005 +    cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3006 +    individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3007 +    individualpt2histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt2",50,0,50, "p_{T,2}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3008 +    individualpt1histos[isample]->SetLineColor(isample+1);
3009 +    individualpt2histos[isample]->SetLineColor(isample+1);
3010 +    float currmaxpt1entry=individualpt1histos[isample]->GetMaximum()/individualpt1histos[isample]->Integral();
3011 +    float currmaxpt2entry=individualpt2histos[isample]->GetMaximum()/individualpt2histos[isample]->Integral();
3012 +    cout << "      pt 1 histo contains; " << individualpt1histos[isample]->Integral() << endl;
3013 +    cout << "      pt 2 histo contains; " << individualpt2histos[isample]->Integral() << endl;
3014 +    if(currmaxpt1entry>maxpt1entry)maxpt1entry=currmaxpt1entry;
3015 +    if(currmaxpt2entry>maxpt2entry)maxpt2entry=currmaxpt2entry;
3016 +    leg->AddEntry(individualpt2histos[isample],((allsamples.collection)[isample].filename).c_str(),"f");
3017 +  }
3018 +
3019 +  fpt1->GetYaxis()->SetRangeUser(0,maxpt1entry);
3020 +  fpt2->GetYaxis()->SetRangeUser(0,maxpt2entry);
3021 +
3022 +  ptsancan->cd(1);
3023 +  fpt1->Draw();
3024 +  ptsancan->cd(2);
3025 +  fpt2->Draw();
3026 +
3027 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3028 +    ptsancan->cd(1);
3029 +    individualpt1histos[isample]->DrawNormalized("same,histo");
3030 +    ptsancan->cd(2);
3031 +    individualpt2histos[isample]->DrawNormalized("same,histo");
3032 +  }
3033 +  ptsancan->cd(3);
3034 +  leg->Draw();
3035 +  CompleteSave(ptsancan,"PtSanityCheck");
3036    
3037 +  delete ptsancan;
3038 + }
3039 +
3040 + void do_mlls_plot(string mcjzb) {
3041 +  cout << "At this point we'd plot the mll distribution" << endl;
3042 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3043 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3044 +    if(!(signalsamples.collection)[isig].events) continue;
3045 +    string nowname=(signalsamples.collection)[isig].filename;
3046 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3047 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3048 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3049 +    stringstream poscutS;
3050 +    poscutS << "((" << mcjzb <<")>50)";
3051 +    TCut poscut(poscutS.str().c_str());
3052 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3053 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3054 +    mll->Draw("histo");
3055 +    mllP->Draw("histo,same");
3056 +    TLegend *leg = make_legend();
3057 +    leg->SetY1(0.8);
3058 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3059 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3060 +    leg->Draw();
3061 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3062 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3063 +    lin->Draw("same");
3064 +    lin2->Draw("same");
3065 +    
3066 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3067 +    delete mll;
3068 +    delete mllP;
3069 +  }
3070 + }
3071 +
3072 + void met_vs_jzb_plots() {
3073 +  
3074 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3075 +  canmetjzb->SetRightMargin(0.16);
3076 +  
3077 +  vector<string> findme;
3078 +  findme.push_back("DY");
3079 +  findme.push_back("TTJets");
3080 +  findme.push_back("LM");
3081 +  
3082 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3083 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3084 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3085 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3086 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3087 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3088 +    }
3089 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3090 +    metvsjzb->SetStats(0);
3091 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3092 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3093 +    metvsjzb->GetXaxis()->CenterTitle();
3094 +    metvsjzb->GetYaxis()->CenterTitle();
3095 +    metvsjzb->Draw("COLZ");
3096 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3097 +    title->SetTextAlign(12);
3098 +    title->Draw();
3099 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3100 +  }
3101 + }
3102 +    
3103  
3104   void test() {
3105    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines