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.4 by buchmann, Fri Mar 2 08:37:03 2012 UTC vs.
Revision 1.20 by buchmann, Wed May 23 16:02:03 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;
# Line 71 | 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 105 | 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 124 | 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 196 | 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 294 | Line 379 | void make_kin_plot(string variable, stri
379    delete ckin;
380   }
381  
297
382   void make_JES_plot() {
383  
384    int nbins=10;
# Line 346 | 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 361 | Line 447 | void do_kinematic_plots(string mcjzb, st
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);
449    make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",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);
# Line 374 | Line 461 | void do_kinematic_plots(string mcjzb, st
461    stringstream jzbcut;
462    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
463    make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_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_osof_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_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_osof_aboveJZB100",doPF,true);
467 +  stringstream jzbcut2;
468 +  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
469 +  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
470 +  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);
471 +  stringstream jzbcut3;
472 +  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
473 +  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);
474 +  
475 +  make_special_obs_pred_mll_plot(mcjzb,0);
476 +  make_special_obs_pred_mll_plot(mcjzb,50);
477 +  make_special_obs_pred_mll_plot(mcjzb,100);
478 +  make_special_obs_pred_mll_plot(mcjzb,150);
479 +  make_special_obs_pred_mll_plot(mcjzb,200);
480 +  make_special_obs_pred_mll_plot(mcjzb,250);
481   }
482  
483   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 445 | Line 549 | void region_comparison_plots(string mcjz
549      
550    
551      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
552 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
552 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
553      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
554      float mll_low=50;float mll_high=170;
555      if(!PlottingSetup::RestrictToMassPeak) {
# Line 483 | Line 587 | void signal_bg_comparison()
587    float simulatedlumi=luminosity;//in pb please - adjust to your likings
588    
589    TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
590 <  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 *JZBplotLM4;
591 >  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"));
592 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
593    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
594    
595    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 507 | Line 613 | void signal_bg_comparison()
613    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
614    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
615    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
616 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
616 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
617 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
618    signal_bg_comparison_leg2->Draw();
619    DrawMCPrelim(simulatedlumi);
620    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 749 | Line 856 | if you want to start from scratch (witho
856    return return_functions;
857   }
858  
859 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
859 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
860   {
861 +  // note: sigma is not used ATM
862 +  switch_overunderflow(true);
863    bool is_data=false;
864    bool use_signal=false;
865    if(use_data==1) is_data=true;
# Line 759 | Line 868 | void do_prediction_plot(string jzb, TCan
868    if(is_data) nbins=50;
869    float low=0;
870    float hi=500;
871 +  
872 +  stringstream largerzeroS;
873 +  largerzeroS << "("<<jzb<<">0)";
874 +  TCut largerzero(largerzeroS.str().c_str());
875 +  stringstream smallerzeroS;
876 +  smallerzeroS << "("<<jzb<<"<0)";
877 +  TCut smallerzero(smallerzeroS.str().c_str());
878 +  
879    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
880 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
881 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
882 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
883 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
880 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
881 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
882 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
883 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
884 >
885    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
886    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
887    blankback->GetXaxis()->CenterTitle();
# Line 778 | Line 896 | void do_prediction_plot(string jzb, TCan
896    TH1F *RcorrJZBeemmNoS;
897  
898      //these are for the ratio
899 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
900 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
901 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
902 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
899 >  
900 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
901 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
902 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
903 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
904    
905    TH1F *JRcorrJZBSBem;
906    TH1F *JLcorrJZBSBem;
907    TH1F *JRcorrJZBSBeemm;
908    TH1F *JLcorrJZBSBeemm;
909    
910 <  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);
910 >  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);
911  
912    
913    if(PlottingSetup::RestrictToMassPeak) {
914 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
915 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
916 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
917 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
918 <
914 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
915 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
916 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
917 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
918 >    
919      //these are for the ratio
920 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
921 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
922 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
923 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
805 <
920 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
921 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
922 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
923 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
924    }
925    
926    TH1F *lm4RcorrJZBeemm;
927 <  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"));
927 >  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"));
928    
929    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
930    
# Line 893 | Line 1011 | void do_prediction_plot(string jzb, TCan
1011    blankback->Draw();
1012    if(use_data==1)
1013    {
1014 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1015 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1016      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1017      kinpad->cd();//necessary because the extended fit function creates its own canvas
1018      RcorrJZBeemm->Draw("e1x0,same");
1019  
1020      Bpred->Draw("hist,same");
1021 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1021 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1022      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1023 +    lm4RcorrJZBeemm->Draw("hist,same");
1024      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1025      legBpred->AddEntry(Bpred,"predicted","l");
1026      legBpred->AddEntry(analytical_function[1],"predicted fit","l");
# Line 909 | Line 1030 | void do_prediction_plot(string jzb, TCan
1030      DrawPrelim();
1031  
1032      //this plot shows what the prediction is composed of
1033 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1034 <    specialcanv->SetLogy(1);
1035 <    Zjetspred->SetFillColor(kYellow);
1036 <    Zjetspred->SetLineColor(kYellow);
1037 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1038 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1033 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1034 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1035 >    Bpred->SetLineWidth(2);
1036 >    predcomppad->cd();
1037 >    predcomppad->SetLogy(1);
1038 >    
1039 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1040 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1041 >    sidebandsemu->Add(jzbnegative,-1);
1042 >    
1043 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1044 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1045 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1046 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1047 >    
1048      THStack predcomposition("predcomposition","prediction composition");
1049 <    predcomposition.Add(TTbarpred);
1050 <    predcomposition.Add(Zjetspred);
1049 >    predcomposition.Add(sidebandsemu);
1050 >    predcomposition.Add(jzbnegative);
1051      blankback->Draw();
1052      RcorrJZBeemm->Draw("e1x0,same");
1053      predcomposition.Draw("histo,same");//
1054      Bpred->Draw("hist,same");
1055 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1055 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1056      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1057 <    legBpred->Draw();
1057 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1058 >    lm4RcorrJZBeemm->SetLineWidth(2);
1059 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1060 >    lm4RcorrJZBeemm->Draw("histo,same");
1061      DrawPrelim();
1062 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1063 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1064 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1065 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1066 <    specialleg->Draw("same");
1067 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1068 <
1062 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1063 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1064 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1065 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1066 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1067 >    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1068 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1069 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1070 >    speciallegBpred->Draw();
1071 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1072 >    
1073 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1074      THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1075      blankback->Draw();
1076      kostack.Draw("same");
# Line 941 | Line 1079 | void do_prediction_plot(string jzb, TCan
1079      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1080      legBpred->Draw();
1081      DrawPrelim();
1082 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1082 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1083 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1084      
1085 <    delete specialcanv;
947 <    delete specialleg;
1085 >    delete speciallegBpred;
1086      delete Zjetspred;
1087      delete TTbarpred;
1088      
# Line 952 | Line 1090 | void do_prediction_plot(string jzb, TCan
1090    }
1091    if(use_data==0) {
1092      RcorrJZBeemm->Draw("e1x0,same");
1093 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1094      Bpred->Draw("hist,same");
1095      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1096 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1097 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1096 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1097 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1098      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1099      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1100      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 966 | Line 1105 | void do_prediction_plot(string jzb, TCan
1105    }
1106    if(use_data==2) {
1107      RcorrJZBeemm->Draw("e1x0,same");
1108 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1109      Bpred->Draw("hist,same");
1110      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1111 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1111 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1112      legBpred->AddEntry(Bpred,"MC predicted","l");
1113 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1113 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1114      legBpred2->AddEntry(Bpred,"MC predicted","l");
1115      {
1116        if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
# Line 981 | Line 1121 | void do_prediction_plot(string jzb, TCan
1121   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1122      }
1123      {
1124 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1125 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1126 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1127 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1128 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1129 +      
1130        RcorrJZBeemmNoS->SetLineStyle(2);
1131        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1132        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 999 | Line 1145 | void do_prediction_plot(string jzb, TCan
1145    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1146    string ytitle("ratio");
1147    if ( use_data==1 ) ytitle = "data/pred";
1148 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1148 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1149 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1150  
1151    
1152    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1153    /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1154 <  if(!PlottingSetup::RestrictToMassPeak) return;
1155 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1156 <  Bpredem->Add(RcorrJZBem);
1157 <  Bpredem->Add(LcorrJZBem,-1);
1158 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1159 <  BpredSBem->Add(RcorrJZBSBem);
1160 <  Bpred->Add(LcorrJZBSBem,-1);
1161 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1162 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1163 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1164 <  globalcanvas->cd();
1165 <  globalcanvas->SetLogy(1);
1166 <
1167 <  RcorrJZBeemm->SetMarkerStyle(20);
1168 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1169 <  blankback->Draw();
1170 <  RcorrJZBeemm->Draw("e1x0,same");
1171 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1172 <  
1173 <  Bpredem->SetLineColor(kRed+1);
1174 <  Bpredem->SetStats(0);
1175 <  Bpredem->Draw("hist,same");
1176 <
1177 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1178 <  BpredSBem->SetLineStyle(2);
1179 <  BpredSBem->Draw("hist,same");
1180 <
1181 <  BpredSBeemm->SetLineColor(kBlue+1);
1182 <  BpredSBeemm->SetLineStyle(3);
1183 <  BpredSBeemm->Draw("hist,same");
1184 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1185 <
1186 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1187 <  if(use_data==1)
1188 <  {
1189 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1190 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1191 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1192 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1193 <    legBpredc->Draw();
1194 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1195 <  }
1196 <  if(use_data==0) {
1197 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1198 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1199 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1200 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1201 <    legBpredc->Draw();
1202 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1203 <  }
1204 <  if(use_data==2) {
1205 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1206 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1207 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1208 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1209 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1210 <    legBpredc->Draw();
1211 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1154 >  if(PlottingSetup::RestrictToMassPeak) {
1155 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1156 >    Bpredem->Add(RcorrJZBem);
1157 >    Bpredem->Add(LcorrJZBem,-1);
1158 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1159 >    BpredSBem->Add(RcorrJZBSBem);
1160 >    Bpred->Add(LcorrJZBSBem,-1);
1161 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1162 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1163 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1164 >    globalcanvas->cd();
1165 >    globalcanvas->SetLogy(1);
1166 >    
1167 >    RcorrJZBeemm->SetMarkerStyle(20);
1168 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1169 >    blankback->Draw();
1170 >    RcorrJZBeemm->Draw("e1x0,same");
1171 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1172 >    
1173 >    Bpredem->SetLineColor(kRed+1);
1174 >    Bpredem->SetStats(0);
1175 >    Bpredem->Draw("hist,same");
1176 >    
1177 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1178 >    BpredSBem->SetLineStyle(2);
1179 >    BpredSBem->Draw("hist,same");
1180 >    
1181 >    BpredSBeemm->SetLineColor(kBlue+1);
1182 >    BpredSBeemm->SetLineStyle(3);
1183 >    BpredSBeemm->Draw("hist,same");
1184 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1185 >    
1186 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1187 >    if(use_data==1)
1188 >    {
1189 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1190 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1191 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1192 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1193 >      legBpredc->Draw();
1194 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1195 >    }
1196 >    if(use_data==0) {
1197 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1198 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1199 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1200 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1201 >      legBpredc->Draw();
1202 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1203 >    }
1204 >    if(use_data==2) {
1205 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1206 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1207 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1208 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1209 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1210 >      legBpredc->Draw();
1211 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1212 >    }
1213    }
1214 +  
1215    delete RcorrJZBeemm;
1216    delete LcorrJZBeemm;
1217    delete RcorrJZBem;
# Line 1087 | Line 1236 | void do_prediction_plot(string jzb, TCan
1236      delete JLcorrJZBSBeemm;
1237    }
1238    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1239 +  switch_overunderflow(false);
1240   }
1241  
1242   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1243    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1244    do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1245 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1246 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1245 >  if ( !PlottingSetup::Approved ) {
1246 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1247 >    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1248 >  } else {
1249 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1250 >  }
1251   }
1252  
1253   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1443 | Line 1597 | void draw_pure_jzb_histo(TCut cut,string
1597    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1598    writeline1->SetTextSize(0.035);
1599    writeline1->Draw();
1600 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1600 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1601 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1602    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1603    jzbpad2->cd();
1604    jzbpad2->SetLogy(1);
# Line 1458 | Line 1613 | void draw_pure_jzb_histo(TCut cut,string
1613    writeline1->SetTextSize(0.035);
1614    writeline1->Draw();
1615    DrawPrelim();
1616 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1616 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1617 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1618    datahisto->Delete();
1619    mcstack.Delete();
1620   }
# Line 1466 | Line 1622 | void draw_pure_jzb_histo(TCut cut,string
1622   Double_t GausR(Double_t *x, Double_t *par) {
1623    return gRandom->Gaus(x[0],par[0]);
1624   }
1625 +
1626 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1627 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1628 +  float max=jzbHigh ;
1629 +  float min=-120;
1630 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1631 +  int coarserbins=int(nbins/2.0);
1632 +  int rebinnedbins=int(nbins/4.0);
1633 +  
1634 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1635 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1636 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1637 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1638 +
1639 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1640 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1641 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1642 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1643 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1644 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1645 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1646 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1647 +  
1648 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1649 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1650 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1651 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1652 +  
1653 +  delete dican;
1654 + }
1655 +  
1656 +
1657 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1658 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1659 +  
1660 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1661 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1662 +    return;
1663 +  }
1664 +  
1665 +  float stretchfactor = 100.0;
1666 +  vector<string> labels;
1667 +  
1668 +  
1669 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1670 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1671 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1672 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1673 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1674 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1675 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1676 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1677 +  }
1678 +  
1679 +  dout << "Going to produce JZB plots" << endl;
1680 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1681 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1682 +  float sigma=123456;
1683 +  
1684 +  dout << "Going to produce prediction plots" << endl;
1685 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1686 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1687 +  delete gloca;
1688 +
1689 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1690 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1691 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1692 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1693 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1694 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1695 +    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;
1696 +    
1697 +  }
1698    
1699 + }
1700   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1701    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1702    float max=jzbHigh ;
# Line 1480 | Line 1710 | void jzb_plots(string mcjzb, string data
1710    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1711    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1712  
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);
1713 >  if ( !PlottingSetup::Approved ) {
1714 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1715 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1716 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1717 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1718 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1719 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1720 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1721 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1722 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1723 >  }
1724    
1725    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
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 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1732 < //  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1501 < //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1502 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1503 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
1726 >  if ( !PlottingSetup::Approved ) {
1727 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1728 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1729 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1730 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1731 >  }
1732 >  delete can;
1733   }
1734  
1735  
# Line 1555 | Line 1784 | void compute_MC_yields(string mcjzb,vect
1784    string posneg[] = {"pos","neg"};
1785    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
1786  
1787 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
1787 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
1788      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
1789      dout << "_________________________________________________________" << endl;
1790      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
1791 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
1791 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
1792        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
1793        else dout << "Sample & ";
1794        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1818 | Line 2047 | void draw_ttbar_and_zjets_shape_for_one_
2047  
2048   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2049    int all_leptons=-1;
1821  int electrons_only=0;
1822  int mu_only=1;
1823  int twojetswith50gev=1;
2050    int threejetswith30gev=0;
2051   /*  
2052 +  int twojetswith50gev=1;
2053 +  int electrons_only=0;
2054 +  int mu_only=1;
2055 +
2056    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2057    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2058    
# Line 1841 | Line 2071 | void find_correction_factors(string &jzb
2071    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2072    cancorr->SetLogz();
2073    cancorr->SetRightMargin(0.13);
2074 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2074 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2075    TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2076 +  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2077    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2078    (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2079    niceresponseplotd->SetStats(0);
# Line 1853 | Line 2084 | void find_correction_factors(string &jzb
2084    niceresponseplotd->Draw("COLZ");
2085    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2086    profd->SetMarkerSize(DataMarkerSize);
2087 <  profd->Fit("pol0","","same,e1",30,400);
2087 >  profd->Fit("pol0","","same,e1",100,400);
2088    DrawPrelim();
2089    TText* title = write_text(0.5,0.7,"Data");
2090    title->SetTextAlign(12);
# Line 1879 | Line 2110 | void find_correction_factors(string &jzb
2110    (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2111    TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2112    profm->SetMarkerSize(DataMarkerSize);
2113 <  profm->Fit("pol0","","same,e1",30,400);
2113 >  profm->Fit("pol0","","same,e1",100,400);
2114    DrawMCPrelim();
2115    title = write_text(0.5,0.7,"MC simulation");
2116    title->SetTextAlign(12);
# Line 1915 | Line 2146 | void pick_up_events(string cut) {
2146    allsamples.PickUpEvents(cut);
2147   }
2148  
2149 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2149 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2150    dout << "Saving configuration template!" << endl;
2151    ofstream configfile;
2152    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1935 | Line 2166 | void save_template(string mcjzb, string
2166    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2167    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2168    configfile<<"vector<float>jzb_cuts;\n";
2169 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2170    configfile<<"float MCPeakError=-999;\n";
2171 +  configfile<<"float DataPeakError=-999;\n";
2172    configfile<<"}\n\n";
2173  
2174    configfile<<"void read_config() {\n";
2175    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2176    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2177 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2178 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2177 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2178 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2179 >  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";
2180 >  configfile<<"\n\n";
2181 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2182 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2183 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2184    configfile<<"\n\n";
2185 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2186 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2187 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2185 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2186 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2187 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n\n";
2188 >  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";
2189    configfile<<"\n\n";
1951  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1952  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1953  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2190    configfile<<"\n\n";
2191    configfile<<"luminosity="<<luminosity<<";\n";
2192 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2193    
2194    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2195    
# Line 1975 | Line 2212 | void draw_all_ttbar_histos(TCanvas *can,
2212    float max=histos[0]->GetMaximum();
2213    if(manualmin>=0) min=manualmin;
2214    else {
2215 <    for(int i=1;i<histos.size();i++) {
2215 >    for(int i=1;i<(int)histos.size();i++) {
2216        float curmin=get_nonzero_minimum(histos[i]);
2217        float curmax=histos[i]->GetMaximum();
2218        if(curmin<min) min=curmin;
# Line 1986 | Line 2223 | void draw_all_ttbar_histos(TCanvas *can,
2223    histos[0]->Draw(drawoption.c_str());
2224    stringstream drawopt;
2225    drawopt << drawoption << ",same";
2226 <  for(int i=1;i<histos.size();i++) {
2226 >  for(int i=1;i<(int)histos.size();i++) {
2227      histos[i]->Draw(drawopt.str().c_str());
2228    }
2229   }
# Line 2053 | Line 2290 | void ttbar_sidebands_comparison(string m
2290    leg->Draw("same");
2291    DrawMCPrelim(simulatedlumi);
2292    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2293 <  
2293 > cout << __LINE__ << endl;  
2294    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2295 + cout << __LINE__ << endl;  
2296    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2297 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2298 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2297 > cout << __LINE__ << endl;  
2298 >  TH1F *TSeemmcopy;
2299 >  TH1F *TSemcopy;
2300 >  if(PlottingSetup::RestrictToMassPeak) {
2301 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2302 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2303 >  }
2304  
2305    TZem->Divide(TZeemm);
2306    TZem->SetMarkerStyle(21);
# Line 2079 | Line 2322 | void ttbar_sidebands_comparison(string m
2322    
2323    float linepos=0.25;
2324    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2325 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2326    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2327    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2328    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2329    
2330 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2331 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2332 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2333 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2334 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2335 +  topalt->Draw("same");bottomalt->Draw("same");*/
2336 +  
2337 +  
2338    top->SetLineColor(kBlue);top->SetLineStyle(2);
2339    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2340    center->SetLineColor(kBlue);
# Line 2107 | Line 2359 | void ttbar_sidebands_comparison(string m
2359    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2360    
2361  
2110
2362   ///-------------- second part: only look at the quantity we actually care about!
2363    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2364    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2234 | Line 2485 | void ttbar_sidebands_comparison(string m
2485   }
2486  
2487  
2488 < void zjets_prediction_comparison() {
2488 > void zjets_prediction_comparison(string mcjzbWithPU) {
2489 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2490 >  zcan->SetLogy(1);
2491 >  TCut weightbackup=cutWeight;
2492 >
2493 > /*
2494    // Do it without PU re-weighting
2495    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2496    stringstream resultsNoPU;
2497  
2498    stringstream mcjzbnoPU;
2499 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2499 >  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2500    if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2501    else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2502  
2503    string mcjzb = mcjzbnoPU.str();
2504    dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2505  
2250  TCut weightbackup=cutWeight;
2506    cutWeight="1.0";
2507 + */
2508 +  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2509    float sbg_min=0.;
2510    float sbg_max=100.;
2511    int sbg_nbins=5;
# Line 2258 | Line 2515 | void zjets_prediction_comparison() {
2515    TCut kNeg((mcjzb+"<0").c_str());
2516    string var( "abs("+mcjzb+")" );
2517  
2518 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2519 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2520 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2264 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2265 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2518 >  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2519 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2520 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2521    hJZBpos->SetLineColor(kBlack);
2522    hJZBneg->SetLineColor(kRed);
2523    
2269  Int_t nbins = 5;
2270  Float_t xmax = 100.;
2271
2272  
2273  TCanvas *zcan = new TCanvas("zcan","zcan");  
2274  zcan->SetLogy(1);
2524  
2525    hJZBpos->Draw("e1");
2526    hJZBneg->Draw("same,hist");
# Line 2354 | Line 2603 | void make_table(samplecollection &coll,
2603    
2604    TCanvas *cannie = new TCanvas("cannie","cannie");
2605    
2606 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
2606 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
2607      float currcut=jzb_cuts[icut];
2608      int nbins=1;float low=currcut;
2609      vector<int> mysample;
# Line 2413 | Line 2662 | void make_table(samplecollection &coll,
2662    //prediction part
2663    if(is_data) cout << "Data prediction & ";
2664    if(subselection!="none") cout << subselection << " prediction &";
2665 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2665 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2666    
2667    cout << endl;
2668    //observation part
2669    if(is_data) cout << "Data observation & ";
2670    if(subselection!="none") cout << subselection << " observation &";
2671 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2671 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2672    cout << endl;
2673    cout << "_________________________________________________________________" << endl;
2674    delete cannie;
# Line 2454 | Line 2703 | void JZBSelEff(string mcjzb, TTree* even
2703    int nbins = sizeof(xbins)/sizeof(float)-1;
2704    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
2705  
2706 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2707 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2708 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2706 >  
2707 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
2708 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
2709 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
2710  
2711    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
2712    TCut kreco(cutmass);
# Line 2472 | Line 2722 | void JZBSelEff(string mcjzb, TTree* even
2722    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
2723    can->SetGridx(1);
2724    can->SetGridy(1);
2725 +  can->SetLeftMargin(0.16);
2726 +  can->SetRightMargin(0.05);
2727    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
2728 +  leg->SetBorderSize(1);
2729 +  leg->SetLineColor(kBlack);
2730 +  leg->SetTextFont(62);
2731  
2732 <  
2478 <
2479 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
2732 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
2733  
2734      ostringstream selection;
2735      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2492 | Line 2745 | void JZBSelEff(string mcjzb, TTree* even
2745      }
2746    
2747      heff->GetXaxis()->SetRangeUser(min, max);
2748 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
2749 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
2750 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
2751 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
2752      heff->SetMarkerStyle(markers[icut]);
2753      heff->Fit("func","Q+","same");
2754  
# Line 2503 | Line 2760 | void JZBSelEff(string mcjzb, TTree* even
2760  
2761      // Store plot
2762      TH1F* h = (TH1F*)heff->Clone(hname);
2763 +    h->SetNdivisions(505,"X");
2764      if ( icut) h->Draw("same");
2765      else h->Draw();
2766      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2523 | Line 2781 | void JZBSelEff(string mcjzb, TTree* even
2781   // Calls the above function for each signal sample
2782   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
2783   {  
2784 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
2784 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
2785      dout << "JZB selection efficiency curve: " << std::endl;
2786      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
2787    }
# Line 2566 | Line 2824 | void qcd_plots(string datajzb, string mc
2824    TH1F *RcorrJZBSBeemm;
2825    TH1F *LcorrJZBSBeemm;
2826    
2827 <  TH1F *RcorrJZBeemmNoS;
2827 > //  TH1F *RcorrJZBeemmNoS;
2828  
2829      //these are for the ratio
2830    TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2697 | Line 2955 | void qcd_plots(string datajzb, string mc
2955    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
2956    
2957    dout << endl;
2958 <  for(int i=0;i<bins.size();i++) {
2958 >  for(int i=0;i<(int)bins.size();i++) {
2959      dout << " JZB > " << bins[i] << " : " << endl;
2960      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
2961      if(PlottingSetup::RestrictToMassPeak) {
# Line 2745 | Line 3003 | void check_ptsanity() {
3003    leg->SetY2(1.0);
3004    
3005    
3006 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3006 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3007      string nowname=(allsamples.collection)[isample].filename;
3008      cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3009      individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
# Line 2769 | Line 3027 | void check_ptsanity() {
3027    ptsancan->cd(2);
3028    fpt2->Draw();
3029  
3030 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3030 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3031      ptsancan->cd(1);
3032      individualpt1histos[isample]->DrawNormalized("same,histo");
3033      ptsancan->cd(2);
# Line 2782 | Line 3040 | void check_ptsanity() {
3040    delete ptsancan;
3041   }
3042  
3043 + void do_mlls_plot(string mcjzb) {
3044 +  cout << "At this point we'd plot the mll distribution" << endl;
3045 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3046 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3047 +    if(!(signalsamples.collection)[isig].events) continue;
3048 +    string nowname=(signalsamples.collection)[isig].filename;
3049 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3050 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3051 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3052 +    stringstream poscutS;
3053 +    poscutS << "((" << mcjzb <<")>50)";
3054 +    TCut poscut(poscutS.str().c_str());
3055 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3056 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3057 +    mll->Draw("histo");
3058 +    mllP->Draw("histo,same");
3059 +    TLegend *leg = make_legend();
3060 +    leg->SetY1(0.8);
3061 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3062 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3063 +    leg->Draw();
3064 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3065 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3066 +    lin->Draw("same");
3067 +    lin2->Draw("same");
3068 +    
3069 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3070 +    delete mll;
3071 +    delete mllP;
3072 +  }
3073 + }
3074 +
3075 + void met_vs_jzb_plots() {
3076 +  
3077 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3078 +  canmetjzb->SetRightMargin(0.16);
3079 +  
3080 +  vector<string> findme;
3081 +  findme.push_back("DY");
3082 +  findme.push_back("TTJets");
3083 +  findme.push_back("LM");
3084 +  
3085 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3086 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3087 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3088 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3089 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3090 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3091 +    }
3092 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3093 +    metvsjzb->SetStats(0);
3094 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3095 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3096 +    metvsjzb->GetXaxis()->CenterTitle();
3097 +    metvsjzb->GetYaxis()->CenterTitle();
3098 +    metvsjzb->Draw("COLZ");
3099 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3100 +    title->SetTextAlign(12);
3101 +    title->Draw();
3102 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3103 +  }
3104 + }
3105 +    
3106 +
3107   void test() {
3108    
3109    TCanvas *testcanv = new TCanvas("testcanv","testcanv");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines