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.3 by buchmann, Thu Feb 23 15:15:52 2012 UTC vs.
Revision 1.32 by buchmann, Fri Jun 29 15:01:28 2012 UTC

# Line 23 | Line 23 | using namespace PlottingSetup;
23   void todo() {
24    dout << "My to do list: " << endl;
25    dout << "  - ExperimentalModule::Poisson_ratio_plot : Get the second part to work!" << endl;
26 +  dout << "  - compare_onpeak_offpeak_signal_distributions: Implement this function ... " << endl;
27    dout << "Info : The trigger requirement is currently set to " << (const char*) passtrig << endl;
28 +  dout << "Info : The pt requirement is currently set to " << (const char*) passtrig << endl;
29 +  dout << "Info : The mll requirement is currently set to " << (const char*) cutmass << endl;
30 +  dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
31 +  dout << "Info : The weight applied to all MC is " << (const char*) cutWeight << endl;
32   }  
33  
34 < void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
34 >
35 >
36 > void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true, string saveas="")
37   {
38    // Temporarily switch off PU reweighting, if asked
39    TCut weightbackup=cutWeight;
40    if ( !doPUreweighting ) cutWeight="1.0";
41 <
41 >  
42 >  int nbins=100;
43 >  if(PlottingSetup::DoBTag) nbins=25;
44 >  
45    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
46 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
47 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
48 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
49 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
46 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,mc, luminosity);
47 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,data, luminosity);
48 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,mc, luminosity);
49 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,data, luminosity);
50    TH1F *rawttbarjzbeemmMC;
51  
52    if(method==doKM) {
53      //we only need this histo for the KM fitting...
54 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
55 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
56 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
54 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
55 >    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
56 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
57 >    delete rawttbarjzbeemmMC;
58    }
59    else {
60      TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
# Line 51 | Line 62 | void find_peaks(float &MCPeak,float &MCP
62      reducedMC->Add(rawJZBemMC,-1);
63      reducedData->Add(rawJZBemData,-1);
64      //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
65 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
66 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
67 <    
65 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
66 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
67 >    delete reducedMC;
68 >    delete reducedData;
69    }
70  
71    // Revert to original PU reweighting
# Line 61 | Line 73 | void find_peaks(float &MCPeak,float &MCP
73      
74   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
75   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
76 <  dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 <  result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
78 <  dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 <  result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
76 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
78 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
80 >  delete rawJZBeemmData;
81 >  delete rawJZBeemmMC;
82 >  delete rawJZBemData;
83 >  delete rawJZBemMC;
84    delete tempcan;
85   }
86  
87 + void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb)
88 + {
89 +  
90 +  bool DoInvidualeemmPeaks=false;
91 +  
92 +  float mcpeak, datapeak;
93 +  float mcpeakerr, datapeakerr;
94 +  
95 +  float mceepeak,mcmmpeak;
96 +  float mceepeakerr,mcmmpeakerr;
97 +  
98 +  float datammpeak,dataeepeak;
99 +  float datammpeakerr,dataeepeakerr;
100 +  
101 +  float mcSigma, dataSigma;
102 +  
103 +  dout << "Finding global peak : " << endl;
104 +  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma, dataSigma,result,doPUreweighting,"");
105 +  
106 +  if(DoInvidualeemmPeaks) {
107 +    dout << "Finding peak for electrons : " << endl;
108 +    find_one_peak_combination(TCut("id1==0"),mceepeak,mceepeakerr, dataeepeak,dataeepeakerr,mcSigma, dataSigma,result,doPUreweighting,"_ele");
109 +    dout << "Finding peak for muons : " << endl;
110 +    find_one_peak_combination(TCut("id1==1"),mcmmpeak,mcmmpeakerr, datammpeak,datammpeakerr,mcSigma, dataSigma,result,doPUreweighting,"_mu");
111 +    
112 +    datajzb << "(" << jzbvariabledata;
113 +    mcjzb << "(" << jzbvariablemc;
114 +    
115 +    if(dataeepeak>0) datajzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
116 +    else datajzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
117 +    
118 +    if(datammpeak>0) datajzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
119 +    else datajzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
120 +    
121 +    if(datapeak>0) datajzb << "- (id1!=id2)*" << TMath::Abs(datapeak) << " ";
122 +    else datajzb << "+ (id1!=id2)*" << TMath::Abs(datapeak) << " ";
123 +    
124 +    datajzb << ")";
125 +    
126 +    if(mceepeak>0) mcjzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
127 +    else mcjzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
128 +    
129 +    if(mcmmpeak>0) mcjzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
130 +    else mcjzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
131 +    
132 +    if(mcpeak>0) mcjzb << "- (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
133 +    else mcjzb << "+ (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
134 +    
135 +    mcjzb << ")";
136 +  } else {
137 +    datajzb << "(" << jzbvariabledata;
138 +    mcjzb << "(" << jzbvariablemc;
139 +    
140 +    if(datapeak>0) datajzb << "- " << TMath::Abs(datapeak) << " ";
141 +    else datajzb << "+ " << TMath::Abs(datapeak) << " ";
142 +    
143 +    datajzb << ")";
144 +    
145 +    if(mcpeak>0) mcjzb << "- " << TMath::Abs(mcpeak) << " ";
146 +    else mcjzb << "+ " << TMath::Abs(mcpeak) << " ";
147 +    
148 +    mcjzb << ")";
149 +  }
150 +    
151 +  
152 + }
153 +
154 + void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
155 +  float min=70.0;
156 +  float max=115.0;
157 +  if(!PlottingSetup::RestrictToMassPeak) {
158 +    min=10;
159 +    max=150;
160 +  }
161 +  int nbins=int((max-min)/5);
162 +  
163 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
164 +  
165 +  stringstream largerzeroS;
166 +  largerzeroS << "(" << mcjzb << ">" << jzbthreshold << ")";
167 +  TCut largerzero(largerzeroS.str().c_str());
168 +  
169 +  stringstream smallerzeroS;
170 +  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
171 +  TCut smallerzero(smallerzeroS.str().c_str());
172 +  
173 +  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
174 +  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets,mc,luminosity);
175 +  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
176 +  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity);
177 +  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity);
178 +
179 +  TH1F *RcorrJZBSBem;
180 +  TH1F *LcorrJZBSBem;
181 +  TH1F *RcorrJZBSBeemm;
182 +  TH1F *LcorrJZBSBeemm;
183 +  
184 + //  TH1F *RcorrJZBeemmNoS;
185 +
186 +  if(PlottingSetup::RestrictToMassPeak) {
187 +    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,data, luminosity);
188 +    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,data, luminosity);
189 +    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,data, luminosity);
190 +    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,data, luminosity);
191 +  }
192 +  
193 +  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
194 +  if(PlottingSetup::RestrictToMassPeak) {
195 +    Bpred->Add(RcorrJZBem,1.0/3.);
196 +    Bpred->Add(LcorrJZBem,-1.0/3.);
197 +    Bpred->Add(RcorrJZBSBem,1.0/3.);
198 +    Bpred->Add(LcorrJZBSBem,-1.0/3.);
199 +    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
200 +    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
201 +  } else {
202 +    Bpred->Add(RcorrJZBem,1.0);
203 +    Bpred->Add(LcorrJZBem,-1.0);
204 +  }
205 +  
206 +  Bpred->SetLineColor(kRed);
207 +  
208 +  RcorrJZBeemm->Draw();
209 +  mcRcorrJZBeemm.Draw("same");
210 +  Bpred->Draw("histo,same");
211 +  RcorrJZBeemm->Draw("same");
212 +  
213 +  TLegend *leg = allsamples.allbglegend();
214 +  leg->SetX1(0.58);
215 +  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
216 +  leg->AddEntry(Bpred,"predicted (data)","l");
217 +  leg->Draw("same");
218 +  
219 +  stringstream saveas;
220 +  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
221 +  CompleteSave(ckin,saveas.str());
222 +
223 +  delete RcorrJZBeemm;
224 +  delete LcorrJZBeemm;
225 +  delete RcorrJZBem;
226 +  delete LcorrJZBem;
227 +  if(PlottingSetup::RestrictToMassPeak) {
228 +    delete RcorrJZBSBeemm;
229 +    delete LcorrJZBSBeemm;
230 +    delete RcorrJZBSBem;
231 +    delete LcorrJZBSBem;
232 +  }
233 +  delete Bpred;
234 +  delete ckin;
235 + }
236 +
237   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
238    
239    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
# Line 102 | Line 268 | void make_special_mll_plot(int nbins, fl
268    TIter next(bgleg->GetListOfPrimitives());
269    TObject* obj;
270    // Copy the nice bkgd legend skipping the "data"
271 <  while ( obj = next() )
271 >  while ( (obj = next()) )
272      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
273        kinleg->GetListOfPrimitives()->Add(obj);
274  
# Line 121 | Line 287 | void draw_ratio_plot(TH1* hdata, THStack
287    TIter next(hmc.GetHists());
288    TObject* obj;
289    TH1* hratio = NULL;
290 <  while ( obj = next() ) {
290 >  while ( (obj = next()) ) {
291      if ( !hratio ) {
292        hratio = (TH1*)obj->Clone();
293        hratio->SetName("hratio");
# Line 182 | Line 348 | void make_kin_plot(string variable, stri
348    TCut cut;
349    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
350    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
351 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
352    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
353    if(filename=="mll") {
354          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 193 | Line 360 | void make_kin_plot(string variable, stri
360          draw_separation_lines=true;
361    }
362    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
363 <  if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
363 >  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
364 >  if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
365    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
366    if(filename=="mll_inclusive_osof") cut=cutOSOF;
367    if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
# Line 208 | Line 376 | void make_kin_plot(string variable, stri
376    THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
377    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
378    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
379 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
379 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
380    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
381    if(filename=="mll_osof") datahisto->SetMinimum(9);
214
382    datahisto->SetMaximum(5.3*datahisto->GetMaximum());
383    datahisto->Draw("e1");
384    ckin->Update();
# Line 291 | Line 458 | void make_kin_plot(string variable, stri
458    delete ckin;
459   }
460  
294
461   void make_JES_plot() {
462  
463    int nbins=10;
# Line 343 | Line 509 | void do_kinematic_plots(string mcjzb, st
509    bool dolog=true;
510    bool nolog=false;
511    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
512 <  float mll_low=40;
512 >  float mll_low=50;
513    float mll_hi=160;
514    if(!PlottingSetup::RestrictToMassPeak) {
515 <        mll_low=30;
516 <        mll_hi=180;
515 >        mll_low=20;
516 >        mll_hi=210;
517    }
518 +  
519 +  make_kin_plot("met[4]","",40,0,200,dolog,"MET [GeV]","met",doPF,true);
520    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
521    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
522    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
# Line 356 | Line 524 | void do_kinematic_plots(string mcjzb, st
524    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
525    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
526    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
527 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
527 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/2,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
528    make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
529 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
530 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
529 >  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
530 > //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
531 > //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
532    make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
533    make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
534    make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
535    make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
536    make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
537 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
538 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
537 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
538 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
539 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
540    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
541    stringstream jzbcut;
542    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
543    make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
544 +  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);
545 +  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
546 +  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);
547 +  stringstream jzbcut2;
548 +  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
549 +  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
550 +  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);
551 +  stringstream jzbcut3;
552 +  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
553 +  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
554 +  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);
555 +  
556 +  make_special_obs_pred_mll_plot(mcjzb,0);
557 +  make_special_obs_pred_mll_plot(mcjzb,50);
558 +  make_special_obs_pred_mll_plot(mcjzb,100);
559 +  make_special_obs_pred_mll_plot(mcjzb,150);
560 +  make_special_obs_pred_mll_plot(mcjzb,200);
561 +  make_special_obs_pred_mll_plot(mcjzb,250);
562   }
563  
564   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 442 | Line 630 | void region_comparison_plots(string mcjz
630      
631    
632      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
633 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
633 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
634      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
635      float mll_low=50;float mll_high=170;
636      if(!PlottingSetup::RestrictToMassPeak) {
# Line 480 | Line 668 | void signal_bg_comparison()
668    float simulatedlumi=luminosity;//in pb please - adjust to your likings
669    
670    TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
671 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
671 >  TH1F *JZBplotLM4;
672 >  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"));
673 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
674    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
675    
676    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 504 | Line 694 | void signal_bg_comparison()
694    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
695    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
696    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
697 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
697 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
698 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
699    signal_bg_comparison_leg2->Draw();
700    DrawMCPrelim(simulatedlumi);
701    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 746 | Line 937 | if you want to start from scratch (witho
937    return return_functions;
938   }
939  
940 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
940 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
941   {
942 +  switch_overunderflow(true);
943    bool is_data=false;
944    bool use_signal=false;
945    if(use_data==1) is_data=true;
# Line 756 | Line 948 | void do_prediction_plot(string jzb, TCan
948    if(is_data) nbins=50;
949    float low=0;
950    float hi=500;
951 +  
952    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
953    TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
954    TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
955    TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
956    TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
957 +
958    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
959    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
960    blankback->GetXaxis()->CenterTitle();
# Line 775 | Line 969 | void do_prediction_plot(string jzb, TCan
969    TH1F *RcorrJZBeemmNoS;
970  
971      //these are for the ratio
972 +  
973    TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
974    TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
975    TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
# Line 793 | Line 988 | void do_prediction_plot(string jzb, TCan
988      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
989      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
990      LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
991 <
991 >    
992      //these are for the ratio
993      JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
994      JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
995      JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
996      JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
802
997    }
998    
999    TH1F *lm4RcorrJZBeemm;
1000 <  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"));
1000 >  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,is_data, luminosity,allsamples.FindSample("LM"));
1001    
1002    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1003    
# Line 812 | Line 1006 | void do_prediction_plot(string jzb, TCan
1006      
1007    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1008    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
1009 +    
1010 +  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1011 +  ClearHisto(BpredSys);
1012 +    
1013    if(PlottingSetup::RestrictToMassPeak) {
1014      Bpred->Add(RcorrJZBem,1.0/3.);
1015      Bpred->Add(LcorrJZBem,-1.0/3.);
# Line 834 | Line 1032 | void do_prediction_plot(string jzb, TCan
1032      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
1033      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
1034      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1035 +      
1036 +    //Systematics:
1037 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1038 +    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1039 +    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1040 +    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1041 +    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1042 +    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1043 +    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1044    } else {
1045      Bpred->Add(RcorrJZBem,1.0);
1046      Bpred->Add(LcorrJZBem,-1.0);
# Line 843 | Line 1050 | void do_prediction_plot(string jzb, TCan
1050      //these are for the ratio
1051      JBpred->Add(JRcorrJZBem,1.0);
1052      JBpred->Add(JLcorrJZBem,-1.0);
1053 +      
1054 +    //Systematics
1055 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1056 +    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1057 +    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1058 +
1059    }
1060      
1061 <  
1061 >  SQRT(BpredSys);
1062 >  BpredSys->Divide(JBpred);
1063 >
1064    
1065    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1066    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
# Line 890 | Line 1105 | void do_prediction_plot(string jzb, TCan
1105    blankback->Draw();
1106    if(use_data==1)
1107    {
1108 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1109 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1110      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1111      kinpad->cd();//necessary because the extended fit function creates its own canvas
1112      RcorrJZBeemm->Draw("e1x0,same");
1113  
1114      Bpred->Draw("hist,same");
1115 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1115 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1116      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1117 +    lm4RcorrJZBeemm->Draw("hist,same");
1118      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1119      legBpred->AddEntry(Bpred,"predicted","l");
1120 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1121 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1122 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1120 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1121 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1122 >    legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1123      legBpred->Draw();
1124      DrawPrelim();
1125  
1126      //this plot shows what the prediction is composed of
1127 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1128 <    specialcanv->SetLogy(1);
1129 <    Zjetspred->SetFillColor(kYellow);
1130 <    Zjetspred->SetLineColor(kYellow);
1131 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1132 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1127 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1128 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1129 >    Bpred->SetLineWidth(2);
1130 >    predcomppad->cd();
1131 >    predcomppad->SetLogy(1);
1132 >    
1133 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1134 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1135 >    sidebandsemu->Add(jzbnegative,-1);
1136 >    
1137 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1138 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1139 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1140 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1141 >    
1142      THStack predcomposition("predcomposition","prediction composition");
1143 <    predcomposition.Add(TTbarpred);
1144 <    predcomposition.Add(Zjetspred);
1143 >    predcomposition.Add(sidebandsemu);
1144 >    predcomposition.Add(jzbnegative);
1145      blankback->Draw();
1146      RcorrJZBeemm->Draw("e1x0,same");
1147      predcomposition.Draw("histo,same");//
1148      Bpred->Draw("hist,same");
1149 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1149 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1150      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1151 <    legBpred->Draw();
1151 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1152 >    lm4RcorrJZBeemm->SetLineWidth(2);
1153 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1154 >    lm4RcorrJZBeemm->Draw("histo,same");
1155      DrawPrelim();
1156 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1157 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1158 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1159 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1160 <    specialleg->Draw("same");
1161 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1162 <
1163 <    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1156 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1157 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1158 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1159 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1160 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1161 >    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1162 >    else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1163 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1164 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1165 >    speciallegBpred->Draw();
1166 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1167 >    
1168 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1169 >    specialcanv->SetLogy(1);
1170 > //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1171      blankback->Draw();
1172 <    kostack.Draw("same");
1172 > //    kostack.Draw("same");
1173 >    predcomposition.Draw();
1174      Bpred->Draw("hist,same");
1175 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1175 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1176      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1177      legBpred->Draw();
1178      DrawPrelim();
1179 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1179 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1180 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1181      
1182 <    delete specialcanv;
944 <    delete specialleg;
1182 >    delete speciallegBpred;
1183      delete Zjetspred;
1184      delete TTbarpred;
1185      
# Line 949 | Line 1187 | void do_prediction_plot(string jzb, TCan
1187    }
1188    if(use_data==0) {
1189      RcorrJZBeemm->Draw("e1x0,same");
1190 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1191      Bpred->Draw("hist,same");
1192      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1193 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1194 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1193 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1194 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1195      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1196      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1197      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 963 | Line 1202 | void do_prediction_plot(string jzb, TCan
1202    }
1203    if(use_data==2) {
1204      RcorrJZBeemm->Draw("e1x0,same");
1205 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1206      Bpred->Draw("hist,same");
1207      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1208 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1208 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1209      legBpred->AddEntry(Bpred,"MC predicted","l");
1210 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1210 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1211      legBpred2->AddEntry(Bpred,"MC predicted","l");
1212      {
1213        if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
# Line 978 | Line 1218 | void do_prediction_plot(string jzb, TCan
1218   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1219      }
1220      {
1221 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1222 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1223 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1224 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1225 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1226 +      
1227        RcorrJZBeemmNoS->SetLineStyle(2);
1228        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1229        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 996 | Line 1242 | void do_prediction_plot(string jzb, TCan
1242    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1243    string ytitle("ratio");
1244    if ( use_data==1 ) ytitle = "data/pred";
1245 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1245 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1246 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle,BpredSys);//not extending the y range anymore up to 4
1247  
1248    
1249    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1250 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1251 <  if(!PlottingSetup::RestrictToMassPeak) return;
1252 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1253 <  Bpredem->Add(RcorrJZBem);
1254 <  Bpredem->Add(LcorrJZBem,-1);
1255 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1256 <  BpredSBem->Add(RcorrJZBSBem);
1257 <  Bpred->Add(LcorrJZBSBem,-1);
1258 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1259 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1260 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1261 <  globalcanvas->cd();
1262 <  globalcanvas->SetLogy(1);
1263 <
1264 <  RcorrJZBeemm->SetMarkerStyle(20);
1265 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1266 <  blankback->Draw();
1267 <  RcorrJZBeemm->Draw("e1x0,same");
1268 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1269 <  
1270 <  Bpredem->SetLineColor(kRed+1);
1271 <  Bpredem->SetStats(0);
1272 <  Bpredem->Draw("hist,same");
1273 <
1274 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1275 <  BpredSBem->SetLineStyle(2);
1276 <  BpredSBem->Draw("hist,same");
1277 <
1278 <  BpredSBeemm->SetLineColor(kBlue+1);
1279 <  BpredSBeemm->SetLineStyle(3);
1280 <  BpredSBeemm->Draw("hist,same");
1281 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1282 <
1283 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1284 <  if(use_data==1)
1285 <  {
1286 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1287 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1288 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1289 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1290 <    legBpredc->Draw();
1291 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1292 <  }
1293 <  if(use_data==0) {
1294 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1295 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1296 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1297 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1298 <    legBpredc->Draw();
1299 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1300 <  }
1301 <  if(use_data==2) {
1302 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1303 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1304 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1305 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1306 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1307 <    legBpredc->Draw();
1308 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1250 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1251 >  if(PlottingSetup::RestrictToMassPeak) {
1252 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1253 >    Bpredem->Add(RcorrJZBem);
1254 >    Bpredem->Add(LcorrJZBem,-1);
1255 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1256 >    BpredSBem->Add(RcorrJZBSBem);
1257 >    Bpred->Add(LcorrJZBSBem,-1);
1258 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1259 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1260 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1261 >    globalcanvas->cd();
1262 >    globalcanvas->SetLogy(1);
1263 >    
1264 >    RcorrJZBeemm->SetMarkerStyle(20);
1265 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1266 >    blankback->Draw();
1267 >    RcorrJZBeemm->Draw("e1x0,same");
1268 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1269 >    
1270 >    Bpredem->SetLineColor(kRed+1);
1271 >    Bpredem->SetStats(0);
1272 >    Bpredem->Draw("hist,same");
1273 >    
1274 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1275 >    BpredSBem->SetLineStyle(2);
1276 >    BpredSBem->Draw("hist,same");
1277 >    
1278 >    BpredSBeemm->SetLineColor(kBlue+1);
1279 >    BpredSBeemm->SetLineStyle(3);
1280 >    BpredSBeemm->Draw("hist,same");
1281 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1282 >    
1283 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1284 >    if(use_data==1)
1285 >    {
1286 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1287 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1288 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1289 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1290 >      legBpredc->Draw();
1291 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1292 >    }
1293 >    if(use_data==0) {
1294 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1295 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1296 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1297 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1298 >      legBpredc->Draw();
1299 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1300 >    }
1301 >    if(use_data==2) {
1302 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1303 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1304 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1305 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1306 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1307 >      legBpredc->Draw();
1308 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1309 >    }
1310    }
1311 +  
1312 +  TFile *f = new TFile("tester.root","RECREATE");
1313 +  RcorrJZBeemm->Write();
1314 +  Bpred->Write();
1315 +  f->Close();
1316 +  
1317    delete RcorrJZBeemm;
1318    delete LcorrJZBeemm;
1319    delete RcorrJZBem;
# Line 1072 | Line 1326 | void do_prediction_plot(string jzb, TCan
1326  
1327    delete blankback;
1328    
1329 +  delete BpredSys;
1330    if(PlottingSetup::RestrictToMassPeak) {
1331      delete RcorrJZBSBem;
1332      delete LcorrJZBSBem;
# Line 1084 | Line 1339 | void do_prediction_plot(string jzb, TCan
1339      delete JLcorrJZBSBeemm;
1340    }
1341    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1342 +  switch_overunderflow(false);
1343   }
1344  
1345   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1346    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1347 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1348 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1349 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1347 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1348 >  if ( !PlottingSetup::Approved ) {
1349 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1350 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1351 >  } else {
1352 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1353 >  }
1354   }
1355  
1356   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1440 | Line 1700 | void draw_pure_jzb_histo(TCut cut,string
1700    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1701    writeline1->SetTextSize(0.035);
1702    writeline1->Draw();
1703 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1703 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1704 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1705    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1706    jzbpad2->cd();
1707    jzbpad2->SetLogy(1);
# Line 1455 | Line 1716 | void draw_pure_jzb_histo(TCut cut,string
1716    writeline1->SetTextSize(0.035);
1717    writeline1->Draw();
1718    DrawPrelim();
1719 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1719 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1720 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1721    datahisto->Delete();
1722    mcstack.Delete();
1723   }
# Line 1463 | Line 1725 | void draw_pure_jzb_histo(TCut cut,string
1725   Double_t GausR(Double_t *x, Double_t *par) {
1726    return gRandom->Gaus(x[0],par[0]);
1727   }
1728 +
1729 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1730 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1731 +  float max=jzbHigh ;
1732 +  float min=-120;
1733 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1734 +  int coarserbins=int(nbins/2.0);
1735 +  int rebinnedbins=int(nbins/4.0);
1736 +  
1737 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1738 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1739 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1740 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1741 +
1742 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1743 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1744 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1745 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1746 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1747 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1748 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1749 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1750 +  
1751 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1752 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1753 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1754 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1755 +  
1756 +  delete dican;
1757 + }
1758 +  
1759 +
1760 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1761 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1762 +  
1763 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1764 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1765 +    return;
1766 +  }
1767 +  
1768 +  float stretchfactor = 100.0;
1769 +  vector<string> labels;
1770 +  
1771 +  
1772 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1773 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1774 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1775 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1776 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1777 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1778 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1779 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1780 +  }
1781 +  
1782 +  dout << "Going to produce JZB plots" << endl;
1783 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1784 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1785 +  
1786 +  dout << "Going to produce prediction plots" << endl;
1787 +  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1788 +  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1789 +  delete gloca;
1790 +
1791 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1792 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1793 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1794 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1795 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1796 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1797 +    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;
1798 +    
1799 +  }
1800    
1801 + }
1802   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1803    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1804    float max=jzbHigh ;
# Line 1477 | Line 1812 | void jzb_plots(string mcjzb, string data
1812    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1813    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1814  
1815 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1816 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1817 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1818 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1819 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1820 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1821 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1822 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1823 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1815 >  if ( !PlottingSetup::Approved ) {
1816 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1817 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1818 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1819 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1820 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1821 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1822 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1823 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1824 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1825 >  }
1826    
1827    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
1828 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1829 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1830 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1831 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1832 <
1833 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1834 < //  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1498 < //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1499 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1500 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
1828 >  if ( !PlottingSetup::Approved ) {
1829 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1830 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1831 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1832 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1833 >  }
1834 >  delete can;
1835   }
1836  
1837  
# Line 1552 | Line 1886 | void compute_MC_yields(string mcjzb,vect
1886    string posneg[] = {"pos","neg"};
1887    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
1888  
1889 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
1889 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
1890      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
1891      dout << "_________________________________________________________" << endl;
1892      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
1893 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
1893 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
1894        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
1895        else dout << "Sample & ";
1896        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1815 | Line 2149 | void draw_ttbar_and_zjets_shape_for_one_
2149  
2150   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2151    int all_leptons=-1;
1818  int electrons_only=0;
1819  int mu_only=1;
1820  int twojetswith50gev=1;
2152    int threejetswith30gev=0;
2153   /*  
2154 +  int twojetswith50gev=1;
2155 +  int electrons_only=0;
2156 +  int mu_only=1;
2157 +
2158    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2159    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2160    
# Line 1833 | Line 2168 | void draw_ttbar_and_zjets_shape(string m
2168    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2169   }
2170  
2171 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
1837 <  //first: colorful plots
2171 > float find_one_correction_factor(string FindKeyword, bool dodata, TCut SpecialCut, string SaveAs) {
2172    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2173    cancorr->SetLogz();
2174    cancorr->SetRightMargin(0.13);
2175 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2176 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2175 >  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)"&&SpecialCut&&passtrig);
2176 >  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2177    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2178 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2178 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2179 >  for(int iSample=0;iSample<SampleIndices.size();iSample++) {
2180 >    if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2181 >    if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2182 >    
2183 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2184 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",zptforresponsepresentation*cutWeight);
2185 >  }
2186 >    
2187    niceresponseplotd->SetStats(0);
2188    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2189    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 1850 | Line 2192 | void find_correction_factors(string &jzb
2192    niceresponseplotd->Draw("COLZ");
2193    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2194    profd->SetMarkerSize(DataMarkerSize);
2195 <  profd->Fit("pol0","","same,e1",30,400);
2195 >  profd->Fit("pol0","","same,e1",100,400);
2196    DrawPrelim();
2197 <  TText* title = write_text(0.5,0.7,"Data");
2197 >  string stitle="Data";
2198 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2199 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2200    title->SetTextAlign(12);
2201    title->Draw();
2202    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2203 <  float datacorrection=datapol->GetParameter(0);
2204 <  stringstream dataresstring;
2205 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2206 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2203 >  float correction=datapol->GetParameter(0);
2204 >  stringstream resstring;
2205 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2206 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2207    restitle->SetTextAlign(12);
2208    restitle->SetTextSize(0.03);
2209    restitle->Draw();
2210 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2211 <  
2212 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2213 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2214 <  niceresponseplotm->SetStats(0);
2215 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2216 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
1873 <  niceresponseplotm->GetXaxis()->CenterTitle();
1874 <  niceresponseplotm->GetYaxis()->CenterTitle();
1875 <  niceresponseplotm->Draw("COLZ");
1876 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
1877 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
1878 <  profm->SetMarkerSize(DataMarkerSize);
1879 <  profm->Fit("pol0","","same,e1",30,400);
1880 <  DrawMCPrelim();
1881 <  title = write_text(0.5,0.7,"MC simulation");
1882 <  title->SetTextAlign(12);
1883 <  title->Draw();
1884 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
1885 <  float mccorrection=mcpol->GetParameter(0);
1886 <  stringstream mcresstring;
1887 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
1888 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
1889 <  mcrestitle->SetTextAlign(12);
1890 <  mcrestitle->SetTextSize(0.03);
1891 <  mcrestitle->Draw();
1892 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2210 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2211 >  delete cancorr;
2212 >  delete niceresponseplotd;
2213 >  return correction;
2214 > }
2215 >
2216 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2217    
2218 +  dout << "Computing response corrections: " << endl;
2219 +  //Step 1 : Get results
2220 +  float datacorrection=find_one_correction_factor("Data",true,"","Data");
2221 +  float mccorrection=find_one_correction_factor("DY",false,"","MC");
2222 +  
2223 +  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
2224 +  float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
2225 +  
2226 +  float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
2227 +  float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
2228 +  
2229 +  cout << "Corrections : " << endl;
2230 +  cout << "   Data : " << datacorrection << endl;
2231 +  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2232 +  cout << "   MC : " << mccorrection << endl;
2233 +  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2234    
2235 <  //Step 2: Getting the result
1896 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2235 >  //Step 2: Processing the result and making it into something useful :-)
2236    stringstream jzbvardatas;
2237 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2238 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2237 >  jzbvardatas << "(";
2238 >  
2239 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2240 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2241 >  
2242 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2243 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2244 >  
2245 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2246 >  
2247 >  if(datacorrection>=1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << datacorrection-1 << "*pt))";
2248 >  if(datacorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]+" << 1-datacorrection << "*pt))";
2249 >  
2250 >  jzbvardatas << ")";
2251    jzbvardata=jzbvardatas.str();
2252 +  
2253    stringstream jzbvarmcs;
2254 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2255 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2254 >  jzbvarmcs << "(";
2255 >  
2256 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2257 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2258 >  
2259 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2260 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2261 >  
2262 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2263 >  
2264 >  if(mccorrection>=1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << mccorrection-1 << "*pt))";
2265 >  if(mccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]+" << 1-mccorrection << "*pt))";
2266 >  
2267 >  jzbvarmcs << ")";
2268    jzbvarmc=jzbvarmcs.str();
2269 +
2270    dout << "JZB Z pt correction summary : " << endl;
2271    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2272    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2273 +  
2274   }
2275  
2276   void pick_up_events(string cut) {
# Line 1912 | Line 2278 | void pick_up_events(string cut) {
2278    allsamples.PickUpEvents(cut);
2279   }
2280  
2281 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2281 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2282    dout << "Saving configuration template!" << endl;
2283    ofstream configfile;
2284    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1932 | Line 2298 | void save_template(string mcjzb, string
2298    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2299    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2300    configfile<<"vector<float>jzb_cuts;\n";
2301 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2302    configfile<<"float MCPeakError=-999;\n";
2303 +  configfile<<"float DataPeakError=-999;\n";
2304    configfile<<"}\n\n";
2305  
2306    configfile<<"void read_config() {\n";
2307    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2308    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2309 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2310 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2309 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2310 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2311 >  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";
2312 >  configfile<<"\n\n";
2313 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2314 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2315 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2316    configfile<<"\n\n";
2317 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2318 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2319 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2317 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2318 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2319 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2320 >  for(int i=0;i<(int)jzb_shape_limit_bins.size();i++) configfile<<"jzb_shape_limit_bins.push_back("<<jzb_shape_limit_bins[i]<<"); // JZB shape bin boundary at " << jzb_shape_limit_bins[i] << "\n";
2321    configfile<<"\n\n";
1948  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1949  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1950  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2322    configfile<<"\n\n";
2323    configfile<<"luminosity="<<luminosity<<";\n";
2324 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2325    
2326    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2327    
# Line 1972 | Line 2344 | void draw_all_ttbar_histos(TCanvas *can,
2344    float max=histos[0]->GetMaximum();
2345    if(manualmin>=0) min=manualmin;
2346    else {
2347 <    for(int i=1;i<histos.size();i++) {
2347 >    for(int i=1;i<(int)histos.size();i++) {
2348        float curmin=get_nonzero_minimum(histos[i]);
2349        float curmax=histos[i]->GetMaximum();
2350        if(curmin<min) min=curmin;
# Line 1983 | Line 2355 | void draw_all_ttbar_histos(TCanvas *can,
2355    histos[0]->Draw(drawoption.c_str());
2356    stringstream drawopt;
2357    drawopt << drawoption << ",same";
2358 <  for(int i=1;i<histos.size();i++) {
2358 >  for(int i=1;i<(int)histos.size();i++) {
2359      histos[i]->Draw(drawopt.str().c_str());
2360    }
2361   }
# Line 1994 | Line 2366 | void ttbar_sidebands_comparison(string m
2366    TCut weightbackup=cutWeight;
2367    cutWeight="1.0";
2368    float simulatedlumi = luminosity; //in pb please - adjust to your likings
1997  
2369  
2370    TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2371    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
# Line 2032 | Line 2403 | void ttbar_sidebands_comparison(string m
2403    }
2404    
2405    vector<TH1F*> histos;
2406 +  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2407 +  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2408    histos.push_back(TZem);
2409    histos.push_back(TZeemm);
2410    if(PlottingSetup::RestrictToMassPeak) {
2411 +    TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2412 +    TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2413      histos.push_back(TSem);
2414      histos.push_back(TSeemm);
2415    }
# Line 2050 | Line 2425 | void ttbar_sidebands_comparison(string m
2425    leg->Draw("same");
2426    DrawMCPrelim(simulatedlumi);
2427    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2053  
2428    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2429    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2430 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2431 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2430 >  TH1F *TSeemmcopy;
2431 >  TH1F *TSemcopy;
2432 >  if(PlottingSetup::RestrictToMassPeak) {
2433 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2434 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2435 >  }
2436  
2437    TZem->Divide(TZeemm);
2438    TZem->SetMarkerStyle(21);
# Line 2076 | Line 2454 | void ttbar_sidebands_comparison(string m
2454    
2455    float linepos=0.25;
2456    if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2457 +  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2458    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2459    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2460    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2461    
2462 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2463 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2464 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2465 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2466 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2467 +  topalt->Draw("same");bottomalt->Draw("same");*/
2468 +  
2469 +  
2470    top->SetLineColor(kBlue);top->SetLineStyle(2);
2471    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2472    center->SetLineColor(kBlue);
# Line 2104 | Line 2491 | void ttbar_sidebands_comparison(string m
2491    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2492    
2493  
2107
2494   ///-------------- second part: only look at the quantity we actually care about!
2495    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2496    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
# Line 2150 | Line 2536 | void ttbar_sidebands_comparison(string m
2536    tcan->SetLogy(0);
2537    rightofzp->Divide(rightsfzp);
2538    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2539 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
2539 >  rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2540    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2541    rightofzp->Draw();
2542    if(PlottingSetup::RestrictToMassPeak) {
# Line 2210 | Line 2596 | void ttbar_sidebands_comparison(string m
2596  
2597   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
2598    vector<float> nicer_binning;
2599 <  nicer_binning.push_back(-125);
2599 >  
2600 >  nicer_binning.push_back(-400);
2601 >  nicer_binning.push_back(-250);
2602 >  nicer_binning.push_back(-200);
2603 >  nicer_binning.push_back(-150);
2604 >  nicer_binning.push_back(-100);
2605 >  nicer_binning.push_back(-50);
2606 >  nicer_binning.push_back(-20);
2607 >  
2608 >  nicer_binning.push_back(0);
2609 >  nicer_binning.push_back(20);
2610 >  nicer_binning.push_back(50);
2611 >  nicer_binning.push_back(100);
2612 >  nicer_binning.push_back(150);
2613 >  nicer_binning.push_back(200);
2614 >  nicer_binning.push_back(250);
2615 >  nicer_binning.push_back(400);
2616 >  /*
2617    nicer_binning.push_back(-100);
2215  nicer_binning.push_back(-75);
2618    nicer_binning.push_back(-50);
2619    nicer_binning.push_back(-25);
2620    nicer_binning.push_back(0);
# Line 2227 | Line 2629 | void ttbar_sidebands_comparison(string m
2629    nicer_binning.push_back(230);
2630    nicer_binning.push_back(280);
2631    nicer_binning.push_back(400);
2632 +  */
2633    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2634   }
2635  
2636  
2637 < void zjets_prediction_comparison() {
2637 > void zjets_prediction_comparison(string mcjzbWithPU) {
2638 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2639 >  zcan->SetLogy(1);
2640 >  TCut weightbackup=cutWeight;
2641 >
2642 > /*
2643    // Do it without PU re-weighting
2644    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2645    stringstream resultsNoPU;
2646  
2647    stringstream mcjzbnoPU;
2648 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2648 >  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2649    if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2650    else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2651  
2652    string mcjzb = mcjzbnoPU.str();
2653    dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2654 <
2247 <  TCut weightbackup=cutWeight;
2654 > */
2655    cutWeight="1.0";
2656 <  float sbg_min=0.;
2657 <  float sbg_max=100.;
2658 <  int sbg_nbins=5;
2656 >
2657 >  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2658 >  
2659 >  vector<float> binning;
2660 >  binning.push_back(0);
2661 >  binning.push_back(20);
2662 >  binning.push_back(40);
2663 >  binning.push_back(60);
2664 >  binning.push_back(80);
2665 >  binning.push_back(100);
2666 > //  float sbg_min=0.;
2667 > //  float sbg_max=100.;
2668 > //  int sbg_nbins=5;
2669    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2670    
2671    TCut kPos((mcjzb+">0").c_str());
2672    TCut kNeg((mcjzb+"<0").c_str());
2673    string var( "abs("+mcjzb+")" );
2674  
2675 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2676 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2677 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2261 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2262 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2675 >  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2676 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2677 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2678    hJZBpos->SetLineColor(kBlack);
2679    hJZBneg->SetLineColor(kRed);
2680    
2681 <  Int_t nbins = 5;
2267 <  Float_t xmax = 100.;
2268 <
2269 <  
2270 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2271 <  zcan->SetLogy(1);
2272 <
2681 >  hJZBpos->SetMinimum(1.0);
2682    hJZBpos->Draw("e1");
2683    hJZBneg->Draw("same,hist");
2684    hJZBpos->Draw("same,e1"); // So it's on top...
# Line 2284 | Line 2693 | void zjets_prediction_comparison() {
2693    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
2694    hratio->Divide(hJZBneg);
2695    
2696 +  for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
2697 +    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << endl;
2698 +  }
2699 +  
2700    zcan->SetLogy(0);
2701    hratio->GetYaxis()->SetRangeUser(0,2.5);
2702    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2703    hratio->Draw("e1");
2704    
2705 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
2706 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
2707 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
2705 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
2706 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2707 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
2708    
2709  
2710    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2333 | Line 2746 | void sideband_assessment(string datajzb,
2746    tout << "\\begin{tabular}{l|cc}" << endl;
2747    tout << "\\hline" << endl;
2748    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
2749 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
2749 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
2750    tout << "\\end{tabular}" << endl;
2751    tout << "\\end{center}" << endl;
2752    tout << "\\end{table}" << endl;
# Line 2351 | Line 2764 | void make_table(samplecollection &coll,
2764    
2765    TCanvas *cannie = new TCanvas("cannie","cannie");
2766    
2767 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
2767 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
2768      float currcut=jzb_cuts[icut];
2769      int nbins=1;float low=currcut;
2770      vector<int> mysample;
# Line 2410 | Line 2823 | void make_table(samplecollection &coll,
2823    //prediction part
2824    if(is_data) cout << "Data prediction & ";
2825    if(subselection!="none") cout << subselection << " prediction &";
2826 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2826 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
2827    
2828    cout << endl;
2829    //observation part
2830    if(is_data) cout << "Data observation & ";
2831    if(subselection!="none") cout << subselection << " observation &";
2832 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2832 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
2833    cout << endl;
2834    cout << "_________________________________________________________________" << endl;
2835    delete cannie;
# Line 2451 | Line 2864 | void JZBSelEff(string mcjzb, TTree* even
2864    int nbins = sizeof(xbins)/sizeof(float)-1;
2865    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
2866  
2867 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2868 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2869 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
2867 >  
2868 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
2869 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
2870 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
2871  
2872    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
2873    TCut kreco(cutmass);
# Line 2469 | Line 2883 | void JZBSelEff(string mcjzb, TTree* even
2883    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
2884    can->SetGridx(1);
2885    can->SetGridy(1);
2886 +  can->SetLeftMargin(0.16);
2887 +  can->SetRightMargin(0.05);
2888    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
2889 +  leg->SetBorderSize(1);
2890 +  leg->SetLineColor(kBlack);
2891 +  leg->SetTextFont(62);
2892  
2893 <  
2475 <
2476 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
2893 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
2894  
2895      ostringstream selection;
2896      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2489 | Line 2906 | void JZBSelEff(string mcjzb, TTree* even
2906      }
2907    
2908      heff->GetXaxis()->SetRangeUser(min, max);
2909 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
2910 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
2911 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
2912 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
2913      heff->SetMarkerStyle(markers[icut]);
2914      heff->Fit("func","Q+","same");
2915  
# Line 2500 | Line 2921 | void JZBSelEff(string mcjzb, TTree* even
2921  
2922      // Store plot
2923      TH1F* h = (TH1F*)heff->Clone(hname);
2924 +    h->SetNdivisions(505,"X");
2925      if ( icut) h->Draw("same");
2926      else h->Draw();
2927      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2520 | Line 2942 | void JZBSelEff(string mcjzb, TTree* even
2942   // Calls the above function for each signal sample
2943   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
2944   {  
2945 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
2945 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
2946      dout << "JZB selection efficiency curve: " << std::endl;
2947      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
2948    }
# Line 2563 | Line 2985 | void qcd_plots(string datajzb, string mc
2985    TH1F *RcorrJZBSBeemm;
2986    TH1F *LcorrJZBSBeemm;
2987    
2988 <  TH1F *RcorrJZBeemmNoS;
2988 > //  TH1F *RcorrJZBeemmNoS;
2989  
2990      //these are for the ratio
2991    TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2647 | Line 3069 | void qcd_plots(string datajzb, string mc
3069    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3070    string ytitle("ratio");
3071    if ( use_data==1 ) ytitle = "data/pred";
3072 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
3072 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
3073    
3074    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
3075    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 2694 | Line 3116 | void qcd_plots(string datajzb, string mc
3116    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
3117    
3118    dout << endl;
3119 <  for(int i=0;i<bins.size();i++) {
3119 >  for(int i=0;i<(int)bins.size();i++) {
3120      dout << " JZB > " << bins[i] << " : " << endl;
3121      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3122      if(PlottingSetup::RestrictToMassPeak) {
# Line 2717 | Line 3139 | void qcd_plots(string datajzb, string mc
3139    if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3140   }
3141  
3142 + void check_ptsanity() {
3143 +  TCanvas *ptsancan = new TCanvas("ptsancan","ptsancan",600,1800);
3144 +  TH1F *individualpt1histos[allsamples.collection.size()];
3145 +  TH1F *individualpt2histos[allsamples.collection.size()];
3146 +  TH1F *fpt1 = new TH1F("fpt1","fpt1",50,0,50);
3147 +  fpt1->GetYaxis()->SetRangeUser(0,1);
3148 +  fpt1->GetXaxis()->SetTitle("p_{T,1}");
3149 +  fpt1->GetXaxis()->CenterTitle();
3150 +
3151 +  TH1F *fpt2 = new TH1F("fpt2","fpt2",50,0,50);
3152 +  fpt2->GetXaxis()->SetTitle("p_{T,2}");
3153 +  fpt2->GetXaxis()->CenterTitle();
3154 +  
3155 +  ptsancan->Divide(1,3);
3156 +  ptsancan->cd(1);
3157 +  float maxpt1entry=0;
3158 +  float maxpt2entry=0;
3159 +  
3160 +  TLegend *leg = make_legend();
3161 +  leg->SetX1(0.0);
3162 +  leg->SetY1(0.0);
3163 +  leg->SetX2(1.0);
3164 +  leg->SetY2(1.0);
3165 +  
3166 +  
3167 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3168 +    string nowname=(allsamples.collection)[isample].filename;
3169 +    cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3170 +    individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3171 +    individualpt2histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt2",50,0,50, "p_{T,2}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3172 +    individualpt1histos[isample]->SetLineColor(isample+1);
3173 +    individualpt2histos[isample]->SetLineColor(isample+1);
3174 +    float currmaxpt1entry=individualpt1histos[isample]->GetMaximum()/individualpt1histos[isample]->Integral();
3175 +    float currmaxpt2entry=individualpt2histos[isample]->GetMaximum()/individualpt2histos[isample]->Integral();
3176 +    cout << "      pt 1 histo contains; " << individualpt1histos[isample]->Integral() << endl;
3177 +    cout << "      pt 2 histo contains; " << individualpt2histos[isample]->Integral() << endl;
3178 +    if(currmaxpt1entry>maxpt1entry)maxpt1entry=currmaxpt1entry;
3179 +    if(currmaxpt2entry>maxpt2entry)maxpt2entry=currmaxpt2entry;
3180 +    leg->AddEntry(individualpt2histos[isample],((allsamples.collection)[isample].filename).c_str(),"f");
3181 +  }
3182 +
3183 +  fpt1->GetYaxis()->SetRangeUser(0,maxpt1entry);
3184 +  fpt2->GetYaxis()->SetRangeUser(0,maxpt2entry);
3185 +
3186 +  ptsancan->cd(1);
3187 +  fpt1->Draw();
3188 +  ptsancan->cd(2);
3189 +  fpt2->Draw();
3190 +
3191 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3192 +    ptsancan->cd(1);
3193 +    individualpt1histos[isample]->DrawNormalized("same,histo");
3194 +    ptsancan->cd(2);
3195 +    individualpt2histos[isample]->DrawNormalized("same,histo");
3196 +  }
3197 +  ptsancan->cd(3);
3198 +  leg->Draw();
3199 +  CompleteSave(ptsancan,"PtSanityCheck");
3200 +  
3201 +  delete ptsancan;
3202 + }
3203 +
3204 + void do_mlls_plot(string mcjzb) {
3205 +  cout << "At this point we'd plot the mll distribution" << endl;
3206 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3207 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3208 +    if(!(signalsamples.collection)[isig].events) continue;
3209 +    string nowname=(signalsamples.collection)[isig].filename;
3210 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3211 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3212 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3213 +    stringstream poscutS;
3214 +    poscutS << "((" << mcjzb <<")>50)";
3215 +    TCut poscut(poscutS.str().c_str());
3216 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3217 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3218 +    mll->Draw("histo");
3219 +    mllP->Draw("histo,same");
3220 +    TLegend *leg = make_legend();
3221 +    leg->SetY1(0.8);
3222 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3223 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3224 +    leg->Draw();
3225 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3226 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3227 +    lin->Draw("same");
3228 +    lin2->Draw("same");
3229 +    
3230 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3231 +    delete mll;
3232 +    delete mllP;
3233 +  }
3234 + }
3235 +
3236 + void met_vs_jzb_plots() {
3237 +  
3238 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3239 +  canmetjzb->SetRightMargin(0.16);
3240 +  
3241 +  vector<string> findme;
3242 +  findme.push_back("DY");
3243 +  findme.push_back("TTJets");
3244 +  findme.push_back("LM");
3245 +  
3246 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3247 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3248 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3249 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3250 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3251 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3252 +    }
3253 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3254 +    metvsjzb->SetStats(0);
3255 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3256 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3257 +    metvsjzb->GetXaxis()->CenterTitle();
3258 +    metvsjzb->GetYaxis()->CenterTitle();
3259 +    metvsjzb->Draw("COLZ");
3260 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3261 +    title->SetTextAlign(12);
3262 +    title->Draw();
3263 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3264 +  }
3265 + }
3266 +    
3267 +
3268   void test() {
3269    
3270    TCanvas *testcanv = new TCanvas("testcanv","testcanv");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines