ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C (file contents):
Revision 1.3 by buchmann, Thu Feb 23 15:15:52 2012 UTC vs.
Revision 1.43 by fronga, Mon Jul 30 08:21:48 2012 UTC

# Line 23 | Line 23 | using namespace PlottingSetup;
23   void todo() {
24    dout << "My to do list: " << endl;
25    dout << "  - ExperimentalModule::Poisson_ratio_plot : Get the second part to work!" << endl;
26 +  dout << "  - compare_onpeak_offpeak_signal_distributions: Implement this function ... " << endl;
27    dout << "Info : The trigger requirement is currently set to " << (const char*) passtrig << endl;
28 +  dout << "Info : The pt requirement is currently set to " << (const char*) passtrig << endl;
29 +  dout << "Info : The mll requirement is currently set to " << (const char*) cutmass << endl;
30 +  dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
31 +  dout << "Info : The weight applied to all MC is " << (const char*) cutWeight << endl;
32   }  
33  
34 < void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
34 >
35 >
36 > void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &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 51 | Line 62 | void find_peaks(float &MCPeak,float &MCP
62      reducedMC->Add(rawJZBemMC,-1);
63      reducedData->Add(rawJZBemData,-1);
64      //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
65 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
66 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
67 <    
65 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,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 61 | Line 73 | void find_peaks(float &MCPeak,float &MCP
73      
74   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
75   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
76 <  dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 <  result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
78 <  dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 <  result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
76 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << 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 +  
264 +
265 +  delete RcorrJZBeemm;
266 +  delete LcorrJZBeemm;
267 +  delete RcorrJZBem;
268 +  delete LcorrJZBem;
269 +  if(PlottingSetup::RestrictToMassPeak) {
270 +    delete RcorrJZBSBeemm;
271 +    delete LcorrJZBSBeemm;
272 +    delete RcorrJZBSBem;
273 +    delete LcorrJZBSBem;
274 +  }
275 +  delete Bpred;
276 +  delete ckin;
277 + }
278 +
279   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
280    
281    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
# Line 102 | Line 310 | void make_special_mll_plot(int nbins, fl
310    TIter next(bgleg->GetListOfPrimitives());
311    TObject* obj;
312    // Copy the nice bkgd legend skipping the "data"
313 <  while ( obj = next() )
313 >  while ( (obj = next()) )
314      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
315        kinleg->GetListOfPrimitives()->Add(obj);
316  
# Line 121 | Line 329 | void draw_ratio_plot(TH1* hdata, THStack
329    TIter next(hmc.GetHists());
330    TObject* obj;
331    TH1* hratio = NULL;
332 <  while ( obj = next() ) {
332 >  while ( (obj = next()) ) {
333      if ( !hratio ) {
334        hratio = (TH1*)obj->Clone();
335        hratio->SetName("hratio");
# Line 182 | Line 390 | void make_kin_plot(string variable, stri
390    TCut cut;
391    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
392    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
393 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
394    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
395    if(filename=="mll") {
396          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 193 | Line 402 | void make_kin_plot(string variable, stri
402          draw_separation_lines=true;
403    }
404    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
405 <  if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
405 >  if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
406 >  if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
407 >  if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
408 >  if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
409    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
410    if(filename=="mll_inclusive_osof") cut=cutOSOF;
411    if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
# Line 205 | Line 417 | void make_kin_plot(string variable, stri
417    ckin->SetLogy(logscale);
418    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
419    datahisto->SetMarkerSize(DataMarkerSize);
420 <  THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
420 >  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
421 >  else datahisto->SetMinimum(0.5);
422 >  // Custom max.
423 >  if(variable=="TMath::Abs(pfJetDphiMet[0])") datahisto->SetMaximum(1.5*datahisto->GetMaximum());
424    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
425    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
426 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
426 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
427    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
428    if(filename=="mll_osof") datahisto->SetMinimum(9);
429 +  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
430 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
431  
215  datahisto->SetMaximum(5.3*datahisto->GetMaximum());
216  datahisto->Draw("e1");
217  ckin->Update();
432    if(loadlastminmax) {
433          datahisto->SetMinimum(lastrange_min);
434          datahisto->SetMaximum(lastrange_max);
# Line 224 | Line 438 | void make_kin_plot(string variable, stri
438          }              
439    }
440  
441 +  // Draw signal by hand (for some reason I don't manage to use the sample class: it adds it to the stack!)
442 +  string signal("LM3");
443 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
444 +  int idx = signalsamples.FindSample(signal)[0];
445 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
446 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
447 +  signalhisto->SetLineColor(kOrange);
448 +
449 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
450 +  datahisto->Draw("e1");
451 +  ckin->Update();
452    mcstack.Draw("same");
453 +  
454    datahisto->Draw("same,e1");
455    TLegend *kinleg = allsamples.allbglegend();
456    kinleg->Draw();
# Line 267 | Line 493 | void make_kin_plot(string variable, stri
493          kinpad->SetLogy(logscale);
494          datahisto->Draw("e1");
495          mcstack.Draw("same");
496 +        signalhisto->Draw("same");
497          datahisto->Draw("same,e1");
498          datahisto->Draw("same,axis");
499          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 274 | Line 501 | void make_kin_plot(string variable, stri
501            upperboundary->Draw("same");
502          }
503            
504 +        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
505          kinleg->Draw();
506          write_cut->Draw();
507          DrawPrelim();
# Line 291 | Line 519 | void make_kin_plot(string variable, stri
519    delete ckin;
520   }
521  
522 <
295 < void make_JES_plot() {
522 > void make_JES_plot(TCut cut, string name) {
523  
524    int nbins=10;
525    float min=-0.5;
526    float max = 9.5;
527    bool logscale=true;
528    string xlabel="nJets";
302  TCut cut=cutmass&&cutOSSF&&basiccut;
529  
530    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
531    ckin->SetLogy(logscale);
532 <  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
532 >  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,data,luminosity);
533    datahisto->SetMarkerSize(DataMarkerSize);
534 <  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
535 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
536 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
534 >  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,mc,luminosity);
535 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum40p1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
536 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum40n1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
537  
538    datahisto->SetMinimum(1);
539    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 332 | Line 558 | void make_JES_plot() {
558    TLegend *kinleg = allsamples.allbglegend();
559    kinleg->AddEntry(JESunc,"JES uncertainty","f");
560    kinleg->Draw();
561 <  CompleteSave(ckin,"Systematics/JES");
561 >  CompleteSave(ckin,"Systematics/JES"+name);
562    datahisto->Delete();
563    delete ckin;
564  
# Line 343 | Line 569 | void do_kinematic_plots(string mcjzb, st
569    bool dolog=true;
570    bool nolog=false;
571    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
572 <  float mll_low=40;
572 >  float mll_low=50;
573    float mll_hi=160;
574    if(!PlottingSetup::RestrictToMassPeak) {
575 <        mll_low=30;
576 <        mll_hi=180;
575 >        mll_low=20;
576 >        mll_hi=300;
577    }
578 +
579 +  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
580 +
581    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
582    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
583    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
584    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
585 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
586 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
587 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
588 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
589 <  make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
361 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
362 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
363 <  make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
364 <  make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
365 <  make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
366 <  make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
367 <  make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
368 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
369 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
585 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
586 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
587 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
588 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
589 >  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
590    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
591 +
592 +  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
593 +  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
594 +
595 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
596 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
597 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
598 +
599 +  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
600 + //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
601 + //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
602 +  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
603 +  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
604 +  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
605 +  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
606 +  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
607    stringstream jzbcut;
608    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
609 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
609 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
610 >  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);
611 >  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);
612 >  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);
613 >  stringstream jzbcut2;
614 >  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
615 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
616 >  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);
617 >  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);
618 >  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);
619 >  stringstream jzbcut3;
620 >  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
621 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
622 >  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);
623 >  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);  
624 >  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);  
625 >
626 >  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);
627 >
628 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
629 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
630 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
631 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
632 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
633 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
634 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
635 >
636 >  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
637 >  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
638 >
639 >
640   }
641  
642   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
643                       int nbins, float xmin, float xmax, bool log,
644                       float ymin=0, float ymax=0, bool leftJustified=false ) {
645 <      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
645 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
646  
647    TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
648    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__));
649 <  if(var=="numVtx") cutWeight=TCut("1.0");
649 >  //if(var=="numVtx") cutWeight=TCut("1.0");
650    TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
651    TCut jzbMC[]  = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
652  
# Line 404 | Line 670 | void make_comp_plot( string var, string
670        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
671        ccomp->SetLogy(log);
672        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
673 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
673 >      TH1F *lm3histo  = signalsamples.Draw("lm3histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],data,luminosity,signalsamples.FindSample("LM3"));
674        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
675        datahisto->SetMarkerSize(DataMarkerSize);
676        if (ymax>ymin) datahisto->SetMaximum(ymax);
677 <      lm4histo->SetLineStyle(2);
677 >      lm3histo->SetLineStyle(2);
678        datahisto->Draw("e1");
679        mcstack.Draw("same");
680        datahisto->Draw("same,e1");
681 < //      lm4histo->Draw("hist,same");
681 >      lm3histo->Draw("hist,same");
682        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
683        if ( leftJustified ) {
684          Float_t w = kinleg->GetX2()-kinleg->GetX1();
685          kinleg->SetX1(0.2);
686          kinleg->SetX2(0.2+w);
687        }
688 < //      kinleg->AddEntry(lm4histo,"LM4","l");
688 >      kinleg->AddEntry(lm3histo,"LM3","l");
689        kinleg->Draw();
690        TText* write_variable = write_text(0.99,0.01,var);
691        write_variable->SetTextAlign(31);
# Line 428 | Line 694 | void make_comp_plot( string var, string
694        CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
695        delete datahisto;
696        delete ccomp;
697 <      delete lm4histo;
697 >      delete lm3histo;
698      }
699    cutWeight=weightbackup;
700   }
# Line 438 | Line 704 | void region_comparison_plots(string mcjz
704    dout << "Creating comparison plots for signal and control regions" << endl;
705    // Compare a few quantities in the signal region and all 7 control regions
706  
707 <  switch_overunderflow(true);  // switching overflow/underflow bins on
707 > //  switch_overunderflow(true);  // switching overflow/underflow bins on
708      
709    
710      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
711 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
711 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
712      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
713      float mll_low=50;float mll_high=170;
714      if(!PlottingSetup::RestrictToMassPeak) {
715 <        mll_high=200;
716 <        mll_low=50;
715 >        mll_high=300;
716 >        mll_low=20;
717      }
718 <    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
718 >    make_comp_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",jzbcut,mcjzb,datajzb,100,0,10,true);
719 >    make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
720 >
721 >    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
722      make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
723 <    make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
723 >    make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
724 >    make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
725      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
726 <    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
726 >    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,40,0.,40.,false,0,16.);
727      make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
728      make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
729 +    make_comp_plot("eta1","#eta_1","eta1",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
730 +    make_comp_plot("eta2","#eta_2","eta2",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
731    }
732  
733    switch_overunderflow(false); // switching overflow/underflow bins off
# Line 480 | Line 752 | void signal_bg_comparison()
752    float simulatedlumi=luminosity;//in pb please - adjust to your likings
753    
754    TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
755 <  TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
755 >  TH1F *JZBplotLM4;
756 >  if(PlottingSetup::RestrictToMassPeak) JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
757 >  else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
758    TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
759    
760    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
# Line 504 | Line 778 | void signal_bg_comparison()
778    TLegend *signal_bg_comparison_leg2 =  make_legend("",0.55,0.75,false);
779    signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
780    signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
781 <  signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
781 >  if(PlottingSetup::RestrictToMassPeak) signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
782 >  else signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM3","f");
783    signal_bg_comparison_leg2->Draw();
784    DrawMCPrelim(simulatedlumi);
785    CompleteSave(can,"jzb_bg_vs_signal_distribution");
# Line 746 | Line 1021 | if you want to start from scratch (witho
1021    return return_functions;
1022   }
1023  
1024 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
1024 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1025   {
1026 + //  switch_overunderflow(true);
1027    bool is_data=false;
1028    bool use_signal=false;
1029    if(use_data==1) is_data=true;
# Line 756 | Line 1032 | void do_prediction_plot(string jzb, TCan
1032    if(is_data) nbins=50;
1033    float low=0;
1034    float hi=500;
1035 +  
1036    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1037    TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1038    TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1039    TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1040    TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1041 +
1042    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1043    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
1044    blankback->GetXaxis()->CenterTitle();
# Line 775 | Line 1053 | void do_prediction_plot(string jzb, TCan
1053    TH1F *RcorrJZBeemmNoS;
1054  
1055      //these are for the ratio
1056 +  
1057    TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1058    TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1059    TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
# Line 793 | Line 1072 | void do_prediction_plot(string jzb, TCan
1072      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1073      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1074      LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1075 <
1075 >    
1076      //these are for the ratio
1077      JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1078      JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1079      JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1080      JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
802
1081    }
1082    
1083    TH1F *lm4RcorrJZBeemm;
1084 <  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"));
1084 >  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"));
1085    
1086    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1087    
# Line 812 | Line 1090 | void do_prediction_plot(string jzb, TCan
1090      
1091    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1092    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
1093 +    
1094 +  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1095 +  ClearHisto(BpredSys);
1096 +    
1097    if(PlottingSetup::RestrictToMassPeak) {
1098      Bpred->Add(RcorrJZBem,1.0/3.);
1099      Bpred->Add(LcorrJZBem,-1.0/3.);
# Line 834 | Line 1116 | void do_prediction_plot(string jzb, TCan
1116      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
1117      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
1118      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1119 +      
1120 +    //Systematics:
1121 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1122 +    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1123 +    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1124 +    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1125 +    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1126 +    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1127 +    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1128    } else {
1129      Bpred->Add(RcorrJZBem,1.0);
1130      Bpred->Add(LcorrJZBem,-1.0);
# Line 843 | Line 1134 | void do_prediction_plot(string jzb, TCan
1134      //these are for the ratio
1135      JBpred->Add(JRcorrJZBem,1.0);
1136      JBpred->Add(JLcorrJZBem,-1.0);
1137 +      
1138 +    //Systematics
1139 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1140 +    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1141 +    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1142 +
1143    }
1144      
1145 <  
1145 >  SQRT(BpredSys);
1146 >  BpredSys->Divide(JBpred);
1147 >
1148    
1149    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1150    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
# Line 890 | Line 1189 | void do_prediction_plot(string jzb, TCan
1189    blankback->Draw();
1190    if(use_data==1)
1191    {
1192 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1193 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1194      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1195      kinpad->cd();//necessary because the extended fit function creates its own canvas
1196      RcorrJZBeemm->Draw("e1x0,same");
1197  
1198      Bpred->Draw("hist,same");
1199 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1199 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1200      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1201 +    lm4RcorrJZBeemm->Draw("hist,same");
1202      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1203      legBpred->AddEntry(Bpred,"predicted","l");
1204 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1205 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1206 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1204 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1205 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1206 >    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1207      legBpred->Draw();
1208      DrawPrelim();
1209  
1210      //this plot shows what the prediction is composed of
1211 <    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1212 <    specialcanv->SetLogy(1);
1213 <    Zjetspred->SetFillColor(kYellow);
1214 <    Zjetspred->SetLineColor(kYellow);
1215 <    TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1216 <    TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1211 >    TPad *predcomppad = new TPad("predcomppad","predcomppad",0,0,1,1);
1212 >    float CurrentBpredLineWidth=Bpred->GetLineWidth();
1213 >    Bpred->SetLineWidth(2);
1214 >    predcomppad->cd();
1215 >    predcomppad->SetLogy(1);
1216 >    
1217 >    TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1218 >    TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1219 >    sidebandsemu->Add(jzbnegative,-1);
1220 >    
1221 >    jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1222 >    jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
1223 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1224 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
1225 >    
1226      THStack predcomposition("predcomposition","prediction composition");
1227 <    predcomposition.Add(TTbarpred);
1228 <    predcomposition.Add(Zjetspred);
1227 >    predcomposition.Add(sidebandsemu);
1228 >    predcomposition.Add(jzbnegative);
1229      blankback->Draw();
1230      RcorrJZBeemm->Draw("e1x0,same");
1231      predcomposition.Draw("histo,same");//
1232      Bpred->Draw("hist,same");
1233 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1233 > //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1234      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1235 <    legBpred->Draw();
1235 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1236 >    lm4RcorrJZBeemm->SetLineWidth(2);
1237 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1238 >    lm4RcorrJZBeemm->Draw("histo,same");
1239      DrawPrelim();
1240 <    TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
1241 <    specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
1242 <    specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
1243 <    specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
1244 <    specialleg->Draw("same");
1245 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
1246 <
1247 <    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1240 >    TLegend *speciallegBpred = make_legend("",0.45,0.55);
1241 >    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1242 >    speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1243 >    speciallegBpred->AddEntry(Bpred,"Total background","l");
1244 >    speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1245 >    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1246 >    else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1247 > //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1248 >    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1249 >    speciallegBpred->Draw();
1250 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1251 >    
1252 >    TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1253 >    specialcanv->SetLogy(1);
1254 > //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1255      blankback->Draw();
1256 <    kostack.Draw("same");
1256 > //    kostack.Draw("same");
1257 >    predcomposition.Draw();
1258      Bpred->Draw("hist,same");
1259 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1259 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1260      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1261      legBpred->Draw();
1262      DrawPrelim();
1263 <    CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
1263 >    CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1264 >    Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1265 >    
1266 >    
1267 >    //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;
1268      
1269 <    delete specialcanv;
944 <    delete specialleg;
1269 >    delete speciallegBpred;
1270      delete Zjetspred;
1271      delete TTbarpred;
1272      
# Line 949 | Line 1274 | void do_prediction_plot(string jzb, TCan
1274    }
1275    if(use_data==0) {
1276      RcorrJZBeemm->Draw("e1x0,same");
1277 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1278      Bpred->Draw("hist,same");
1279      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1280 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1281 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1280 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1281 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1282      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1283      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1284      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 963 | Line 1289 | void do_prediction_plot(string jzb, TCan
1289    }
1290    if(use_data==2) {
1291      RcorrJZBeemm->Draw("e1x0,same");
1292 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1293      Bpred->Draw("hist,same");
1294      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1295 <    legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
1295 >    legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1296      legBpred->AddEntry(Bpred,"MC predicted","l");
1297 <    legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
1297 >    legBpred2->AddEntry(RcorrJZBeemm,"MC true","p");
1298      legBpred2->AddEntry(Bpred,"MC predicted","l");
1299      {
1300        if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
# Line 978 | Line 1305 | void do_prediction_plot(string jzb, TCan
1305   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1306      }
1307      {
1308 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1309 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1310 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1311 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1312 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1313 +      
1314        RcorrJZBeemmNoS->SetLineStyle(2);
1315        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1316        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 996 | Line 1329 | void do_prediction_plot(string jzb, TCan
1329    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
1330    string ytitle("ratio");
1331    if ( use_data==1 ) ytitle = "data/pred";
1332 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1332 >  //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1333 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1334  
1335    
1336    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1337 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1338 <  if(!PlottingSetup::RestrictToMassPeak) return;
1339 <  TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1340 <  Bpredem->Add(RcorrJZBem);
1341 <  Bpredem->Add(LcorrJZBem,-1);
1342 <  TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1343 <  BpredSBem->Add(RcorrJZBSBem);
1344 <  Bpred->Add(LcorrJZBSBem,-1);
1345 <  TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1346 <  BpredSBeemm->Add(RcorrJZBSBeemm);
1347 <  BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1348 <  globalcanvas->cd();
1349 <  globalcanvas->SetLogy(1);
1350 <
1351 <  RcorrJZBeemm->SetMarkerStyle(20);
1352 <  RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1353 <  blankback->Draw();
1354 <  RcorrJZBeemm->Draw("e1x0,same");
1355 <  RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1356 <  
1357 <  Bpredem->SetLineColor(kRed+1);
1358 <  Bpredem->SetStats(0);
1359 <  Bpredem->Draw("hist,same");
1360 <
1361 <  BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1362 <  BpredSBem->SetLineStyle(2);
1363 <  BpredSBem->Draw("hist,same");
1364 <
1365 <  BpredSBeemm->SetLineColor(kBlue+1);
1366 <  BpredSBeemm->SetLineStyle(3);
1367 <  BpredSBeemm->Draw("hist,same");
1368 <  RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1369 <
1370 <  TLegend *legBpredc = make_legend("",0.6,0.55);
1371 <  if(use_data==1)
1372 <  {
1373 <    legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1374 <    legBpredc->AddEntry(Bpredem,"OFZP","l");
1375 <    legBpredc->AddEntry(BpredSBem,"OFSB","l");
1376 <    legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1377 <    legBpredc->Draw();
1378 <    CompleteSave(globalcanvas,"Bpred_Data_comparison");
1379 <  }
1380 <  if(use_data==0) {
1381 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1382 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1383 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1384 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1385 <    legBpredc->Draw();
1386 <    CompleteSave(globalcanvas,"Bpred_MC_comparison");
1387 <  }
1388 <  if(use_data==2) {
1389 <    legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
1390 <    legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1391 <    legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1392 <    legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1393 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1394 <    legBpredc->Draw();
1395 <    CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
1337 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1338 >  if(PlottingSetup::RestrictToMassPeak) {
1339 >    TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1340 >    Bpredem->Add(RcorrJZBem);
1341 >    Bpredem->Add(LcorrJZBem,-1);
1342 >    TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
1343 >    BpredSBem->Add(RcorrJZBSBem);
1344 >    Bpred->Add(LcorrJZBSBem,-1);
1345 >    TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");  
1346 >    BpredSBeemm->Add(RcorrJZBSBeemm);
1347 >    BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
1348 >    globalcanvas->cd();
1349 >    globalcanvas->SetLogy(1);
1350 >    
1351 >    RcorrJZBeemm->SetMarkerStyle(20);
1352 >    RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
1353 >    blankback->Draw();
1354 >    RcorrJZBeemm->Draw("e1x0,same");
1355 >    RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
1356 >    
1357 >    Bpredem->SetLineColor(kRed+1);
1358 >    Bpredem->SetStats(0);
1359 >    Bpredem->Draw("hist,same");
1360 >    
1361 >    BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
1362 >    BpredSBem->SetLineStyle(2);
1363 >    BpredSBem->Draw("hist,same");
1364 >    
1365 >    BpredSBeemm->SetLineColor(kBlue+1);
1366 >    BpredSBeemm->SetLineStyle(3);
1367 >    BpredSBeemm->Draw("hist,same");
1368 >    RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1369 >    
1370 >    TLegend *legBpredc = make_legend("",0.6,0.55);
1371 >    if(use_data==1)
1372 >    {
1373 >      legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
1374 >      legBpredc->AddEntry(Bpredem,"OFZP","l");
1375 >      legBpredc->AddEntry(BpredSBem,"OFSB","l");
1376 >      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
1377 >      legBpredc->Draw();
1378 >      CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
1379 >    }
1380 >    if(use_data==0) {
1381 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1382 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1383 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1384 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1385 >      legBpredc->Draw();
1386 >      CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
1387 >    }
1388 >    if(use_data==2) {
1389 >      legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
1390 >      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1391 >      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1392 >      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1393 >      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1394 >      legBpredc->Draw();
1395 >      CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1396 >    }
1397    }
1398 +  
1399 +  TFile *f = new TFile("tester.root","RECREATE");
1400 +  RcorrJZBeemm->Write();
1401 +  Bpred->Write();
1402 +  f->Close();
1403 +  
1404    delete RcorrJZBeemm;
1405    delete LcorrJZBeemm;
1406    delete RcorrJZBem;
# Line 1072 | Line 1413 | void do_prediction_plot(string jzb, TCan
1413  
1414    delete blankback;
1415    
1416 +  delete BpredSys;
1417    if(PlottingSetup::RestrictToMassPeak) {
1418      delete RcorrJZBSBem;
1419      delete LcorrJZBSBem;
# Line 1084 | Line 1426 | void do_prediction_plot(string jzb, TCan
1426      delete JLcorrJZBSBeemm;
1427    }
1428    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1429 +  switch_overunderflow(false);
1430   }
1431  
1432   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1433    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1434 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1435 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1436 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1434 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1435 >  if ( !PlottingSetup::Approved ) {
1436 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1437 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1438 >  } else {
1439 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1440 >  }
1441   }
1442  
1443   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1427 | Line 1774 | void draw_pure_jzb_histo(TCut cut,string
1774    datahisto->Draw("same,e1");
1775    
1776    TLegend *leg;
1777 <  if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1778 <  else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1779 <  else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1780 <  else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1781 <  else {
1782 <    std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1783 <    exit(-1);
1784 <      }
1777 >  if (!PlottingSetup::RestrictToMassPeak) {
1778 >    if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1779 >    else leg = allsamples.allbglegend("Same flavor",datahisto);
1780 >  } else {
1781 >    if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1782 >    else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1783 >    else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1784 >    else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1785 >    else {
1786 >      std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1787 >      exit(-1);
1788 >    }
1789 >  }
1790    leg->Draw();
1791    string write_cut = decipher_cut(cut,"");
1792    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
1793    writeline1->SetTextSize(0.035);
1794    writeline1->Draw();
1795 <  save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1795 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
1796 >  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
1797    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
1798    jzbpad2->cd();
1799    jzbpad2->SetLogy(1);
# Line 1455 | Line 1808 | void draw_pure_jzb_histo(TCut cut,string
1808    writeline1->SetTextSize(0.035);
1809    writeline1->Draw();
1810    DrawPrelim();
1811 <  save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1811 >  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
1812 >  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
1813    datahisto->Delete();
1814    mcstack.Delete();
1815   }
# Line 1463 | Line 1817 | void draw_pure_jzb_histo(TCut cut,string
1817   Double_t GausR(Double_t *x, Double_t *par) {
1818    return gRandom->Gaus(x[0],par[0]);
1819   }
1820 +
1821 + void produce_stretched_jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1822 +  TCanvas *dican = new TCanvas("dican","JZB Plots Canvas");
1823 +  float max=jzbHigh ;
1824 +  float min=-120;
1825 +  int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
1826 +  int coarserbins=int(nbins/2.0);
1827 +  int rebinnedbins=int(nbins/4.0);
1828 +  
1829 +  vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
1830 +  for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
1831 +  for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1832 +  for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1833 +
1834 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP",dican,binning);
1835 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP",dican,binning);
1836 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_SFZP",dican,binning);
1837 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1838 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1839 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1840 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1841 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1842 +  
1843 +  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1844 +  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1845 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1846 +  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1847 +  
1848 +  delete dican;
1849 + }
1850 +  
1851 +
1852 + void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1853 +  vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1854 +  
1855 +  if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
1856 +    write_error(__FUNCTION__,"Could not find any diboson samples - aborting diboson plots");
1857 +    return;
1858 +  }
1859 +  
1860 +  float stretchfactor = 100.0;
1861 +  vector<string> labels;
1862 +  
1863 +  
1864 +  dout << "Going to increase the cross section for diboson samples ... " << endl;
1865 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1866 +    float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1867 +    (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
1868 +    dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
1869 +    labels.push_back((allsamples.collection)[SamplesToBeModified[i]].samplename);
1870 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=any2string(int(stretchfactor))+" x "+(allsamples.collection)[SamplesToBeModified[i]].samplename;
1871 +    dout << "         (also renamed it to " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " )" << endl;
1872 +  }
1873 +  
1874 +  dout << "Going to produce JZB plots" << endl;
1875 +  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1876 +  TCanvas *gloca = new TCanvas("gloca","gloca");
1877 +  
1878 +  dout << "Going to produce prediction plots" << endl;
1879 +  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1880 +  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1881 +  delete gloca;
1882 +
1883 +  dout << "Going to reset the cross section for diboson samples ... " << endl;
1884 +  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
1885 +    float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
1886 +    (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
1887 +    string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
1888 +    (allsamples.collection)[SamplesToBeModified[i]].samplename=labels[i];
1889 +    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;
1890 +    
1891 +  }
1892 +  
1893 + }
1894 +
1895 +
1896 + void draw_normalized_data_vs_data_histo(TCut cut1, TCut cut2, string variable, string legentry1, string legentry2, string savename, TCanvas *can,vector<float> binning) {
1897 +  TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
1898 +  jzbpad->cd();
1899 +  jzbpad->SetLogy(1);
1900 +  string xlabel="JZB [GeV]";
1901 +
1902 +  TH1F *datahisto1 = allsamples.Draw("datahisto1",variable,binning, xlabel, "events",cut1,data,luminosity);
1903 +  datahisto1->SetLineColor(kRed);
1904 +  datahisto1->SetMarkerColor(kRed);
1905 +  TH1F *datahisto2 = allsamples.Draw("datahisto2",variable,binning, xlabel, "events",cut2,data,luminosity);
1906 +  datahisto2->SetLineColor(kBlue);
1907 +  datahisto2->SetMarkerColor(kBlue);
1908 +  
1909 +  datahisto2->SetMarkerSize(DataMarkerSize);
1910 +  datahisto1->DrawNormalized("e1");
1911 +  datahisto2->DrawNormalized("histo,same");
1912 +  datahisto1->DrawNormalized("same,e1");
1913 +  
1914 +  TLegend *leg = make_legend();
1915 +  leg->AddEntry(datahisto1,legentry1.c_str());
1916 +  leg->AddEntry(datahisto2,legentry2.c_str());
1917 +  leg->Draw();
1918 +  
1919 +  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
1920    
1921 +  datahisto1->Delete();
1922 +  datahisto2->Delete();
1923 + }
1924 +
1925 +
1926   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1927    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1928    float max=jzbHigh ;
# Line 1477 | Line 1936 | void jzb_plots(string mcjzb, string data
1936    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
1937    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
1938  
1939 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1940 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1941 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1942 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1943 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1944 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1945 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1946 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1947 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1939 >  if ( !PlottingSetup::Approved ) {
1940 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
1941 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
1942 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
1943 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
1944 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
1945 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
1946 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1947 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1948 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1949 >    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);
1950 >    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);
1951 >    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);
1952 >
1953 >  }
1954    
1955    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
1956 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1957 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1958 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1959 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1960 <
1961 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1962 < //  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1498 < //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1499 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1500 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
1956 >  if ( !PlottingSetup::Approved ) {
1957 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
1958 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1959 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
1960 >    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
1961 >  }
1962 >  delete can;
1963   }
1964  
1965  
# Line 1552 | Line 2014 | void compute_MC_yields(string mcjzb,vect
2014    string posneg[] = {"pos","neg"};
2015    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
2016  
2017 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
2017 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
2018      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
2019      dout << "_________________________________________________________" << endl;
2020      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
2021 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
2021 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
2022        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
2023        else dout << "Sample & ";
2024        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 1815 | Line 2277 | void draw_ttbar_and_zjets_shape_for_one_
2277  
2278   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2279    int all_leptons=-1;
1818  int electrons_only=0;
1819  int mu_only=1;
1820  int twojetswith50gev=1;
2280    int threejetswith30gev=0;
2281   /*  
2282 +  int twojetswith50gev=1;
2283 +  int electrons_only=0;
2284 +  int mu_only=1;
2285 +
2286    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2287    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2288    
# Line 1833 | Line 2296 | void draw_ttbar_and_zjets_shape(string m
2296    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2297   }
2298  
2299 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
1837 <  //first: colorful plots
2299 > float find_one_correction_factor(string FindKeyword, bool dodata, TCut SpecialCut, string SaveAs) {
2300    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2301    cancorr->SetLogz();
2302    cancorr->SetRightMargin(0.13);
2303 <  flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
2304 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2303 >  TCut zptforresponsepresentation(Restrmasscut&&SpecialCut&&passtrig);
2304 >
2305 >  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2306    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2307 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2307 >  niceresponseplotd->Sumw2();
2308 >  TH2F* emuResponse = (TH2F*)niceresponseplotd->Clone("emuResponse");
2309 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2310 >  for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2311 >    if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2312 >    if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2313 >    
2314 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2315 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
2316 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
2317 >  }
2318 >  niceresponseplotd->Add(emuResponse,-1);
2319 >  
2320    niceresponseplotd->SetStats(0);
2321    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2322    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 1849 | Line 2324 | void find_correction_factors(string &jzb
2324    niceresponseplotd->GetYaxis()->CenterTitle();
2325    niceresponseplotd->Draw("COLZ");
2326    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2327 +  profd->Rebin(2);
2328    profd->SetMarkerSize(DataMarkerSize);
2329 <  profd->Fit("pol0","","same,e1",30,400);
2329 >  profd->Fit("pol0","","same,e1",100,400);
2330    DrawPrelim();
2331 <  TText* title = write_text(0.5,0.7,"Data");
2331 >  string stitle="Data";
2332 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2333 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2334    title->SetTextAlign(12);
2335    title->Draw();
2336    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2337 <  float datacorrection=datapol->GetParameter(0);
2338 <  stringstream dataresstring;
2339 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2340 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2337 >  float correction=datapol->GetParameter(0);
2338 >  stringstream resstring;
2339 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2340 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2341    restitle->SetTextAlign(12);
2342    restitle->SetTextSize(0.03);
2343    restitle->Draw();
2344 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2345 <  
2346 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2347 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2348 <  niceresponseplotm->SetStats(0);
2349 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2350 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2351 <  niceresponseplotm->GetXaxis()->CenterTitle();
1874 <  niceresponseplotm->GetYaxis()->CenterTitle();
1875 <  niceresponseplotm->Draw("COLZ");
1876 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
1877 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
1878 <  profm->SetMarkerSize(DataMarkerSize);
1879 <  profm->Fit("pol0","","same,e1",30,400);
1880 <  DrawMCPrelim();
1881 <  title = write_text(0.5,0.7,"MC simulation");
1882 <  title->SetTextAlign(12);
1883 <  title->Draw();
1884 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
1885 <  float mccorrection=mcpol->GetParameter(0);
1886 <  stringstream mcresstring;
1887 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
1888 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
1889 <  mcrestitle->SetTextAlign(12);
1890 <  mcrestitle->SetTextSize(0.03);
1891 <  mcrestitle->Draw();
1892 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2344 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2345 >  delete cancorr;
2346 >  delete niceresponseplotd;
2347 >  delete profd;
2348 >  return correction;
2349 > }
2350 >
2351 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2352    
2353 +  dout << "Computing response corrections: " << endl;
2354 +  //Step 1 : Get results
2355 +  float datacorrection=find_one_correction_factor("Data",true,"","Data");
2356 +  float mccorrection=find_one_correction_factor("DY",false,"","MC");
2357 +  
2358 +  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
2359 +  float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
2360 +  
2361 +  float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
2362 +  float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
2363 +  
2364 +  cout << "Corrections : " << endl;
2365 +  cout << "   Data : " << datacorrection << endl;
2366 +  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2367 +  cout << "   MC : " << mccorrection << endl;
2368 +  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2369    
2370 <  //Step 2: Getting the result
1896 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2370 >  //Step 2: Processing the result and making it into something useful :-)
2371    stringstream jzbvardatas;
2372 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2373 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2372 >  jzbvardatas << "(";
2373 >  
2374 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2375 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2376 >  
2377 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2378 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2379 >  
2380 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2381 >  
2382 >  if(datacorrection>=1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << datacorrection-1 << "*pt))";
2383 >  if(datacorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]+" << 1-datacorrection << "*pt))";
2384 >  
2385 >  jzbvardatas << ")";
2386    jzbvardata=jzbvardatas.str();
2387 +  
2388    stringstream jzbvarmcs;
2389 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2390 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2389 >  jzbvarmcs << "(";
2390 >  
2391 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2392 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2393 >  
2394 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2395 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2396 >  
2397 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2398 >  
2399 >  if(mccorrection>=1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << mccorrection-1 << "*pt))";
2400 >  if(mccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]+" << 1-mccorrection << "*pt))";
2401 >  
2402 >  jzbvarmcs << ")";
2403    jzbvarmc=jzbvarmcs.str();
2404 +
2405    dout << "JZB Z pt correction summary : " << endl;
2406    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2407    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2408 +  
2409   }
2410  
2411   void pick_up_events(string cut) {
# Line 1912 | Line 2413 | void pick_up_events(string cut) {
2413    allsamples.PickUpEvents(cut);
2414   }
2415  
2416 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
2416 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2417    dout << "Saving configuration template!" << endl;
2418    ofstream configfile;
2419    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 1932 | Line 2433 | void save_template(string mcjzb, string
2433    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2434    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2435    configfile<<"vector<float>jzb_cuts;\n";
2436 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2437    configfile<<"float MCPeakError=-999;\n";
2438 +  configfile<<"float DataPeakError=-999;\n";
2439    configfile<<"}\n\n";
2440  
2441    configfile<<"void read_config() {\n";
2442    configfile<<"datajzb=\""<<datajzb<<"\";\n";
2443    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2444 <  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
2445 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2444 >  configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2445 >  configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2446 >  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";
2447 >  configfile<<"\n\n";
2448 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2449 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2450 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2451    configfile<<"\n\n";
2452 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2453 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2454 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2452 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2453 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2454 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2455 >  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";
2456    configfile<<"\n\n";
1948  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1949  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
1950  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2457    configfile<<"\n\n";
2458    configfile<<"luminosity="<<luminosity<<";\n";
2459 +  configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2460    
2461    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2462    
# Line 1972 | Line 2479 | void draw_all_ttbar_histos(TCanvas *can,
2479    float max=histos[0]->GetMaximum();
2480    if(manualmin>=0) min=manualmin;
2481    else {
2482 <    for(int i=1;i<histos.size();i++) {
2482 >    for(int i=1;i<(int)histos.size();i++) {
2483        float curmin=get_nonzero_minimum(histos[i]);
2484        float curmax=histos[i]->GetMaximum();
2485        if(curmin<min) min=curmin;
# Line 1983 | Line 2490 | void draw_all_ttbar_histos(TCanvas *can,
2490    histos[0]->Draw(drawoption.c_str());
2491    stringstream drawopt;
2492    drawopt << drawoption << ",same";
2493 <  for(int i=1;i<histos.size();i++) {
2493 >  for(int i=1;i<(int)histos.size();i++) {
2494      histos[i]->Draw(drawopt.str().c_str());
2495    }
2496   }
# Line 1992 | Line 2499 | void ttbar_sidebands_comparison(string m
2499    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2500    //in the case of the OFF peak analysis, we compare our control region to the real value
2501    TCut weightbackup=cutWeight;
1995  cutWeight="1.0";
1996  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2502    
2503 +  bool doPURW=false;
2504 +  
2505 +  
2506 +  if(!doPURW) {
2507 +    dout << "Not doing PU reweighting for ttbar closure test" << endl;
2508 +    cutWeight="1.0";
2509 +    // Do it without PU re-weighting
2510 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2511 +    stringstream resultsNoPU;
2512 +    stringstream noPUdatajzb;
2513 +    stringstream noPUmcjzb;
2514 +    
2515 +    stringstream mcjzbnoPU;
2516 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2517 +    mcjzb = noPUmcjzb.str();
2518 +  }
2519 +
2520 +      
2521 +  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2522  
2523 <  TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2523 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2524    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2525    TH1F *TSem;
2526    TH1F *nTSem;
2527 <  TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2527 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2528    TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2529    TH1F *TSeemm;
2530    TH1F *nTSeemm;
2531    
2532    if(PlottingSetup::RestrictToMassPeak) {
2533 <    TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2534 <    nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2535 <    TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2533 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2534 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2535 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2536      nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2537    }
2538  
2539    TCanvas *tcan = new TCanvas("tcan","tcan");
2016  
2540    tcan->SetLogy(1);
2541    
2542    TZeemm->SetLineColor(kBlack);
# Line 2032 | Line 2555 | void ttbar_sidebands_comparison(string m
2555    }
2556    
2557    vector<TH1F*> histos;
2558 +  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2559 +  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2560    histos.push_back(TZem);
2561    histos.push_back(TZeemm);
2562    if(PlottingSetup::RestrictToMassPeak) {
2563 +    TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2564 +    TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2565      histos.push_back(TSem);
2566      histos.push_back(TSeemm);
2567    }
2568 <  draw_all_ttbar_histos(tcan,histos,"histo",0.04);
2568 >  draw_all_ttbar_histos(tcan,histos,"histo",1);
2569    
2570    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2571    leg->AddEntry(TZeemm,"SFZP","l");
# Line 2050 | Line 2577 | void ttbar_sidebands_comparison(string m
2577    leg->Draw("same");
2578    DrawMCPrelim(simulatedlumi);
2579    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2053  
2580    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2581    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2582 <  TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2583 <  TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2582 >  TH1F *TSeemmcopy;
2583 >  TH1F *TSemcopy;
2584 >  if(PlottingSetup::RestrictToMassPeak) {
2585 >    TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2586 >    TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2587 >  }
2588  
2589    TZem->Divide(TZeemm);
2590    TZem->SetMarkerStyle(21);
# Line 2063 | Line 2593 | void ttbar_sidebands_comparison(string m
2593      TSeemm->Divide(TZeemm);
2594      TSem->SetMarkerStyle(24);
2595      TSeemm->SetMarkerStyle(32);
2596 < }
2596 >  }
2597  
2598    tcan->SetLogy(0);
2599    TZem->GetYaxis()->SetRangeUser(0,2.5);
# Line 2074 | Line 2604 | void ttbar_sidebands_comparison(string m
2604      TSeemm->Draw("same");
2605    }
2606    
2607 <  float linepos=0.25;
2608 <  if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2607 >  float linepos=emuncertONPEAK;
2608 >  if(!PlottingSetup::RestrictToMassPeak) linepos=emuncertOFFPEAK;
2609 >  
2610    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2611    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2612    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
2613    
2614 +  /*write_warning(__FUNCTION__,"These two lines are to be removed!");
2615 +  TLine *topalt = new TLine(binning[0],1.0+0.1,binning[binning.size()-1],1.0+0.1);
2616 +  TLine *bottomalt = new TLine(binning[0],1.0-0.1,binning[binning.size()-1],1.0-0.1);
2617 +  topalt->SetLineColor(kRed);topalt->SetLineStyle(3);
2618 +  bottomalt->SetLineColor(kRed);bottomalt->SetLineStyle(3);
2619 +  topalt->Draw("same");bottomalt->Draw("same");*/
2620 +  
2621 +  
2622    top->SetLineColor(kBlue);top->SetLineStyle(2);
2623    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
2624    center->SetLineColor(kBlue);
# Line 2103 | Line 2642 | void ttbar_sidebands_comparison(string m
2642    DrawMCPrelim(simulatedlumi);
2643    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2644    
2645 +  if (0) { // Turn this off: we don't need this
2646  
2647 +    ///-------------- second part: only look at the quantity we actually care about!
2648 +    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2649 +    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2650 +    rightsfzp->Add(leftsfzp,-1);
2651 +    TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2652 +    TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2653 +    rightofzp->Add(leftofzp,-1);
2654 +    TH1F *leftofsb;
2655 +    TH1F *rightofsb;
2656 +    TH1F *leftsfsb;
2657 +    TH1F *rightsfsb;
2658 +    if(PlottingSetup::RestrictToMassPeak) {
2659 +      leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2660 +      rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2661 +      rightofsb->Add(leftofsb,-1);
2662 +      leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2663 +      rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2664 +      rightsfsb->Add(leftsfsb,-1);
2665 +    }
2666  
2667 < ///-------------- second part: only look at the quantity we actually care about!
2668 <  TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2669 <  TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2670 <  rightsfzp->Add(leftsfzp,-1);
2671 <  TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2672 <  TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2673 <  rightofzp->Add(leftofzp,-1);
2674 <  TH1F *leftofsb;
2675 <  TH1F *rightofsb;
2676 <  TH1F *leftsfsb;
2118 <  TH1F *rightsfsb;
2119 <  if(PlottingSetup::RestrictToMassPeak) {
2120 <        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2121 <        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2122 <        rightofsb->Add(leftofsb,-1);
2123 <        leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2124 <        rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2125 <        rightsfsb->Add(leftsfsb,-1);
2126 <  }
2667 >    tcan->SetLogy(1);
2668 >    rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2669 >    rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2670 >    rightsfzp->Draw("histo");
2671 >    rightofzp->Draw("histo,same");
2672 >    if(PlottingSetup::RestrictToMassPeak) {
2673 >      rightofsb->Draw("histo,same");
2674 >      rightsfsb->Draw("histo,same");
2675 >    }
2676 >    DrawMCPrelim(simulatedlumi);
2677  
2678 <  tcan->SetLogy(1);
2679 <  rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2680 <  rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2681 <  rightsfzp->Draw("histo");
2682 <  rightofzp->Draw("histo,same");
2683 <  if(PlottingSetup::RestrictToMassPeak) {
2684 <    rightofsb->Draw("histo,same");
2685 <    rightsfsb->Draw("histo,same");
2136 <  }
2137 <  DrawMCPrelim(simulatedlumi);
2678 >    TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2679 >    legA->AddEntry(rightsfzp,"SFZP","l");
2680 >    legA->AddEntry(rightofzp,"OFZP","l");
2681 >    if(PlottingSetup::RestrictToMassPeak) {
2682 >      legA->AddEntry(rightofsb,"SFSB","l");
2683 >      legA->AddEntry(rightsfsb,"OFSB","l");
2684 >    }
2685 >    legA->Draw();
2686  
2687 <  TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2140 <  legA->AddEntry(rightsfzp,"SFZP","l");
2141 <  legA->AddEntry(rightofzp,"OFZP","l");
2142 <  if(PlottingSetup::RestrictToMassPeak) {
2143 <    legA->AddEntry(rightofsb,"SFSB","l");
2144 <    legA->AddEntry(rightsfsb,"OFSB","l");
2145 <  }
2146 <  legA->Draw();
2687 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2688  
2689 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2689 >    tcan->SetLogy(0);
2690 >    rightofzp->Divide(rightsfzp);
2691 >    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2692 >    rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2693 >    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2694 >    rightofzp->Draw();
2695 >    if(PlottingSetup::RestrictToMassPeak) {
2696 >      rightofsb->Divide(rightsfzp);
2697 >      rightsfsb->Divide(rightsfzp);
2698 >      rightofsb->Draw("same");
2699 >      rightsfsb->Draw("same");
2700 >    }
2701  
2702 <  tcan->SetLogy(0);
2703 <  rightofzp->Divide(rightsfzp);
2704 <  rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2705 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
2706 <  rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2707 <  rightofzp->Draw();
2708 <  if(PlottingSetup::RestrictToMassPeak) {
2709 <    rightofsb->Divide(rightsfzp);
2710 <    rightsfsb->Divide(rightsfzp);
2711 <    rightofsb->Draw("same");
2712 <    rightsfsb->Draw("same");
2713 <  }
2702 >    TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2703 >    TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2704 >    TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2705 >  
2706 >    top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2707 >    bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2708 >    center2->SetLineColor(kBlue);
2709 >  
2710 >    top2->Draw("same");
2711 >    center2->Draw("same");
2712 >    bottom2->Draw("same");
2713 >
2714 >    rightofzp->SetMarkerStyle(21);
2715 >    if(PlottingSetup::RestrictToMassPeak) {
2716 >      rightofsb->SetMarkerStyle(24);
2717 >      rightsfsb->SetMarkerStyle(32);
2718 >    }
2719  
2720 <  TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2721 <  TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2722 <  TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2720 >    TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2721 >    leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2722 >    if(PlottingSetup::RestrictToMassPeak) {
2723 >      leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2724 >      leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2725 >    }
2726 >    leg3->AddEntry(bottom,"syst. envelope","l");
2727 >    leg3->SetX1(0.25);leg3->SetX2(0.6);
2728 >    leg3->SetY1(0.65);
2729    
2730 <  top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2168 <  bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2169 <  center2->SetLineColor(kBlue);
2730 >    leg3->Draw("same");
2731    
2732 <  top2->Draw("same");
2733 <  center2->Draw("same");
2173 <  bottom2->Draw("same");
2732 >    DrawMCPrelim(simulatedlumi);
2733 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2734  
2175  rightofzp->SetMarkerStyle(21);
2176  if(PlottingSetup::RestrictToMassPeak) {
2177    rightofsb->SetMarkerStyle(24);
2178    rightsfsb->SetMarkerStyle(32);
2735    }
2736  
2181  TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2182  leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2183  if(PlottingSetup::RestrictToMassPeak) {
2184        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2185        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2186  }
2187  leg3->AddEntry(bottom,"syst. envelope","l");
2188  leg3->SetX1(0.25);leg3->SetX2(0.6);
2189  leg3->SetY1(0.65);
2190  
2191  leg3->Draw("same");
2192  
2193  DrawMCPrelim(simulatedlumi);
2194  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2195
2737    delete TZem;
2738    delete nTZem;
2739    delete TZeemm;
# Line 2210 | Line 2751 | void ttbar_sidebands_comparison(string m
2751  
2752   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
2753    vector<float> nicer_binning;
2754 <  nicer_binning.push_back(-125);
2754 >  
2755 > /*  nicer_binning.push_back(-400);
2756 >  nicer_binning.push_back(-250);
2757 >  nicer_binning.push_back(-200);
2758 >  nicer_binning.push_back(-150);
2759 >  nicer_binning.push_back(-100);
2760 >  nicer_binning.push_back(-50);
2761 >  nicer_binning.push_back(-20);
2762 >  
2763 >  nicer_binning.push_back(0);
2764 >  nicer_binning.push_back(20);
2765 >  nicer_binning.push_back(50);
2766 >  nicer_binning.push_back(100);
2767 >  nicer_binning.push_back(150);
2768 >  nicer_binning.push_back(200);
2769 >  nicer_binning.push_back(250);
2770 >  nicer_binning.push_back(400);*/
2771 >  
2772    nicer_binning.push_back(-100);
2215  nicer_binning.push_back(-75);
2773    nicer_binning.push_back(-50);
2774    nicer_binning.push_back(-25);
2775    nicer_binning.push_back(0);
# Line 2222 | Line 2779 | void ttbar_sidebands_comparison(string m
2779    nicer_binning.push_back(100);
2780    nicer_binning.push_back(125);
2781    nicer_binning.push_back(150);
2782 <  nicer_binning.push_back(175);
2782 >  //nicer_binning.push_back(175);
2783    nicer_binning.push_back(200);
2784 <  nicer_binning.push_back(230);
2785 <  nicer_binning.push_back(280);
2784 >  nicer_binning.push_back(250);
2785 >  nicer_binning.push_back(300);
2786    nicer_binning.push_back(400);
2787 +  
2788    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2789   }
2790  
2791  
2792 < void zjets_prediction_comparison() {
2793 <  // Do it without PU re-weighting
2794 <  float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2795 <  stringstream resultsNoPU;
2796 <
2797 <  stringstream mcjzbnoPU;
2798 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2799 <  if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2800 <  else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2792 > void zjets_prediction_comparison(string mcjzbWithPUa) {
2793 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2794 > //  zcan->SetLogy(1);
2795 >  TCut weightbackup=cutWeight;
2796 >  
2797 >  bool UsePURW=false;
2798 >  
2799 >  
2800 >  string mcjzb;
2801 >  if(UsePURW) {
2802 >    mcjzb=mcjzbWithPUa;
2803 >  } else {
2804 >    // Do it without PU re-weighting
2805 >    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2806 >    stringstream resultsNoPU;
2807 >    stringstream noPUdatajzb;
2808 >    stringstream noPUmcjzb;
2809 >    
2810 >    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2811 >    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2812 >    
2813 >    mcjzb = noPUmcjzb.str();
2814 >    
2815 >    cutWeight="1.0";
2816 >  }
2817  
2818 <  string mcjzb = mcjzbnoPU.str();
2819 <  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2818 >  
2819 >  vector<float> binning;
2820 >  binning.push_back(0);
2821 >  binning.push_back(10);
2822 >  binning.push_back(20);
2823 >  binning.push_back(40);
2824 >  binning.push_back(60);
2825 > //   binning.push_back(50);
2826 > //   binning.push_back(60);
2827 > //   binning.push_back(70);
2828 > //   binning.push_back(80);
2829 > //   binning.push_back(90);
2830 >  binning.push_back(100);
2831  
2247  TCut weightbackup=cutWeight;
2248  cutWeight="1.0";
2249  float sbg_min=0.;
2250  float sbg_max=100.;
2251  int sbg_nbins=5;
2832    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2833    
2834    TCut kPos((mcjzb+">0").c_str());
2835    TCut kNeg((mcjzb+"<0").c_str());
2836    string var( "abs("+mcjzb+")" );
2837 +  
2838 +  TCut notTau("abs(genMID1)!=15");
2839 +  TCut ONLYTau("mll>20");
2840 +  
2841  
2842 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2843 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2844 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2261 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2262 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2842 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2843 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2844 >  
2845    hJZBpos->SetLineColor(kBlack);
2846    hJZBneg->SetLineColor(kRed);
2847    
2848 <  Int_t nbins = 5;
2267 <  Float_t xmax = 100.;
2268 <
2269 <  
2270 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2271 <  zcan->SetLogy(1);
2272 <
2848 >  hJZBpos->SetMinimum(1.0);
2849    hJZBpos->Draw("e1");
2850    hJZBneg->Draw("same,hist");
2851    hJZBpos->Draw("same,e1"); // So it's on top...
2852    
2853 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2853 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2854    leg->AddEntry(hJZBpos,"Observed","pe");
2855    leg->AddEntry(hJZBneg,"Predicted","l");
2856    leg->Draw("same");
2857    DrawMCPrelim(simulatedlumi);
2858 <  CompleteSave(zcan,"Systematics/zjets_prediction");
2858 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
2859    
2860    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
2861    hratio->Divide(hJZBneg);
2862    
2863 +  for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
2864 +    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
2865 +  }
2866 +  
2867    zcan->SetLogy(0);
2868 <  hratio->GetYaxis()->SetRangeUser(0,2.5);
2868 >  hratio->GetYaxis()->SetRangeUser(0,2.0);
2869    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2870    hratio->Draw("e1");
2871    
2872 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
2873 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
2874 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
2872 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
2873 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2874 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
2875    
2876  
2877    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2302 | Line 2882 | void zjets_prediction_comparison() {
2882    center->Draw("same");
2883    bottom->Draw("same");
2884    
2885 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
2885 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
2886    leg2->AddEntry(hratio,"obs / pred","pe");
2887    leg2->AddEntry(bottom,"syst. envelope","l");
2888    leg2->Draw("same");
2889    DrawMCPrelim(simulatedlumi);
2890 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
2890 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
2891 >  
2892 >  TCut reducedNJets(cutnJets);
2893 >  
2894 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2895 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2896 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2897 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2898 >
2899 >  TH1F *RcorrJZBSBem;
2900 >  TH1F *LcorrJZBSBem;
2901 >  TH1F *RcorrJZBSBeemm;
2902 >  TH1F *LcorrJZBSBeemm;
2903 >
2904 >  if(PlottingSetup::RestrictToMassPeak) {
2905 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2906 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2907 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2908 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2909 >  }
2910 >  
2911 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
2912 >  if(PlottingSetup::RestrictToMassPeak) {
2913 >    Bpred->Add(RcorrJZBem,1.0/3.);
2914 >    Bpred->Add(LcorrJZBem,-1.0/3.);
2915 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
2916 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
2917 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
2918 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
2919 >  } else {
2920 >    Bpred->Add(RcorrJZBem,1.0);
2921 >    Bpred->Add(LcorrJZBem,-1.0);
2922 >  }
2923 >  
2924 >  Bpred->SetLineColor(kRed);
2925 >
2926 >  TAUhJZBpos->SetLineColor(kBlack);
2927 >  Bpred->SetLineColor(kRed);
2928 >  
2929 >  TAUhJZBpos->SetMinimum(1.0);
2930 >  TAUhJZBpos->Draw("e1");
2931 >  Bpred->Draw("same,hist");
2932 >  TAUhJZBpos->Draw("same,e1");
2933 >  
2934 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
2935 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
2936 >  TAUleg->AddEntry(Bpred,"Predicted","l");
2937 >  TAUleg->Draw("same");
2938 >  DrawMCPrelim(simulatedlumi);
2939 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
2940 >  
2941 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
2942 >  TAUhratio->Divide(Bpred);
2943 >  
2944 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
2945 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
2946 >  }
2947 >  
2948 >  zcan->SetLogy(0);
2949 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
2950 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
2951 >  TAUhratio->Draw("e1");
2952 >  
2953 >  top->Draw("same");
2954 >  center->Draw("same");
2955 >  bottom->Draw("same");
2956 >  
2957 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
2958 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
2959 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
2960 >  TAUleg2->Draw("same");
2961 >  DrawMCPrelim(simulatedlumi);
2962 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
2963 >  
2964 >  delete Bpred;
2965 >  delete TAUhJZBpos;
2966 >  delete LcorrJZBeemm;
2967 >  delete RcorrJZBem;
2968 >  delete LcorrJZBem;
2969 >  
2970 >  if(PlottingSetup::RestrictToMassPeak) {
2971 >    delete RcorrJZBSBem;
2972 >    delete LcorrJZBSBem;
2973 >    delete RcorrJZBSBeemm;
2974 >    delete LcorrJZBSBeemm;
2975 >  }
2976 >  
2977    
2978    delete zcan;
2979    cutWeight=weightbackup;
# Line 2333 | Line 2999 | void sideband_assessment(string datajzb,
2999    tout << "\\begin{tabular}{l|cc}" << endl;
3000    tout << "\\hline" << endl;
3001    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
3002 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
3002 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
3003    tout << "\\end{tabular}" << endl;
3004    tout << "\\end{center}" << endl;
3005    tout << "\\end{table}" << endl;
# Line 2351 | Line 3017 | void make_table(samplecollection &coll,
3017    
3018    TCanvas *cannie = new TCanvas("cannie","cannie");
3019    
3020 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
3020 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
3021      float currcut=jzb_cuts[icut];
3022      int nbins=1;float low=currcut;
3023      vector<int> mysample;
# Line 2410 | Line 3076 | void make_table(samplecollection &coll,
3076    //prediction part
3077    if(is_data) cout << "Data prediction & ";
3078    if(subselection!="none") cout << subselection << " prediction &";
3079 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3079 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3080    
3081    cout << endl;
3082    //observation part
3083    if(is_data) cout << "Data observation & ";
3084    if(subselection!="none") cout << subselection << " observation &";
3085 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3085 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3086    cout << endl;
3087    cout << "_________________________________________________________________" << endl;
3088    delete cannie;
# Line 2451 | Line 3117 | void JZBSelEff(string mcjzb, TTree* even
3117    int nbins = sizeof(xbins)/sizeof(float)-1;
3118    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
3119  
3120 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3121 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3122 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3120 >  
3121 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
3122 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
3123 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
3124  
3125    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
3126    TCut kreco(cutmass);
# Line 2469 | Line 3136 | void JZBSelEff(string mcjzb, TTree* even
3136    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
3137    can->SetGridx(1);
3138    can->SetGridy(1);
3139 +  can->SetLeftMargin(0.16);
3140 +  can->SetRightMargin(0.05);
3141    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
3142 +  leg->SetBorderSize(1);
3143 +  leg->SetLineColor(kBlack);
3144 +  leg->SetTextFont(62);
3145  
3146 <  
2475 <
2476 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
3146 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
3147  
3148      ostringstream selection;
3149      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2489 | Line 3159 | void JZBSelEff(string mcjzb, TTree* even
3159      }
3160    
3161      heff->GetXaxis()->SetRangeUser(min, max);
3162 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
3163 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
3164 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
3165 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
3166      heff->SetMarkerStyle(markers[icut]);
3167      heff->Fit("func","Q+","same");
3168  
# Line 2500 | Line 3174 | void JZBSelEff(string mcjzb, TTree* even
3174  
3175      // Store plot
3176      TH1F* h = (TH1F*)heff->Clone(hname);
3177 +    h->SetNdivisions(505,"X");
3178      if ( icut) h->Draw("same");
3179      else h->Draw();
3180      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2520 | Line 3195 | void JZBSelEff(string mcjzb, TTree* even
3195   // Calls the above function for each signal sample
3196   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
3197   {  
3198 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
3198 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
3199      dout << "JZB selection efficiency curve: " << std::endl;
3200      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
3201    }
# Line 2563 | Line 3238 | void qcd_plots(string datajzb, string mc
3238    TH1F *RcorrJZBSBeemm;
3239    TH1F *LcorrJZBSBeemm;
3240    
3241 <  TH1F *RcorrJZBeemmNoS;
3241 > //  TH1F *RcorrJZBeemmNoS;
3242  
3243      //these are for the ratio
3244    TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2647 | Line 3322 | void qcd_plots(string datajzb, string mc
3322    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3323    string ytitle("ratio");
3324    if ( use_data==1 ) ytitle = "data/pred";
3325 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
3325 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
3326    
3327    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
3328    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 2694 | Line 3369 | void qcd_plots(string datajzb, string mc
3369    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
3370    
3371    dout << endl;
3372 <  for(int i=0;i<bins.size();i++) {
3372 >  for(int i=0;i<(int)bins.size();i++) {
3373      dout << " JZB > " << bins[i] << " : " << endl;
3374      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3375      if(PlottingSetup::RestrictToMassPeak) {
# Line 2717 | Line 3392 | void qcd_plots(string datajzb, string mc
3392    if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3393   }
3394  
3395 + void check_ptsanity() {
3396 +  TCanvas *ptsancan = new TCanvas("ptsancan","ptsancan",600,1800);
3397 +  TH1F *individualpt1histos[allsamples.collection.size()];
3398 +  TH1F *individualpt2histos[allsamples.collection.size()];
3399 +  TH1F *fpt1 = new TH1F("fpt1","fpt1",50,0,50);
3400 +  fpt1->GetYaxis()->SetRangeUser(0,1);
3401 +  fpt1->GetXaxis()->SetTitle("p_{T,1}");
3402 +  fpt1->GetXaxis()->CenterTitle();
3403 +
3404 +  TH1F *fpt2 = new TH1F("fpt2","fpt2",50,0,50);
3405 +  fpt2->GetXaxis()->SetTitle("p_{T,2}");
3406 +  fpt2->GetXaxis()->CenterTitle();
3407 +  
3408 +  ptsancan->Divide(1,3);
3409 +  ptsancan->cd(1);
3410 +  float maxpt1entry=0;
3411 +  float maxpt2entry=0;
3412 +  
3413 +  TLegend *leg = make_legend();
3414 +  leg->SetX1(0.0);
3415 +  leg->SetY1(0.0);
3416 +  leg->SetX2(1.0);
3417 +  leg->SetY2(1.0);
3418 +  
3419 +  
3420 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3421 +    string nowname=(allsamples.collection)[isample].filename;
3422 +    cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3423 +    individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3424 +    individualpt2histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt2",50,0,50, "p_{T,2}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
3425 +    individualpt1histos[isample]->SetLineColor(isample+1);
3426 +    individualpt2histos[isample]->SetLineColor(isample+1);
3427 +    float currmaxpt1entry=individualpt1histos[isample]->GetMaximum()/individualpt1histos[isample]->Integral();
3428 +    float currmaxpt2entry=individualpt2histos[isample]->GetMaximum()/individualpt2histos[isample]->Integral();
3429 +    cout << "      pt 1 histo contains; " << individualpt1histos[isample]->Integral() << endl;
3430 +    cout << "      pt 2 histo contains; " << individualpt2histos[isample]->Integral() << endl;
3431 +    if(currmaxpt1entry>maxpt1entry)maxpt1entry=currmaxpt1entry;
3432 +    if(currmaxpt2entry>maxpt2entry)maxpt2entry=currmaxpt2entry;
3433 +    leg->AddEntry(individualpt2histos[isample],((allsamples.collection)[isample].filename).c_str(),"f");
3434 +  }
3435 +
3436 +  fpt1->GetYaxis()->SetRangeUser(0,maxpt1entry);
3437 +  fpt2->GetYaxis()->SetRangeUser(0,maxpt2entry);
3438 +
3439 +  ptsancan->cd(1);
3440 +  fpt1->Draw();
3441 +  ptsancan->cd(2);
3442 +  fpt2->Draw();
3443 +
3444 +  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3445 +    ptsancan->cd(1);
3446 +    individualpt1histos[isample]->DrawNormalized("same,histo");
3447 +    ptsancan->cd(2);
3448 +    individualpt2histos[isample]->DrawNormalized("same,histo");
3449 +  }
3450 +  ptsancan->cd(3);
3451 +  leg->Draw();
3452 +  CompleteSave(ptsancan,"PtSanityCheck");
3453 +  
3454 +  delete ptsancan;
3455 + }
3456 +
3457 + void do_mlls_plot(string mcjzb) {
3458 +  cout << "At this point we'd plot the mll distribution" << endl;
3459 +  TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3460 +  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3461 +    if(!(signalsamples.collection)[isig].events) continue;
3462 +    string nowname=(signalsamples.collection)[isig].filename;
3463 +    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
3464 + //    TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events","",mc,luminosity,signalsamples.FindSample(nowname));
3465 +    mll->SetLineColor(TColor::GetColor("#04B404"));
3466 +    stringstream poscutS;
3467 +    poscutS << "((" << mcjzb <<")>50)";
3468 +    TCut poscut(poscutS.str().c_str());
3469 +    TH1F *mllP = signalsamples.Draw("mllhistoP","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets&&poscut,mc,luminosity,signalsamples.FindSample(nowname));
3470 +    mllP->SetLineColor(TColor::GetColor("#0040FF"));
3471 +    mll->Draw("histo");
3472 +    mllP->Draw("histo,same");
3473 +    TLegend *leg = make_legend();
3474 +    leg->SetY1(0.8);
3475 +    leg->AddEntry(mll,(signalsamples.collection)[isig].samplename.c_str(),"L");
3476 +    leg->AddEntry(mllP,((signalsamples.collection)[isig].samplename+", JZB>50").c_str(),"L");
3477 +    leg->Draw();
3478 +    TLine *lin = new TLine(71.2,0,71.2,mll->GetMaximum());
3479 +    TLine *lin2 = new TLine(111.2,0,111.2,mll->GetMaximum());
3480 +    lin->Draw("same");
3481 +    lin2->Draw("same");
3482 +    
3483 +    CompleteSave(sigcan,"MllShape/"+(signalsamples.collection)[isig].samplename);
3484 +    delete mll;
3485 +    delete mllP;
3486 +  }
3487 + }
3488 +
3489 + void met_vs_jzb_plots() {
3490 +  
3491 +  TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3492 +  canmetjzb->SetRightMargin(0.16);
3493 +  
3494 +  vector<string> findme;
3495 +  findme.push_back("DY");
3496 +  findme.push_back("TTJets");
3497 +  findme.push_back("LM");
3498 +  
3499 +  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3500 +    vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3501 +    TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3502 +    for(int isel=0;isel<(int)selsamples.size();isel++) {
3503 +      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3504 +      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3505 +    }
3506 +    metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3507 +    metvsjzb->SetStats(0);
3508 +    metvsjzb->GetXaxis()->SetTitle("MET (GeV)");
3509 +    metvsjzb->GetYaxis()->SetTitle("JZB (GeV)");
3510 +    metvsjzb->GetXaxis()->CenterTitle();
3511 +    metvsjzb->GetYaxis()->CenterTitle();
3512 +    metvsjzb->Draw("COLZ");
3513 +    TText* title = write_text(0.5,0.95,allsamples.collection[selsamples[0]].samplename);
3514 +    title->SetTextAlign(12);
3515 +    title->Draw();
3516 +    CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3517 +  }
3518 + }
3519 +    
3520 +
3521   void test() {
3522    
3523    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
3524    testcanv->cd();
3525 <  switch_overunderflow(true);
3525 > //  switch_overunderflow(true);
3526    TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
3527    switch_overunderflow(false);
3528    ptdistr->Draw();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines