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.33 by buchmann, Thu Jul 5 10:07:53 2012 UTC vs.
Revision 1.46 by pablom, Thu Aug 2 16:45:47 2012 UTC

# Line 33 | Line 33 | void todo() {
33  
34  
35  
36 < void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true, string saveas="")
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;
# Line 52 | Line 52 | void find_one_peak_combination(TCut spec
52    if(method==doKM) {
53      //we only need this histo for the KM fitting...
54      rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
55 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
56 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
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 {
# Line 62 | Line 62 | void find_one_peak_combination(TCut spec
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,saveas);
66 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
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    }
# Line 73 | Line 73 | void find_one_peak_combination(TCut spec
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;
# Line 98 | Line 98 | void find_peaks(float &MCPeak,float &MCP
98    float datammpeak,dataeepeak;
99    float datammpeakerr,dataeepeakerr;
100    
101 <  float mcSigma, dataSigma;
101 >  float mcSigma,mcSigmaError, dataSigma, dataSigmaError;
102    
103    dout << "Finding global peak : " << endl;
104 <  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma, dataSigma,result,doPUreweighting,"");
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, dataSigma,result,doPUreweighting,"_ele");
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, dataSigma,result,doPUreweighting,"_mu");
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;
# Line 147 | Line 147 | void find_peaks(float &MCPeak,float &MCP
147      
148      mcjzb << ")";
149    }
150 <    
150 >  
151    
152   }
153  
154 < void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
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=10;
159 <    max=150;
158 >    min=20;
159 >    max=300;
160    }
161 <  int nbins=int((max-min)/5);
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 << "(" << mcjzb << ">" << jzbthreshold << ")";
167 <  TCut largerzero(largerzeroS.str().c_str());
165 >  stringstream largerzeroS;
166 >  largerzeroS << "(" << datajzb << ">" << jzbthreshold << ")";
167 >  TCut largerzeroD(largerzeroS.str().c_str());
168    
169    stringstream smallerzeroS;
170 <  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
171 <  TCut smallerzero(smallerzeroS.str().c_str());*/
172 <  
173 <  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
174 <  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets,mc,luminosity);
175 <  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
176 <  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity);
177 <  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity);
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;
# Line 184 | Line 189 | void make_special_obs_pred_mll_plot(stri
189   //  TH1F *RcorrJZBeemmNoS;
190  
191    if(PlottingSetup::RestrictToMassPeak) {
192 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,data, luminosity);
193 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,data, luminosity);
194 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,data, luminosity);
195 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,data, luminosity);
196 <  }
197 <  
198 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
199 <  if(PlottingSetup::RestrictToMassPeak) {
200 <    Bpred->Add(RcorrJZBem,1.0/3.);
201 <    Bpred->Add(LcorrJZBem,-1.0/3.);
202 <    Bpred->Add(RcorrJZBSBem,1.0/3.);
203 <    Bpred->Add(LcorrJZBSBem,-1.0/3.);
204 <    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
205 <    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
206 <  } else {
207 <    Bpred->Add(RcorrJZBem,1.0);
208 <    Bpred->Add(LcorrJZBem,-1.0);
209 <  }
210 <  
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");
# Line 219 | Line 228 | void make_special_obs_pred_mll_plot(stri
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 +  
264  
265    delete RcorrJZBeemm;
266    delete LcorrJZBeemm;
# Line 318 | Line 360 | void draw_ratio_plot(TH1* hdata, THStack
360    oneline->Draw("same");
361   }
362  
363 + void make_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, bool logscale,
364 +                   string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.3) {
365 +
366 +  TCut ibasiccut=basiccut;
367 +  bool draw_separation_lines=false;
368 +
369 +  if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
370 +
371 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
372 +
373 +  TCut cutSF;
374 +  TCut cutOF;
375 +
376 +  cutOF=cutOSOF&&cutnJets&&ibasiccut;
377 +  cutSF=cutOSSF&&cutnJets&&ibasiccut;
378 +
379 +
380 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
381 +  ckin->SetLogy(logscale);
382 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
383 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
384 +  string signal("LM3");
385 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
386 +  int idx = signalsamples.FindSample(signal)[0];
387 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
388 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
389 +  signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
390 +  datahistoSF->SetMarkerSize(DataMarkerSize);
391 +  datahistoOF->SetLineColor(kRed);
392 +
393 +  if ( !logscale ) {
394 +    datahistoSF->SetMinimum(0); // Defaults
395 +    datahistoOF->SetMinimum(0); // Defaults
396 +  } else {
397 +    datahistoSF->SetMinimum(0.5);
398 +    datahistoOF->SetMinimum(0.5);
399 +  }
400 +  if (logscale) {
401 +    datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
402 +    datahistoOF->SetMaximum(5.3*datahistoSF->GetMaximum());
403 +  } else {
404 +    datahistoSF->SetMaximum(2.0*datahistoSF->GetMaximum());
405 +    datahistoOF->SetMaximum(2.0*datahistoOF->GetMaximum());
406 +  }
407 +
408 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
409 +  datahistoOF->GetXaxis()->SetTitle(xlabel.c_str());
410 +  signalhisto->GetXaxis()->SetTitle(xlabel.c_str());
411 +  datahistoSF->GetYaxis()->SetTitle("N. Events");
412 +  datahistoOF->GetYaxis()->SetTitle("N. Events");
413 +  signalhisto->GetYaxis()->SetTitle("N. Events");
414 +  datahistoSF->GetXaxis()->CenterTitle();
415 +  datahistoOF->GetXaxis()->CenterTitle();
416 +  signalhisto->GetXaxis()->CenterTitle();
417 +  datahistoSF->GetYaxis()->CenterTitle();
418 +  datahistoOF->GetYaxis()->CenterTitle();
419 +  signalhisto->GetYaxis()->CenterTitle();
420 +
421 +  TLegend *mleg = new TLegend(0.2+legendPosition, 0.72, 0.55+legendPosition, 0.87, legendTitle.c_str());
422 +  mleg->SetFillColor(kWhite);
423 +  mleg->SetTextFont(42);
424 +  mleg->SetTextSize(0.048);
425 +  mleg->SetLineWidth(0);
426 +  mleg->SetBorderSize(0);
427 +  mleg->AddEntry(datahistoSF, "S. Flavor", "PL");
428 +  mleg->AddEntry(datahistoOF, "O. Flavor", "L");
429 +  mleg->AddEntry(signalhisto, "LM3", "L");
430 +
431 +  datahistoSF->Draw("E1");
432 +  datahistoOF->Draw("HIST,SAMES");
433 +  signalhisto->Draw("HIST,SAMES");
434 +  mleg->Draw();
435 +  DrawPrelim();
436 +  CompleteSave(ckin, "./SFOF/" + filename);
437 +
438 +  datahistoSF->Delete();
439 +  datahistoOF->Delete();
440 +  signalhisto->Delete();
441 +  delete mleg;
442 +  delete ckin;
443 +
444 + }
445 +
446 +
447 +
448   float lastrange_min=0;
449   float lastrange_max=0;
450  
# Line 360 | Line 487 | void make_kin_plot(string variable, stri
487          draw_separation_lines=true;
488    }
489    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
490 <  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
490 >  if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
491 >  if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
492 >  if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
493    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
494    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
495    if(filename=="mll_inclusive_osof") cut=cutOSOF;
# Line 373 | Line 502 | void make_kin_plot(string variable, stri
502    ckin->SetLogy(logscale);
503    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
504    datahisto->SetMarkerSize(DataMarkerSize);
505 <  THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
505 >  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
506 >  else datahisto->SetMinimum(0.5);
507 >  // Custom max.
508 >  if(variable=="TMath::Abs(pfJetDphiMet[0])") datahisto->SetMaximum(1.5*datahisto->GetMaximum());
509    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
510    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
511    if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
512    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
513    if(filename=="mll_osof") datahisto->SetMinimum(9);
514 <  datahisto->SetMaximum(5.3*datahisto->GetMaximum());
515 <  datahisto->Draw("e1");
516 <  ckin->Update();
514 >  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
515 >  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
516 >
517    if(loadlastminmax) {
518          datahisto->SetMinimum(lastrange_min);
519          datahisto->SetMaximum(lastrange_max);
# Line 391 | Line 523 | void make_kin_plot(string variable, stri
523          }              
524    }
525  
526 +  // Draw signal by hand (for some reason I don't manage to use the sample class: it adds it to the stack!)
527 +  string signal("LM3");
528 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
529 +  int idx = signalsamples.FindSample(signal)[0];
530 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
531 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
532 +  signalhisto->SetLineColor(kOrange);
533 +
534 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
535 +  datahisto->Draw("e1");
536 +  ckin->Update();
537    mcstack.Draw("same");
538 +  
539    datahisto->Draw("same,e1");
540    TLegend *kinleg = allsamples.allbglegend();
541    kinleg->Draw();
# Line 434 | Line 578 | void make_kin_plot(string variable, stri
578          kinpad->SetLogy(logscale);
579          datahisto->Draw("e1");
580          mcstack.Draw("same");
581 +        signalhisto->Draw("same");
582          datahisto->Draw("same,e1");
583          datahisto->Draw("same,axis");
584          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 441 | Line 586 | void make_kin_plot(string variable, stri
586            upperboundary->Draw("same");
587          }
588            
589 +        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
590          kinleg->Draw();
591          write_cut->Draw();
592          DrawPrelim();
# Line 458 | Line 604 | void make_kin_plot(string variable, stri
604    delete ckin;
605   }
606  
607 < void make_JES_plot() {
607 > void make_JES_plot(TCut cut, string name) {
608  
609    int nbins=10;
610    float min=-0.5;
611    float max = 9.5;
612    bool logscale=true;
613    string xlabel="nJets";
468  TCut cut=cutmass&&cutOSSF&&basiccut;
614  
615    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
616    ckin->SetLogy(logscale);
617 <  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
617 >  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,data,luminosity);
618    datahisto->SetMarkerSize(DataMarkerSize);
619 <  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
620 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
621 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
619 >  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,mc,luminosity);
620 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum40p1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
621 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum40n1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
622  
623    datahisto->SetMinimum(1);
624    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 498 | Line 643 | void make_JES_plot() {
643    TLegend *kinleg = allsamples.allbglegend();
644    kinleg->AddEntry(JESunc,"JES uncertainty","f");
645    kinleg->Draw();
646 <  CompleteSave(ckin,"Systematics/JES");
646 >  CompleteSave(ckin,"Systematics/JES"+name);
647    datahisto->Delete();
648    delete ckin;
649  
# Line 513 | Line 658 | void do_kinematic_plots(string mcjzb, st
658    float mll_hi=160;
659    if(!PlottingSetup::RestrictToMassPeak) {
660          mll_low=20;
661 <        mll_hi=210;
661 >        mll_hi=300;
662    }
663 <  
664 <  make_kin_plot("met[4]","",40,0,200,dolog,"MET [GeV]","met",doPF,true);
663 >
664 >  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);
665 >  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);
666 >  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);
667 >  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);
668 >  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);
669 >  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);
670 >  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);
671 >  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);
672 >  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);
673 >  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);
674 >  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);
675 >  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);
676 >  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);
677 >  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);
678 >  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);
679 >  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);
680 >  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);
681 >  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);
682 >  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);
683 >  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);
684 >
685 >
686 >
687 >  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
688 >
689    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
690    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
691    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
692    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
693 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
694 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
695 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
696 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/2,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
697 <  make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
698 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
699 < //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
700 < //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
701 <  make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
702 <  make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
534 <  make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
535 <  make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
536 <  make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
693 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
694 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
695 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
696 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
697 >  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
698 >  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
699 >
700 >  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
701 >  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
702 >
703    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
704    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
705    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
706 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
706 >
707 >  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
708 > //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
709 > //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
710 >  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
711 >  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
712 >  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
713 >  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
714 >  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
715    stringstream jzbcut;
716    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
717 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
718 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
719 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
720 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
717 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_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_osof_aboveJZB100",doPF,true);
719 >  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);
720 >  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);
721    stringstream jzbcut2;
722    jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
723 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
724 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
723 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_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_osof_aboveJZB150",doPF,true);
725 >  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);
726 >  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);
727    stringstream jzbcut3;
728    jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
729 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
730 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
731 <  
732 <  make_special_obs_pred_mll_plot(mcjzb,0);
733 <  make_special_obs_pred_mll_plot(mcjzb,50);
734 <  make_special_obs_pred_mll_plot(mcjzb,100);
735 <  make_special_obs_pred_mll_plot(mcjzb,150);
736 <  make_special_obs_pred_mll_plot(mcjzb,200);
737 <  make_special_obs_pred_mll_plot(mcjzb,250);
729 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_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_osof_aboveJZB50",doPF,true,true);
731 >  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);  
732 >  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);  
733 >
734 >  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);
735 >
736 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
737 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
738 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
739 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
740 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
741 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
742 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
743 >
744 >  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
745 >  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
746 >
747 >
748   }
749  
750   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
751                       int nbins, float xmin, float xmax, bool log,
752                       float ymin=0, float ymax=0, bool leftJustified=false ) {
753 <      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
753 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
754  
755    TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
756    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__));
757 <  if(var=="numVtx") cutWeight=TCut("1.0");
757 >  //if(var=="numVtx") cutWeight=TCut("1.0");
758    TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
759    TCut jzbMC[]  = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
760  
# Line 592 | Line 778 | void make_comp_plot( string var, string
778        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
779        ccomp->SetLogy(log);
780        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
781 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
781 >      TH1F *lm3histo  = signalsamples.Draw("lm3histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],data,luminosity,signalsamples.FindSample("LM3"));
782        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
783        datahisto->SetMarkerSize(DataMarkerSize);
784        if (ymax>ymin) datahisto->SetMaximum(ymax);
785 <      lm4histo->SetLineStyle(2);
785 >      lm3histo->SetLineStyle(2);
786        datahisto->Draw("e1");
787        mcstack.Draw("same");
788        datahisto->Draw("same,e1");
789 < //      lm4histo->Draw("hist,same");
789 >      lm3histo->Draw("hist,same");
790        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
791        if ( leftJustified ) {
792          Float_t w = kinleg->GetX2()-kinleg->GetX1();
793          kinleg->SetX1(0.2);
794          kinleg->SetX2(0.2+w);
795        }
796 < //      kinleg->AddEntry(lm4histo,"LM4","l");
796 >      kinleg->AddEntry(lm3histo,"LM3","l");
797        kinleg->Draw();
798        TText* write_variable = write_text(0.99,0.01,var);
799        write_variable->SetTextAlign(31);
# Line 616 | Line 802 | void make_comp_plot( string var, string
802        CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
803        delete datahisto;
804        delete ccomp;
805 <      delete lm4histo;
805 >      delete lm3histo;
806      }
807    cutWeight=weightbackup;
808   }
# Line 634 | Line 820 | void region_comparison_plots(string mcjz
820      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
821      float mll_low=50;float mll_high=170;
822      if(!PlottingSetup::RestrictToMassPeak) {
823 <        mll_high=200;
824 <        mll_low=50;
823 >        mll_high=300;
824 >        mll_low=20;
825      }
826 <    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
826 >    make_comp_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",jzbcut,mcjzb,datajzb,100,0,10,true);
827 >    make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
828 >
829 >    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
830      make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
831 <    make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
831 >    make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
832 >    make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
833      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
834 <    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
834 >    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,40,0.,40.,false,0,16.);
835      make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
836      make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
837 +    make_comp_plot("eta1","#eta_1","eta1",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
838 +    make_comp_plot("eta2","#eta_2","eta2",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
839    }
840  
841    switch_overunderflow(false); // switching overflow/underflow bins off
# Line 1119 | Line 1311 | void do_prediction_plot(string jzb, TCan
1311      legBpred->AddEntry(Bpred,"predicted","l");
1312   //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1313   //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1314 <    legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1314 >    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1315      legBpred->Draw();
1316      DrawPrelim();
1317  
# Line 1179 | Line 1371 | void do_prediction_plot(string jzb, TCan
1371      CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1372      Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1373      
1374 +    
1375 +    //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;
1376 +    
1377      delete speciallegBpred;
1378      delete Zjetspred;
1379      delete TTbarpred;
# Line 1243 | Line 1438 | void do_prediction_plot(string jzb, TCan
1438    string ytitle("ratio");
1439    if ( use_data==1 ) ytitle = "data/pred";
1440    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1441 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle,BpredSys);//not extending the y range anymore up to 4
1441 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1442  
1443    
1444    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
# Line 1687 | Line 1882 | void draw_pure_jzb_histo(TCut cut,string
1882    datahisto->Draw("same,e1");
1883    
1884    TLegend *leg;
1885 <  if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1886 <  else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1887 <  else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1888 <  else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1889 <  else {
1890 <    std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1891 <    exit(-1);
1892 <      }
1885 >  if (!PlottingSetup::RestrictToMassPeak) {
1886 >    if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1887 >    else leg = allsamples.allbglegend("Same flavor",datahisto);
1888 >  } else {
1889 >    if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1890 >    else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1891 >    else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1892 >    else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1893 >    else {
1894 >      std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1895 >      exit(-1);
1896 >    }
1897 >  }
1898    leg->Draw();
1899    string write_cut = decipher_cut(cut,"");
1900    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
# Line 1799 | Line 1999 | void diboson_plots(string mcjzb, string
1999    }
2000    
2001   }
2002 +
2003 +
2004 + void draw_normalized_data_vs_data_histo(TCut cut1, TCut cut2, string variable, string legentry1, string legentry2, string savename, TCanvas *can,vector<float> binning) {
2005 +  TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
2006 +  jzbpad->cd();
2007 +  jzbpad->SetLogy(1);
2008 +  string xlabel="JZB [GeV]";
2009 +
2010 +  TH1F *datahisto1 = allsamples.Draw("datahisto1",variable,binning, xlabel, "events",cut1,data,luminosity);
2011 +  datahisto1->SetLineColor(kRed);
2012 +  datahisto1->SetMarkerColor(kRed);
2013 +  TH1F *datahisto2 = allsamples.Draw("datahisto2",variable,binning, xlabel, "events",cut2,data,luminosity);
2014 +  datahisto2->SetLineColor(kBlue);
2015 +  datahisto2->SetMarkerColor(kBlue);
2016 +  
2017 +  datahisto2->SetMarkerSize(DataMarkerSize);
2018 +  datahisto1->DrawNormalized("e1");
2019 +  datahisto2->DrawNormalized("histo,same");
2020 +  datahisto1->DrawNormalized("same,e1");
2021 +  
2022 +  TLegend *leg = make_legend();
2023 +  leg->AddEntry(datahisto1,legentry1.c_str());
2024 +  leg->AddEntry(datahisto2,legentry2.c_str());
2025 +  leg->Draw();
2026 +  
2027 +  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
2028 +  
2029 +  datahisto1->Delete();
2030 +  datahisto2->Delete();
2031 + }
2032 +
2033 +
2034   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2035    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2036    float max=jzbHigh ;
# Line 1822 | Line 2054 | void jzb_plots(string mcjzb, string data
2054      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2055      if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2056      if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,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",can,binning);
2058 +    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);
2059 +    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);
2060 +
2061    }
2062    
2063    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
# Line 2172 | Line 2408 | float find_one_correction_factor(string
2408    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2409    cancorr->SetLogz();
2410    cancorr->SetRightMargin(0.13);
2411 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)"&&SpecialCut&&passtrig);
2411 >  TCut zptforresponsepresentation(Restrmasscut&&SpecialCut&&passtrig);
2412 >
2413    if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2414    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2415 +  niceresponseplotd->Sumw2();
2416 +  TH2F* emuResponse = (TH2F*)niceresponseplotd->Clone("emuResponse");
2417    vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2418    for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2419      if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2420      if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2421      
2422      dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2423 <    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",zptforresponsepresentation*cutWeight);
2423 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
2424 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
2425    }
2426 <    
2426 >  niceresponseplotd->Add(emuResponse,-1);
2427 >  
2428    niceresponseplotd->SetStats(0);
2429    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2430    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2191 | Line 2432 | float find_one_correction_factor(string
2432    niceresponseplotd->GetYaxis()->CenterTitle();
2433    niceresponseplotd->Draw("COLZ");
2434    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2435 +  profd->Rebin(2);
2436    profd->SetMarkerSize(DataMarkerSize);
2437    profd->Fit("pol0","","same,e1",100,400);
2438    DrawPrelim();
# Line 2210 | Line 2452 | float find_one_correction_factor(string
2452    CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2453    delete cancorr;
2454    delete niceresponseplotd;
2455 +  delete profd;
2456    return correction;
2457   }
2458  
# Line 2364 | Line 2607 | void ttbar_sidebands_comparison(string m
2607    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2608    //in the case of the OFF peak analysis, we compare our control region to the real value
2609    TCut weightbackup=cutWeight;
2610 < //  cutWeight="1.0";
2610 >  
2611 >  bool doPURW=false;
2612 >  
2613 >  
2614 >  if(!doPURW) {
2615 >    dout << "Not doing PU reweighting for ttbar closure test" << endl;
2616 >    cutWeight="1.0";
2617 >    // Do it without PU re-weighting
2618 >    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2619 >    stringstream resultsNoPU;
2620 >    stringstream noPUdatajzb;
2621 >    stringstream noPUmcjzb;
2622 >    
2623 >    stringstream mcjzbnoPU;
2624 >    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2625 >    mcjzb = noPUmcjzb.str();
2626 >  }
2627 >
2628 >      
2629    float simulatedlumi = luminosity; //in pb please - adjust to your likings
2630  
2631 <  TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2631 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2632    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2633    TH1F *TSem;
2634    TH1F *nTSem;
2635 <  TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2635 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2636    TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2637    TH1F *TSeemm;
2638    TH1F *nTSeemm;
2639    
2640    if(PlottingSetup::RestrictToMassPeak) {
2641 <    TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2642 <    nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2643 <    TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2641 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2642 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2643 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2644      nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2645    }
2646  
2647    TCanvas *tcan = new TCanvas("tcan","tcan");
2387  
2648    tcan->SetLogy(1);
2649    
2650    TZeemm->SetLineColor(kBlack);
# Line 2413 | Line 2673 | void ttbar_sidebands_comparison(string m
2673      histos.push_back(TSem);
2674      histos.push_back(TSeemm);
2675    }
2676 <  draw_all_ttbar_histos(tcan,histos,"histo",0.04);
2676 >  draw_all_ttbar_histos(tcan,histos,"histo",1);
2677    
2678    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2679    leg->AddEntry(TZeemm,"SFZP","l");
# Line 2441 | Line 2701 | void ttbar_sidebands_comparison(string m
2701      TSeemm->Divide(TZeemm);
2702      TSem->SetMarkerStyle(24);
2703      TSeemm->SetMarkerStyle(32);
2704 < }
2704 >  }
2705  
2706    tcan->SetLogy(0);
2707    TZem->GetYaxis()->SetRangeUser(0,2.5);
# Line 2490 | Line 2750 | void ttbar_sidebands_comparison(string m
2750    DrawMCPrelim(simulatedlumi);
2751    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2752    
2753 +  if (0) { // Turn this off: we don't need this
2754  
2755 < ///-------------- second part: only look at the quantity we actually care about!
2756 <  TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2757 <  TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2758 <  rightsfzp->Add(leftsfzp,-1);
2759 <  TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2760 <  TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2761 <  rightofzp->Add(leftofzp,-1);
2762 <  TH1F *leftofsb;
2763 <  TH1F *rightofsb;
2764 <  TH1F *leftsfsb;
2765 <  TH1F *rightsfsb;
2766 <  if(PlottingSetup::RestrictToMassPeak) {
2767 <        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2768 <        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2769 <        rightofsb->Add(leftofsb,-1);
2770 <        leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2771 <        rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2772 <        rightsfsb->Add(leftsfsb,-1);
2773 <  }
2755 >    ///-------------- second part: only look at the quantity we actually care about!
2756 >    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2757 >    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2758 >    rightsfzp->Add(leftsfzp,-1);
2759 >    TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2760 >    TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2761 >    rightofzp->Add(leftofzp,-1);
2762 >    TH1F *leftofsb;
2763 >    TH1F *rightofsb;
2764 >    TH1F *leftsfsb;
2765 >    TH1F *rightsfsb;
2766 >    if(PlottingSetup::RestrictToMassPeak) {
2767 >      leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2768 >      rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2769 >      rightofsb->Add(leftofsb,-1);
2770 >      leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2771 >      rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2772 >      rightsfsb->Add(leftsfsb,-1);
2773 >    }
2774  
2775 <  tcan->SetLogy(1);
2776 <  rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2777 <  rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2778 <  rightsfzp->Draw("histo");
2779 <  rightofzp->Draw("histo,same");
2780 <  if(PlottingSetup::RestrictToMassPeak) {
2781 <    rightofsb->Draw("histo,same");
2782 <    rightsfsb->Draw("histo,same");
2783 <  }
2784 <  DrawMCPrelim(simulatedlumi);
2775 >    tcan->SetLogy(1);
2776 >    rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2777 >    rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2778 >    rightsfzp->Draw("histo");
2779 >    rightofzp->Draw("histo,same");
2780 >    if(PlottingSetup::RestrictToMassPeak) {
2781 >      rightofsb->Draw("histo,same");
2782 >      rightsfsb->Draw("histo,same");
2783 >    }
2784 >    DrawMCPrelim(simulatedlumi);
2785  
2786 <  TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2787 <  legA->AddEntry(rightsfzp,"SFZP","l");
2788 <  legA->AddEntry(rightofzp,"OFZP","l");
2789 <  if(PlottingSetup::RestrictToMassPeak) {
2790 <    legA->AddEntry(rightofsb,"SFSB","l");
2791 <    legA->AddEntry(rightsfsb,"OFSB","l");
2792 <  }
2793 <  legA->Draw();
2786 >    TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2787 >    legA->AddEntry(rightsfzp,"SFZP","l");
2788 >    legA->AddEntry(rightofzp,"OFZP","l");
2789 >    if(PlottingSetup::RestrictToMassPeak) {
2790 >      legA->AddEntry(rightofsb,"SFSB","l");
2791 >      legA->AddEntry(rightsfsb,"OFSB","l");
2792 >    }
2793 >    legA->Draw();
2794  
2795 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2795 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2796  
2797 <  tcan->SetLogy(0);
2798 <  rightofzp->Divide(rightsfzp);
2799 <  rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2800 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2801 <  rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2802 <  rightofzp->Draw();
2803 <  if(PlottingSetup::RestrictToMassPeak) {
2804 <    rightofsb->Divide(rightsfzp);
2805 <    rightsfsb->Divide(rightsfzp);
2806 <    rightofsb->Draw("same");
2807 <    rightsfsb->Draw("same");
2808 <  }
2797 >    tcan->SetLogy(0);
2798 >    rightofzp->Divide(rightsfzp);
2799 >    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2800 >    rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2801 >    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2802 >    rightofzp->Draw();
2803 >    if(PlottingSetup::RestrictToMassPeak) {
2804 >      rightofsb->Divide(rightsfzp);
2805 >      rightsfsb->Divide(rightsfzp);
2806 >      rightofsb->Draw("same");
2807 >      rightsfsb->Draw("same");
2808 >    }
2809 >
2810 >    TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2811 >    TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2812 >    TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2813 >  
2814 >    top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2815 >    bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2816 >    center2->SetLineColor(kBlue);
2817 >  
2818 >    top2->Draw("same");
2819 >    center2->Draw("same");
2820 >    bottom2->Draw("same");
2821 >
2822 >    rightofzp->SetMarkerStyle(21);
2823 >    if(PlottingSetup::RestrictToMassPeak) {
2824 >      rightofsb->SetMarkerStyle(24);
2825 >      rightsfsb->SetMarkerStyle(32);
2826 >    }
2827  
2828 <  TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2829 <  TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2830 <  TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2828 >    TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2829 >    leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2830 >    if(PlottingSetup::RestrictToMassPeak) {
2831 >      leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2832 >      leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2833 >    }
2834 >    leg3->AddEntry(bottom,"syst. envelope","l");
2835 >    leg3->SetX1(0.25);leg3->SetX2(0.6);
2836 >    leg3->SetY1(0.65);
2837    
2838 <  top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2554 <  bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2555 <  center2->SetLineColor(kBlue);
2838 >    leg3->Draw("same");
2839    
2840 <  top2->Draw("same");
2841 <  center2->Draw("same");
2559 <  bottom2->Draw("same");
2560 <
2561 <  rightofzp->SetMarkerStyle(21);
2562 <  if(PlottingSetup::RestrictToMassPeak) {
2563 <    rightofsb->SetMarkerStyle(24);
2564 <    rightsfsb->SetMarkerStyle(32);
2565 <  }
2840 >    DrawMCPrelim(simulatedlumi);
2841 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2842  
2567  TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2568  leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2569  if(PlottingSetup::RestrictToMassPeak) {
2570        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2571        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2843    }
2573  leg3->AddEntry(bottom,"syst. envelope","l");
2574  leg3->SetX1(0.25);leg3->SetX2(0.6);
2575  leg3->SetY1(0.65);
2576  
2577  leg3->Draw("same");
2578  
2579  DrawMCPrelim(simulatedlumi);
2580  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2844  
2845    delete TZem;
2846    delete nTZem;
# Line 2624 | Line 2887 | void ttbar_sidebands_comparison(string m
2887    nicer_binning.push_back(100);
2888    nicer_binning.push_back(125);
2889    nicer_binning.push_back(150);
2890 <  nicer_binning.push_back(175);
2890 >  //nicer_binning.push_back(175);
2891    nicer_binning.push_back(200);
2892 <  nicer_binning.push_back(230);
2893 <  nicer_binning.push_back(280);
2892 >  nicer_binning.push_back(250);
2893 >  nicer_binning.push_back(300);
2894    nicer_binning.push_back(400);
2895    
2896    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2897   }
2898  
2899  
2900 < void zjets_prediction_comparison(string mcjzbWithPU) {
2900 > void zjets_prediction_comparison(string mcjzbWithPUa) {
2901    TCanvas *zcan = new TCanvas("zcan","zcan");  
2902 <  zcan->SetLogy(1);
2902 > //  zcan->SetLogy(1);
2903    TCut weightbackup=cutWeight;
2904 +  
2905 +  bool UsePURW=false;
2906 +  
2907 +  
2908 +  string mcjzb;
2909 +  if(UsePURW) {
2910 +    mcjzb=mcjzbWithPUa;
2911 +  } else {
2912 +    // Do it without PU re-weighting
2913 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2914 +    stringstream resultsNoPU;
2915 +    stringstream noPUdatajzb;
2916 +    stringstream noPUmcjzb;
2917 +    
2918 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2919 +    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2920 +    
2921 +    mcjzb = noPUmcjzb.str();
2922 +    
2923 +    cutWeight="1.0";
2924 +  }
2925  
2642 /*
2643  // Do it without PU re-weighting
2644  float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2645  stringstream resultsNoPU;
2646
2647  stringstream mcjzbnoPU;
2648  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2649  if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2650  else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2651
2652  string mcjzb = mcjzbnoPU.str();
2653  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2654 */
2655 //  cutWeight="1.0";
2656
2657  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2926    
2927    vector<float> binning;
2928    binning.push_back(0);
2929    binning.push_back(10);
2930 <  binning.push_back(30);
2931 <  binning.push_back(50);
2932 < //  binning.push_back(80);
2930 >  binning.push_back(20);
2931 >  binning.push_back(40);
2932 >  binning.push_back(60);
2933 > //   binning.push_back(50);
2934 > //   binning.push_back(60);
2935 > //   binning.push_back(70);
2936 > //   binning.push_back(80);
2937 > //   binning.push_back(90);
2938    binning.push_back(100);
2939 < //  float sbg_min=0.;
2667 < //  float sbg_max=100.;
2668 < //  int sbg_nbins=5;
2939 >
2940    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2941    
2942    TCut kPos((mcjzb+">0").c_str());
2943    TCut kNeg((mcjzb+"<0").c_str());
2944    string var( "abs("+mcjzb+")" );
2945 +  
2946 +  TCut notTau("abs(genMID1)!=15");
2947 +  TCut ONLYTau("mll>20");
2948 +  
2949  
2950 <  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2951 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2952 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2950 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2951 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2952 >  
2953    hJZBpos->SetLineColor(kBlack);
2954    hJZBneg->SetLineColor(kRed);
2955    
# Line 2683 | Line 2958 | void zjets_prediction_comparison(string
2958    hJZBneg->Draw("same,hist");
2959    hJZBpos->Draw("same,e1"); // So it's on top...
2960    
2961 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2961 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2962    leg->AddEntry(hJZBpos,"Observed","pe");
2963    leg->AddEntry(hJZBneg,"Predicted","l");
2964    leg->Draw("same");
2965    DrawMCPrelim(simulatedlumi);
2966 <  CompleteSave(zcan,"Systematics/zjets_prediction");
2966 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
2967    
2968    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
2969    hratio->Divide(hJZBneg);
2970    
2971    for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
2972 <    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << endl;
2972 >    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
2973    }
2974    
2975    zcan->SetLogy(0);
2976 <  hratio->GetYaxis()->SetRangeUser(0,2.5);
2976 >  hratio->GetYaxis()->SetRangeUser(0,2.0);
2977    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2978    hratio->Draw("e1");
2979    
# Line 2715 | Line 2990 | void zjets_prediction_comparison(string
2990    center->Draw("same");
2991    bottom->Draw("same");
2992    
2993 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
2993 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
2994    leg2->AddEntry(hratio,"obs / pred","pe");
2995    leg2->AddEntry(bottom,"syst. envelope","l");
2996    leg2->Draw("same");
2997    DrawMCPrelim(simulatedlumi);
2998 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
2998 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
2999 >  
3000 >  TCut reducedNJets(cutnJets);
3001 >  
3002 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3003 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3004 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3005 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3006 >
3007 >  TH1F *RcorrJZBSBem;
3008 >  TH1F *LcorrJZBSBem;
3009 >  TH1F *RcorrJZBSBeemm;
3010 >  TH1F *LcorrJZBSBeemm;
3011 >
3012 >  if(PlottingSetup::RestrictToMassPeak) {
3013 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3014 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3015 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3016 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3017 >  }
3018 >  
3019 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3020 >  if(PlottingSetup::RestrictToMassPeak) {
3021 >    Bpred->Add(RcorrJZBem,1.0/3.);
3022 >    Bpred->Add(LcorrJZBem,-1.0/3.);
3023 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
3024 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
3025 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
3026 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
3027 >  } else {
3028 >    Bpred->Add(RcorrJZBem,1.0);
3029 >    Bpred->Add(LcorrJZBem,-1.0);
3030 >  }
3031 >  
3032 >  Bpred->SetLineColor(kRed);
3033 >
3034 >  TAUhJZBpos->SetLineColor(kBlack);
3035 >  Bpred->SetLineColor(kRed);
3036 >  
3037 >  TAUhJZBpos->SetMinimum(1.0);
3038 >  TAUhJZBpos->Draw("e1");
3039 >  Bpred->Draw("same,hist");
3040 >  TAUhJZBpos->Draw("same,e1");
3041 >  
3042 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
3043 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
3044 >  TAUleg->AddEntry(Bpred,"Predicted","l");
3045 >  TAUleg->Draw("same");
3046 >  DrawMCPrelim(simulatedlumi);
3047 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
3048 >  
3049 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
3050 >  TAUhratio->Divide(Bpred);
3051 >  
3052 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
3053 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
3054 >  }
3055 >  
3056 >  zcan->SetLogy(0);
3057 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
3058 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
3059 >  TAUhratio->Draw("e1");
3060 >  
3061 >  top->Draw("same");
3062 >  center->Draw("same");
3063 >  bottom->Draw("same");
3064 >  
3065 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
3066 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3067 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
3068 >  TAUleg2->Draw("same");
3069 >  DrawMCPrelim(simulatedlumi);
3070 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
3071 >  
3072 >  delete Bpred;
3073 >  delete TAUhJZBpos;
3074 >  delete LcorrJZBeemm;
3075 >  delete RcorrJZBem;
3076 >  delete LcorrJZBem;
3077 >  
3078 >  if(PlottingSetup::RestrictToMassPeak) {
3079 >    delete RcorrJZBSBem;
3080 >    delete LcorrJZBSBem;
3081 >    delete RcorrJZBSBeemm;
3082 >    delete LcorrJZBSBeemm;
3083 >  }
3084 >  
3085    
3086    delete zcan;
3087    cutWeight=weightbackup;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines