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.12 by buchmann, Wed Apr 18 09:20:36 2012 UTC vs.
Revision 1.50 by buchmann, Wed Aug 15 13:52:12 2012 UTC

# Line 28 | Line 28 | void todo() {
28    dout << "Info : The pt requirement is currently set to " << (const char*) passtrig << endl;
29    dout << "Info : The mll requirement is currently set to " << (const char*) cutmass << endl;
30    dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
31 +  dout << "Info : The weight applied to all MC is " << (const char*) cutWeight << endl;
32   }  
33  
34 < void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
34 >
35 >
36 > void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &MCSigmaError, float &DataSigma, float& DataSigmaError, stringstream &result, bool doPUreweighting = true, string saveas="")
37   {
38    // Temporarily switch off PU reweighting, if asked
39    TCut weightbackup=cutWeight;
40    if ( !doPUreweighting ) cutWeight="1.0";
41 <
41 >  
42 >  int nbins=100;
43 >  if(PlottingSetup::DoBTag) nbins=25;
44 >  
45    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
46 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
47 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
48 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
49 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
46 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,mc, luminosity);
47 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,data, luminosity);
48 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,mc, luminosity);
49 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,data, luminosity);
50    TH1F *rawttbarjzbeemmMC;
51  
52    if(method==doKM) {
53      //we only need this histo for the KM fitting...
54 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
55 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
56 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
54 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
55 >    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,MCSigmaError,method,saveas);
56 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
57 >    delete rawttbarjzbeemmMC;
58    }
59    else {
60      TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
# Line 55 | Line 62 | void find_peaks(float &MCPeak,float &MCP
62      reducedMC->Add(rawJZBemMC,-1);
63      reducedData->Add(rawJZBemData,-1);
64      //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
65 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
66 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
67 <    
65 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,MCSigmaError,method,saveas);
66 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
67 >    delete reducedMC;
68 >    delete reducedData;
69    }
70  
71    // Revert to original PU reweighting
# Line 65 | Line 73 | void find_peaks(float &MCPeak,float &MCP
73      
74   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
75   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
76 <  dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 <  result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
78 <  dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 <  result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
76 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
77 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
78 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
79 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
80 >  delete rawJZBeemmData;
81 >  delete rawJZBeemmMC;
82 >  delete rawJZBemData;
83 >  delete rawJZBemMC;
84    delete tempcan;
85   }
86  
87 < void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
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=10;
159 <    max=150;
158 >    min=20;
159 >    max=300;
160    }
161 <  int nbins=int((max-min)/5);
161 >  int nbins=int((max-min)/binWidth);
162    
163    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
164    
165    stringstream largerzeroS;
166 <  largerzeroS << "(" << mcjzb << ">" << jzbthreshold << ")";
167 <  TCut largerzero(largerzeroS.str().c_str());
166 >  largerzeroS << "(" << datajzb << ">" << jzbthreshold << ")";
167 >  TCut largerzeroD(largerzeroS.str().c_str());
168    
169    stringstream smallerzeroS;
170 <  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
171 <  TCut smallerzero(smallerzeroS.str().c_str());
172 <  
173 <  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,data,luminosity);
174 <  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,mc,luminosity);
175 <  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,data,luminosity);
176 <  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,data,luminosity);
177 <  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,data,luminosity);
170 >  smallerzeroS << "(" << datajzb << "<-" << jzbthreshold << ")";
171 >  TCut smallerzeroD(smallerzeroS.str().c_str());
172 >
173 >
174 >  stringstream largerzeroMS;
175 >  largerzeroMS << "(" << mcjzb << ">" << jzbthreshold << ")";
176 >  TCut largerzeroM(largerzeroMS.str().c_str());
177 >  
178 >  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroD,data,luminosity);
179 >  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroM,mc,luminosity);
180 >  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzeroD,data,luminosity);
181 >  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzeroD,data,luminosity);
182 >  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzeroD,data,luminosity);
183  
184    TH1F *RcorrJZBSBem;
185    TH1F *LcorrJZBSBem;
186    TH1F *RcorrJZBSBeemm;
187    TH1F *LcorrJZBSBeemm;
188    
189 <  TH1F *RcorrJZBeemmNoS;
189 > //  TH1F *RcorrJZBeemmNoS;
190  
191 <  if(PlottingSetup::RestrictToMassPeak) {
192 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,data, luminosity);
193 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,data, luminosity);
194 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,data, luminosity);
195 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,data, luminosity);
196 <  }
197 <  
198 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
199 <  if(PlottingSetup::RestrictToMassPeak) {
200 <    Bpred->Add(RcorrJZBem,1.0/3.);
201 <    Bpred->Add(LcorrJZBem,-1.0/3.);
202 <    Bpred->Add(RcorrJZBSBem,1.0/3.);
203 <    Bpred->Add(LcorrJZBSBem,-1.0/3.);
204 <    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
205 <    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
206 <  } else {
207 <    Bpred->Add(RcorrJZBem,1.0);
208 <    Bpred->Add(LcorrJZBem,-1.0);
209 <  }
210 <  
191 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
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&&PlottingSetup::UseSidebandsForcJZB) {
203 >    OFP->Scale(1.0/3.0);
204 >    OFP->Add(RcorrJZBSBem,1.0/3.);
205 >    OFP->Add(RcorrJZBSBeemm,1.0/3.);
206 >    OFN->Scale(1.0/3.0);
207 >    OFN->Add(LcorrJZBSBem,1.0/3.);
208 >    OFN->Add(LcorrJZBSBeemm,1.0/3.);
209 >  }
210 >
211 >  TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
212 >  Bpred->Add(OFP);
213 >  Bpred->Add(OFN,-1);
214    Bpred->SetLineColor(kRed);
215    
216 +  RcorrJZBeemm->SetTitleOffset(1.3,"y");
217    RcorrJZBeemm->Draw();
218    mcRcorrJZBeemm.Draw("same");
219    Bpred->Draw("histo,same");
# Line 140 | Line 228 | void make_special_obs_pred_mll_plot(stri
228    stringstream saveas;
229    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
230    CompleteSave(ckin,saveas.str());
231 <
231 >  
232 >  // Draw all predictions overlayed
233 >  unsigned int w = gStyle->GetHistLineWidth()+1; // Make line a bit wider, since we dash it
234 >  SFN->SetLineColor(kGreen+2);
235 >  SFN->SetLineStyle(2);
236 >  SFN->SetLineWidth(w);
237 >  OFP->SetLineColor(kBlue+2);
238 >  OFP->SetLineStyle(2);
239 >  OFP->SetLineWidth(w);
240 >  OFN->SetLineColor(kMagenta+2);
241 >  OFN->SetLineStyle(3);
242 >  OFN->SetLineWidth(w);
243 >  
244 >  RcorrJZBeemm->Draw();
245 >  SFN->Draw("histo,same");
246 >  OFP->Draw("histo,same");
247 >  OFN->Draw("histo,same");
248 >  Bpred->Draw("histo,same");
249 >  RcorrJZBeemm->Draw("same");
250 >  
251 >  TLegend *leg2 = make_legend("",0.52,0.7);
252 >  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
253 >  leg2->AddEntry(Bpred,"predicted (data)","l");
254 >  leg2->AddEntry(SFN,  "  SF JZB<0","l");
255 >  leg2->AddEntry(OFN,  "  OF JZB<0","l");
256 >  leg2->AddEntry(OFP,  "  OF JZB>0","l");
257 >  leg2->Draw("same");
258 >  
259 >  saveas.str("");
260 >  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
261 >  CompleteSave(ckin,saveas.str());
262 >  
263    delete RcorrJZBeemm;
264    delete LcorrJZBeemm;
265    delete RcorrJZBem;
266    delete LcorrJZBem;
267 <  if(PlottingSetup::RestrictToMassPeak) {
267 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
268      delete RcorrJZBSBeemm;
269      delete LcorrJZBSBeemm;
270      delete RcorrJZBSBem;
# Line 189 | Line 308 | void make_special_mll_plot(int nbins, fl
308    TIter next(bgleg->GetListOfPrimitives());
309    TObject* obj;
310    // Copy the nice bkgd legend skipping the "data"
311 <  while ( obj = next() )
311 >  while ( (obj = next()) )
312      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
313        kinleg->GetListOfPrimitives()->Add(obj);
314  
# Line 208 | Line 327 | void draw_ratio_plot(TH1* hdata, THStack
327    TIter next(hmc.GetHists());
328    TObject* obj;
329    TH1* hratio = NULL;
330 <  while ( obj = next() ) {
330 >  while ( (obj = next()) ) {
331      if ( !hratio ) {
332        hratio = (TH1*)obj->Clone();
333        hratio->SetName("hratio");
# Line 239 | Line 358 | void draw_ratio_plot(TH1* hdata, THStack
358    oneline->Draw("same");
359   }
360  
361 + void make_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, bool logscale,
362 +                   string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.3) {
363 +
364 +  TCut ibasiccut=basiccut;
365 +  bool draw_separation_lines=false;
366 +
367 +  if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
368 +
369 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
370 +
371 +  TCut cutSF;
372 +  TCut cutOF;
373 +
374 +  cutOF=cutOSOF&&cutnJets&&ibasiccut;
375 +  cutSF=cutOSSF&&cutnJets&&ibasiccut;
376 +
377 +
378 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
379 +  ckin->SetLogy(logscale);
380 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
381 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
382 +  string signal("LM3");
383 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
384 +  int idx = signalsamples.FindSample(signal)[0];
385 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
386 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
387 +  signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
388 +  datahistoSF->SetMarkerSize(DataMarkerSize);
389 +  datahistoOF->SetLineColor(kRed);
390 +
391 +  if ( !logscale ) {
392 +    datahistoSF->SetMinimum(0); // Defaults
393 +    datahistoOF->SetMinimum(0); // Defaults
394 +  } else {
395 +    datahistoSF->SetMinimum(0.5);
396 +    datahistoOF->SetMinimum(0.5);
397 +  }
398 +  if (logscale) {
399 +    datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
400 +    datahistoOF->SetMaximum(5.3*datahistoSF->GetMaximum());
401 +  } else {
402 +    datahistoSF->SetMaximum(2.0*datahistoSF->GetMaximum());
403 +    datahistoOF->SetMaximum(2.0*datahistoOF->GetMaximum());
404 +  }
405 +
406 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
407 +  datahistoOF->GetXaxis()->SetTitle(xlabel.c_str());
408 +  signalhisto->GetXaxis()->SetTitle(xlabel.c_str());
409 +  datahistoSF->GetYaxis()->SetTitle("N. Events");
410 +  datahistoOF->GetYaxis()->SetTitle("N. Events");
411 +  signalhisto->GetYaxis()->SetTitle("N. Events");
412 +  datahistoSF->GetXaxis()->CenterTitle();
413 +  datahistoOF->GetXaxis()->CenterTitle();
414 +  signalhisto->GetXaxis()->CenterTitle();
415 +  datahistoSF->GetYaxis()->CenterTitle();
416 +  datahistoOF->GetYaxis()->CenterTitle();
417 +  signalhisto->GetYaxis()->CenterTitle();
418 +
419 +  TLegend *mleg = new TLegend(0.2+legendPosition, 0.72, 0.55+legendPosition, 0.87, legendTitle.c_str());
420 +  mleg->SetFillColor(kWhite);
421 +  mleg->SetTextFont(42);
422 +  mleg->SetTextSize(0.048);
423 +  mleg->SetLineWidth(0);
424 +  mleg->SetBorderSize(0);
425 +  mleg->AddEntry(datahistoSF, "S. Flavor", "PL");
426 +  mleg->AddEntry(datahistoOF, "O. Flavor", "L");
427 +  mleg->AddEntry(signalhisto, "LM3", "L");
428 +
429 +  datahistoSF->Draw("E1");
430 +  datahistoOF->Draw("HIST,SAMES");
431 +  signalhisto->Draw("HIST,SAMES");
432 +  mleg->Draw();
433 +  DrawPrelim();
434 +  CompleteSave(ckin, "./SFOF/" + filename);
435 +
436 +  datahistoSF->Delete();
437 +  datahistoOF->Delete();
438 +  signalhisto->Delete();
439 +  delete mleg;
440 +  delete ckin;
441 +
442 + }
443 +
444 +
445 +
446   float lastrange_min=0;
447   float lastrange_max=0;
448  
# Line 269 | Line 473 | void make_kin_plot(string variable, stri
473    TCut cut;
474    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
475    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
476 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
477    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
478    if(filename=="mll") {
479          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 280 | Line 485 | void make_kin_plot(string variable, stri
485          draw_separation_lines=true;
486    }
487    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
488 <  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
488 >  if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
489 >  if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
490 >  if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
491    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
492    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
493    if(filename=="mll_inclusive_osof") cut=cutOSOF;
# Line 293 | Line 500 | void make_kin_plot(string variable, stri
500    ckin->SetLogy(logscale);
501    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
502    datahisto->SetMarkerSize(DataMarkerSize);
503 <  THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
503 >  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
504 >  else datahisto->SetMinimum(0.5);
505 >  // Custom max.
506 >  if(variable=="TMath::Abs(pfJetDphiMet[0])") datahisto->SetMaximum(1.5*datahisto->GetMaximum());
507    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
508    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
509 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
509 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
510    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
511    if(filename=="mll_osof") datahisto->SetMinimum(9);
512 +  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
513 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
514  
515 <  datahisto->SetMaximum(5.3*datahisto->GetMaximum());
304 <  datahisto->Draw("e1");
305 <  ckin->Update();
515 >  cout << "******** Cut used : " << (const char*) cut << endl;
516    if(loadlastminmax) {
517          datahisto->SetMinimum(lastrange_min);
518          datahisto->SetMaximum(lastrange_max);
# Line 312 | Line 522 | void make_kin_plot(string variable, stri
522          }              
523    }
524  
525 +  // Draw signal by hand (for some reason I don't manage to use the sample class: it adds it to the stack!)
526 +  string signal("LM3");
527 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
528 +  int idx = signalsamples.FindSample(signal)[0];
529 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
530 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
531 +  signalhisto->SetLineColor(kOrange);
532 +
533 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
534 +  datahisto->Draw("e1");
535 +  ckin->Update();
536    mcstack.Draw("same");
537 +  
538    datahisto->Draw("same,e1");
539    TLegend *kinleg = allsamples.allbglegend();
540    kinleg->Draw();
# Line 355 | Line 577 | void make_kin_plot(string variable, stri
577          kinpad->SetLogy(logscale);
578          datahisto->Draw("e1");
579          mcstack.Draw("same");
580 +        signalhisto->Draw("same");
581          datahisto->Draw("same,e1");
582          datahisto->Draw("same,axis");
583          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 362 | Line 585 | void make_kin_plot(string variable, stri
585            upperboundary->Draw("same");
586          }
587            
588 +        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
589          kinleg->Draw();
590          write_cut->Draw();
591          DrawPrelim();
# Line 379 | Line 603 | void make_kin_plot(string variable, stri
603    delete ckin;
604   }
605  
606 < void make_JES_plot() {
606 > void make_JES_plot(TCut cut, string name) {
607  
608    int nbins=10;
609    float min=-0.5;
610    float max = 9.5;
611    bool logscale=true;
612    string xlabel="nJets";
389  TCut cut=cutmass&&cutOSSF&&basiccut;
613  
614    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
615    ckin->SetLogy(logscale);
616 <  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
616 >  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,data,luminosity);
617    datahisto->SetMarkerSize(DataMarkerSize);
618 <  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
619 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
620 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
618 >  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,mc,luminosity);
619 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum40p1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
620 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum40n1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
621  
622    datahisto->SetMinimum(1);
623    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 419 | Line 642 | void make_JES_plot() {
642    TLegend *kinleg = allsamples.allbglegend();
643    kinleg->AddEntry(JESunc,"JES uncertainty","f");
644    kinleg->Draw();
645 <  CompleteSave(ckin,"Systematics/JES");
645 >  CompleteSave(ckin,"Systematics/JES"+name);
646    datahisto->Delete();
647    delete ckin;
648  
# Line 430 | Line 653 | void do_kinematic_plots(string mcjzb, st
653    bool dolog=true;
654    bool nolog=false;
655    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
656 <  float mll_low=40;
656 >  float mll_low=50;
657    float mll_hi=160;
658    if(!PlottingSetup::RestrictToMassPeak) {
659 <        mll_low=10;
660 <        mll_hi=210;
659 >        mll_low=20;
660 >        mll_hi=300;
661    }
662 +
663    /*
664 +  make_OFSF_plot("pfJetGoodNum40", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 5, 3, 8, true, "N. jets", "njetsLow", false, false, false, 0.2);
665 +  make_OFSF_plot("pfJetGoodNum40", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 5, 3, 8, true, "N. jets", "njetsMed", false, false, false, 0.2);
666 +  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Low", false, false, false, 0.2);
667 +  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Med", false, false, false, 0.2);
668 +  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetLow", false, false, false, 0.0);
669 +  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetMed", false, false, false, 0.0);
670 +  make_OFSF_plot("TMath::Abs(dphi)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiLow", false, false, false, 0.2);
671 +  make_OFSF_plot("TMath::Abs(dphi)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiMed", false, false, false, 0.2);
672 +  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Low", false, false, false, 0.2);
673 +  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Med", false, false, false, 0.2);
674 +  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Low", false, false, false, 0.2);
675 +  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Med", false, false, false, 0.2);
676 +  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcLow", false, false, false, 0.2);
677 +  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcMed", false, false, false, 0.2);
678 +  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcLow", false, false, false, 0.2);
679 +  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcMed", false, false, false, 0.2);
680 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoLow", false, false, false, 0.2);
681 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoMed", false, false, false, 0.2);
682 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoLow", false, false, false, 0.2);
683 +  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoMed", false, false, false, 0.2);
684 +
685 +
686 +  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
687 +
688    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
689    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
690    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
691    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
692 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
693 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
694 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
695 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
696 <  make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);/*
449 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
450 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
451 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
452 <  make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
453 <  make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
454 <  make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
455 <  make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
456 <  make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
457 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
458 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);*//*
692 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
693 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
694 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
695 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
696 >  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
697    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
698 +
699 +  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
700 +  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
701 +
702 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
703 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
704 +  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
705 +
706 +  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
707 + //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
708 + //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
709 +  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
710 +  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
711 +  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
712 +  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
713 +  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
714    stringstream jzbcut;
715    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
716 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
717 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
718 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
719 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
716 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
717 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
718 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB100",doPF,true);
719 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB100",doPF,true);
720    stringstream jzbcut2;
721    jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
722 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
723 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
722 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
723 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
724 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB150",doPF,true);
725 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB150",doPF,true);
726    stringstream jzbcut3;
727    jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
728 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
728 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
729 >  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);
730 >  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);  
731 >  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);  
732 >
733 >  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);
734 >
735 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
736 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
737 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
738 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
739 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
740 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
741 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
742 >
743 >  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
744 >  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
745    */
746 <  make_special_obs_pred_mll_plot(mcjzb,50);
747 <  make_special_obs_pred_mll_plot(mcjzb,100);
748 <  make_special_obs_pred_mll_plot(mcjzb,150);
749 <  make_special_obs_pred_mll_plot(mcjzb,200);
750 <  make_special_obs_pred_mll_plot(mcjzb,250);
746 >  
747 >  string regioncut[4] =    {"mll>0&&","mll>20&&mll<70&&","mll>70&&mll<110&&","mll>110&&"};
748 >  string regionname[4] = {"global","lowmass","Zregion","highmass"};
749 >  bool StoreRatioPlots=false;
750 >  for(int iregion=0;iregion<4;iregion++) {
751 >    cout << regionname[iregion] << " : " << regioncut[iregion] << endl;
752 >
753 >    //Z properties
754 >    make_kin_plot("pt","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),40,0,200,dolog,"p_{T}^{ee} [GeV] (MET>100GeV)","Z/ZPT_ee_met100_"+regionname[iregion],doPF,StoreRatioPlots);
755 >    make_kin_plot("pt","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),40,0,200,dolog,"p_{T}^{#mu#mu} [GeV] (MET>100GeV)","Z/ZPT_mm_met100_"+regionname[iregion],doPF,StoreRatioPlots);
756 >    
757 >    make_kin_plot("phi","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),32,-3.2,3.2,nolog,"#phi^{ee} (MET>100GeV)","Z/ZPhi_ee_met100_"+regionname[iregion],doPF,StoreRatioPlots);
758 >    make_kin_plot("phi","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),32,-3.2,3.2,nolog,"#phi^{#mu#mu} (MET>100GeV)","Z/ZPhi_mm_met100_"+regionname[iregion],doPF,StoreRatioPlots);
759 >    
760 >    make_kin_plot("eta","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),30,-3.0,3.0,nolog,"#eta^{ee} (MET>100GeV)","Z/ZEta_ee_met100_"+regionname[iregion],doPF,StoreRatioPlots);
761 >    make_kin_plot("eta","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),30,-3.0,3.0,nolog,"#eta^{#mu#mu} (MET>100GeV)","Z/ZEta_mm_met100_"+regionname[iregion],doPF,StoreRatioPlots);
762 >    
763 >    // lepton properties
764 >    make_kin_plot("pt1","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{e1} [GeV] (MET>100GeV)","Lepton/LeadingElectronPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
765 >    make_kin_plot("pt1","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{#mu1} [GeV] (MET>100GeV)","Lepton/LeadingMuonPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
766 >    make_kin_plot("pt2","met[4]>100&&id2==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{e2} [GeV] (MET>100GeV)","Lepton/SubLeadingElectronPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
767 >    make_kin_plot("pt2","met[4]>100&&id2==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{#mu2} [GeV] (MET>100GeV)","Lepton/SubLeadingMuonPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
768 >    
769 >    make_kin_plot("phi1","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{e1} (MET>100GeV)","Lepton/LeadingElectronPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
770 >    make_kin_plot("phi1","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{#mu1} (MET>100GeV)","Lepton/LeadingMuonPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
771 >    make_kin_plot("phi2","met[4]>100&&id2==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{e2} (MET>100GeV)","Lepton/SubLeadingElectronPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
772 >    make_kin_plot("phi2","met[4]>100&&id2==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{#mu2} (MET>100GeV)","Lepton/SubLeadingMuonPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
773 >    
774 >    make_kin_plot("eta1","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{e1} (MET>100GeV)","Lepton/LeadingElectronEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
775 >    make_kin_plot("eta1","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{#mu1} (MET>100GeV)","Lepton/LeadingMuonEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
776 >    make_kin_plot("eta2","met[4]>100&&id2==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{e2} (MET>100GeV)","Lepton/SubLeadingElectronEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
777 >    make_kin_plot("eta2","met[4]>100&&id2==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{#mu2} (MET>100GeV)","Lepton/SubLeadingMuonEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
778 >    
779 >    
780 >  }
781 >
782   }
783  
784   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
785                       int nbins, float xmin, float xmax, bool log,
786                       float ymin=0, float ymax=0, bool leftJustified=false ) {
787 <      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
787 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
788  
789    TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
790    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__));
791 <  if(var=="numVtx") cutWeight=TCut("1.0");
791 >  //if(var=="numVtx") cutWeight=TCut("1.0");
792    TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
793    TCut jzbMC[]  = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
794  
795    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
796    int nRegions=4;
797 <  if(!PlottingSetup::RestrictToMassPeak) {
797 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
798      nRegions=2;
799    }
800    
# Line 509 | Line 812 | void make_comp_plot( string var, string
812        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
813        ccomp->SetLogy(log);
814        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
815 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
815 >      TH1F *lm3histo  = signalsamples.Draw("lm3histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],data,luminosity,signalsamples.FindSample("LM3"));
816        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
817        datahisto->SetMarkerSize(DataMarkerSize);
818        if (ymax>ymin) datahisto->SetMaximum(ymax);
819 <      lm4histo->SetLineStyle(2);
819 >      lm3histo->SetLineStyle(2);
820        datahisto->Draw("e1");
821        mcstack.Draw("same");
822        datahisto->Draw("same,e1");
823 < //      lm4histo->Draw("hist,same");
823 >      lm3histo->Draw("hist,same");
824        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
825        if ( leftJustified ) {
826          Float_t w = kinleg->GetX2()-kinleg->GetX1();
827          kinleg->SetX1(0.2);
828          kinleg->SetX2(0.2+w);
829        }
830 < //      kinleg->AddEntry(lm4histo,"LM4","l");
830 >      kinleg->AddEntry(lm3histo,"LM3","l");
831        kinleg->Draw();
832        TText* write_variable = write_text(0.99,0.01,var);
833        write_variable->SetTextAlign(31);
# Line 533 | Line 836 | void make_comp_plot( string var, string
836        CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
837        delete datahisto;
838        delete ccomp;
839 <      delete lm4histo;
839 >      delete lm3histo;
840      }
841    cutWeight=weightbackup;
842   }
# Line 543 | Line 846 | void region_comparison_plots(string mcjz
846    dout << "Creating comparison plots for signal and control regions" << endl;
847    // Compare a few quantities in the signal region and all 7 control regions
848  
849 <  switch_overunderflow(true);  // switching overflow/underflow bins on
849 > //  switch_overunderflow(true);  // switching overflow/underflow bins on
850      
851    
852      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
853 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
853 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
854      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
855      float mll_low=50;float mll_high=170;
856      if(!PlottingSetup::RestrictToMassPeak) {
857 <        mll_high=200;
858 <        mll_low=50;
857 >        mll_high=300;
858 >        mll_low=20;
859      }
860 <    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
860 >    make_comp_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",jzbcut,mcjzb,datajzb,100,0,10,true);
861 >    make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
862 >
863 >    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
864      make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
865 <    make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
865 >    make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
866 >    make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
867      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
868 <    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
868 >    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,40,0.,40.,false,0,16.);
869      make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
870      make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
871 +    make_comp_plot("eta1","#eta_1","eta1",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
872 +    make_comp_plot("eta2","#eta_2","eta2",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
873    }
874  
875    switch_overunderflow(false); // switching overflow/underflow bins off
# Line 759 | Line 1068 | vector<TF1*> do_extended_fit_to_plot(TH1
1068   //      the line above is not necessary anymore as we're now looking at a prediction without Z+Jets, and not multiplied with (1.0/3)
1069    TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
1070    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1071 <  if(PlottingSetup::RestrictToMassPeak) ttbarlogpar->SetParameter(0,1.0/3*ttbarlogpar->GetParameter(0));//correcting for the fact that we didn't multiply with (1.0/3);
1071 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) ttbarlogpar->SetParameter(0,1.0/3*ttbarlogpar->GetParameter(0));//correcting for the fact that we didn't multiply with (1.0/3);
1072  
1073  
1074    TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
# Line 854 | Line 1163 | if you want to start from scratch (witho
1163    return return_functions;
1164   }
1165  
1166 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
1166 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1167   {
1168 <  // note: sigma is not used ATM
860 <  switch_overunderflow(true);
1168 > //  switch_overunderflow(true);
1169    bool is_data=false;
1170    bool use_signal=false;
1171    if(use_data==1) is_data=true;
# Line 867 | Line 1175 | void do_prediction_plot(string jzb, TCan
1175    float low=0;
1176    float hi=500;
1177    
870  stringstream largerzeroS;
871  largerzeroS << "("<<jzb<<">0)";
872  TCut largerzero(largerzeroS.str().c_str());
873  stringstream smallerzeroS;
874  smallerzeroS << "("<<jzb<<"<0)";
875  TCut smallerzero(smallerzeroS.str().c_str());
876  
1178    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1179 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1180 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1181 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1182 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1179 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1180 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1181 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1182 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1183  
1184    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1185    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 895 | Line 1196 | void do_prediction_plot(string jzb, TCan
1196  
1197      //these are for the ratio
1198    
1199 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1200 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1201 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1202 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1199 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1200 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1201 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1202 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1203    
1204    TH1F *JRcorrJZBSBem;
1205    TH1F *JLcorrJZBSBem;
1206    TH1F *JRcorrJZBSBeemm;
1207    TH1F *JLcorrJZBSBeemm;
1208    
1209 <  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,false);
1209 >  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
1210  
1211    
1212 <  if(PlottingSetup::RestrictToMassPeak) {
1213 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1214 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1215 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1216 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1212 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1213 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1214 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1215 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1216 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1217      
1218      //these are for the ratio
1219 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1220 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1221 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1222 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1219 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1220 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1221 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1222 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1223    }
1224    
1225    TH1F *lm4RcorrJZBeemm;
1226 <  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,allsamples.FindSample("LM"));
1226 >  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"));
1227    
1228    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1229    
# Line 931 | Line 1232 | void do_prediction_plot(string jzb, TCan
1232      
1233    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1234    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
1235 <  if(PlottingSetup::RestrictToMassPeak) {
1235 >    
1236 >  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1237 >  ClearHisto(BpredSys);
1238 >    
1239 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1240      Bpred->Add(RcorrJZBem,1.0/3.);
1241      Bpred->Add(LcorrJZBem,-1.0/3.);
1242      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 953 | Line 1258 | void do_prediction_plot(string jzb, TCan
1258      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
1259      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
1260      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1261 +      
1262 +    //Systematics:
1263 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1264 +    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1265 +    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1266 +    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1267 +    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1268 +    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1269 +    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1270    } else {
1271      Bpred->Add(RcorrJZBem,1.0);
1272      Bpred->Add(LcorrJZBem,-1.0);
# Line 962 | Line 1276 | void do_prediction_plot(string jzb, TCan
1276      //these are for the ratio
1277      JBpred->Add(JRcorrJZBem,1.0);
1278      JBpred->Add(JLcorrJZBem,-1.0);
1279 +      
1280 +    //Systematics
1281 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1282 +    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1283 +    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1284 +
1285    }
1286      
1287 <  
1287 >  SQRT(BpredSys);
1288 >  BpredSys->Divide(JBpred);
1289 >
1290    
1291    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1292    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1293    Tpred->Add(LcorrJZBem,-1.0);
1294 <  if(PlottingSetup::RestrictToMassPeak) {
1294 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1295      Tpred->Add(RcorrJZBSBem,1.0);
1296      Tpred->Add(LcorrJZBSBem,-1.0);
1297      Tpred->Add(RcorrJZBSBeemm,1.0);
# Line 1009 | Line 1331 | void do_prediction_plot(string jzb, TCan
1331    blankback->Draw();
1332    if(use_data==1)
1333    {
1334 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1335 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1336      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1337      kinpad->cd();//necessary because the extended fit function creates its own canvas
1338      RcorrJZBeemm->Draw("e1x0,same");
1339  
1340      Bpred->Draw("hist,same");
1341 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1341 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1342      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1343      lm4RcorrJZBeemm->Draw("hist,same");
1344      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1345      legBpred->AddEntry(Bpred,"predicted","l");
1346 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1347 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1348 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1346 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1347 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1348 >    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1349      legBpred->Draw();
1350      DrawPrelim();
1351  
# Line 1050 | Line 1374 | void do_prediction_plot(string jzb, TCan
1374      Bpred->Draw("hist,same");
1375   //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1376      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1377 < //    TH1F *lm4RcorrJZBeemmC = (TH1F*)lm4RcorrJZBeemm->Clone("lm4RcorrJZBeemmC");
1054 < //    lm4RcorrJZBeemmC->SetLineColor(kOrange+1);
1055 <    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1056 < //    lm4RcorrJZBeemmC->Draw("histo,same");
1377 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1378      lm4RcorrJZBeemm->SetLineWidth(2);
1379 +    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1380      lm4RcorrJZBeemm->Draw("histo,same");
1381      DrawPrelim();
1382      TLegend *speciallegBpred = make_legend("",0.45,0.55);
1383 +    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1384      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1385      speciallegBpred->AddEntry(Bpred,"Total background","l");
1386      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1387 <    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1387 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1388 >    else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1389   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1390      speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1391      speciallegBpred->Draw();
1392 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1392 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1393      
1394      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1395 <    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1395 >    specialcanv->SetLogy(1);
1396 > //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1397      blankback->Draw();
1398 <    kostack.Draw("same");
1398 > //    kostack.Draw("same");
1399 >    predcomposition.Draw();
1400      Bpred->Draw("hist,same");
1401 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1401 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1402      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1403      legBpred->Draw();
1404      DrawPrelim();
1405      CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1406      Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1407      
1408 +    
1409 +    //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;
1410 +    
1411      delete speciallegBpred;
1412      delete Zjetspred;
1413      delete TTbarpred;
# Line 1087 | Line 1416 | void do_prediction_plot(string jzb, TCan
1416    }
1417    if(use_data==0) {
1418      RcorrJZBeemm->Draw("e1x0,same");
1419 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1420      Bpred->Draw("hist,same");
1421      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1422      legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1423 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1423 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1424      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1425      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1426      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 1101 | Line 1431 | void do_prediction_plot(string jzb, TCan
1431    }
1432    if(use_data==2) {
1433      RcorrJZBeemm->Draw("e1x0,same");
1434 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1435      Bpred->Draw("hist,same");
1436      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1437      legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
# Line 1116 | Line 1447 | void do_prediction_plot(string jzb, TCan
1447   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1448      }
1449      {
1450 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1451 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1452 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1453 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1454 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1455 +      
1456        RcorrJZBeemmNoS->SetLineStyle(2);
1457        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1458        legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
# Line 1135 | Line 1472 | void do_prediction_plot(string jzb, TCan
1472    string ytitle("ratio");
1473    if ( use_data==1 ) ytitle = "data/pred";
1474    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1475 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1475 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1476  
1477    
1478    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1479 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1480 <  if(PlottingSetup::RestrictToMassPeak) {
1479 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1480 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1481      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1482      Bpredem->Add(RcorrJZBem);
1483      Bpredem->Add(LcorrJZBem,-1);
# Line 1201 | Line 1538 | void do_prediction_plot(string jzb, TCan
1538      }
1539    }
1540    
1541 +  TFile *f = new TFile("tester.root","RECREATE");
1542 +  RcorrJZBeemm->Write();
1543 +  Bpred->Write();
1544 +  f->Close();
1545 +  
1546    delete RcorrJZBeemm;
1547    delete LcorrJZBeemm;
1548    delete RcorrJZBem;
# Line 1213 | Line 1555 | void do_prediction_plot(string jzb, TCan
1555  
1556    delete blankback;
1557    
1558 <  if(PlottingSetup::RestrictToMassPeak) {
1558 >  delete BpredSys;
1559 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1560      delete RcorrJZBSBem;
1561      delete LcorrJZBSBem;
1562      delete RcorrJZBSBeemm;
# Line 1230 | Line 1573 | void do_prediction_plot(string jzb, TCan
1573  
1574   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1575    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1576 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1577 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1578 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1576 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1577 >  if ( !PlottingSetup::Approved ) {
1578 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1579 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1580 >  } else {
1581 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1582 >  }
1583   }
1584  
1585   void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
# Line 1250 | Line 1597 | void do_ratio_plot(int is_data,vector<fl
1597    TH1F *RcorrJZBSBeemm;
1598    TH1F *LcorrJZBSbeemm;
1599    
1600 <  if(PlottingSetup::RestrictToMassPeak) {
1600 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1601      RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1602      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1603      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
# Line 1262 | Line 1609 | void do_ratio_plot(int is_data,vector<fl
1609  
1610    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1611    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1612 <  if(PlottingSetup::RestrictToMassPeak) {
1612 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1613      Bpred->Add(RcorrJZBem,1.0/3);
1614      Bpred->Add(LcorrJZBem,-1.0/3);
1615      Bpred->Add(RcorrJZBSBem,1.0/3);
# Line 1569 | Line 1916 | void draw_pure_jzb_histo(TCut cut,string
1916    datahisto->Draw("same,e1");
1917    
1918    TLegend *leg;
1919 <  if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1920 <  else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1921 <  else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1922 <  else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1923 <  else {
1924 <    std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1925 <    exit(-1);
1926 <      }
1919 >  if (!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
1920 >    if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1921 >    else leg = allsamples.allbglegend("Same flavor",datahisto);
1922 >  } else {
1923 >    if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1924 >    else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1925 >    else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1926 >    else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1927 >    else {
1928 >      std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1929 >      exit(-1);
1930 >    }
1931 >  }
1932    leg->Draw();
1933    string write_cut = decipher_cut(cut,"");
1934    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
# Line 1627 | Line 1979 | void produce_stretched_jzb_plots(string
1979    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1980    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1981    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1982 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1983 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1982 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1983 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1984    
1985    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1986    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1987 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1988 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1987 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1988 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1989    
1990    delete dican;
1991   }
# Line 1652 | Line 2004 | void diboson_plots(string mcjzb, string
2004    
2005    
2006    dout << "Going to increase the cross section for diboson samples ... " << endl;
2007 <  for(int i=0;i<SamplesToBeModified.size();i++) {
2007 >  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
2008      float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
2009      (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
2010      dout << "     Increased xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].filename << " from " << origxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ")" << endl;
# Line 1662 | Line 2014 | void diboson_plots(string mcjzb, string
2014    }
2015    
2016    dout << "Going to produce JZB plots" << endl;
2017 < //  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
2017 >  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
2018    TCanvas *gloca = new TCanvas("gloca","gloca");
1667  float sigma=123456;
2019    
2020    dout << "Going to produce prediction plots" << endl;
2021 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
2022 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
2021 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
2022 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
2023    delete gloca;
2024  
2025    dout << "Going to reset the cross section for diboson samples ... " << endl;
2026 <  for(int i=0;i<SamplesToBeModified.size();i++) {
2026 >  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
2027      float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
2028      (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
2029      string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
# Line 1682 | Line 2033 | void diboson_plots(string mcjzb, string
2033    }
2034    
2035   }
2036 +
2037 +
2038 + void draw_normalized_data_vs_data_histo(TCut cut1, TCut cut2, string variable, string legentry1, string legentry2, string savename, TCanvas *can,vector<float> binning) {
2039 +  TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
2040 +  jzbpad->cd();
2041 +  jzbpad->SetLogy(1);
2042 +  string xlabel="JZB [GeV]";
2043 +
2044 +  TH1F *datahisto1 = allsamples.Draw("datahisto1",variable,binning, xlabel, "events",cut1,data,luminosity);
2045 +  datahisto1->SetLineColor(kRed);
2046 +  datahisto1->SetMarkerColor(kRed);
2047 +  TH1F *datahisto2 = allsamples.Draw("datahisto2",variable,binning, xlabel, "events",cut2,data,luminosity);
2048 +  datahisto2->SetLineColor(kBlue);
2049 +  datahisto2->SetMarkerColor(kBlue);
2050 +  
2051 +  datahisto2->SetMarkerSize(DataMarkerSize);
2052 +  datahisto1->DrawNormalized("e1");
2053 +  datahisto2->DrawNormalized("histo,same");
2054 +  datahisto1->DrawNormalized("same,e1");
2055 +  
2056 +  TLegend *leg = make_legend();
2057 +  leg->AddEntry(datahisto1,legentry1.c_str());
2058 +  leg->AddEntry(datahisto2,legentry2.c_str());
2059 +  leg->Draw();
2060 +  
2061 +  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
2062 +  
2063 +  datahisto1->Delete();
2064 +  datahisto2->Delete();
2065 + }
2066 +
2067 +
2068   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2069    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2070    float max=jzbHigh ;
# Line 1695 | Line 2078 | void jzb_plots(string mcjzb, string data
2078    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
2079    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
2080  
2081 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
2082 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
2083 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
2084 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
2085 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2086 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2087 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2088 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2089 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2081 >  if ( !PlottingSetup::Approved ) {
2082 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
2083 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
2084 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
2085 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
2086 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2087 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2088 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2089 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2090 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2091 >    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);
2092 >    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);
2093 >    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);
2094 >
2095 >  }
2096    
2097    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
2098 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2099 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2100 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2101 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2102 <
2103 < //  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
1715 < //  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
1716 < //  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1717 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
1718 < //  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
2098 >  if ( !PlottingSetup::Approved ) {
2099 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2100 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2101 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2102 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2103 >  }
2104    delete can;
2105   }
2106  
# Line 1766 | Line 2151 | void compute_MC_yields(string mcjzb,vect
2151    TCanvas *yica = new TCanvas("yica","yield canvas");
2152    
2153    int nRegions=4;
2154 <  if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
2154 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
2155    string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
2156    string posneg[] = {"pos","neg"};
2157    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
2158  
2159 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
2159 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
2160      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
2161      dout << "_________________________________________________________" << endl;
2162      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
2163 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
2163 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
2164        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
2165        else dout << "Sample & ";
2166        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 2034 | Line 2419 | void draw_ttbar_and_zjets_shape_for_one_
2419  
2420   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2421    int all_leptons=-1;
2037  int electrons_only=0;
2038  int mu_only=1;
2039  int twojetswith50gev=1;
2422    int threejetswith30gev=0;
2423   /*  
2424 +  int twojetswith50gev=1;
2425 +  int electrons_only=0;
2426 +  int mu_only=1;
2427 +
2428    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2429    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2430    
# Line 2052 | Line 2438 | void draw_ttbar_and_zjets_shape(string m
2438    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2439   }
2440  
2441 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2056 <  //first: colorful plots
2441 > float find_one_correction_factor(string FindKeyword, bool dodata, TCut SpecialCut, string SaveAs) {
2442    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2443    cancorr->SetLogz();
2444    cancorr->SetRightMargin(0.13);
2445 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2446 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2445 >  TCut zptforresponsepresentation(Restrmasscut&&SpecialCut&&passtrig);
2446 >
2447 >  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2448    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2449 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2449 >  niceresponseplotd->Sumw2();
2450 >  TH2F* emuResponse = (TH2F*)niceresponseplotd->Clone("emuResponse");
2451 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2452 >  for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2453 >    if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2454 >    if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2455 >    
2456 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2457 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
2458 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
2459 >  }
2460 >  niceresponseplotd->Add(emuResponse,-1);
2461 >  
2462    niceresponseplotd->SetStats(0);
2463    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2464    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2068 | Line 2466 | void find_correction_factors(string &jzb
2466    niceresponseplotd->GetYaxis()->CenterTitle();
2467    niceresponseplotd->Draw("COLZ");
2468    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2469 +  profd->Rebin(2);
2470    profd->SetMarkerSize(DataMarkerSize);
2471 <  profd->Fit("pol0","","same,e1",30,400);
2471 >  profd->Fit("pol0","","same,e1",100,400);
2472    DrawPrelim();
2473 <  TText* title = write_text(0.5,0.7,"Data");
2473 >  string stitle="Data";
2474 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2475 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2476    title->SetTextAlign(12);
2477    title->Draw();
2478    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2479 <  float datacorrection=datapol->GetParameter(0);
2480 <  stringstream dataresstring;
2481 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2482 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2479 >  float correction=datapol->GetParameter(0);
2480 >  stringstream resstring;
2481 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2482 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2483    restitle->SetTextAlign(12);
2484    restitle->SetTextSize(0.03);
2485    restitle->Draw();
2486 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2487 <  
2488 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2489 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2490 <  niceresponseplotm->SetStats(0);
2491 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2492 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2493 <  niceresponseplotm->GetXaxis()->CenterTitle();
2093 <  niceresponseplotm->GetYaxis()->CenterTitle();
2094 <  niceresponseplotm->Draw("COLZ");
2095 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2096 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2097 <  profm->SetMarkerSize(DataMarkerSize);
2098 <  profm->Fit("pol0","","same,e1",30,400);
2099 <  DrawMCPrelim();
2100 <  title = write_text(0.5,0.7,"MC simulation");
2101 <  title->SetTextAlign(12);
2102 <  title->Draw();
2103 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
2104 <  float mccorrection=mcpol->GetParameter(0);
2105 <  stringstream mcresstring;
2106 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
2107 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
2108 <  mcrestitle->SetTextAlign(12);
2109 <  mcrestitle->SetTextSize(0.03);
2110 <  mcrestitle->Draw();
2111 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2486 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2487 >  delete cancorr;
2488 >  delete niceresponseplotd;
2489 >  delete profd;
2490 >  return correction;
2491 > }
2492 >
2493 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2494    
2495 +  dout << "Computing response corrections: " << endl;
2496 +  //Step 1 : Get results
2497 +  float datacorrection=find_one_correction_factor("Data",true,"","Data");
2498 +  float mccorrection=find_one_correction_factor("DY",false,"","MC");
2499 +  
2500 +  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
2501 +  float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
2502 +  
2503 +  float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
2504 +  float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
2505 +  
2506 +  cout << "Corrections : " << endl;
2507 +  cout << "   Data : " << datacorrection << endl;
2508 +  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2509 +  cout << "   MC : " << mccorrection << endl;
2510 +  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2511    
2512 <  //Step 2: Getting the result
2115 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2512 >  //Step 2: Processing the result and making it into something useful :-)
2513    stringstream jzbvardatas;
2514 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2515 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2514 >  jzbvardatas << "(";
2515 >  
2516 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2517 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2518 >  
2519 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2520 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2521 >  
2522 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2523 >  
2524 >  if(datacorrection>=1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << datacorrection-1 << "*pt))";
2525 >  if(datacorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]+" << 1-datacorrection << "*pt))";
2526 >  
2527 >  jzbvardatas << ")";
2528    jzbvardata=jzbvardatas.str();
2529 +  
2530    stringstream jzbvarmcs;
2531 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2532 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2531 >  jzbvarmcs << "(";
2532 >  
2533 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2534 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2535 >  
2536 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2537 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2538 >  
2539 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2540 >  
2541 >  if(mccorrection>=1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << mccorrection-1 << "*pt))";
2542 >  if(mccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]+" << 1-mccorrection << "*pt))";
2543 >  
2544 >  jzbvarmcs << ")";
2545    jzbvarmc=jzbvarmcs.str();
2546 +
2547    dout << "JZB Z pt correction summary : " << endl;
2548    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2549    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2550 +  
2551   }
2552  
2553   void pick_up_events(string cut) {
# Line 2131 | Line 2555 | void pick_up_events(string cut) {
2555    allsamples.PickUpEvents(cut);
2556   }
2557  
2558 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError) {
2558 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2559    dout << "Saving configuration template!" << endl;
2560    ofstream configfile;
2561    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 2151 | Line 2575 | void save_template(string mcjzb, string
2575    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2576    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2577    configfile<<"vector<float>jzb_cuts;\n";
2578 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2579    configfile<<"float MCPeakError=-999;\n";
2580    configfile<<"float DataPeakError=-999;\n";
2581    configfile<<"}\n\n";
# Line 2160 | Line 2585 | void save_template(string mcjzb, string
2585    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2586    configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2587    configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2588 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2588 >  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";
2589    configfile<<"\n\n";
2590 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2591 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2592 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2590 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2591 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2592 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2593 >  configfile<<"\n\n";
2594 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2595 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2596 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2597 >  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";
2598    configfile<<"\n\n";
2169  for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2170  for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2171  for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2599    configfile<<"\n\n";
2600    configfile<<"luminosity="<<luminosity<<";\n";
2601    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
# Line 2194 | Line 2621 | void draw_all_ttbar_histos(TCanvas *can,
2621    float max=histos[0]->GetMaximum();
2622    if(manualmin>=0) min=manualmin;
2623    else {
2624 <    for(int i=1;i<histos.size();i++) {
2624 >    for(int i=1;i<(int)histos.size();i++) {
2625        float curmin=get_nonzero_minimum(histos[i]);
2626        float curmax=histos[i]->GetMaximum();
2627        if(curmin<min) min=curmin;
# Line 2205 | Line 2632 | void draw_all_ttbar_histos(TCanvas *can,
2632    histos[0]->Draw(drawoption.c_str());
2633    stringstream drawopt;
2634    drawopt << drawoption << ",same";
2635 <  for(int i=1;i<histos.size();i++) {
2635 >  for(int i=1;i<(int)histos.size();i++) {
2636      histos[i]->Draw(drawopt.str().c_str());
2637    }
2638   }
# Line 2214 | Line 2641 | void ttbar_sidebands_comparison(string m
2641    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2642    //in the case of the OFF peak analysis, we compare our control region to the real value
2643    TCut weightbackup=cutWeight;
2217  cutWeight="1.0";
2218  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2644    
2645 +  bool doPURW=false;
2646 +  
2647 +  
2648 +  if(!doPURW) {
2649 +    dout << "Not doing PU reweighting for ttbar closure test" << endl;
2650 +    cutWeight="1.0";
2651 +    // Do it without PU re-weighting
2652 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2653 +    stringstream resultsNoPU;
2654 +    stringstream noPUdatajzb;
2655 +    stringstream noPUmcjzb;
2656 +    
2657 +    stringstream mcjzbnoPU;
2658 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2659 +    mcjzb = noPUmcjzb.str();
2660 +  }
2661  
2662 <  TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2662 >      
2663 >  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2664 >
2665 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2666    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2667    TH1F *TSem;
2668    TH1F *nTSem;
2669 <  TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2669 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2670    TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2671    TH1F *TSeemm;
2672    TH1F *nTSeemm;
2673    
2674 <  if(PlottingSetup::RestrictToMassPeak) {
2675 <    TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2676 <    nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2677 <    TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2674 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2675 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2676 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2677 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2678      nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2679    }
2680  
2681    TCanvas *tcan = new TCanvas("tcan","tcan");
2238  
2682    tcan->SetLogy(1);
2683    
2684    TZeemm->SetLineColor(kBlack);
# Line 2244 | Line 2687 | void ttbar_sidebands_comparison(string m
2687    TZem->SetMarkerColor(kRed);
2688  
2689  
2690 <  if(PlottingSetup::RestrictToMassPeak) {
2690 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2691          TSem->SetLineColor(TColor::GetColor("#00A616"));
2692          TSeemm->SetLineColor(kMagenta+2);
2693          TSem->SetMarkerColor(TColor::GetColor("#00A616"));
# Line 2254 | Line 2697 | void ttbar_sidebands_comparison(string m
2697    }
2698    
2699    vector<TH1F*> histos;
2700 +  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2701 +  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2702    histos.push_back(TZem);
2703    histos.push_back(TZeemm);
2704 <  if(PlottingSetup::RestrictToMassPeak) {
2704 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2705 >    TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2706 >    TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2707      histos.push_back(TSem);
2708      histos.push_back(TSeemm);
2709    }
2710 <  draw_all_ttbar_histos(tcan,histos,"histo",0.04);
2710 >  draw_all_ttbar_histos(tcan,histos,"histo",1);
2711    
2712    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2713    leg->AddEntry(TZeemm,"SFZP","l");
2714    leg->AddEntry(TZem,"OFZP","l");
2715 <  if(PlottingSetup::RestrictToMassPeak) {
2715 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2716      leg->AddEntry(TSeemm,"SFSB","l");
2717      leg->AddEntry(TSem,"OFSB","l");
2718    }
2719    leg->Draw("same");
2720    DrawMCPrelim(simulatedlumi);
2721    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2275 cout << __LINE__ << endl;  
2722    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2277 cout << __LINE__ << endl;  
2723    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2279 cout << __LINE__ << endl;  
2724    TH1F *TSeemmcopy;
2725    TH1F *TSemcopy;
2726 <  if(PlottingSetup::RestrictToMassPeak) {
2726 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2727      TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2728      TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2729    }
2730  
2731    TZem->Divide(TZeemm);
2732    TZem->SetMarkerStyle(21);
2733 <  if(PlottingSetup::RestrictToMassPeak) {
2733 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2734      TSem->Divide(TZeemm);
2735      TSeemm->Divide(TZeemm);
2736      TSem->SetMarkerStyle(24);
2737      TSeemm->SetMarkerStyle(32);
2738 < }
2738 >  }
2739  
2740    tcan->SetLogy(0);
2741    TZem->GetYaxis()->SetRangeUser(0,2.5);
2742    TZem->GetYaxis()->SetTitle("ratio");
2743    TZem->Draw();
2744 <  if(PlottingSetup::RestrictToMassPeak) {
2744 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2745      TSem->Draw("same");
2746      TSeemm->Draw("same");
2747    }
2748    
2749 <  float linepos=0.25;
2750 <  if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2751 <  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2749 >  float linepos=emuncertONPEAK;
2750 >  if(!PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) linepos=emuncertOFFPEAK;
2751 >  
2752    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2753    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2754    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
# Line 2327 | Line 2771 | cout << __LINE__ << endl;
2771    
2772    TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
2773    leg2->AddEntry(TZem,"OFZP / SFZP","ple");
2774 <  if(PlottingSetup::RestrictToMassPeak) {
2774 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2775      leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
2776      leg2->AddEntry(TSem,"OFSB / SFZP","ple");
2777    }
# Line 2340 | Line 2784 | cout << __LINE__ << endl;
2784    DrawMCPrelim(simulatedlumi);
2785    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2786    
2787 +  if (0) { // Turn this off: we don't need this
2788  
2789 < ///-------------- second part: only look at the quantity we actually care about!
2790 <  TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2791 <  TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2792 <  rightsfzp->Add(leftsfzp,-1);
2793 <  TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2794 <  TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2795 <  rightofzp->Add(leftofzp,-1);
2796 <  TH1F *leftofsb;
2797 <  TH1F *rightofsb;
2798 <  TH1F *leftsfsb;
2799 <  TH1F *rightsfsb;
2800 <  if(PlottingSetup::RestrictToMassPeak) {
2801 <        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2802 <        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2803 <        rightofsb->Add(leftofsb,-1);
2804 <        leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2805 <        rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2806 <        rightsfsb->Add(leftsfsb,-1);
2807 <  }
2789 >    ///-------------- second part: only look at the quantity we actually care about!
2790 >    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2791 >    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2792 >    rightsfzp->Add(leftsfzp,-1);
2793 >    TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2794 >    TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2795 >    rightofzp->Add(leftofzp,-1);
2796 >    TH1F *leftofsb;
2797 >    TH1F *rightofsb;
2798 >    TH1F *leftsfsb;
2799 >    TH1F *rightsfsb;
2800 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2801 >      leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2802 >      rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2803 >      rightofsb->Add(leftofsb,-1);
2804 >      leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2805 >      rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2806 >      rightsfsb->Add(leftsfsb,-1);
2807 >    }
2808  
2809 <  tcan->SetLogy(1);
2810 <  rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2811 <  rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2812 <  rightsfzp->Draw("histo");
2813 <  rightofzp->Draw("histo,same");
2814 <  if(PlottingSetup::RestrictToMassPeak) {
2815 <    rightofsb->Draw("histo,same");
2816 <    rightsfsb->Draw("histo,same");
2817 <  }
2818 <  DrawMCPrelim(simulatedlumi);
2809 >    tcan->SetLogy(1);
2810 >    rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2811 >    rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2812 >    rightsfzp->Draw("histo");
2813 >    rightofzp->Draw("histo,same");
2814 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2815 >      rightofsb->Draw("histo,same");
2816 >      rightsfsb->Draw("histo,same");
2817 >    }
2818 >    DrawMCPrelim(simulatedlumi);
2819  
2820 <  TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2821 <  legA->AddEntry(rightsfzp,"SFZP","l");
2822 <  legA->AddEntry(rightofzp,"OFZP","l");
2823 <  if(PlottingSetup::RestrictToMassPeak) {
2824 <    legA->AddEntry(rightofsb,"SFSB","l");
2825 <    legA->AddEntry(rightsfsb,"OFSB","l");
2826 <  }
2827 <  legA->Draw();
2820 >    TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2821 >    legA->AddEntry(rightsfzp,"SFZP","l");
2822 >    legA->AddEntry(rightofzp,"OFZP","l");
2823 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2824 >      legA->AddEntry(rightofsb,"SFSB","l");
2825 >      legA->AddEntry(rightsfsb,"OFSB","l");
2826 >    }
2827 >    legA->Draw();
2828  
2829 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2829 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2830  
2831 <  tcan->SetLogy(0);
2832 <  rightofzp->Divide(rightsfzp);
2833 <  rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2834 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
2835 <  rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2836 <  rightofzp->Draw();
2837 <  if(PlottingSetup::RestrictToMassPeak) {
2838 <    rightofsb->Divide(rightsfzp);
2839 <    rightsfsb->Divide(rightsfzp);
2840 <    rightofsb->Draw("same");
2841 <    rightsfsb->Draw("same");
2842 <  }
2843 <
2844 <  TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2845 <  TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2846 <  TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2847 <  
2848 <  top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2849 <  bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2850 <  center2->SetLineColor(kBlue);
2851 <  
2852 <  top2->Draw("same");
2853 <  center2->Draw("same");
2854 <  bottom2->Draw("same");
2855 <
2856 <  rightofzp->SetMarkerStyle(21);
2857 <  if(PlottingSetup::RestrictToMassPeak) {
2858 <    rightofsb->SetMarkerStyle(24);
2859 <    rightsfsb->SetMarkerStyle(32);
2860 <  }
2861 <
2862 <  TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2863 <  leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2864 <  if(PlottingSetup::RestrictToMassPeak) {
2865 <        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2866 <        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2867 <  }
2868 <  leg3->AddEntry(bottom,"syst. envelope","l");
2869 <  leg3->SetX1(0.25);leg3->SetX2(0.6);
2870 <  leg3->SetY1(0.65);
2831 >    tcan->SetLogy(0);
2832 >    rightofzp->Divide(rightsfzp);
2833 >    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2834 >    rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2835 >    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2836 >    rightofzp->Draw();
2837 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2838 >      rightofsb->Divide(rightsfzp);
2839 >      rightsfsb->Divide(rightsfzp);
2840 >      rightofsb->Draw("same");
2841 >      rightsfsb->Draw("same");
2842 >    }
2843 >
2844 >    TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2845 >    TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2846 >    TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2847 >  
2848 >    top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2849 >    bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2850 >    center2->SetLineColor(kBlue);
2851 >  
2852 >    top2->Draw("same");
2853 >    center2->Draw("same");
2854 >    bottom2->Draw("same");
2855 >
2856 >    rightofzp->SetMarkerStyle(21);
2857 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2858 >      rightofsb->SetMarkerStyle(24);
2859 >      rightsfsb->SetMarkerStyle(32);
2860 >    }
2861 >
2862 >    TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2863 >    leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2864 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2865 >      leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2866 >      leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2867 >    }
2868 >    leg3->AddEntry(bottom,"syst. envelope","l");
2869 >    leg3->SetX1(0.25);leg3->SetX2(0.6);
2870 >    leg3->SetY1(0.65);
2871    
2872 <  leg3->Draw("same");
2872 >    leg3->Draw("same");
2873    
2874 <  DrawMCPrelim(simulatedlumi);
2875 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2874 >    DrawMCPrelim(simulatedlumi);
2875 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2876 >
2877 >  }
2878  
2879    delete TZem;
2880    delete nTZem;
2881    delete TZeemm;
2882    delete nTZeemm;
2883 <  if(PlottingSetup::RestrictToMassPeak) {
2883 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2884          delete TSem;
2885          delete nTSem;
2886          delete TSeemm;
# Line 2446 | Line 2893 | cout << __LINE__ << endl;
2893  
2894   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
2895    vector<float> nicer_binning;
2896 <  nicer_binning.push_back(-125);
2896 >  
2897 > /*  nicer_binning.push_back(-400);
2898 >  nicer_binning.push_back(-250);
2899 >  nicer_binning.push_back(-200);
2900 >  nicer_binning.push_back(-150);
2901 >  nicer_binning.push_back(-100);
2902 >  nicer_binning.push_back(-50);
2903 >  nicer_binning.push_back(-20);
2904 >  
2905 >  nicer_binning.push_back(0);
2906 >  nicer_binning.push_back(20);
2907 >  nicer_binning.push_back(50);
2908 >  nicer_binning.push_back(100);
2909 >  nicer_binning.push_back(150);
2910 >  nicer_binning.push_back(200);
2911 >  nicer_binning.push_back(250);
2912 >  nicer_binning.push_back(400);*/
2913 >  
2914    nicer_binning.push_back(-100);
2451  nicer_binning.push_back(-75);
2915    nicer_binning.push_back(-50);
2916    nicer_binning.push_back(-25);
2917    nicer_binning.push_back(0);
# Line 2458 | Line 2921 | void ttbar_sidebands_comparison(string m
2921    nicer_binning.push_back(100);
2922    nicer_binning.push_back(125);
2923    nicer_binning.push_back(150);
2924 <  nicer_binning.push_back(175);
2924 >  //nicer_binning.push_back(175);
2925    nicer_binning.push_back(200);
2926 <  nicer_binning.push_back(230);
2927 <  nicer_binning.push_back(280);
2926 >  nicer_binning.push_back(250);
2927 >  nicer_binning.push_back(300);
2928    nicer_binning.push_back(400);
2929 +  
2930    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2931   }
2932  
2933  
2934 < void zjets_prediction_comparison() {
2935 <  // Do it without PU re-weighting
2936 <  float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2937 <  stringstream resultsNoPU;
2938 <
2939 <  stringstream mcjzbnoPU;
2940 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2941 <  if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2942 <  else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2934 > void zjets_prediction_comparison(string mcjzbWithPUa) {
2935 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2936 > //  zcan->SetLogy(1);
2937 >  TCut weightbackup=cutWeight;
2938 >  
2939 >  bool UsePURW=false;
2940 >  
2941 >  
2942 >  string mcjzb;
2943 >  if(UsePURW) {
2944 >    mcjzb=mcjzbWithPUa;
2945 >  } else {
2946 >    // Do it without PU re-weighting
2947 >    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2948 >    stringstream resultsNoPU;
2949 >    stringstream noPUdatajzb;
2950 >    stringstream noPUmcjzb;
2951 >    
2952 >    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2953 >    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2954 >    
2955 >    mcjzb = noPUmcjzb.str();
2956 >    
2957 >    cutWeight="1.0";
2958 >  }
2959  
2960 <  string mcjzb = mcjzbnoPU.str();
2961 <  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2960 >  
2961 >  vector<float> binning;
2962 >  binning.push_back(0);
2963 >  binning.push_back(10);
2964 >  binning.push_back(20);
2965 >  binning.push_back(40);
2966 >  binning.push_back(60);
2967 > //   binning.push_back(50);
2968 > //   binning.push_back(60);
2969 > //   binning.push_back(70);
2970 > //   binning.push_back(80);
2971 > //   binning.push_back(90);
2972 >  binning.push_back(100);
2973  
2483  TCut weightbackup=cutWeight;
2484  cutWeight="1.0";
2485  float sbg_min=0.;
2486  float sbg_max=100.;
2487  int sbg_nbins=5;
2974    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2975    
2976    TCut kPos((mcjzb+">0").c_str());
2977    TCut kNeg((mcjzb+"<0").c_str());
2978    string var( "abs("+mcjzb+")" );
2979 +  
2980 +  TCut notTau("abs(genMID1)!=15");
2981 +  TCut ONLYTau("mll>20");
2982 +  
2983  
2984 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2985 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2986 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2497 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2498 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2984 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2985 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2986 >  
2987    hJZBpos->SetLineColor(kBlack);
2988    hJZBneg->SetLineColor(kRed);
2989    
2990 <  Int_t nbins = 5;
2503 <  Float_t xmax = 100.;
2504 <
2505 <  
2506 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2507 <  zcan->SetLogy(1);
2508 <
2990 >  hJZBpos->SetMinimum(1.0);
2991    hJZBpos->Draw("e1");
2992    hJZBneg->Draw("same,hist");
2993    hJZBpos->Draw("same,e1"); // So it's on top...
2994    
2995 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2995 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2996    leg->AddEntry(hJZBpos,"Observed","pe");
2997    leg->AddEntry(hJZBneg,"Predicted","l");
2998    leg->Draw("same");
2999    DrawMCPrelim(simulatedlumi);
3000 <  CompleteSave(zcan,"Systematics/zjets_prediction");
3000 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
3001    
3002    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
3003    hratio->Divide(hJZBneg);
3004    
3005 +  for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
3006 +    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
3007 +  }
3008 +  
3009    zcan->SetLogy(0);
3010 <  hratio->GetYaxis()->SetRangeUser(0,2.5);
3010 >  hratio->GetYaxis()->SetRangeUser(0,2.0);
3011    hratio->GetYaxis()->SetTitle("Observed/Predicted");
3012    hratio->Draw("e1");
3013    
3014 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
3015 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
3016 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
3014 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
3015 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
3016 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
3017    
3018  
3019    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2538 | Line 3024 | void zjets_prediction_comparison() {
3024    center->Draw("same");
3025    bottom->Draw("same");
3026    
3027 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
3027 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3028    leg2->AddEntry(hratio,"obs / pred","pe");
3029    leg2->AddEntry(bottom,"syst. envelope","l");
3030    leg2->Draw("same");
3031    DrawMCPrelim(simulatedlumi);
3032 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
3032 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
3033 >  
3034 >  TCut reducedNJets(cutnJets);
3035 >  
3036 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3037 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3038 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3039 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 >
3041 >  TH1F *RcorrJZBSBem;
3042 >  TH1F *LcorrJZBSBem;
3043 >  TH1F *RcorrJZBSBeemm;
3044 >  TH1F *LcorrJZBSBeemm;
3045 >
3046 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3047 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3048 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3049 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3050 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 >  }
3052 >  
3053 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3054 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3055 >    Bpred->Add(RcorrJZBem,1.0/3.);
3056 >    Bpred->Add(LcorrJZBem,-1.0/3.);
3057 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
3058 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
3059 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
3060 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
3061 >  } else {
3062 >    Bpred->Add(RcorrJZBem,1.0);
3063 >    Bpred->Add(LcorrJZBem,-1.0);
3064 >  }
3065 >  
3066 >  Bpred->SetLineColor(kRed);
3067 >
3068 >  TAUhJZBpos->SetLineColor(kBlack);
3069 >  Bpred->SetLineColor(kRed);
3070 >  
3071 >  TAUhJZBpos->SetMinimum(1.0);
3072 >  TAUhJZBpos->Draw("e1");
3073 >  Bpred->Draw("same,hist");
3074 >  TAUhJZBpos->Draw("same,e1");
3075 >  
3076 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
3077 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
3078 >  TAUleg->AddEntry(Bpred,"Predicted","l");
3079 >  TAUleg->Draw("same");
3080 >  DrawMCPrelim(simulatedlumi);
3081 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
3082 >  
3083 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
3084 >  TAUhratio->Divide(Bpred);
3085 >  
3086 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
3087 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
3088 >  }
3089 >  
3090 >  zcan->SetLogy(0);
3091 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
3092 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
3093 >  TAUhratio->Draw("e1");
3094 >  
3095 >  top->Draw("same");
3096 >  center->Draw("same");
3097 >  bottom->Draw("same");
3098 >  
3099 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
3100 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3101 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
3102 >  TAUleg2->Draw("same");
3103 >  DrawMCPrelim(simulatedlumi);
3104 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
3105 >  
3106 >  delete Bpred;
3107 >  delete TAUhJZBpos;
3108 >  delete LcorrJZBeemm;
3109 >  delete RcorrJZBem;
3110 >  delete LcorrJZBem;
3111 >  
3112 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3113 >    delete RcorrJZBSBem;
3114 >    delete LcorrJZBSBem;
3115 >    delete RcorrJZBSBeemm;
3116 >    delete LcorrJZBSBeemm;
3117 >  }
3118 >  
3119    
3120    delete zcan;
3121    cutWeight=weightbackup;
# Line 2569 | Line 3141 | void sideband_assessment(string datajzb,
3141    tout << "\\begin{tabular}{l|cc}" << endl;
3142    tout << "\\hline" << endl;
3143    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
3144 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
3144 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
3145    tout << "\\end{tabular}" << endl;
3146    tout << "\\end{center}" << endl;
3147    tout << "\\end{table}" << endl;
# Line 2587 | Line 3159 | void make_table(samplecollection &coll,
3159    
3160    TCanvas *cannie = new TCanvas("cannie","cannie");
3161    
3162 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
3162 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
3163      float currcut=jzb_cuts[icut];
3164      int nbins=1;float low=currcut;
3165      vector<int> mysample;
# Line 2602 | Line 3174 | void make_table(samplecollection &coll,
3174      TH1F *RcorrJZBSBeemm;
3175      TH1F *LcorrJZBSBeemm;
3176      
3177 <    if(PlottingSetup::RestrictToMassPeak) {
3177 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3178        RcorrJZBSBem   = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3179        LcorrJZBSBem   = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3180        RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
# Line 2610 | Line 3182 | void make_table(samplecollection &coll,
3182      }
3183      
3184      TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3185 <    if(PlottingSetup::RestrictToMassPeak) {
3185 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3186        Bpred->Add(RcorrJZBem,1.0/3.);
3187        Bpred->Add(LcorrJZBem,-1.0/3.);
3188        Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 2646 | Line 3218 | void make_table(samplecollection &coll,
3218    //prediction part
3219    if(is_data) cout << "Data prediction & ";
3220    if(subselection!="none") cout << subselection << " prediction &";
3221 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3221 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3222    
3223    cout << endl;
3224    //observation part
3225    if(is_data) cout << "Data observation & ";
3226    if(subselection!="none") cout << subselection << " observation &";
3227 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3227 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3228    cout << endl;
3229    cout << "_________________________________________________________________" << endl;
3230    delete cannie;
# Line 2687 | Line 3259 | void JZBSelEff(string mcjzb, TTree* even
3259    int nbins = sizeof(xbins)/sizeof(float)-1;
3260    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
3261  
3262 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3263 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3264 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3262 >  
3263 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
3264 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
3265 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
3266  
3267    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
3268    TCut kreco(cutmass);
# Line 2705 | Line 3278 | void JZBSelEff(string mcjzb, TTree* even
3278    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
3279    can->SetGridx(1);
3280    can->SetGridy(1);
3281 +  can->SetLeftMargin(0.16);
3282 +  can->SetRightMargin(0.05);
3283    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
3284 +  leg->SetBorderSize(1);
3285 +  leg->SetLineColor(kBlack);
3286 +  leg->SetTextFont(62);
3287  
3288 <  
2711 <
2712 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
3288 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
3289  
3290      ostringstream selection;
3291      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2725 | Line 3301 | void JZBSelEff(string mcjzb, TTree* even
3301      }
3302    
3303      heff->GetXaxis()->SetRangeUser(min, max);
3304 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
3305 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
3306 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
3307 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
3308      heff->SetMarkerStyle(markers[icut]);
3309      heff->Fit("func","Q+","same");
3310  
# Line 2736 | Line 3316 | void JZBSelEff(string mcjzb, TTree* even
3316  
3317      // Store plot
3318      TH1F* h = (TH1F*)heff->Clone(hname);
3319 +    h->SetNdivisions(505,"X");
3320      if ( icut) h->Draw("same");
3321      else h->Draw();
3322      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2756 | Line 3337 | void JZBSelEff(string mcjzb, TTree* even
3337   // Calls the above function for each signal sample
3338   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
3339   {  
3340 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
3340 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
3341      dout << "JZB selection efficiency curve: " << std::endl;
3342      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
3343    }
# Line 2799 | Line 3380 | void qcd_plots(string datajzb, string mc
3380    TH1F *RcorrJZBSBeemm;
3381    TH1F *LcorrJZBSBeemm;
3382    
3383 <  TH1F *RcorrJZBeemmNoS;
3383 > //  TH1F *RcorrJZBeemmNoS;
3384  
3385      //these are for the ratio
3386    TH1F *JRcorrJZBeemm   = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2812 | Line 3393 | void qcd_plots(string datajzb, string mc
3393    TH1F *JRcorrJZBSBeemm;
3394    TH1F *JLcorrJZBSBeemm;
3395    
3396 <  if(PlottingSetup::RestrictToMassPeak) {
3396 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3397      RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3398      LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3399      RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2833 | Line 3414 | void qcd_plots(string datajzb, string mc
3414      
3415    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3416    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
3417 <  if(PlottingSetup::RestrictToMassPeak) {
3417 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3418      Bpred->Add(RcorrJZBem,1.0/3.);
3419      Bpred->Add(LcorrJZBem,-1.0/3.);
3420      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 2883 | Line 3464 | void qcd_plots(string datajzb, string mc
3464    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3465    string ytitle("ratio");
3466    if ( use_data==1 ) ytitle = "data/pred";
3467 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
3467 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
3468    
3469    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
3470    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 2903 | Line 3484 | void qcd_plots(string datajzb, string mc
3484    dout << "______________________________________________" << endl;
3485    dout << "How QCD shows up in the different regions: " << endl;
3486    dout << "OSSF: " << endl;
3487 <  if(PlottingSetup::RestrictToMassPeak) {
3487 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3488      dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3489      dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
3490    } else {
3491      dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3492    }
3493    dout << "OSOF: " << endl;
3494 <  if(PlottingSetup::RestrictToMassPeak) {
3494 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3495      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3496      dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
3497    } else {
3498      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3499    }
3500    dout << "Therefore: " << endl;
3501 <  if(PlottingSetup::RestrictToMassPeak) {
3501 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3502      dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
3503      dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
3504      dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
# Line 2930 | Line 3511 | void qcd_plots(string datajzb, string mc
3511    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
3512    
3513    dout << endl;
3514 <  for(int i=0;i<bins.size();i++) {
3514 >  for(int i=0;i<(int)bins.size();i++) {
3515      dout << " JZB > " << bins[i] << " : " << endl;
3516      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3517 <    if(PlottingSetup::RestrictToMassPeak) {
3517 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3518          dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + (1.0/3)*(RcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX())) << endl;
3519      } else {
3520          dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
# Line 2947 | Line 3528 | void qcd_plots(string datajzb, string mc
3528    if(LcorrJZBem) delete LcorrJZBem;
3529    if(RcorrJZBeemm) delete RcorrJZBeemm;
3530    if(LcorrJZBeemm) delete LcorrJZBeemm;
3531 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3532 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3533 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3534 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3531 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBem) delete RcorrJZBSBem;
3532 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBem) delete LcorrJZBSBem;
3533 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3534 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3535   }
3536  
3537   void check_ptsanity() {
# Line 2978 | Line 3559 | void check_ptsanity() {
3559    leg->SetY2(1.0);
3560    
3561    
3562 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3562 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3563      string nowname=(allsamples.collection)[isample].filename;
3564      cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3565      individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
# Line 3002 | Line 3583 | void check_ptsanity() {
3583    ptsancan->cd(2);
3584    fpt2->Draw();
3585  
3586 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3586 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3587      ptsancan->cd(1);
3588      individualpt1histos[isample]->DrawNormalized("same,histo");
3589      ptsancan->cd(2);
# Line 3018 | Line 3599 | void check_ptsanity() {
3599   void do_mlls_plot(string mcjzb) {
3600    cout << "At this point we'd plot the mll distribution" << endl;
3601    TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3602 <  for(int isig=0;isig<(signalsamples.collection).size();isig++) {
3602 >  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3603      if(!(signalsamples.collection)[isig].events) continue;
3604      string nowname=(signalsamples.collection)[isig].filename;
3605      TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
# Line 3047 | Line 3628 | void do_mlls_plot(string mcjzb) {
3628    }
3629   }
3630  
3631 < void met_vs_jzb_plots() {
3631 > void met_vs_jzb_plots(string datajzb, string mcjzb) {
3632    
3633    TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3634    canmetjzb->SetRightMargin(0.16);
# Line 3056 | Line 3637 | void met_vs_jzb_plots() {
3637    findme.push_back("DY");
3638    findme.push_back("TTJets");
3639    findme.push_back("LM");
3640 <  
3641 <  for(int ifind=0;ifind<findme.size();ifind++) {
3640 >  /*
3641 >  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3642      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3643      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3644 <    for(int isel=0;isel<selsamples.size();isel++) {
3645 <      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3646 <      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3644 >    for(int isel=0;isel<(int)selsamples.size();isel++) {
3645 >      dout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3646 >      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF&&cutnJets);
3647      }
3648      metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3649      metvsjzb->SetStats(0);
# Line 3076 | Line 3657 | void met_vs_jzb_plots() {
3657      title->Draw();
3658      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3659    }
3660 +  */
3661 +  
3662 +  dout << "About to produce MET plot for DY split up by JZB" << endl;
3663 +  
3664 +  int nbins=14;
3665 +  float low=0;
3666 +  float high=140;
3667 +  
3668 +  stringstream sLEFT;
3669 +  sLEFT << "((" << mcjzb << ")<0)";
3670 +  TCut LEFT(sLEFT.str().c_str());
3671 +  stringstream sRIGHT;
3672 +  sRIGHT << "((" << mcjzb << ")>0)";
3673 +  TCut RIGHT(sRIGHT.str().c_str());
3674 +  
3675 +  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3676 +  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3677 +  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3678 +  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3679 +  
3680 +  
3681 +  TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
3682 +  Bpred->Add(metleftO,-1);
3683 +  Bpred->Add(metrightO);
3684 +  TH1F *obs = (TH1F*)metright->Clone("obs");
3685 +  
3686 +  metleft->Add(metleftO,-1);
3687 +  metright->Add(metrightO,-1);
3688 +  
3689 +  metleft->SetLineColor(kRed);
3690 +  metright->SetLineColor(kBlack);
3691 +  TPad *metpad = new TPad("metpad","metpad",0,0,1,1);
3692 +  metpad->cd();
3693 +  metpad->SetLogy(1);
3694 +  metleft->Draw("histo");
3695 +  metright->Draw("same");
3696 +  TLegend *lg = make_legend();
3697 +  lg->SetX1(0.5);
3698 +  lg->SetY1(0.7);
3699 +  lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3700 +  lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3701 +  lg->SetHeader("DY");
3702 +  
3703 +  lg->Draw();
3704 +  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3705 +  
3706 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3707 +  metpad3->cd();
3708 +  metpad3->SetLogy(1);
3709 +  Bpred->SetLineColor(kRed);
3710 +  Bpred->Draw("histo");
3711 +  obs->SetLineColor(kBlack);
3712 +  obs->Draw("same");
3713 +  TLegend *lg2 = make_legend();
3714 +  lg2->SetX1(0.5);
3715 +  lg2->SetY1(0.7);
3716 +  lg2->AddEntry(obs,"observed","P");
3717 +  lg2->AddEntry(Bpred,"predicted","L");
3718 +  lg2->SetHeader("DY");
3719 +
3720 +  lg2->Draw();
3721 +  
3722 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
3723 +  
3724 +  TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3725 +  metpad2->cd();
3726 +  metpad2->SetLogy(1);
3727 +  
3728 +  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3729 +  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3730 +  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3731 +  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3732 +  
3733 +  metlefta->Add(metleftOa,-1);
3734 +  metrighta->Add(metrightOa,-1);
3735 +  
3736 +  metlefta->SetLineColor(kRed);
3737 +  metpad2->cd();
3738 +  metlefta->Draw("histo");
3739 +  metrighta->Draw("same");
3740 +  lg->Draw();
3741 +  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3742 +  
3743 +  delete Bpred;
3744 +  delete obs;
3745 +  
3746 +  float newhigh=300;
3747 +  int newNBins=30;
3748 +  
3749 +  TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
3750 +  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
3751 +  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
3752 +  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
3753 +  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
3754 +  
3755 +  TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
3756 +  aBpred->Add(AmetleftO,-1);
3757 +  aBpred->Add(AmetrightO);
3758 +  aBpred->SetLineColor(kRed);
3759 +  
3760 +  TH1F *aobs = (TH1F*)Ametright->Clone("aobs");
3761 +  metpad4->cd();
3762 +  metpad4->SetLogy(1);
3763 +  aobs->Draw();
3764 +  aBpred->Draw("histo,same");
3765 +  aobs->Draw("same");
3766 +  lg->SetHeader("All MC");
3767 +  lg->Draw();
3768 +  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
3769 +  
3770 +  
3771 +  delete lg;
3772 +  delete canmetjzb;
3773 +  delete metleft;
3774 +  delete metleftO;
3775 +  delete metright;
3776 +  delete metrightO;
3777   }
3778      
3779  
# Line 3083 | Line 3781 | void test() {
3781    
3782    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
3783    testcanv->cd();
3784 <  switch_overunderflow(true);
3784 > //  switch_overunderflow(true);
3785    TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
3786    switch_overunderflow(false);
3787    ptdistr->Draw();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines