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.12 by buchmann, Wed Apr 18 09:20:36 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 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 360 | Line 445 | void do_kinematic_plots(string mcjzb, st
445    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
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);
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 369 | Line 455 | void do_kinematic_plots(string mcjzb, st
455    make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
456    make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
457    make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
458 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
458 >  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);*//*
459    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
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,50);
475 +  make_special_obs_pred_mll_plot(mcjzb,100);
476 +  make_special_obs_pred_mll_plot(mcjzb,150);
477 +  make_special_obs_pred_mll_plot(mcjzb,200);
478 +  make_special_obs_pred_mll_plot(mcjzb,250);
479   }
480  
481   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 483 | Line 585 | void signal_bg_comparison()
585    float simulatedlumi=luminosity;//in pb please - adjust to your likings
586    
587    TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
588 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
588 >  TH1F *JZBplotLM4;
589 >  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"));
590 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
591    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
592    
593    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 507 | Line 611 | void signal_bg_comparison()
611    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
612    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
613    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
614 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
614 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
615 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
616    signal_bg_comparison_leg2->Draw();
617    DrawMCPrelim(simulatedlumi);
618    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 749 | Line 854 | if you want to start from scratch (witho
854    return return_functions;
855   }
856  
857 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
857 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
858   {
859 +  // note: sigma is not used ATM
860 +  switch_overunderflow(true);
861    bool is_data=false;
862    bool use_signal=false;
863    if(use_data==1) is_data=true;
# Line 759 | Line 866 | void do_prediction_plot(string jzb, TCan
866    if(is_data) nbins=50;
867    float low=0;
868    float hi=500;
869 +  
870 +  stringstream largerzeroS;
871 +  largerzeroS << "("<<jzb<<">0)";
872 +  TCut largerzero(largerzeroS.str().c_str());
873 +  stringstream smallerzeroS;
874 +  smallerzeroS << "("<<jzb<<"<0)";
875 +  TCut smallerzero(smallerzeroS.str().c_str());
876 +  
877    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
878 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
879 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
880 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
881 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
878 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
879 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
880 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
881 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
882 >
883    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
884    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
885    blankback->GetXaxis()->CenterTitle();
# Line 778 | Line 894 | void do_prediction_plot(string jzb, TCan
894    TH1F *RcorrJZBeemmNoS;
895  
896      //these are for the ratio
897 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
898 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
899 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
900 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
897 >  
898 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
899 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
900 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
901 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
902    
903    TH1F *JRcorrJZBSBem;
904    TH1F *JLcorrJZBSBem;
905    TH1F *JRcorrJZBSBeemm;
906    TH1F *JLcorrJZBSBeemm;
907    
908 <  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);
908 >  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);
909  
910    
911    if(PlottingSetup::RestrictToMassPeak) {
912 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
913 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
914 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
915 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
916 <
912 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
913 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
914 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
915 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
916 >    
917      //these are for the ratio
918 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
919 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
920 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
921 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
805 <
918 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
919 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
920 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
921 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
922    }
923    
924    TH1F *lm4RcorrJZBeemm;
925 <  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"));
925 >  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"));
926    
927    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
928    
# Line 900 | Line 1016 | void do_prediction_plot(string jzb, TCan
1016      Bpred->Draw("hist,same");
1017      analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1018      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1019 +    lm4RcorrJZBeemm->Draw("hist,same");
1020      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1021      legBpred->AddEntry(Bpred,"predicted","l");
1022      legBpred->AddEntry(analytical_function[1],"predicted fit","l");
# Line 909 | Line 1026 | void do_prediction_plot(string jzb, TCan
1026      DrawPrelim();
1027  
1028      //this plot shows what the prediction is composed of
1029 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1030 <    specialcanv->SetLogy(1);
1031 <    Zjetspred->SetFillColor(kYellow);
1032 <    Zjetspred->SetLineColor(kYellow);
1033 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1034 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1029 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1030 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1031 >    Bpred->SetLineWidth(2);
1032 >    predcomppad->cd();
1033 >    predcomppad->SetLogy(1);
1034 >    
1035 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1036 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1037 >    sidebandsemu->Add(jzbnegative,-1);
1038 >    
1039 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1040 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1041 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1042 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1043 >    
1044      THStack predcomposition("predcomposition","prediction composition");
1045 <    predcomposition.Add(TTbarpred);
1046 <    predcomposition.Add(Zjetspred);
1045 >    predcomposition.Add(sidebandsemu);
1046 >    predcomposition.Add(jzbnegative);
1047      blankback->Draw();
1048      RcorrJZBeemm->Draw("e1x0,same");
1049      predcomposition.Draw("histo,same");//
1050      Bpred->Draw("hist,same");
1051 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1051 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1052      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1053 <    legBpred->Draw();
1053 > //    TH1F *lm4RcorrJZBeemmC = (TH1F*)lm4RcorrJZBeemm->Clone("lm4RcorrJZBeemmC");
1054 > //    lm4RcorrJZBeemmC->SetLineColor(kOrange+1);
1055 >    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1056 > //    lm4RcorrJZBeemmC->Draw("histo,same");
1057 >    lm4RcorrJZBeemm->SetLineWidth(2);
1058 >    lm4RcorrJZBeemm->Draw("histo,same");
1059      DrawPrelim();
1060 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1061 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1062 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1063 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1064 <    specialleg->Draw("same");
1065 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1066 <
1060 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1061 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1062 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1063 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1064 >    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1065 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1066 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1067 >    speciallegBpred->Draw();
1068 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1069 >    
1070 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1071      THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1072      blankback->Draw();
1073      kostack.Draw("same");
# Line 941 | Line 1076 | void do_prediction_plot(string jzb, TCan
1076      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1077      legBpred->Draw();
1078      DrawPrelim();
1079 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1079 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1080 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1081      
1082 <    delete specialcanv;
947 <    delete specialleg;
1082 >    delete speciallegBpred;
1083      delete Zjetspred;
1084      delete TTbarpred;
1085      
# Line 954 | Line 1089 | void do_prediction_plot(string jzb, TCan
1089      RcorrJZBeemm->Draw("e1x0,same");
1090      Bpred->Draw("hist,same");
1091      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1092 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1092 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1093      legBpred->AddEntry(Bpred,"MC predicted","l");
1094      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1095      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
# Line 968 | Line 1103 | void do_prediction_plot(string jzb, TCan
1103      RcorrJZBeemm->Draw("e1x0,same");
1104      Bpred->Draw("hist,same");
1105      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1106 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1106 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1107      legBpred->AddEntry(Bpred,"MC predicted","l");
1108 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1108 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1109      legBpred2->AddEntry(Bpred,"MC predicted","l");
1110      {
1111        if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
# Line 999 | Line 1134 | void do_prediction_plot(string jzb, TCan
1134    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1135    string ytitle("ratio");
1136    if ( use_data==1 ) ytitle = "data/pred";
1137 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1137 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1138 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1139  
1140    
1141    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1142    /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1143 <  if(!PlottingSetup::RestrictToMassPeak) return;
1144 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1145 <  Bpredem->Add(RcorrJZBem);
1146 <  Bpredem->Add(LcorrJZBem,-1);
1147 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1148 <  BpredSBem->Add(RcorrJZBSBem);
1149 <  Bpred->Add(LcorrJZBSBem,-1);
1150 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1151 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1152 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1153 <  globalcanvas->cd();
1154 <  globalcanvas->SetLogy(1);
1155 <
1156 <  RcorrJZBeemm->SetMarkerStyle(20);
1157 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1158 <  blankback->Draw();
1159 <  RcorrJZBeemm->Draw("e1x0,same");
1160 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1161 <  
1162 <  Bpredem->SetLineColor(kRed+1);
1163 <  Bpredem->SetStats(0);
1164 <  Bpredem->Draw("hist,same");
1165 <
1166 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1167 <  BpredSBem->SetLineStyle(2);
1168 <  BpredSBem->Draw("hist,same");
1169 <
1170 <  BpredSBeemm->SetLineColor(kBlue+1);
1171 <  BpredSBeemm->SetLineStyle(3);
1172 <  BpredSBeemm->Draw("hist,same");
1173 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1174 <
1175 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1176 <  if(use_data==1)
1177 <  {
1178 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1179 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1180 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1181 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1182 <    legBpredc->Draw();
1183 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1184 <  }
1185 <  if(use_data==0) {
1186 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1187 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1188 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1189 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1190 <    legBpredc->Draw();
1191 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1192 <  }
1193 <  if(use_data==2) {
1194 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1195 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1196 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1197 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1198 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1199 <    legBpredc->Draw();
1200 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1143 >  if(PlottingSetup::RestrictToMassPeak) {
1144 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1145 >    Bpredem->Add(RcorrJZBem);
1146 >    Bpredem->Add(LcorrJZBem,-1);
1147 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1148 >    BpredSBem->Add(RcorrJZBSBem);
1149 >    Bpred->Add(LcorrJZBSBem,-1);
1150 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1151 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1152 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1153 >    globalcanvas->cd();
1154 >    globalcanvas->SetLogy(1);
1155 >    
1156 >    RcorrJZBeemm->SetMarkerStyle(20);
1157 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1158 >    blankback->Draw();
1159 >    RcorrJZBeemm->Draw("e1x0,same");
1160 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1161 >    
1162 >    Bpredem->SetLineColor(kRed+1);
1163 >    Bpredem->SetStats(0);
1164 >    Bpredem->Draw("hist,same");
1165 >    
1166 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1167 >    BpredSBem->SetLineStyle(2);
1168 >    BpredSBem->Draw("hist,same");
1169 >    
1170 >    BpredSBeemm->SetLineColor(kBlue+1);
1171 >    BpredSBeemm->SetLineStyle(3);
1172 >    BpredSBeemm->Draw("hist,same");
1173 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1174 >    
1175 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1176 >    if(use_data==1)
1177 >    {
1178 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1179 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1180 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1181 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1182 >      legBpredc->Draw();
1183 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1184 >    }
1185 >    if(use_data==0) {
1186 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1187 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1188 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1189 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1190 >      legBpredc->Draw();
1191 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1192 >    }
1193 >    if(use_data==2) {
1194 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1195 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1196 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1197 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1198 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1199 >      legBpredc->Draw();
1200 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1201 >    }
1202    }
1203 +  
1204    delete RcorrJZBeemm;
1205    delete LcorrJZBeemm;
1206    delete RcorrJZBem;
# Line 1087 | Line 1225 | void do_prediction_plot(string jzb, TCan
1225      delete JLcorrJZBSBeemm;
1226    }
1227    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1228 +  switch_overunderflow(false);
1229   }
1230  
1231   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
# Line 1443 | Line 1582 | void draw_pure_jzb_histo(TCut cut,string
1582    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1583    writeline1->SetTextSize(0.035);
1584    writeline1->Draw();
1585 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1585 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1586 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1587    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1588    jzbpad2->cd();
1589    jzbpad2->SetLogy(1);
# Line 1458 | Line 1598 | void draw_pure_jzb_histo(TCut cut,string
1598    writeline1->SetTextSize(0.035);
1599    writeline1->Draw();
1600    DrawPrelim();
1601 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1601 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1602 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1603    datahisto->Delete();
1604    mcstack.Delete();
1605   }
# Line 1466 | Line 1607 | void draw_pure_jzb_histo(TCut cut,string
1607   Double_t GausR(Double_t *x, Double_t *par) {
1608    return gRandom->Gaus(x[0],par[0]);
1609   }
1610 +
1611 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1612 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1613 +  float max=jzbHigh ;
1614 +  float min=-120;
1615 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1616 +  int coarserbins=int(nbins/2.0);
1617 +  int rebinnedbins=int(nbins/4.0);
1618 +  
1619 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1620 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1621 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1622 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1623 +
1624 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1625 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1626 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1627 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1628 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1629 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1630 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1631 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1632 +  
1633 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1634 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1635 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1636 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1637 +  
1638 +  delete dican;
1639 + }
1640 +  
1641 +
1642 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1643 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1644 +  
1645 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1646 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1647 +    return;
1648 +  }
1649 +  
1650 +  float stretchfactor = 100.0;
1651 +  vector<string> labels;
1652 +  
1653 +  
1654 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1655 +  for(int i=0;i<SamplesToBeModified.size();i++) {
1656 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1657 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1658 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1659 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1660 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1661 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1662 +  }
1663 +  
1664 +  dout << "Going to produce JZB plots" << endl;
1665 + //  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1666 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1667 +  float sigma=123456;
1668 +  
1669 +  dout << "Going to produce prediction plots" << endl;
1670 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1671 +  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1672 +  delete gloca;
1673 +
1674 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1675 +  for(int i=0;i<SamplesToBeModified.size();i++) {
1676 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1677 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1678 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1679 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1680 +    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;
1681 +    
1682 +  }
1683    
1684 + }
1685   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1686    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1687    float max=jzbHigh ;
# Line 1501 | Line 1716 | void jzb_plots(string mcjzb, string data
1716   //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1717   //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1718   //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
1719 +  delete can;
1720   }
1721  
1722  
# Line 1841 | Line 2057 | void find_correction_factors(string &jzb
2057    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2058    cancorr->SetLogz();
2059    cancorr->SetRightMargin(0.13);
2060 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2060 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2061    TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2062    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2063    (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
# Line 1915 | Line 2131 | void pick_up_events(string cut) {
2131    allsamples.PickUpEvents(cut);
2132   }
2133  
2134 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2134 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError) {
2135    dout << "Saving configuration template!" << endl;
2136    ofstream configfile;
2137    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1936 | Line 2152 | void save_template(string mcjzb, string
2152    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2153    configfile<<"vector<float>jzb_cuts;\n";
2154    configfile<<"float MCPeakError=-999;\n";
2155 +  configfile<<"float DataPeakError=-999;\n";
2156    configfile<<"}\n\n";
2157  
2158    configfile<<"void read_config() {\n";
2159    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2160    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2161 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2161 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2162 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2163    for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2164    configfile<<"\n\n";
2165    for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
# Line 1953 | Line 2171 | void save_template(string mcjzb, string
2171    for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2172    configfile<<"\n\n";
2173    configfile<<"luminosity="<<luminosity<<";\n";
2174 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2175    
2176    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2177    
# Line 2053 | Line 2272 | void ttbar_sidebands_comparison(string m
2272    leg->Draw("same");
2273    DrawMCPrelim(simulatedlumi);
2274    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2275 <  
2275 > cout << __LINE__ << endl;  
2276    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2277 + cout << __LINE__ << endl;  
2278    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2279 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2280 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2279 > cout << __LINE__ << endl;  
2280 >  TH1F *TSeemmcopy;
2281 >  TH1F *TSemcopy;
2282 >  if(PlottingSetup::RestrictToMassPeak) {
2283 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2284 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2285 >  }
2286  
2287    TZem->Divide(TZeemm);
2288    TZem->SetMarkerStyle(21);
# Line 2079 | Line 2304 | void ttbar_sidebands_comparison(string m
2304    
2305    float linepos=0.25;
2306    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2307 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2308    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2309    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2310    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2311    
2312 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2313 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2314 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2315 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2316 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2317 +  topalt->Draw("same");bottomalt->Draw("same");*/
2318 +  
2319 +  
2320    top->SetLineColor(kBlue);top->SetLineStyle(2);
2321    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2322    center->SetLineColor(kBlue);
# Line 2107 | Line 2341 | void ttbar_sidebands_comparison(string m
2341    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2342    
2343  
2110
2344   ///-------------- second part: only look at the quantity we actually care about!
2345    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2346    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2782 | Line 3015 | void check_ptsanity() {
3015    delete ptsancan;
3016   }
3017  
3018 + void do_mlls_plot(string mcjzb) {
3019 +  cout << "At this point we'd plot the mll distribution" << endl;
3020 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3021 +  for(int isig=0;isig<(signalsamples.collection).size();isig++) {
3022 +    if(!(signalsamples.collection)[isig].events) continue;
3023 +    string nowname=(signalsamples.collection)[isig].filename;
3024 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3025 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3026 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3027 +    stringstream poscutS;
3028 +    poscutS << "((" << mcjzb <<")>50)";
3029 +    TCut poscut(poscutS.str().c_str());
3030 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3031 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3032 +    mll->Draw("histo");
3033 +    mllP->Draw("histo,same");
3034 +    TLegend *leg = make_legend();
3035 +    leg->SetY1(0.8);
3036 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3037 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3038 +    leg->Draw();
3039 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3040 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3041 +    lin->Draw("same");
3042 +    lin2->Draw("same");
3043 +    
3044 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3045 +    delete mll;
3046 +    delete mllP;
3047 +  }
3048 + }
3049 +
3050 + void met_vs_jzb_plots() {
3051 +  
3052 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3053 +  canmetjzb->SetRightMargin(0.16);
3054 +  
3055 +  vector<string> findme;
3056 +  findme.push_back("DY");
3057 +  findme.push_back("TTJets");
3058 +  findme.push_back("LM");
3059 +  
3060 +  for(int ifind=0;ifind<findme.size();ifind++) {
3061 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3062 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3063 +    for(int isel=0;isel<selsamples.size();isel++) {
3064 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3065 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3066 +    }
3067 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3068 +    metvsjzb->SetStats(0);
3069 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3070 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3071 +    metvsjzb->GetXaxis()->CenterTitle();
3072 +    metvsjzb->GetYaxis()->CenterTitle();
3073 +    metvsjzb->Draw("COLZ");
3074 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3075 +    title->SetTextAlign(12);
3076 +    title->Draw();
3077 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3078 +  }
3079 + }
3080 +    
3081 +
3082   void test() {
3083    
3084    TCanvas *testcanv = new TCanvas("testcanv","testcanv");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines