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.16 by buchmann, Mon Apr 30 08:38: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;
# 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 349 | Line 433 | void do_kinematic_plots(string mcjzb, st
433    float mll_low=40;
434    float mll_hi=160;
435    if(!PlottingSetup::RestrictToMassPeak) {
436 <        mll_low=30;
437 <        mll_hi=180;
436 >        mll_low=10;
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 361 | 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 374 | 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 445 | 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 483 | Line 586 | void signal_bg_comparison()
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("/DY"));
589 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
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 507 | 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 749 | 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 759 | 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 778 | 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);
805 <
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 893 | 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 909 | 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 941 | 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;
947 <    delete specialleg;
1084 >    delete speciallegBpred;
1085      delete Zjetspred;
1086      delete TTbarpred;
1087      
# Line 952 | 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");
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
# Line 966 | 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 981 | 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 999 | 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 1087 | 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 1443 | 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 1458 | 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 1466 | 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 1480 | 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);
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);
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 1555 | 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 1818 | 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;
1821  int electrons_only=0;
1822  int mu_only=1;
1823  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 1841 | 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    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2076    (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
# Line 1915 | Line 2144 | void pick_up_events(string cut) {
2144    allsamples.PickUpEvents(cut);
2145   }
2146  
2147 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2147 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError) {
2148    dout << "Saving configuration template!" << endl;
2149    ofstream configfile;
2150    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1936 | Line 2165 | void save_template(string mcjzb, string
2165    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2166    configfile<<"vector<float>jzb_cuts;\n";
2167    configfile<<"float MCPeakError=-999;\n";
2168 +  configfile<<"float DataPeakError=-999;\n";
2169    configfile<<"}\n\n";
2170  
2171    configfile<<"void read_config() {\n";
2172    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2173    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2174 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2175 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2174 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2175 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2176 >  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";
2177    configfile<<"\n\n";
2178 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2179 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2180 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2178 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2179 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2180 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2181    configfile<<"\n\n";
2182 <  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2183 <  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2184 <  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2182 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2183 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2184 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2185    configfile<<"\n\n";
2186    configfile<<"luminosity="<<luminosity<<";\n";
2187 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2188    
2189    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2190    
# Line 1975 | Line 2207 | void draw_all_ttbar_histos(TCanvas *can,
2207    float max=histos[0]->GetMaximum();
2208    if(manualmin>=0) min=manualmin;
2209    else {
2210 <    for(int i=1;i<histos.size();i++) {
2210 >    for(int i=1;i<(int)histos.size();i++) {
2211        float curmin=get_nonzero_minimum(histos[i]);
2212        float curmax=histos[i]->GetMaximum();
2213        if(curmin<min) min=curmin;
# Line 1986 | Line 2218 | void draw_all_ttbar_histos(TCanvas *can,
2218    histos[0]->Draw(drawoption.c_str());
2219    stringstream drawopt;
2220    drawopt << drawoption << ",same";
2221 <  for(int i=1;i<histos.size();i++) {
2221 >  for(int i=1;i<(int)histos.size();i++) {
2222      histos[i]->Draw(drawopt.str().c_str());
2223    }
2224   }
# Line 2053 | Line 2285 | void ttbar_sidebands_comparison(string m
2285    leg->Draw("same");
2286    DrawMCPrelim(simulatedlumi);
2287    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2288 <  
2288 > cout << __LINE__ << endl;  
2289    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2290 + cout << __LINE__ << endl;  
2291    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2292 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2293 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2292 > cout << __LINE__ << endl;  
2293 >  TH1F *TSeemmcopy;
2294 >  TH1F *TSemcopy;
2295 >  if(PlottingSetup::RestrictToMassPeak) {
2296 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2297 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2298 >  }
2299  
2300    TZem->Divide(TZeemm);
2301    TZem->SetMarkerStyle(21);
# Line 2079 | Line 2317 | void ttbar_sidebands_comparison(string m
2317    
2318    float linepos=0.25;
2319    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2320 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2321    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2322    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2323    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2324    
2325 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2326 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2327 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2328 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2329 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2330 +  topalt->Draw("same");bottomalt->Draw("same");*/
2331 +  
2332 +  
2333    top->SetLineColor(kBlue);top->SetLineStyle(2);
2334    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2335    center->SetLineColor(kBlue);
# Line 2107 | Line 2354 | void ttbar_sidebands_comparison(string m
2354    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2355    
2356  
2110
2357   ///-------------- second part: only look at the quantity we actually care about!
2358    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2359    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2266 | Line 2512 | void zjets_prediction_comparison() {
2512    hJZBpos->SetLineColor(kBlack);
2513    hJZBneg->SetLineColor(kRed);
2514    
2269  Int_t nbins = 5;
2270  Float_t xmax = 100.;
2271
2272  
2515    TCanvas *zcan = new TCanvas("zcan","zcan");  
2516    zcan->SetLogy(1);
2517  
# Line 2354 | Line 2596 | void make_table(samplecollection &coll,
2596    
2597    TCanvas *cannie = new TCanvas("cannie","cannie");
2598    
2599 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
2599 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
2600      float currcut=jzb_cuts[icut];
2601      int nbins=1;float low=currcut;
2602      vector<int> mysample;
# Line 2413 | Line 2655 | void make_table(samplecollection &coll,
2655    //prediction part
2656    if(is_data) cout << "Data prediction & ";
2657    if(subselection!="none") cout << subselection << " prediction &";
2658 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2658 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2659    
2660    cout << endl;
2661    //observation part
2662    if(is_data) cout << "Data observation & ";
2663    if(subselection!="none") cout << subselection << " observation &";
2664 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2664 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2665    cout << endl;
2666    cout << "_________________________________________________________________" << endl;
2667    delete cannie;
# Line 2454 | Line 2696 | void JZBSelEff(string mcjzb, TTree* even
2696    int nbins = sizeof(xbins)/sizeof(float)-1;
2697    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
2698  
2699 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2700 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2701 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2699 >  
2700 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
2701 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
2702 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
2703  
2704    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
2705    TCut kreco(cutmass);
# Line 2472 | Line 2715 | void JZBSelEff(string mcjzb, TTree* even
2715    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
2716    can->SetGridx(1);
2717    can->SetGridy(1);
2718 +  can->SetLeftMargin(0.16);
2719 +  can->SetRightMargin(0.05);
2720    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
2721 +  leg->SetBorderSize(1);
2722 +  leg->SetLineColor(kBlack);
2723 +  leg->SetTextFont(62);
2724  
2725 <  
2478 <
2479 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
2725 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
2726  
2727      ostringstream selection;
2728      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2492 | Line 2738 | void JZBSelEff(string mcjzb, TTree* even
2738      }
2739    
2740      heff->GetXaxis()->SetRangeUser(min, max);
2741 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
2742 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
2743 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
2744 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
2745      heff->SetMarkerStyle(markers[icut]);
2746      heff->Fit("func","Q+","same");
2747  
# Line 2503 | Line 2753 | void JZBSelEff(string mcjzb, TTree* even
2753  
2754      // Store plot
2755      TH1F* h = (TH1F*)heff->Clone(hname);
2756 +    h->SetNdivisions(505,"X");
2757      if ( icut) h->Draw("same");
2758      else h->Draw();
2759      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2523 | Line 2774 | void JZBSelEff(string mcjzb, TTree* even
2774   // Calls the above function for each signal sample
2775   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
2776   {  
2777 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
2777 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
2778      dout << "JZB selection efficiency curve: " << std::endl;
2779      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
2780    }
# Line 2566 | Line 2817 | void qcd_plots(string datajzb, string mc
2817    TH1F *RcorrJZBSBeemm;
2818    TH1F *LcorrJZBSBeemm;
2819    
2820 <  TH1F *RcorrJZBeemmNoS;
2820 > //  TH1F *RcorrJZBeemmNoS;
2821  
2822      //these are for the ratio
2823    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 2948 | void qcd_plots(string datajzb, string mc
2948    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
2949    
2950    dout << endl;
2951 <  for(int i=0;i<bins.size();i++) {
2951 >  for(int i=0;i<(int)bins.size();i++) {
2952      dout << " JZB > " << bins[i] << " : " << endl;
2953      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
2954      if(PlottingSetup::RestrictToMassPeak) {
# Line 2745 | Line 2996 | void check_ptsanity() {
2996    leg->SetY2(1.0);
2997    
2998    
2999 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
2999 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3000      string nowname=(allsamples.collection)[isample].filename;
3001      cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3002      individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
# Line 2769 | Line 3020 | void check_ptsanity() {
3020    ptsancan->cd(2);
3021    fpt2->Draw();
3022  
3023 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3023 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3024      ptsancan->cd(1);
3025      individualpt1histos[isample]->DrawNormalized("same,histo");
3026      ptsancan->cd(2);
# Line 2782 | Line 3033 | void check_ptsanity() {
3033    delete ptsancan;
3034   }
3035  
3036 + void do_mlls_plot(string mcjzb) {
3037 +  cout << "At this point we'd plot the mll distribution" << endl;
3038 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3039 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3040 +    if(!(signalsamples.collection)[isig].events) continue;
3041 +    string nowname=(signalsamples.collection)[isig].filename;
3042 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3043 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3044 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3045 +    stringstream poscutS;
3046 +    poscutS << "((" << mcjzb <<")>50)";
3047 +    TCut poscut(poscutS.str().c_str());
3048 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3049 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3050 +    mll->Draw("histo");
3051 +    mllP->Draw("histo,same");
3052 +    TLegend *leg = make_legend();
3053 +    leg->SetY1(0.8);
3054 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3055 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3056 +    leg->Draw();
3057 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3058 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3059 +    lin->Draw("same");
3060 +    lin2->Draw("same");
3061 +    
3062 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3063 +    delete mll;
3064 +    delete mllP;
3065 +  }
3066 + }
3067 +
3068 + void met_vs_jzb_plots() {
3069 +  
3070 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3071 +  canmetjzb->SetRightMargin(0.16);
3072 +  
3073 +  vector<string> findme;
3074 +  findme.push_back("DY");
3075 +  findme.push_back("TTJets");
3076 +  findme.push_back("LM");
3077 +  
3078 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3079 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3080 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3081 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3082 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3083 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3084 +    }
3085 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3086 +    metvsjzb->SetStats(0);
3087 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3088 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3089 +    metvsjzb->GetXaxis()->CenterTitle();
3090 +    metvsjzb->GetYaxis()->CenterTitle();
3091 +    metvsjzb->Draw("COLZ");
3092 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3093 +    title->SetTextAlign(12);
3094 +    title->Draw();
3095 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3096 +  }
3097 + }
3098 +    
3099 +
3100   void test() {
3101    
3102    TCanvas *testcanv = new TCanvas("testcanv","testcanv");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines