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.9 by buchmann, Tue Mar 27 09:53:08 2012 UTC vs.
Revision 1.47 by buchmann, Tue Aug 14 09:32:53 2012 UTC

# Line 28 | Line 28 | void todo() {
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 &MCSigmaError, float &DataSigma, float& DataSigmaError, 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,MCSigmaError,method,saveas);
56 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
57 >    delete rawttbarjzbeemmMC;
58    }
59    else {
60      TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
# Line 55 | 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,MCSigmaError,method,saveas);
66 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
67 >    delete reducedMC;
68 >    delete reducedData;
69    }
70  
71    // Revert to original PU reweighting
# Line 65 | 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 << " +/- " << DataSigmaError << endl;
77 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
78 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
79 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << 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,mcSigmaError, dataSigma, dataSigmaError;
102 +  
103 +  dout << "Finding global peak : " << endl;
104 +  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma,mcSigmaError, dataSigma,dataSigmaError,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,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_ele");
109 +    dout << "Finding peak for muons : " << endl;
110 +    find_one_peak_combination(TCut("id1==1"),mcmmpeak,mcmmpeakerr,datammpeak,datammpeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,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 datajzb, string mcjzb, float jzbthreshold, float binWidth = 5.0) {
155 +  float min=70.0;
156 +  float max=115.0;
157 +  if(!PlottingSetup::RestrictToMassPeak) {
158 +    min=20;
159 +    max=300;
160 +  }
161 +  int nbins=int((max-min)/binWidth);
162 +  
163 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
164 +  
165 +  stringstream largerzeroS;
166 +  largerzeroS << "(" << datajzb << ">" << jzbthreshold << ")";
167 +  TCut largerzeroD(largerzeroS.str().c_str());
168 +  
169 +  stringstream smallerzeroS;
170 +  smallerzeroS << "(" << datajzb << "<-" << jzbthreshold << ")";
171 +  TCut smallerzeroD(smallerzeroS.str().c_str());
172 +
173 +
174 +  stringstream largerzeroMS;
175 +  largerzeroMS << "(" << mcjzb << ">" << jzbthreshold << ")";
176 +  TCut largerzeroM(largerzeroMS.str().c_str());
177 +  
178 +  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroD,data,luminosity);
179 +  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroM,mc,luminosity);
180 +  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzeroD,data,luminosity);
181 +  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzeroD,data,luminosity);
182 +  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzeroD,data,luminosity);
183 +
184 +  TH1F *RcorrJZBSBem;
185 +  TH1F *LcorrJZBSBem;
186 +  TH1F *RcorrJZBSBeemm;
187 +  TH1F *LcorrJZBSBeemm;
188 +  
189 + //  TH1F *RcorrJZBeemmNoS;
190 +
191 +  if(PlottingSetup::RestrictToMassPeak) {
192 +    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
193 +    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
194 +    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
195 +    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzeroD,data, luminosity);
196 +  }
197 +  
198 +  // Separate predictions
199 +  TH1F* SFN = (TH1F*)LcorrJZBeemm->Clone("SFN");
200 +  TH1F* OFP = (TH1F*)RcorrJZBem->Clone("OFP");
201 +  TH1F* OFN = (TH1F*)LcorrJZBem->Clone("OFN");
202 +  if(PlottingSetup::RestrictToMassPeak) {
203 +    OFP->Scale(1.0/3.0);
204 +    OFP->Add(RcorrJZBSBem,1.0/3.);
205 +    OFP->Add(RcorrJZBSBeemm,1.0/3.);
206 +    OFN->Scale(1.0/3.0);
207 +    OFN->Add(LcorrJZBSBem,1.0/3.);
208 +    OFN->Add(LcorrJZBSBeemm,1.0/3.);
209 +  }
210 +
211 +  TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
212 +  Bpred->Add(OFP);
213 +  Bpred->Add(OFN,-1);
214 +  Bpred->SetLineColor(kRed);
215 +  
216 +  RcorrJZBeemm->SetTitleOffset(1.3,"y");
217 +  RcorrJZBeemm->Draw();
218 +  mcRcorrJZBeemm.Draw("same");
219 +  Bpred->Draw("histo,same");
220 +  RcorrJZBeemm->Draw("same");
221 +  
222 +  TLegend *leg = allsamples.allbglegend();
223 +  leg->SetX1(0.58);
224 +  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
225 +  leg->AddEntry(Bpred,"predicted (data)","l");
226 +  leg->Draw("same");
227 +  
228 +  stringstream saveas;
229 +  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
230 +  CompleteSave(ckin,saveas.str());
231 +  
232 +  // Draw all predictions overlayed
233 +  unsigned int w = gStyle->GetHistLineWidth()+1; // Make line a bit wider, since we dash it
234 +  SFN->SetLineColor(kGreen+2);
235 +  SFN->SetLineStyle(2);
236 +  SFN->SetLineWidth(w);
237 +  OFP->SetLineColor(kBlue+2);
238 +  OFP->SetLineStyle(2);
239 +  OFP->SetLineWidth(w);
240 +  OFN->SetLineColor(kMagenta+2);
241 +  OFN->SetLineStyle(3);
242 +  OFN->SetLineWidth(w);
243 +  
244 +  RcorrJZBeemm->Draw();
245 +  SFN->Draw("histo,same");
246 +  OFP->Draw("histo,same");
247 +  OFN->Draw("histo,same");
248 +  Bpred->Draw("histo,same");
249 +  RcorrJZBeemm->Draw("same");
250 +  
251 +  TLegend *leg2 = make_legend("",0.52,0.7);
252 +  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
253 +  leg2->AddEntry(Bpred,"predicted (data)","l");
254 +  leg2->AddEntry(SFN,  "  SF JZB<0","l");
255 +  leg2->AddEntry(OFN,  "  OF JZB<0","l");
256 +  leg2->AddEntry(OFP,  "  OF JZB>0","l");
257 +  leg2->Draw("same");
258 +  
259 +  saveas.str("");
260 +  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
261 +  CompleteSave(ckin,saveas.str());
262 +  
263 +  delete RcorrJZBeemm;
264 +  delete LcorrJZBeemm;
265 +  delete RcorrJZBem;
266 +  delete LcorrJZBem;
267 +  if(PlottingSetup::RestrictToMassPeak) {
268 +    delete RcorrJZBSBeemm;
269 +    delete LcorrJZBSBeemm;
270 +    delete RcorrJZBSBem;
271 +    delete LcorrJZBSBem;
272 +  }
273 +  delete Bpred;
274 +  delete ckin;
275 + }
276 +
277   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
278    
279    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
# Line 106 | Line 308 | void make_special_mll_plot(int nbins, fl
308    TIter next(bgleg->GetListOfPrimitives());
309    TObject* obj;
310    // Copy the nice bkgd legend skipping the "data"
311 <  while ( obj = next() )
311 >  while ( (obj = next()) )
312      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
313        kinleg->GetListOfPrimitives()->Add(obj);
314  
# Line 125 | Line 327 | void draw_ratio_plot(TH1* hdata, THStack
327    TIter next(hmc.GetHists());
328    TObject* obj;
329    TH1* hratio = NULL;
330 <  while ( obj = next() ) {
330 >  while ( (obj = next()) ) {
331      if ( !hratio ) {
332        hratio = (TH1*)obj->Clone();
333        hratio->SetName("hratio");
# Line 156 | Line 358 | void draw_ratio_plot(TH1* hdata, THStack
358    oneline->Draw("same");
359   }
360  
361 + void make_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, bool logscale,
362 +                   string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.3) {
363 +
364 +  TCut ibasiccut=basiccut;
365 +  bool draw_separation_lines=false;
366 +
367 +  if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
368 +
369 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
370 +
371 +  TCut cutSF;
372 +  TCut cutOF;
373 +
374 +  cutOF=cutOSOF&&cutnJets&&ibasiccut;
375 +  cutSF=cutOSSF&&cutnJets&&ibasiccut;
376 +
377 +
378 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
379 +  ckin->SetLogy(logscale);
380 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
381 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
382 +  string signal("LM3");
383 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
384 +  int idx = signalsamples.FindSample(signal)[0];
385 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
386 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
387 +  signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
388 +  datahistoSF->SetMarkerSize(DataMarkerSize);
389 +  datahistoOF->SetLineColor(kRed);
390 +
391 +  if ( !logscale ) {
392 +    datahistoSF->SetMinimum(0); // Defaults
393 +    datahistoOF->SetMinimum(0); // Defaults
394 +  } else {
395 +    datahistoSF->SetMinimum(0.5);
396 +    datahistoOF->SetMinimum(0.5);
397 +  }
398 +  if (logscale) {
399 +    datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
400 +    datahistoOF->SetMaximum(5.3*datahistoSF->GetMaximum());
401 +  } else {
402 +    datahistoSF->SetMaximum(2.0*datahistoSF->GetMaximum());
403 +    datahistoOF->SetMaximum(2.0*datahistoOF->GetMaximum());
404 +  }
405 +
406 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
407 +  datahistoOF->GetXaxis()->SetTitle(xlabel.c_str());
408 +  signalhisto->GetXaxis()->SetTitle(xlabel.c_str());
409 +  datahistoSF->GetYaxis()->SetTitle("N. Events");
410 +  datahistoOF->GetYaxis()->SetTitle("N. Events");
411 +  signalhisto->GetYaxis()->SetTitle("N. Events");
412 +  datahistoSF->GetXaxis()->CenterTitle();
413 +  datahistoOF->GetXaxis()->CenterTitle();
414 +  signalhisto->GetXaxis()->CenterTitle();
415 +  datahistoSF->GetYaxis()->CenterTitle();
416 +  datahistoOF->GetYaxis()->CenterTitle();
417 +  signalhisto->GetYaxis()->CenterTitle();
418 +
419 +  TLegend *mleg = new TLegend(0.2+legendPosition, 0.72, 0.55+legendPosition, 0.87, legendTitle.c_str());
420 +  mleg->SetFillColor(kWhite);
421 +  mleg->SetTextFont(42);
422 +  mleg->SetTextSize(0.048);
423 +  mleg->SetLineWidth(0);
424 +  mleg->SetBorderSize(0);
425 +  mleg->AddEntry(datahistoSF, "S. Flavor", "PL");
426 +  mleg->AddEntry(datahistoOF, "O. Flavor", "L");
427 +  mleg->AddEntry(signalhisto, "LM3", "L");
428 +
429 +  datahistoSF->Draw("E1");
430 +  datahistoOF->Draw("HIST,SAMES");
431 +  signalhisto->Draw("HIST,SAMES");
432 +  mleg->Draw();
433 +  DrawPrelim();
434 +  CompleteSave(ckin, "./SFOF/" + filename);
435 +
436 +  datahistoSF->Delete();
437 +  datahistoOF->Delete();
438 +  signalhisto->Delete();
439 +  delete mleg;
440 +  delete ckin;
441 +
442 + }
443 +
444 +
445 +
446   float lastrange_min=0;
447   float lastrange_max=0;
448  
# Line 186 | Line 473 | void make_kin_plot(string variable, stri
473    TCut cut;
474    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
475    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
476 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
477    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
478    if(filename=="mll") {
479          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 197 | Line 485 | void make_kin_plot(string variable, stri
485          draw_separation_lines=true;
486    }
487    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
488 <  if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
488 >  if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
489 >  if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
490 >  if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
491 >  if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
492    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
493    if(filename=="mll_inclusive_osof") cut=cutOSOF;
494    if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
# Line 209 | Line 500 | void make_kin_plot(string variable, stri
500    ckin->SetLogy(logscale);
501    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
502    datahisto->SetMarkerSize(DataMarkerSize);
503 <  THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
503 >  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
504 >  else datahisto->SetMinimum(0.5);
505 >  // Custom max.
506 >  if(variable=="TMath::Abs(pfJetDphiMet[0])") datahisto->SetMaximum(1.5*datahisto->GetMaximum());
507    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
508    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
509 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
509 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
510    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
511    if(filename=="mll_osof") datahisto->SetMinimum(9);
512 +  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
513 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
514  
219  datahisto->SetMaximum(5.3*datahisto->GetMaximum());
220  datahisto->Draw("e1");
221  ckin->Update();
515    if(loadlastminmax) {
516          datahisto->SetMinimum(lastrange_min);
517          datahisto->SetMaximum(lastrange_max);
# Line 228 | Line 521 | void make_kin_plot(string variable, stri
521          }              
522    }
523  
524 +  // Draw signal by hand (for some reason I don't manage to use the sample class: it adds it to the stack!)
525 +  string signal("LM3");
526 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
527 +  int idx = signalsamples.FindSample(signal)[0];
528 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
529 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
530 +  signalhisto->SetLineColor(kOrange);
531 +
532 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
533 +  datahisto->Draw("e1");
534 +  ckin->Update();
535    mcstack.Draw("same");
536 +  
537    datahisto->Draw("same,e1");
538    TLegend *kinleg = allsamples.allbglegend();
539    kinleg->Draw();
# Line 271 | Line 576 | void make_kin_plot(string variable, stri
576          kinpad->SetLogy(logscale);
577          datahisto->Draw("e1");
578          mcstack.Draw("same");
579 +        signalhisto->Draw("same");
580          datahisto->Draw("same,e1");
581          datahisto->Draw("same,axis");
582          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 278 | Line 584 | void make_kin_plot(string variable, stri
584            upperboundary->Draw("same");
585          }
586            
587 +        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
588          kinleg->Draw();
589          write_cut->Draw();
590          DrawPrelim();
# Line 295 | Line 602 | void make_kin_plot(string variable, stri
602    delete ckin;
603   }
604  
605 <
299 < void make_JES_plot() {
605 > void make_JES_plot(TCut cut, string name) {
606  
607    int nbins=10;
608    float min=-0.5;
609    float max = 9.5;
610    bool logscale=true;
611    string xlabel="nJets";
306  TCut cut=cutmass&&cutOSSF&&basiccut;
612  
613    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
614    ckin->SetLogy(logscale);
615 <  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
615 >  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,data,luminosity);
616    datahisto->SetMarkerSize(DataMarkerSize);
617 <  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
618 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
619 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
617 >  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,mc,luminosity);
618 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum40p1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
619 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum40n1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
620  
621    datahisto->SetMinimum(1);
622    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 336 | Line 641 | void make_JES_plot() {
641    TLegend *kinleg = allsamples.allbglegend();
642    kinleg->AddEntry(JESunc,"JES uncertainty","f");
643    kinleg->Draw();
644 <  CompleteSave(ckin,"Systematics/JES");
644 >  CompleteSave(ckin,"Systematics/JES"+name);
645    datahisto->Delete();
646    delete ckin;
647  
# Line 347 | Line 652 | void do_kinematic_plots(string mcjzb, st
652    bool dolog=true;
653    bool nolog=false;
654    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
655 <  float mll_low=40;
655 >  float mll_low=50;
656    float mll_hi=160;
657    if(!PlottingSetup::RestrictToMassPeak) {
658 <        mll_low=30;
659 <        mll_hi=180;
658 >        mll_low=20;
659 >        mll_hi=300;
660    }
661 +
662 +  make_OFSF_plot("pfJetGoodNum40", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 5, 3, 8, true, "N. jets", "njetsLow", false, false, false, 0.2);
663 +  make_OFSF_plot("pfJetGoodNum40", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 5, 3, 8, true, "N. jets", "njetsMed", false, false, false, 0.2);
664 +  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Low", false, false, false, 0.2);
665 +  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Med", false, false, false, 0.2);
666 +  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetLow", false, false, false, 0.0);
667 +  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetMed", false, false, false, 0.0);
668 +  make_OFSF_plot("TMath::Abs(dphi)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiLow", false, false, false, 0.2);
669 +  make_OFSF_plot("TMath::Abs(dphi)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiMed", false, false, false, 0.2);
670 +  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Low", false, false, false, 0.2);
671 +  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Med", false, false, false, 0.2);
672 +  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Low", false, false, false, 0.2);
673 +  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Med", false, false, false, 0.2);
674 +  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcLow", false, false, false, 0.2);
675 +  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcMed", false, false, false, 0.2);
676 +  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcLow", false, false, false, 0.2);
677 +  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcMed", false, false, false, 0.2);
678 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoLow", false, false, false, 0.2);
679 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoMed", false, false, false, 0.2);
680 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoLow", false, false, false, 0.2);
681 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoMed", false, false, false, 0.2);
682 +
683 +
684 +
685 +  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
686 +
687    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
688    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
689    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
690    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
691 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
692 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
693 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
694 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
695 <  make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
365 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
366 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
367 <  make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
368 <  make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
369 <  make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
370 <  make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
371 <  make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
372 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
373 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
691 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
692 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
693 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
694 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
695 >  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
696    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
697 +
698 +  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
699 +  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
700 +
701 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
702 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
703 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
704 +
705 +  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
706 + //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
707 + //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
708 +  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
709 +  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
710 +  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
711 +  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
712 +  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
713    stringstream jzbcut;
714    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
715 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
715 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
716 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
717 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB100",doPF,true);
718 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB100",doPF,true);
719 >  stringstream jzbcut2;
720 >  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
721 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
722 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
723 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB150",doPF,true);
724 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB150",doPF,true);
725 >  stringstream jzbcut3;
726 >  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
727 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
728 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
729 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB50",doPF,true);  
730 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB50",doPF,true);  
731 >
732 >  make_kin_plot("mll","met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV] (MET>100GeV)","mll_met100",doPF,true);
733 >
734 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
735 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
736 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
737 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
738 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
739 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
740 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
741 >
742 >  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
743 >  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
744 >
745 >
746   }
747  
748   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
749                       int nbins, float xmin, float xmax, bool log,
750                       float ymin=0, float ymax=0, bool leftJustified=false ) {
751 <      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
751 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
752  
753    TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
754    if(weightbackup==TCut("1.0")||weightbackup==TCut("1")) write_warning(__FUNCTION__,"WATCH OUT THE WEIGHT HAS POSSIBLY NOT BEEN RESET!!!! PLEASE CHANGE LINE "+any2string(__LINE__));
755 <  if(var=="numVtx") cutWeight=TCut("1.0");
755 >  //if(var=="numVtx") cutWeight=TCut("1.0");
756    TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
757    TCut jzbMC[]  = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
758  
# Line 408 | Line 776 | void make_comp_plot( string var, string
776        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
777        ccomp->SetLogy(log);
778        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
779 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
779 >      TH1F *lm3histo  = signalsamples.Draw("lm3histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],data,luminosity,signalsamples.FindSample("LM3"));
780        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
781        datahisto->SetMarkerSize(DataMarkerSize);
782        if (ymax>ymin) datahisto->SetMaximum(ymax);
783 <      lm4histo->SetLineStyle(2);
783 >      lm3histo->SetLineStyle(2);
784        datahisto->Draw("e1");
785        mcstack.Draw("same");
786        datahisto->Draw("same,e1");
787 < //      lm4histo->Draw("hist,same");
787 >      lm3histo->Draw("hist,same");
788        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
789        if ( leftJustified ) {
790          Float_t w = kinleg->GetX2()-kinleg->GetX1();
791          kinleg->SetX1(0.2);
792          kinleg->SetX2(0.2+w);
793        }
794 < //      kinleg->AddEntry(lm4histo,"LM4","l");
794 >      kinleg->AddEntry(lm3histo,"LM3","l");
795        kinleg->Draw();
796        TText* write_variable = write_text(0.99,0.01,var);
797        write_variable->SetTextAlign(31);
# Line 432 | Line 800 | void make_comp_plot( string var, string
800        CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
801        delete datahisto;
802        delete ccomp;
803 <      delete lm4histo;
803 >      delete lm3histo;
804      }
805    cutWeight=weightbackup;
806   }
# Line 442 | Line 810 | void region_comparison_plots(string mcjz
810    dout << "Creating comparison plots for signal and control regions" << endl;
811    // Compare a few quantities in the signal region and all 7 control regions
812  
813 <  switch_overunderflow(true);  // switching overflow/underflow bins on
813 > //  switch_overunderflow(true);  // switching overflow/underflow bins on
814      
815    
816      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
817 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
817 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
818      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
819      float mll_low=50;float mll_high=170;
820      if(!PlottingSetup::RestrictToMassPeak) {
821 <        mll_high=200;
822 <        mll_low=50;
821 >        mll_high=300;
822 >        mll_low=20;
823      }
824 <    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
824 >    make_comp_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",jzbcut,mcjzb,datajzb,100,0,10,true);
825 >    make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
826 >
827 >    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
828      make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
829 <    make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
829 >    make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
830 >    make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
831      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
832 <    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
832 >    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,40,0.,40.,false,0,16.);
833      make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
834      make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
835 +    make_comp_plot("eta1","#eta_1","eta1",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
836 +    make_comp_plot("eta2","#eta_2","eta2",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
837    }
838  
839    switch_overunderflow(false); // switching overflow/underflow bins off
# Line 753 | Line 1127 | if you want to start from scratch (witho
1127    return return_functions;
1128   }
1129  
1130 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
1130 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1131   {
1132 + //  switch_overunderflow(true);
1133    bool is_data=false;
1134    bool use_signal=false;
1135    if(use_data==1) is_data=true;
# Line 763 | Line 1138 | void do_prediction_plot(string jzb, TCan
1138    if(is_data) nbins=50;
1139    float low=0;
1140    float hi=500;
1141 +  
1142    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1143    TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1144    TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1145    TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1146    TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1147 +
1148    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1149    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
1150    blankback->GetXaxis()->CenterTitle();
# Line 782 | Line 1159 | void do_prediction_plot(string jzb, TCan
1159    TH1F *RcorrJZBeemmNoS;
1160  
1161      //these are for the ratio
1162 +  
1163    TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1164    TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1165    TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
# Line 800 | Line 1178 | void do_prediction_plot(string jzb, TCan
1178      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1179      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1180      LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1181 <
1181 >    
1182      //these are for the ratio
1183      JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1184      JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1185      JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1186      JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
809
1187    }
1188    
1189    TH1F *lm4RcorrJZBeemm;
1190 <  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"));
1190 >  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"));
1191    
1192    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1193    
# Line 819 | Line 1196 | void do_prediction_plot(string jzb, TCan
1196      
1197    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1198    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
1199 +    
1200 +  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1201 +  ClearHisto(BpredSys);
1202 +    
1203    if(PlottingSetup::RestrictToMassPeak) {
1204      Bpred->Add(RcorrJZBem,1.0/3.);
1205      Bpred->Add(LcorrJZBem,-1.0/3.);
# Line 841 | Line 1222 | void do_prediction_plot(string jzb, TCan
1222      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
1223      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
1224      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1225 +      
1226 +    //Systematics:
1227 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1228 +    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1229 +    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1230 +    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1231 +    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1232 +    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1233 +    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1234    } else {
1235      Bpred->Add(RcorrJZBem,1.0);
1236      Bpred->Add(LcorrJZBem,-1.0);
# Line 850 | Line 1240 | void do_prediction_plot(string jzb, TCan
1240      //these are for the ratio
1241      JBpred->Add(JRcorrJZBem,1.0);
1242      JBpred->Add(JLcorrJZBem,-1.0);
1243 +      
1244 +    //Systematics
1245 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1246 +    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1247 +    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1248 +
1249    }
1250      
1251 <  
1251 >  SQRT(BpredSys);
1252 >  BpredSys->Divide(JBpred);
1253 >
1254    
1255    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1256    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
# Line 897 | Line 1295 | void do_prediction_plot(string jzb, TCan
1295    blankback->Draw();
1296    if(use_data==1)
1297    {
1298 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1299 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1300      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1301      kinpad->cd();//necessary because the extended fit function creates its own canvas
1302      RcorrJZBeemm->Draw("e1x0,same");
1303  
1304      Bpred->Draw("hist,same");
1305 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1305 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1306      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1307 +    lm4RcorrJZBeemm->Draw("hist,same");
1308      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1309      legBpred->AddEntry(Bpred,"predicted","l");
1310 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1311 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1312 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1310 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1311 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1312 >    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1313      legBpred->Draw();
1314      DrawPrelim();
1315  
1316      //this plot shows what the prediction is composed of
1317 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1318 <    specialcanv->SetLogy(1);
1319 <    Zjetspred->SetFillColor(kYellow);
1320 <    Zjetspred->SetLineColor(kYellow);
1321 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1322 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1317 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1318 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1319 >    Bpred->SetLineWidth(2);
1320 >    predcomppad->cd();
1321 >    predcomppad->SetLogy(1);
1322 >    
1323 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1324 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1325 >    sidebandsemu->Add(jzbnegative,-1);
1326 >    
1327 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1328 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1329 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1330 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1331 >    
1332      THStack predcomposition("predcomposition","prediction composition");
1333 <    predcomposition.Add(TTbarpred);
1334 <    predcomposition.Add(Zjetspred);
1333 >    predcomposition.Add(sidebandsemu);
1334 >    predcomposition.Add(jzbnegative);
1335      blankback->Draw();
1336      RcorrJZBeemm->Draw("e1x0,same");
1337      predcomposition.Draw("histo,same");//
1338      Bpred->Draw("hist,same");
1339 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1339 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1340      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1341 <    legBpred->Draw();
1341 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1342 >    lm4RcorrJZBeemm->SetLineWidth(2);
1343 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1344 >    lm4RcorrJZBeemm->Draw("histo,same");
1345      DrawPrelim();
1346 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1347 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1348 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1349 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1350 <    specialleg->Draw("same");
1351 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1352 <
1353 <    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1346 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1347 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1348 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1349 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1350 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1351 >    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1352 >    else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1353 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1354 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1355 >    speciallegBpred->Draw();
1356 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1357 >    
1358 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1359 >    specialcanv->SetLogy(1);
1360 > //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1361      blankback->Draw();
1362 <    kostack.Draw("same");
1362 > //    kostack.Draw("same");
1363 >    predcomposition.Draw();
1364      Bpred->Draw("hist,same");
1365 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1365 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1366      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1367      legBpred->Draw();
1368      DrawPrelim();
1369 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1369 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1370 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1371      
1372 <    delete specialcanv;
1373 <    delete specialleg;
1372 >    
1373 >    //for(int i=1;i<=Bpred->GetNbinsX();i++) cout << Bpred->GetBinLowEdge(i) << ";" << Bpred->GetBinLowEdge(i)+Bpred->GetBinWidth(i) << ";;" << RcorrJZBeemm->GetBinContent(i) << ";" << LcorrJZBeemm->GetBinContent(i) << ";" << RcorrJZBem->GetBinContent(i) << ";" << LcorrJZBem->GetBinContent(i) << endl;
1374 >    
1375 >    delete speciallegBpred;
1376      delete Zjetspred;
1377      delete TTbarpred;
1378      
# Line 956 | Line 1380 | void do_prediction_plot(string jzb, TCan
1380    }
1381    if(use_data==0) {
1382      RcorrJZBeemm->Draw("e1x0,same");
1383 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1384      Bpred->Draw("hist,same");
1385      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1386 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1387 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1386 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1387 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1388      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1389      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1390      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 970 | Line 1395 | void do_prediction_plot(string jzb, TCan
1395    }
1396    if(use_data==2) {
1397      RcorrJZBeemm->Draw("e1x0,same");
1398 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1399      Bpred->Draw("hist,same");
1400      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1401 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1401 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1402      legBpred->AddEntry(Bpred,"MC predicted","l");
1403 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1403 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1404      legBpred2->AddEntry(Bpred,"MC predicted","l");
1405      {
1406        if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
# Line 985 | Line 1411 | void do_prediction_plot(string jzb, TCan
1411   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1412      }
1413      {
1414 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1415 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1416 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1417 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1418 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1419 +      
1420        RcorrJZBeemmNoS->SetLineStyle(2);
1421        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1422        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 1004 | Line 1436 | void do_prediction_plot(string jzb, TCan
1436    string ytitle("ratio");
1437    if ( use_data==1 ) ytitle = "data/pred";
1438    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1439 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1439 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1440  
1441    
1442    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1443 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1444 <  if(!PlottingSetup::RestrictToMassPeak) return;
1445 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1446 <  Bpredem->Add(RcorrJZBem);
1447 <  Bpredem->Add(LcorrJZBem,-1);
1448 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1449 <  BpredSBem->Add(RcorrJZBSBem);
1450 <  Bpred->Add(LcorrJZBSBem,-1);
1451 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1452 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1453 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1454 <  globalcanvas->cd();
1455 <  globalcanvas->SetLogy(1);
1456 <
1457 <  RcorrJZBeemm->SetMarkerStyle(20);
1458 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1459 <  blankback->Draw();
1460 <  RcorrJZBeemm->Draw("e1x0,same");
1461 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1462 <  
1463 <  Bpredem->SetLineColor(kRed+1);
1464 <  Bpredem->SetStats(0);
1465 <  Bpredem->Draw("hist,same");
1466 <
1467 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1468 <  BpredSBem->SetLineStyle(2);
1469 <  BpredSBem->Draw("hist,same");
1470 <
1471 <  BpredSBeemm->SetLineColor(kBlue+1);
1472 <  BpredSBeemm->SetLineStyle(3);
1473 <  BpredSBeemm->Draw("hist,same");
1474 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1475 <
1476 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1477 <  if(use_data==1)
1478 <  {
1479 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1480 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1481 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1482 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1483 <    legBpredc->Draw();
1484 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1485 <  }
1486 <  if(use_data==0) {
1487 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1488 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1489 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1490 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1491 <    legBpredc->Draw();
1492 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1493 <  }
1494 <  if(use_data==2) {
1495 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1496 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1497 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1498 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1499 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1500 <    legBpredc->Draw();
1501 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1443 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1444 >  if(PlottingSetup::RestrictToMassPeak) {
1445 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1446 >    Bpredem->Add(RcorrJZBem);
1447 >    Bpredem->Add(LcorrJZBem,-1);
1448 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1449 >    BpredSBem->Add(RcorrJZBSBem);
1450 >    Bpred->Add(LcorrJZBSBem,-1);
1451 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1452 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1453 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1454 >    globalcanvas->cd();
1455 >    globalcanvas->SetLogy(1);
1456 >    
1457 >    RcorrJZBeemm->SetMarkerStyle(20);
1458 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1459 >    blankback->Draw();
1460 >    RcorrJZBeemm->Draw("e1x0,same");
1461 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1462 >    
1463 >    Bpredem->SetLineColor(kRed+1);
1464 >    Bpredem->SetStats(0);
1465 >    Bpredem->Draw("hist,same");
1466 >    
1467 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1468 >    BpredSBem->SetLineStyle(2);
1469 >    BpredSBem->Draw("hist,same");
1470 >    
1471 >    BpredSBeemm->SetLineColor(kBlue+1);
1472 >    BpredSBeemm->SetLineStyle(3);
1473 >    BpredSBeemm->Draw("hist,same");
1474 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1475 >    
1476 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1477 >    if(use_data==1)
1478 >    {
1479 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1480 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1481 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1482 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1483 >      legBpredc->Draw();
1484 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1485 >    }
1486 >    if(use_data==0) {
1487 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1488 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1489 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1490 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1491 >      legBpredc->Draw();
1492 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1493 >    }
1494 >    if(use_data==2) {
1495 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1496 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1497 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1498 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1499 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1500 >      legBpredc->Draw();
1501 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1502 >    }
1503    }
1504 +  
1505 +  TFile *f = new TFile("tester.root","RECREATE");
1506 +  RcorrJZBeemm->Write();
1507 +  Bpred->Write();
1508 +  f->Close();
1509 +  
1510    delete RcorrJZBeemm;
1511    delete LcorrJZBeemm;
1512    delete RcorrJZBem;
# Line 1080 | Line 1519 | void do_prediction_plot(string jzb, TCan
1519  
1520    delete blankback;
1521    
1522 +  delete BpredSys;
1523    if(PlottingSetup::RestrictToMassPeak) {
1524      delete RcorrJZBSBem;
1525      delete LcorrJZBSBem;
# Line 1092 | Line 1532 | void do_prediction_plot(string jzb, TCan
1532      delete JLcorrJZBSBeemm;
1533    }
1534    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1535 +  switch_overunderflow(false);
1536   }
1537  
1538   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1539    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1540 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1541 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1542 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1540 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1541 >  if ( !PlottingSetup::Approved ) {
1542 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1543 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1544 >  } else {
1545 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1546 >  }
1547   }
1548  
1549   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1435 | Line 1880 | void draw_pure_jzb_histo(TCut cut,string
1880    datahisto->Draw("same,e1");
1881    
1882    TLegend *leg;
1883 <  if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1884 <  else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1885 <  else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1886 <  else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1887 <  else {
1888 <    std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1889 <    exit(-1);
1890 <      }
1883 >  if (!PlottingSetup::RestrictToMassPeak) {
1884 >    if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1885 >    else leg = allsamples.allbglegend("Same flavor",datahisto);
1886 >  } else {
1887 >    if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1888 >    else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1889 >    else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1890 >    else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1891 >    else {
1892 >      std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1893 >      exit(-1);
1894 >    }
1895 >  }
1896    leg->Draw();
1897    string write_cut = decipher_cut(cut,"");
1898    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1899    writeline1->SetTextSize(0.035);
1900    writeline1->Draw();
1901 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1901 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1902 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1903    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1904    jzbpad2->cd();
1905    jzbpad2->SetLogy(1);
# Line 1463 | Line 1914 | void draw_pure_jzb_histo(TCut cut,string
1914    writeline1->SetTextSize(0.035);
1915    writeline1->Draw();
1916    DrawPrelim();
1917 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1917 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1918 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1919    datahisto->Delete();
1920    mcstack.Delete();
1921   }
# Line 1471 | Line 1923 | void draw_pure_jzb_histo(TCut cut,string
1923   Double_t GausR(Double_t *x, Double_t *par) {
1924    return gRandom->Gaus(x[0],par[0]);
1925   }
1926 +
1927 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1928 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1929 +  float max=jzbHigh ;
1930 +  float min=-120;
1931 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1932 +  int coarserbins=int(nbins/2.0);
1933 +  int rebinnedbins=int(nbins/4.0);
1934 +  
1935 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1936 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1937 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1938 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1939 +
1940 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1941 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1942 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1943 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1944 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1945 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1946 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1947 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1948 +  
1949 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1950 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1951 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1952 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1953 +  
1954 +  delete dican;
1955 + }
1956 +  
1957 +
1958 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1959 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1960 +  
1961 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1962 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1963 +    return;
1964 +  }
1965 +  
1966 +  float stretchfactor = 100.0;
1967 +  vector<string> labels;
1968 +  
1969 +  
1970 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1971 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1972 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1973 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1974 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1975 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1976 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1977 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1978 +  }
1979 +  
1980 +  dout << "Going to produce JZB plots" << endl;
1981 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1982 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1983    
1984 +  dout << "Going to produce prediction plots" << endl;
1985 +  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1986 +  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1987 +  delete gloca;
1988 +
1989 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1990 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1991 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1992 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1993 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1994 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1995 +    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;
1996 +    
1997 +  }
1998 +  
1999 + }
2000 +
2001 +
2002 + void draw_normalized_data_vs_data_histo(TCut cut1, TCut cut2, string variable, string legentry1, string legentry2, string savename, TCanvas *can,vector<float> binning) {
2003 +  TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
2004 +  jzbpad->cd();
2005 +  jzbpad->SetLogy(1);
2006 +  string xlabel="JZB [GeV]";
2007 +
2008 +  TH1F *datahisto1 = allsamples.Draw("datahisto1",variable,binning, xlabel, "events",cut1,data,luminosity);
2009 +  datahisto1->SetLineColor(kRed);
2010 +  datahisto1->SetMarkerColor(kRed);
2011 +  TH1F *datahisto2 = allsamples.Draw("datahisto2",variable,binning, xlabel, "events",cut2,data,luminosity);
2012 +  datahisto2->SetLineColor(kBlue);
2013 +  datahisto2->SetMarkerColor(kBlue);
2014 +  
2015 +  datahisto2->SetMarkerSize(DataMarkerSize);
2016 +  datahisto1->DrawNormalized("e1");
2017 +  datahisto2->DrawNormalized("histo,same");
2018 +  datahisto1->DrawNormalized("same,e1");
2019 +  
2020 +  TLegend *leg = make_legend();
2021 +  leg->AddEntry(datahisto1,legentry1.c_str());
2022 +  leg->AddEntry(datahisto2,legentry2.c_str());
2023 +  leg->Draw();
2024 +  
2025 +  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
2026 +  
2027 +  datahisto1->Delete();
2028 +  datahisto2->Delete();
2029 + }
2030 +
2031 +
2032   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2033    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2034    float max=jzbHigh ;
# Line 1485 | Line 2042 | void jzb_plots(string mcjzb, string data
2042    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
2043    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
2044  
2045 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
2046 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
2047 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
2048 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
2049 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2050 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2051 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2052 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2053 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2045 >  if ( !PlottingSetup::Approved ) {
2046 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
2047 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
2048 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
2049 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
2050 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2051 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2052 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2053 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2054 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2055 >    draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm",can,binning);
2056 >    draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm_coarse",can,coarse_binning);
2057 >    draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm_coarsest",can,coarsest_binning);
2058 >
2059 >  }
2060    
2061    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
2062 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2063 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2064 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2065 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2066 <
2067 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
2068 < //  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1506 < //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1507 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1508 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
2062 >  if ( !PlottingSetup::Approved ) {
2063 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2064 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2065 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2066 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2067 >  }
2068 >  delete can;
2069   }
2070  
2071  
# Line 1560 | Line 2120 | void compute_MC_yields(string mcjzb,vect
2120    string posneg[] = {"pos","neg"};
2121    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
2122  
2123 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
2123 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
2124      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
2125      dout << "_________________________________________________________" << endl;
2126      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
2127 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
2127 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
2128        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
2129        else dout << "Sample & ";
2130        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1823 | Line 2383 | void draw_ttbar_and_zjets_shape_for_one_
2383  
2384   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2385    int all_leptons=-1;
1826  int electrons_only=0;
1827  int mu_only=1;
1828  int twojetswith50gev=1;
2386    int threejetswith30gev=0;
2387   /*  
2388 +  int twojetswith50gev=1;
2389 +  int electrons_only=0;
2390 +  int mu_only=1;
2391 +
2392    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2393    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2394    
# Line 1841 | Line 2402 | void draw_ttbar_and_zjets_shape(string m
2402    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2403   }
2404  
2405 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
1845 <  //first: colorful plots
2405 > float find_one_correction_factor(string FindKeyword, bool dodata, TCut SpecialCut, string SaveAs) {
2406    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2407    cancorr->SetLogz();
2408    cancorr->SetRightMargin(0.13);
2409 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2410 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2409 >  TCut zptforresponsepresentation(Restrmasscut&&SpecialCut&&passtrig);
2410 >
2411 >  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2412    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2413 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2413 >  niceresponseplotd->Sumw2();
2414 >  TH2F* emuResponse = (TH2F*)niceresponseplotd->Clone("emuResponse");
2415 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2416 >  for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2417 >    if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2418 >    if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2419 >    
2420 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2421 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
2422 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
2423 >  }
2424 >  niceresponseplotd->Add(emuResponse,-1);
2425 >  
2426    niceresponseplotd->SetStats(0);
2427    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2428    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 1857 | Line 2430 | void find_correction_factors(string &jzb
2430    niceresponseplotd->GetYaxis()->CenterTitle();
2431    niceresponseplotd->Draw("COLZ");
2432    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2433 +  profd->Rebin(2);
2434    profd->SetMarkerSize(DataMarkerSize);
2435 <  profd->Fit("pol0","","same,e1",30,400);
2435 >  profd->Fit("pol0","","same,e1",100,400);
2436    DrawPrelim();
2437 <  TText* title = write_text(0.5,0.7,"Data");
2437 >  string stitle="Data";
2438 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2439 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2440    title->SetTextAlign(12);
2441    title->Draw();
2442    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2443 <  float datacorrection=datapol->GetParameter(0);
2444 <  stringstream dataresstring;
2445 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2446 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2443 >  float correction=datapol->GetParameter(0);
2444 >  stringstream resstring;
2445 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2446 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2447    restitle->SetTextAlign(12);
2448    restitle->SetTextSize(0.03);
2449    restitle->Draw();
2450 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2451 <  
2452 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2453 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2454 <  niceresponseplotm->SetStats(0);
2455 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2456 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2457 <  niceresponseplotm->GetXaxis()->CenterTitle();
1882 <  niceresponseplotm->GetYaxis()->CenterTitle();
1883 <  niceresponseplotm->Draw("COLZ");
1884 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
1885 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
1886 <  profm->SetMarkerSize(DataMarkerSize);
1887 <  profm->Fit("pol0","","same,e1",30,400);
1888 <  DrawMCPrelim();
1889 <  title = write_text(0.5,0.7,"MC simulation");
1890 <  title->SetTextAlign(12);
1891 <  title->Draw();
1892 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
1893 <  float mccorrection=mcpol->GetParameter(0);
1894 <  stringstream mcresstring;
1895 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
1896 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
1897 <  mcrestitle->SetTextAlign(12);
1898 <  mcrestitle->SetTextSize(0.03);
1899 <  mcrestitle->Draw();
1900 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2450 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2451 >  delete cancorr;
2452 >  delete niceresponseplotd;
2453 >  delete profd;
2454 >  return correction;
2455 > }
2456 >
2457 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2458    
2459 +  dout << "Computing response corrections: " << endl;
2460 +  //Step 1 : Get results
2461 +  float datacorrection=find_one_correction_factor("Data",true,"","Data");
2462 +  float mccorrection=find_one_correction_factor("DY",false,"","MC");
2463 +  
2464 +  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
2465 +  float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
2466 +  
2467 +  float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
2468 +  float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
2469 +  
2470 +  cout << "Corrections : " << endl;
2471 +  cout << "   Data : " << datacorrection << endl;
2472 +  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2473 +  cout << "   MC : " << mccorrection << endl;
2474 +  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2475    
2476 <  //Step 2: Getting the result
1904 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2476 >  //Step 2: Processing the result and making it into something useful :-)
2477    stringstream jzbvardatas;
2478 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2479 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2478 >  jzbvardatas << "(";
2479 >  
2480 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2481 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2482 >  
2483 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2484 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2485 >  
2486 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2487 >  
2488 >  if(datacorrection>=1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << datacorrection-1 << "*pt))";
2489 >  if(datacorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]+" << 1-datacorrection << "*pt))";
2490 >  
2491 >  jzbvardatas << ")";
2492    jzbvardata=jzbvardatas.str();
2493 +  
2494    stringstream jzbvarmcs;
2495 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2496 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2495 >  jzbvarmcs << "(";
2496 >  
2497 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2498 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2499 >  
2500 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2501 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2502 >  
2503 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2504 >  
2505 >  if(mccorrection>=1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << mccorrection-1 << "*pt))";
2506 >  if(mccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]+" << 1-mccorrection << "*pt))";
2507 >  
2508 >  jzbvarmcs << ")";
2509    jzbvarmc=jzbvarmcs.str();
2510 +
2511    dout << "JZB Z pt correction summary : " << endl;
2512    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2513    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2514 +  
2515   }
2516  
2517   void pick_up_events(string cut) {
# Line 1920 | Line 2519 | void pick_up_events(string cut) {
2519    allsamples.PickUpEvents(cut);
2520   }
2521  
2522 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2522 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2523    dout << "Saving configuration template!" << endl;
2524    ofstream configfile;
2525    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1940 | Line 2539 | void save_template(string mcjzb, string
2539    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2540    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2541    configfile<<"vector<float>jzb_cuts;\n";
2542 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2543    configfile<<"float MCPeakError=-999;\n";
2544 +  configfile<<"float DataPeakError=-999;\n";
2545    configfile<<"}\n\n";
2546  
2547    configfile<<"void read_config() {\n";
2548    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2549    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2550 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2551 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2550 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2551 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2552 >  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";
2553    configfile<<"\n\n";
2554 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2555 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2556 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2554 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2555 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2556 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2557 >  configfile<<"\n\n";
2558 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2559 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2560 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2561 >  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";
2562    configfile<<"\n\n";
1956  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1957  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1958  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2563    configfile<<"\n\n";
2564    configfile<<"luminosity="<<luminosity<<";\n";
2565    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
# Line 1981 | Line 2585 | void draw_all_ttbar_histos(TCanvas *can,
2585    float max=histos[0]->GetMaximum();
2586    if(manualmin>=0) min=manualmin;
2587    else {
2588 <    for(int i=1;i<histos.size();i++) {
2588 >    for(int i=1;i<(int)histos.size();i++) {
2589        float curmin=get_nonzero_minimum(histos[i]);
2590        float curmax=histos[i]->GetMaximum();
2591        if(curmin<min) min=curmin;
# Line 1992 | Line 2596 | void draw_all_ttbar_histos(TCanvas *can,
2596    histos[0]->Draw(drawoption.c_str());
2597    stringstream drawopt;
2598    drawopt << drawoption << ",same";
2599 <  for(int i=1;i<histos.size();i++) {
2599 >  for(int i=1;i<(int)histos.size();i++) {
2600      histos[i]->Draw(drawopt.str().c_str());
2601    }
2602   }
# Line 2001 | Line 2605 | void ttbar_sidebands_comparison(string m
2605    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2606    //in the case of the OFF peak analysis, we compare our control region to the real value
2607    TCut weightbackup=cutWeight;
2004  cutWeight="1.0";
2005  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2608    
2609 +  bool doPURW=false;
2610 +  
2611 +  
2612 +  if(!doPURW) {
2613 +    dout << "Not doing PU reweighting for ttbar closure test" << endl;
2614 +    cutWeight="1.0";
2615 +    // Do it without PU re-weighting
2616 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2617 +    stringstream resultsNoPU;
2618 +    stringstream noPUdatajzb;
2619 +    stringstream noPUmcjzb;
2620 +    
2621 +    stringstream mcjzbnoPU;
2622 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2623 +    mcjzb = noPUmcjzb.str();
2624 +  }
2625  
2626 <  TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2626 >      
2627 >  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2628 >
2629 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2630    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2631    TH1F *TSem;
2632    TH1F *nTSem;
2633 <  TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2633 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2634    TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2635    TH1F *TSeemm;
2636    TH1F *nTSeemm;
2637    
2638    if(PlottingSetup::RestrictToMassPeak) {
2639 <    TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2640 <    nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2641 <    TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2639 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2640 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2641 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2642      nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2643    }
2644  
2645    TCanvas *tcan = new TCanvas("tcan","tcan");
2025  
2646    tcan->SetLogy(1);
2647    
2648    TZeemm->SetLineColor(kBlack);
# Line 2041 | Line 2661 | void ttbar_sidebands_comparison(string m
2661    }
2662    
2663    vector<TH1F*> histos;
2664 +  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2665 +  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2666    histos.push_back(TZem);
2667    histos.push_back(TZeemm);
2668    if(PlottingSetup::RestrictToMassPeak) {
2669 +    TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2670 +    TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2671      histos.push_back(TSem);
2672      histos.push_back(TSeemm);
2673    }
2674 <  draw_all_ttbar_histos(tcan,histos,"histo",0.04);
2674 >  draw_all_ttbar_histos(tcan,histos,"histo",1);
2675    
2676    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2677    leg->AddEntry(TZeemm,"SFZP","l");
# Line 2059 | Line 2683 | void ttbar_sidebands_comparison(string m
2683    leg->Draw("same");
2684    DrawMCPrelim(simulatedlumi);
2685    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2062  
2686    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2687    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2688 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2689 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2688 >  TH1F *TSeemmcopy;
2689 >  TH1F *TSemcopy;
2690 >  if(PlottingSetup::RestrictToMassPeak) {
2691 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2692 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2693 >  }
2694  
2695    TZem->Divide(TZeemm);
2696    TZem->SetMarkerStyle(21);
# Line 2072 | Line 2699 | void ttbar_sidebands_comparison(string m
2699      TSeemm->Divide(TZeemm);
2700      TSem->SetMarkerStyle(24);
2701      TSeemm->SetMarkerStyle(32);
2702 < }
2702 >  }
2703  
2704    tcan->SetLogy(0);
2705    TZem->GetYaxis()->SetRangeUser(0,2.5);
# Line 2083 | Line 2710 | void ttbar_sidebands_comparison(string m
2710      TSeemm->Draw("same");
2711    }
2712    
2713 <  float linepos=0.25;
2714 <  if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2713 >  float linepos=emuncertONPEAK;
2714 >  if(!PlottingSetup::RestrictToMassPeak) linepos=emuncertOFFPEAK;
2715 >  
2716    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2717    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2718    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2719    
2720 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2721 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2722 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2723 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2724 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2725 +  topalt->Draw("same");bottomalt->Draw("same");*/
2726 +  
2727 +  
2728    top->SetLineColor(kBlue);top->SetLineStyle(2);
2729    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2730    center->SetLineColor(kBlue);
# Line 2112 | Line 2748 | void ttbar_sidebands_comparison(string m
2748    DrawMCPrelim(simulatedlumi);
2749    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2750    
2751 +  if (0) { // Turn this off: we don't need this
2752  
2753 +    ///-------------- second part: only look at the quantity we actually care about!
2754 +    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2755 +    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2756 +    rightsfzp->Add(leftsfzp,-1);
2757 +    TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2758 +    TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2759 +    rightofzp->Add(leftofzp,-1);
2760 +    TH1F *leftofsb;
2761 +    TH1F *rightofsb;
2762 +    TH1F *leftsfsb;
2763 +    TH1F *rightsfsb;
2764 +    if(PlottingSetup::RestrictToMassPeak) {
2765 +      leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2766 +      rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2767 +      rightofsb->Add(leftofsb,-1);
2768 +      leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2769 +      rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2770 +      rightsfsb->Add(leftsfsb,-1);
2771 +    }
2772  
2773 < ///-------------- second part: only look at the quantity we actually care about!
2774 <  TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2775 <  TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2776 <  rightsfzp->Add(leftsfzp,-1);
2777 <  TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2778 <  TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2779 <  rightofzp->Add(leftofzp,-1);
2780 <  TH1F *leftofsb;
2781 <  TH1F *rightofsb;
2782 <  TH1F *leftsfsb;
2127 <  TH1F *rightsfsb;
2128 <  if(PlottingSetup::RestrictToMassPeak) {
2129 <        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2130 <        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2131 <        rightofsb->Add(leftofsb,-1);
2132 <        leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2133 <        rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2134 <        rightsfsb->Add(leftsfsb,-1);
2135 <  }
2773 >    tcan->SetLogy(1);
2774 >    rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2775 >    rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2776 >    rightsfzp->Draw("histo");
2777 >    rightofzp->Draw("histo,same");
2778 >    if(PlottingSetup::RestrictToMassPeak) {
2779 >      rightofsb->Draw("histo,same");
2780 >      rightsfsb->Draw("histo,same");
2781 >    }
2782 >    DrawMCPrelim(simulatedlumi);
2783  
2784 <  tcan->SetLogy(1);
2785 <  rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2786 <  rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2787 <  rightsfzp->Draw("histo");
2788 <  rightofzp->Draw("histo,same");
2789 <  if(PlottingSetup::RestrictToMassPeak) {
2790 <    rightofsb->Draw("histo,same");
2791 <    rightsfsb->Draw("histo,same");
2145 <  }
2146 <  DrawMCPrelim(simulatedlumi);
2784 >    TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2785 >    legA->AddEntry(rightsfzp,"SFZP","l");
2786 >    legA->AddEntry(rightofzp,"OFZP","l");
2787 >    if(PlottingSetup::RestrictToMassPeak) {
2788 >      legA->AddEntry(rightofsb,"SFSB","l");
2789 >      legA->AddEntry(rightsfsb,"OFSB","l");
2790 >    }
2791 >    legA->Draw();
2792  
2793 <  TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2149 <  legA->AddEntry(rightsfzp,"SFZP","l");
2150 <  legA->AddEntry(rightofzp,"OFZP","l");
2151 <  if(PlottingSetup::RestrictToMassPeak) {
2152 <    legA->AddEntry(rightofsb,"SFSB","l");
2153 <    legA->AddEntry(rightsfsb,"OFSB","l");
2154 <  }
2155 <  legA->Draw();
2793 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2794  
2795 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2795 >    tcan->SetLogy(0);
2796 >    rightofzp->Divide(rightsfzp);
2797 >    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2798 >    rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2799 >    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2800 >    rightofzp->Draw();
2801 >    if(PlottingSetup::RestrictToMassPeak) {
2802 >      rightofsb->Divide(rightsfzp);
2803 >      rightsfsb->Divide(rightsfzp);
2804 >      rightofsb->Draw("same");
2805 >      rightsfsb->Draw("same");
2806 >    }
2807  
2808 <  tcan->SetLogy(0);
2809 <  rightofzp->Divide(rightsfzp);
2810 <  rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2811 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
2812 <  rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2813 <  rightofzp->Draw();
2814 <  if(PlottingSetup::RestrictToMassPeak) {
2815 <    rightofsb->Divide(rightsfzp);
2816 <    rightsfsb->Divide(rightsfzp);
2817 <    rightofsb->Draw("same");
2818 <    rightsfsb->Draw("same");
2819 <  }
2808 >    TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2809 >    TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2810 >    TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2811 >  
2812 >    top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2813 >    bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2814 >    center2->SetLineColor(kBlue);
2815 >  
2816 >    top2->Draw("same");
2817 >    center2->Draw("same");
2818 >    bottom2->Draw("same");
2819 >
2820 >    rightofzp->SetMarkerStyle(21);
2821 >    if(PlottingSetup::RestrictToMassPeak) {
2822 >      rightofsb->SetMarkerStyle(24);
2823 >      rightsfsb->SetMarkerStyle(32);
2824 >    }
2825  
2826 <  TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2827 <  TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2828 <  TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2826 >    TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2827 >    leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2828 >    if(PlottingSetup::RestrictToMassPeak) {
2829 >      leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2830 >      leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2831 >    }
2832 >    leg3->AddEntry(bottom,"syst. envelope","l");
2833 >    leg3->SetX1(0.25);leg3->SetX2(0.6);
2834 >    leg3->SetY1(0.65);
2835    
2836 <  top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2177 <  bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2178 <  center2->SetLineColor(kBlue);
2836 >    leg3->Draw("same");
2837    
2838 <  top2->Draw("same");
2839 <  center2->Draw("same");
2182 <  bottom2->Draw("same");
2183 <
2184 <  rightofzp->SetMarkerStyle(21);
2185 <  if(PlottingSetup::RestrictToMassPeak) {
2186 <    rightofsb->SetMarkerStyle(24);
2187 <    rightsfsb->SetMarkerStyle(32);
2188 <  }
2838 >    DrawMCPrelim(simulatedlumi);
2839 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2840  
2190  TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2191  leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2192  if(PlottingSetup::RestrictToMassPeak) {
2193        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2194        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2841    }
2196  leg3->AddEntry(bottom,"syst. envelope","l");
2197  leg3->SetX1(0.25);leg3->SetX2(0.6);
2198  leg3->SetY1(0.65);
2199  
2200  leg3->Draw("same");
2201  
2202  DrawMCPrelim(simulatedlumi);
2203  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2842  
2843    delete TZem;
2844    delete nTZem;
# Line 2219 | Line 2857 | void ttbar_sidebands_comparison(string m
2857  
2858   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
2859    vector<float> nicer_binning;
2860 <  nicer_binning.push_back(-125);
2860 >  
2861 > /*  nicer_binning.push_back(-400);
2862 >  nicer_binning.push_back(-250);
2863 >  nicer_binning.push_back(-200);
2864 >  nicer_binning.push_back(-150);
2865 >  nicer_binning.push_back(-100);
2866 >  nicer_binning.push_back(-50);
2867 >  nicer_binning.push_back(-20);
2868 >  
2869 >  nicer_binning.push_back(0);
2870 >  nicer_binning.push_back(20);
2871 >  nicer_binning.push_back(50);
2872 >  nicer_binning.push_back(100);
2873 >  nicer_binning.push_back(150);
2874 >  nicer_binning.push_back(200);
2875 >  nicer_binning.push_back(250);
2876 >  nicer_binning.push_back(400);*/
2877 >  
2878    nicer_binning.push_back(-100);
2224  nicer_binning.push_back(-75);
2879    nicer_binning.push_back(-50);
2880    nicer_binning.push_back(-25);
2881    nicer_binning.push_back(0);
# Line 2231 | Line 2885 | void ttbar_sidebands_comparison(string m
2885    nicer_binning.push_back(100);
2886    nicer_binning.push_back(125);
2887    nicer_binning.push_back(150);
2888 <  nicer_binning.push_back(175);
2888 >  //nicer_binning.push_back(175);
2889    nicer_binning.push_back(200);
2890 <  nicer_binning.push_back(230);
2891 <  nicer_binning.push_back(280);
2890 >  nicer_binning.push_back(250);
2891 >  nicer_binning.push_back(300);
2892    nicer_binning.push_back(400);
2893 +  
2894    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2895   }
2896  
2897  
2898 < void zjets_prediction_comparison() {
2899 <  // Do it without PU re-weighting
2900 <  float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2901 <  stringstream resultsNoPU;
2902 <
2903 <  stringstream mcjzbnoPU;
2904 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2905 <  if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2906 <  else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2898 > void zjets_prediction_comparison(string mcjzbWithPUa) {
2899 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2900 > //  zcan->SetLogy(1);
2901 >  TCut weightbackup=cutWeight;
2902 >  
2903 >  bool UsePURW=false;
2904 >  
2905 >  
2906 >  string mcjzb;
2907 >  if(UsePURW) {
2908 >    mcjzb=mcjzbWithPUa;
2909 >  } else {
2910 >    // Do it without PU re-weighting
2911 >    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2912 >    stringstream resultsNoPU;
2913 >    stringstream noPUdatajzb;
2914 >    stringstream noPUmcjzb;
2915 >    
2916 >    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2917 >    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2918 >    
2919 >    mcjzb = noPUmcjzb.str();
2920 >    
2921 >    cutWeight="1.0";
2922 >  }
2923  
2924 <  string mcjzb = mcjzbnoPU.str();
2925 <  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2924 >  
2925 >  vector<float> binning;
2926 >  binning.push_back(0);
2927 >  binning.push_back(10);
2928 >  binning.push_back(20);
2929 >  binning.push_back(40);
2930 >  binning.push_back(60);
2931 > //   binning.push_back(50);
2932 > //   binning.push_back(60);
2933 > //   binning.push_back(70);
2934 > //   binning.push_back(80);
2935 > //   binning.push_back(90);
2936 >  binning.push_back(100);
2937  
2256  TCut weightbackup=cutWeight;
2257  cutWeight="1.0";
2258  float sbg_min=0.;
2259  float sbg_max=100.;
2260  int sbg_nbins=5;
2938    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2939    
2940    TCut kPos((mcjzb+">0").c_str());
2941    TCut kNeg((mcjzb+"<0").c_str());
2942    string var( "abs("+mcjzb+")" );
2943 +  
2944 +  TCut notTau("abs(genMID1)!=15");
2945 +  TCut ONLYTau("mll>20");
2946 +  
2947  
2948 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2949 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2950 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2270 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2271 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2948 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2949 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2950 >  
2951    hJZBpos->SetLineColor(kBlack);
2952    hJZBneg->SetLineColor(kRed);
2953    
2954 <  Int_t nbins = 5;
2276 <  Float_t xmax = 100.;
2277 <
2278 <  
2279 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2280 <  zcan->SetLogy(1);
2281 <
2954 >  hJZBpos->SetMinimum(1.0);
2955    hJZBpos->Draw("e1");
2956    hJZBneg->Draw("same,hist");
2957    hJZBpos->Draw("same,e1"); // So it's on top...
2958    
2959 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2959 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2960    leg->AddEntry(hJZBpos,"Observed","pe");
2961    leg->AddEntry(hJZBneg,"Predicted","l");
2962    leg->Draw("same");
2963    DrawMCPrelim(simulatedlumi);
2964 <  CompleteSave(zcan,"Systematics/zjets_prediction");
2964 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
2965    
2966    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
2967    hratio->Divide(hJZBneg);
2968    
2969 +  for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
2970 +    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
2971 +  }
2972 +  
2973    zcan->SetLogy(0);
2974 <  hratio->GetYaxis()->SetRangeUser(0,2.5);
2974 >  hratio->GetYaxis()->SetRangeUser(0,2.0);
2975    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2976    hratio->Draw("e1");
2977    
2978 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
2979 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
2980 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
2978 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
2979 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2980 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
2981    
2982  
2983    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2311 | Line 2988 | void zjets_prediction_comparison() {
2988    center->Draw("same");
2989    bottom->Draw("same");
2990    
2991 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
2991 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
2992    leg2->AddEntry(hratio,"obs / pred","pe");
2993    leg2->AddEntry(bottom,"syst. envelope","l");
2994    leg2->Draw("same");
2995    DrawMCPrelim(simulatedlumi);
2996 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
2996 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
2997 >  
2998 >  TCut reducedNJets(cutnJets);
2999 >  
3000 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3001 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3002 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3003 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3004 >
3005 >  TH1F *RcorrJZBSBem;
3006 >  TH1F *LcorrJZBSBem;
3007 >  TH1F *RcorrJZBSBeemm;
3008 >  TH1F *LcorrJZBSBeemm;
3009 >
3010 >  if(PlottingSetup::RestrictToMassPeak) {
3011 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3012 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3013 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3014 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3015 >  }
3016 >  
3017 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3018 >  if(PlottingSetup::RestrictToMassPeak) {
3019 >    Bpred->Add(RcorrJZBem,1.0/3.);
3020 >    Bpred->Add(LcorrJZBem,-1.0/3.);
3021 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
3022 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
3023 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
3024 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
3025 >  } else {
3026 >    Bpred->Add(RcorrJZBem,1.0);
3027 >    Bpred->Add(LcorrJZBem,-1.0);
3028 >  }
3029 >  
3030 >  Bpred->SetLineColor(kRed);
3031 >
3032 >  TAUhJZBpos->SetLineColor(kBlack);
3033 >  Bpred->SetLineColor(kRed);
3034 >  
3035 >  TAUhJZBpos->SetMinimum(1.0);
3036 >  TAUhJZBpos->Draw("e1");
3037 >  Bpred->Draw("same,hist");
3038 >  TAUhJZBpos->Draw("same,e1");
3039 >  
3040 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
3041 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
3042 >  TAUleg->AddEntry(Bpred,"Predicted","l");
3043 >  TAUleg->Draw("same");
3044 >  DrawMCPrelim(simulatedlumi);
3045 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
3046 >  
3047 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
3048 >  TAUhratio->Divide(Bpred);
3049 >  
3050 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
3051 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
3052 >  }
3053 >  
3054 >  zcan->SetLogy(0);
3055 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
3056 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
3057 >  TAUhratio->Draw("e1");
3058 >  
3059 >  top->Draw("same");
3060 >  center->Draw("same");
3061 >  bottom->Draw("same");
3062 >  
3063 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
3064 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3065 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
3066 >  TAUleg2->Draw("same");
3067 >  DrawMCPrelim(simulatedlumi);
3068 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
3069 >  
3070 >  delete Bpred;
3071 >  delete TAUhJZBpos;
3072 >  delete LcorrJZBeemm;
3073 >  delete RcorrJZBem;
3074 >  delete LcorrJZBem;
3075 >  
3076 >  if(PlottingSetup::RestrictToMassPeak) {
3077 >    delete RcorrJZBSBem;
3078 >    delete LcorrJZBSBem;
3079 >    delete RcorrJZBSBeemm;
3080 >    delete LcorrJZBSBeemm;
3081 >  }
3082 >  
3083    
3084    delete zcan;
3085    cutWeight=weightbackup;
# Line 2342 | Line 3105 | void sideband_assessment(string datajzb,
3105    tout << "\\begin{tabular}{l|cc}" << endl;
3106    tout << "\\hline" << endl;
3107    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
3108 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
3108 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
3109    tout << "\\end{tabular}" << endl;
3110    tout << "\\end{center}" << endl;
3111    tout << "\\end{table}" << endl;
# Line 2360 | Line 3123 | void make_table(samplecollection &coll,
3123    
3124    TCanvas *cannie = new TCanvas("cannie","cannie");
3125    
3126 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
3126 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
3127      float currcut=jzb_cuts[icut];
3128      int nbins=1;float low=currcut;
3129      vector<int> mysample;
# Line 2419 | Line 3182 | void make_table(samplecollection &coll,
3182    //prediction part
3183    if(is_data) cout << "Data prediction & ";
3184    if(subselection!="none") cout << subselection << " prediction &";
3185 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3185 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3186    
3187    cout << endl;
3188    //observation part
3189    if(is_data) cout << "Data observation & ";
3190    if(subselection!="none") cout << subselection << " observation &";
3191 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3191 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3192    cout << endl;
3193    cout << "_________________________________________________________________" << endl;
3194    delete cannie;
# Line 2460 | Line 3223 | void JZBSelEff(string mcjzb, TTree* even
3223    int nbins = sizeof(xbins)/sizeof(float)-1;
3224    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
3225  
3226 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3227 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3228 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3226 >  
3227 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
3228 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
3229 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
3230  
3231    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
3232    TCut kreco(cutmass);
# Line 2478 | Line 3242 | void JZBSelEff(string mcjzb, TTree* even
3242    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
3243    can->SetGridx(1);
3244    can->SetGridy(1);
3245 +  can->SetLeftMargin(0.16);
3246 +  can->SetRightMargin(0.05);
3247    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
3248 +  leg->SetBorderSize(1);
3249 +  leg->SetLineColor(kBlack);
3250 +  leg->SetTextFont(62);
3251  
3252 <  
2484 <
2485 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
3252 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
3253  
3254      ostringstream selection;
3255      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2498 | Line 3265 | void JZBSelEff(string mcjzb, TTree* even
3265      }
3266    
3267      heff->GetXaxis()->SetRangeUser(min, max);
3268 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
3269 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
3270 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
3271 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
3272      heff->SetMarkerStyle(markers[icut]);
3273      heff->Fit("func","Q+","same");
3274  
# Line 2509 | Line 3280 | void JZBSelEff(string mcjzb, TTree* even
3280  
3281      // Store plot
3282      TH1F* h = (TH1F*)heff->Clone(hname);
3283 +    h->SetNdivisions(505,"X");
3284      if ( icut) h->Draw("same");
3285      else h->Draw();
3286      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2529 | Line 3301 | void JZBSelEff(string mcjzb, TTree* even
3301   // Calls the above function for each signal sample
3302   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
3303   {  
3304 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
3304 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
3305      dout << "JZB selection efficiency curve: " << std::endl;
3306      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
3307    }
# Line 2572 | Line 3344 | void qcd_plots(string datajzb, string mc
3344    TH1F *RcorrJZBSBeemm;
3345    TH1F *LcorrJZBSBeemm;
3346    
3347 <  TH1F *RcorrJZBeemmNoS;
3347 > //  TH1F *RcorrJZBeemmNoS;
3348  
3349      //these are for the ratio
3350    TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2656 | Line 3428 | void qcd_plots(string datajzb, string mc
3428    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3429    string ytitle("ratio");
3430    if ( use_data==1 ) ytitle = "data/pred";
3431 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
3431 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
3432    
3433    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
3434    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 2703 | Line 3475 | void qcd_plots(string datajzb, string mc
3475    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
3476    
3477    dout << endl;
3478 <  for(int i=0;i<bins.size();i++) {
3478 >  for(int i=0;i<(int)bins.size();i++) {
3479      dout << " JZB > " << bins[i] << " : " << endl;
3480      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3481      if(PlottingSetup::RestrictToMassPeak) {
# Line 2751 | Line 3523 | void check_ptsanity() {
3523    leg->SetY2(1.0);
3524    
3525    
3526 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3526 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3527      string nowname=(allsamples.collection)[isample].filename;
3528      cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3529      individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
# Line 2775 | Line 3547 | void check_ptsanity() {
3547    ptsancan->cd(2);
3548    fpt2->Draw();
3549  
3550 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3550 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3551      ptsancan->cd(1);
3552      individualpt1histos[isample]->DrawNormalized("same,histo");
3553      ptsancan->cd(2);
# Line 2791 | Line 3563 | void check_ptsanity() {
3563   void do_mlls_plot(string mcjzb) {
3564    cout << "At this point we'd plot the mll distribution" << endl;
3565    TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3566 <  for(int isig=0;isig<(signalsamples.collection).size();isig++) {
3566 >  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3567      if(!(signalsamples.collection)[isig].events) continue;
3568      string nowname=(signalsamples.collection)[isig].filename;
3569      TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
# Line 2820 | Line 3592 | void do_mlls_plot(string mcjzb) {
3592    }
3593   }
3594  
3595 < void met_vs_jzb_plots() {
3595 > void met_vs_jzb_plots(string datajzb, string mcjzb) {
3596    
3597    TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3598    canmetjzb->SetRightMargin(0.16);
# Line 2830 | Line 3602 | void met_vs_jzb_plots() {
3602    findme.push_back("TTJets");
3603    findme.push_back("LM");
3604    
3605 <  for(int ifind=0;ifind<findme.size();ifind++) {
3605 >  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3606      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3607      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3608 <    for(int isel=0;isel<selsamples.size();isel++) {
3609 <      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3610 <      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3608 >    for(int isel=0;isel<(int)selsamples.size();isel++) {
3609 >      dout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3610 >      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF&&cutnJets);
3611      }
3612      metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3613      metvsjzb->SetStats(0);
# Line 2849 | Line 3621 | void met_vs_jzb_plots() {
3621      title->Draw();
3622      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3623    }
3624 +  
3625 +  
3626 +  dout << "About to produce MET plot for DY split up by JZB" << endl;
3627 +  
3628 +  int nbins=14;
3629 +  float low=0;
3630 +  float high=140;
3631 +  
3632 +  stringstream sLEFT;
3633 +  sLEFT << "((" << mcjzb << ")<0)";
3634 +  TCut LEFT(sLEFT.str().c_str());
3635 +  stringstream sRIGHT;
3636 +  sRIGHT << "((" << mcjzb << ")>0)";
3637 +  TCut RIGHT(sRIGHT.str().c_str());
3638 +  
3639 +  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3640 +  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3641 +  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3642 +  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3643 +  
3644 +  metleft->Add(metleftO,-1);
3645 +  metright->Add(metrightO,-1);
3646 +  
3647 +  metleft->SetLineColor(kRed);
3648 +  metright->SetLineColor(kBlack);
3649 +  TPad *metpad = new TPad("metpad","metpad",0,0,1,1);
3650 +  metpad->cd();
3651 +  metpad->SetLogy(1);
3652 +  metleft->Draw("histo");
3653 +  metright->Draw("same");
3654 +  TLegend *lg = make_legend();
3655 +  lg->SetX1(0.5);
3656 +  lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3657 +  lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3658 +  lg->Draw();
3659 +  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3660 +  TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3661 +  
3662 +  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3663 +  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3664 +  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3665 +  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3666 +  
3667 +  TH1F *Bpred =  (TH1F*)metlefta->Clone("Bpred");
3668 +  Bpred->Add(metleftOa,-1);
3669 +  Bpred->Add(metrightOa);
3670 +  TH1F *obs = (TH1F*)metrighta->Clone("obs");
3671 +  
3672 +  metlefta->Add(metleftOa,-1);
3673 +  metrighta->Add(metrightOa,-1);
3674 +  
3675 +  metlefta->SetLineColor(kRed);
3676 +  metpad2->cd();
3677 +  metlefta->Draw("histo");
3678 +  metrighta->Draw("same");
3679 +  lg->Draw();
3680 +  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3681 +  
3682 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3683 +  metpad3->cd();
3684 +  Bpred->SetLineColor(kRed);
3685 +  Bpred->Draw("histo");
3686 +  obs->SetLineColor(kBlack);
3687 +  obs->Draw("same");
3688 +  TLegend *lg2 = make_legend();
3689 +  lg2->SetX1(0.5);
3690 +  lg2->AddEntry(obs,"observed","P");
3691 +  lg2->AddEntry(Bpred,"predicted","L");
3692 +  lg2->Draw();
3693 +  
3694 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET_type1_spectrum");
3695 +  delete lg;
3696 +  delete canmetjzb;
3697 +  delete metleft;
3698 +  delete metleftO;
3699 +  delete metright;
3700 +  delete metrightO;
3701   }
3702      
3703  
# Line 2856 | Line 3705 | void test() {
3705    
3706    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
3707    testcanv->cd();
3708 <  switch_overunderflow(true);
3708 > //  switch_overunderflow(true);
3709    TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
3710    switch_overunderflow(false);
3711    ptdistr->Draw();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines