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.67 by buchmann, Fri Sep 14 10:18:31 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, bool SwitchOffNJetsCut, 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 >  TCut nJetsCut(cutnJets);
46 >  if(SwitchOffNJetsCut) nJetsCut=specialcut;
47 >  
48    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
49 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
50 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
51 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
52 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
49 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&nJetsCut&&specialcut,mc, luminosity);
50 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&nJetsCut&&specialcut,data, luminosity);
51 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&nJetsCut&&specialcut,mc, luminosity);
52 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&nJetsCut&&specialcut,data, luminosity);
53    TH1F *rawttbarjzbeemmMC;
54  
55    if(method==doKM) {
56      //we only need this histo for the KM fitting...
57 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
58 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
59 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
57 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&nJetsCut&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
58 >    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,MCSigmaError,method,saveas);
59 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
60 >    delete rawttbarjzbeemmMC;
61    }
62    else {
63      TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
# Line 55 | Line 65 | void find_peaks(float &MCPeak,float &MCP
65      reducedMC->Add(rawJZBemMC,-1);
66      reducedData->Add(rawJZBemData,-1);
67      //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)
68 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
69 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
70 <    
68 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,MCSigmaError,method,saveas);
69 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
70 >    delete reducedMC;
71 >    delete reducedData;
72    }
73  
74    // Revert to original PU reweighting
# Line 65 | Line 76 | void find_peaks(float &MCPeak,float &MCP
76      
77   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
78   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
79 <  dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
80 <  result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
81 <  dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
82 <  result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
80 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
81 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
82 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
83 >  delete rawJZBeemmData;
84 >  delete rawJZBeemmMC;
85 >  delete rawJZBemData;
86 >  delete rawJZBemMC;
87    delete tempcan;
88   }
89  
90 < void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
90 > void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb, string sSpecialCut="", bool SwitchOffNJetsCut=false)
91 > {
92 >  bool overunderflowstatus=addoverunderflowbins;
93 >  switch_overunderflow(false);
94 >  
95 >  TCut SpecialCut("mll>=0");
96 >  if(sSpecialCut!="") SpecialCut=TCut(sSpecialCut.c_str());
97 >  
98 >  bool DoInvidualeemmPeaks=false;
99 >  
100 >  float mcpeak, datapeak;
101 >  float mcpeakerr, datapeakerr;
102 >  
103 >  float mceepeak,mcmmpeak;
104 >  float mceepeakerr,mcmmpeakerr;
105 >  
106 >  float datammpeak,dataeepeak;
107 >  float datammpeakerr,dataeepeakerr;
108 >  
109 >  float mcSigma,mcSigmaError, dataSigma, dataSigmaError;
110 >  
111 >  dout << "Finding global peak : " << endl;
112 >  find_one_peak_combination(SpecialCut,SwitchOffNJetsCut,mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
113 >  
114 >  if(DoInvidualeemmPeaks) {
115 >    dout << "Finding peak for electrons : " << endl;
116 >    find_one_peak_combination(SpecialCut&&TCut("id1==0"),SwitchOffNJetsCut,mceepeak,mceepeakerr,dataeepeak,dataeepeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_ele");
117 >    dout << "Finding peak for muons : " << endl;
118 >    find_one_peak_combination(SpecialCut&&TCut("id1==1"),SwitchOffNJetsCut,mcmmpeak,mcmmpeakerr,datammpeak,datammpeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_mu");
119 >    
120 >    datajzb << "(" << jzbvariabledata;
121 >    mcjzb << "(" << jzbvariablemc;
122 >    
123 >    if(dataeepeak>0) datajzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
124 >    else datajzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
125 >    
126 >    if(datammpeak>0) datajzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
127 >    else datajzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
128 >    
129 >    if(datapeak>0) datajzb << "- (id1!=id2)*" << TMath::Abs(datapeak) << " ";
130 >    else datajzb << "+ (id1!=id2)*" << TMath::Abs(datapeak) << " ";
131 >    
132 >    datajzb << ")";
133 >    
134 >    if(mceepeak>0) mcjzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
135 >    else mcjzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
136 >    
137 >    if(mcmmpeak>0) mcjzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
138 >    else mcjzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
139 >    
140 >    if(mcpeak>0) mcjzb << "- (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
141 >    else mcjzb << "+ (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
142 >    
143 >    mcjzb << ")";
144 >    
145 >  } else {
146 >    datajzb << "(" << jzbvariabledata;
147 >      mcjzb << "(" << jzbvariablemc;
148 >    
149 >    if(datapeak>0) datajzb << "- " << TMath::Abs(datapeak) << " ";
150 >    else datajzb << "+ " << TMath::Abs(datapeak) << " ";
151 >    
152 >    datajzb << ")";
153 >    
154 >    if(mcpeak>0) mcjzb << "- " << TMath::Abs(mcpeak) << " ";
155 >    else mcjzb << "+ " << TMath::Abs(mcpeak) << " ";
156 >    
157 >    mcjzb << ")";
158 >  }
159 >  
160 >    MCPeak=mcpeak;
161 >    MCPeakError=mcpeakerr;
162 >    DataPeak=datapeak;
163 >    DataPeakError=datapeakerr;
164 >    switch_overunderflow(overunderflowstatus);
165 > }
166 >
167 > void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold, float binWidth = 5.0) {
168    float min=70.0;
169    float max=115.0;
170    if(!PlottingSetup::RestrictToMassPeak) {
171 <    min=10;
172 <    max=150;
171 >    min=20;
172 >    max=300;
173    }
174 <  int nbins=int((max-min)/5);
174 >  int nbins=int((max-min)/binWidth);
175    
176    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
177    
178    stringstream largerzeroS;
179 <  largerzeroS << "(" << mcjzb << ">" << jzbthreshold << ")";
180 <  TCut largerzero(largerzeroS.str().c_str());
179 >  largerzeroS << "(" << datajzb << ">" << jzbthreshold << ")";
180 >  TCut largerzeroD(largerzeroS.str().c_str());
181    
182    stringstream smallerzeroS;
183 <  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
184 <  TCut smallerzero(smallerzeroS.str().c_str());
185 <  
186 <  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,data,luminosity);
187 <  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,mc,luminosity);
188 <  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,data,luminosity);
189 <  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,data,luminosity);
190 <  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,data,luminosity);
183 >  smallerzeroS << "(" << datajzb << "<-" << jzbthreshold << ")";
184 >  TCut smallerzeroD(smallerzeroS.str().c_str());
185 >
186 >
187 >  stringstream largerzeroMS;
188 >  largerzeroMS << "(" << mcjzb << ">" << jzbthreshold << ")";
189 >  TCut largerzeroM(largerzeroMS.str().c_str());
190 >  
191 >  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroD,data,luminosity);
192 >  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroM,mc,luminosity);
193 >  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzeroD,data,luminosity);
194 >  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzeroD,data,luminosity);
195 >  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzeroD,data,luminosity);
196  
197    TH1F *RcorrJZBSBem;
198    TH1F *LcorrJZBSBem;
199    TH1F *RcorrJZBSBeemm;
200    TH1F *LcorrJZBSBeemm;
201    
202 <  TH1F *RcorrJZBeemmNoS;
202 > //  TH1F *RcorrJZBeemmNoS;
203  
204 <  if(PlottingSetup::RestrictToMassPeak) {
205 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,data, luminosity);
206 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,data, luminosity);
207 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,data, luminosity);
208 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,data, luminosity);
209 <  }
210 <  
211 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
212 <  if(PlottingSetup::RestrictToMassPeak) {
213 <    Bpred->Add(RcorrJZBem,1.0/3.);
214 <    Bpred->Add(LcorrJZBem,-1.0/3.);
215 <    Bpred->Add(RcorrJZBSBem,1.0/3.);
216 <    Bpred->Add(LcorrJZBSBem,-1.0/3.);
217 <    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
218 <    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
219 <  } else {
220 <    Bpred->Add(RcorrJZBem,1.0);
221 <    Bpred->Add(LcorrJZBem,-1.0);
222 <  }
223 <  
204 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
205 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
206 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
207 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
208 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzeroD,data, luminosity);
209 >  }
210 >  
211 >  // Separate predictions
212 >  TH1F* SFN = (TH1F*)LcorrJZBeemm->Clone("SFN");
213 >  TH1F* OFP = (TH1F*)RcorrJZBem->Clone("OFP");
214 >  TH1F* OFN = (TH1F*)LcorrJZBem->Clone("OFN");
215 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
216 >    OFP->Scale(1.0/3.0);
217 >    OFP->Add(RcorrJZBSBem,1.0/3.);
218 >    OFP->Add(RcorrJZBSBeemm,1.0/3.);
219 >    OFN->Scale(1.0/3.0);
220 >    OFN->Add(LcorrJZBSBem,1.0/3.);
221 >    OFN->Add(LcorrJZBSBeemm,1.0/3.);
222 >  }
223 >
224 >  TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
225 >  Bpred->Add(OFP);
226 >  Bpred->Add(OFN,-1);
227    Bpred->SetLineColor(kRed);
228    
229 +  RcorrJZBeemm->SetTitleOffset(1.3,"y");
230    RcorrJZBeemm->Draw();
231    mcRcorrJZBeemm.Draw("same");
232    Bpred->Draw("histo,same");
# Line 140 | Line 241 | void make_special_obs_pred_mll_plot(stri
241    stringstream saveas;
242    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
243    CompleteSave(ckin,saveas.str());
244 <
244 >  
245 >  // Draw all predictions overlayed
246 >  unsigned int w = gStyle->GetHistLineWidth()+1; // Make line a bit wider, since we dash it
247 >  SFN->SetLineColor(kGreen+2);
248 >  SFN->SetLineStyle(2);
249 >  SFN->SetLineWidth(w);
250 >  OFP->SetLineColor(kBlue+2);
251 >  OFP->SetLineStyle(2);
252 >  OFP->SetLineWidth(w);
253 >  OFN->SetLineColor(kMagenta+2);
254 >  OFN->SetLineStyle(3);
255 >  OFN->SetLineWidth(w);
256 >  
257 >  RcorrJZBeemm->Draw();
258 >  SFN->Draw("histo,same");
259 >  OFP->Draw("histo,same");
260 >  OFN->Draw("histo,same");
261 >  Bpred->Draw("histo,same");
262 >  RcorrJZBeemm->Draw("same");
263 >  
264 >  TLegend *leg2 = make_legend("",0.52,0.7);
265 >  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
266 >  leg2->AddEntry(Bpred,"predicted (data)","l");
267 >  leg2->AddEntry(SFN,  "  SF JZB<0","l");
268 >  leg2->AddEntry(OFN,  "  OF JZB<0","l");
269 >  leg2->AddEntry(OFP,  "  OF JZB>0","l");
270 >  leg2->Draw("same");
271 >  
272 >  saveas.str("");
273 >  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
274 >  CompleteSave(ckin,saveas.str());
275 >  
276    delete RcorrJZBeemm;
277    delete LcorrJZBeemm;
278    delete RcorrJZBem;
279    delete LcorrJZBem;
280 <  if(PlottingSetup::RestrictToMassPeak) {
280 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
281      delete RcorrJZBSBeemm;
282      delete LcorrJZBSBeemm;
283      delete RcorrJZBSBem;
# Line 189 | Line 321 | void make_special_mll_plot(int nbins, fl
321    TIter next(bgleg->GetListOfPrimitives());
322    TObject* obj;
323    // Copy the nice bkgd legend skipping the "data"
324 <  while ( obj = next() )
324 >  while ( (obj = next()) )
325      if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
326        kinleg->GetListOfPrimitives()->Add(obj);
327  
# Line 208 | Line 340 | void draw_ratio_plot(TH1* hdata, THStack
340    TIter next(hmc.GetHists());
341    TObject* obj;
342    TH1* hratio = NULL;
343 <  while ( obj = next() ) {
343 >  while ( (obj = next()) ) {
344      if ( !hratio ) {
345        hratio = (TH1*)obj->Clone();
346        hratio->SetName("hratio");
# Line 239 | Line 371 | void draw_ratio_plot(TH1* hdata, THStack
371    oneline->Draw("same");
372   }
373  
374 + float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
375 +                        string xlabel, string filename, float legendPosition=0.55) {
376 +
377 +  TCut ibasiccut=basiccut;
378 +  bool draw_separation_lines=false;
379 +
380 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
381 +
382 +  TCut cutSF;
383 +  TCut cutOF;
384 +
385 +  cutOF = cutOSOF&&cutnJets&&ibasiccut;
386 +  cutSF = cutOSSF&&cutnJets&&ibasiccut;
387 +
388 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
389 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
390 +  rcan->SetLogy(logscale);
391 +  rcan->cd();
392 +
393 +  std::cout << "OF/SF comparison: variable = " << variable << ", cut = " << cutSF.GetTitle() << std::endl;
394 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
395 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
396 + //   string signal("LM3");
397 + //   TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
398 + //   int idx = signalsamples.FindSample(signal)[0];
399 + //   (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
400 + //   signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
401 + //   signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
402 + //   signalhisto->SetLineStyle(2);
403 +  datahistoSF->SetMarkerSize(DataMarkerSize);
404 +  datahistoOF->SetLineColor(kRed);
405 +
406 +  if ( !logscale ) {
407 +    datahistoSF->SetMinimum(0); // Defaults
408 +  } else {
409 +    datahistoSF->SetMinimum(0.5);
410 +  }
411 +  if (ymax<0) {
412 +    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
413 +    else datahistoSF->SetMaximum(1.5*datahistoSF->GetMaximum());
414 +  } else {
415 +    datahistoSF->SetMaximum(ymax);
416 +  }
417 +
418 +  float ymaxSet = datahistoSF->GetMaximum();
419 +
420 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
421 +  datahistoSF->GetYaxis()->SetTitle("Events");
422 +  datahistoSF->GetXaxis()->CenterTitle();
423 +  datahistoSF->GetYaxis()->CenterTitle();
424 +
425 +  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
426 +  mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
427 +  if (datahistoOF->Integral()>0) {
428 +    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
429 +  } else {
430 +    mleg->AddEntry((TObject*)0, "", "");
431 +  }
432 +  //mleg->AddEntry(signalhisto, "LM3", "L");
433 +
434 +  datahistoSF->Draw("E1");
435 +  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
436 +  //signalhisto->Draw("HIST,SAMES");
437 +  mleg->Draw();
438 +  DrawPrelim();
439 +  if (datahistoOF->Integral()>0) {
440 +    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
441 +  } else {
442 +    CompleteSave(rcan, "SFOF/" + filename);
443 +    delete rcan;
444 +  }
445 +
446 +  datahistoSF->Delete();
447 +  datahistoOF->Delete();
448 +  //signalhisto->Delete();
449 +  delete mleg;
450 +  delete ckin;
451 +
452 +  return ymaxSet;
453 +
454 + }
455 +
456 + // Compare data to data
457 + float make_data_comparison_plot(string variable, TCut cut, int nbins, float min, float max, float ymax, bool logscale,
458 +                                string xlabel, string filename, float legendPosition=0.55) {
459 +
460 +  TCut ibasiccut=basiccut&&cut;
461 +
462 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
463 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
464 +  rcan->SetLogy(logscale);
465 +  rcan->cd();
466 +
467 +  std::cout << "Data comparison: variable = " << variable << ", cut = " << ibasiccut.GetTitle() << std::endl;
468 +
469 +  TH1F *data1 = allsamples.Draw("data1",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
470 +  TH1F *data2 = comparesamples.Draw("data2",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
471 +
472 +  data1->SetMarkerSize(DataMarkerSize);
473 +  data2->SetLineColor(kRed);
474 +
475 +  if ( !logscale ) {
476 +    data1->SetMinimum(0); // Defaults
477 +  } else {
478 +    data1->SetMinimum(0.5);
479 +  }
480 +  if (ymax<0) {
481 +    if ( logscale ) data1->SetMaximum(5.3*data1->GetMaximum());
482 +    else data1->SetMaximum(1.5*data1->GetMaximum());
483 +  } else {
484 +    data1->SetMaximum(ymax);
485 +  }
486 +
487 +  float ymaxSet = data1->GetMaximum();
488 +
489 +  data1->GetXaxis()->SetTitle(xlabel.c_str());
490 +  data1->GetYaxis()->SetTitle("Events");
491 +  data1->GetXaxis()->CenterTitle();
492 +  data1->GetYaxis()->CenterTitle();
493 +
494 +  TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
495 +  mleg->AddEntry(data1, "New 3.8/fb", "PL");
496 +  mleg->AddEntry(data2, "Old 5.1/fb", "L");
497 +
498 +  data1->Draw("E1");
499 +  data2->Draw("HIST,SAMES");
500 +  mleg->Draw();
501 +  DrawPrelim();
502 +  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "old/new" );
503 +
504 +  data1->Delete();
505 +  data2->Delete();
506 +  delete mleg;
507 +  delete ckin;
508 +
509 + }
510 +
511 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
512 +                     string xlabel, string filename, float legendPosition=0.55) {
513 +
514 +  string mllcuts[] = { "mll>15","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
515 +  string mllcutname[] = { "m_{ll} > 15 GeV", "15 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 120 GeV" };
516 +  string plotname[] = {"_all","_low","_peak","_high"};
517 +  float ymax;
518 +
519 +  int start = 0;
520 +  if ( !PlottingSetup::openBox ) start = 3;
521 +
522 +  for ( int i=start; i<4; ++i ) {
523 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
524 +    if ( i==start ) {
525 +      ymax = make_one_OFSF_plot(variable, mllcuts[i], mllcutname[i], nbins, min, max, -1, logscale, xlabel,
526 +                         filename+plotname[i], legendPosition );
527 +    } else {
528 +      make_one_OFSF_plot(variable, mllcuts[i],        mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
529 +                         filename+plotname[i], legendPosition );
530 +    }
531 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
532 +                       filename+plotname[i]+"_mm", legendPosition );
533 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
534 +                       filename+plotname[i]+"_ee", legendPosition );
535 +  }
536 +
537 + }
538 +
539 +
540   float lastrange_min=0;
541   float lastrange_max=0;
542  
# Line 247 | Line 545 | void make_kin_plot(string variable, stri
545   //  TCut basiccut("(pfJetGoodNum>=2&&pfJetGoodID[0])&&(pfJetGoodNum>=2&&pfJetGoodID[1])&&(passed_triggers||!is_data)");
546    TCut ibasiccut=basiccut;
547    bool draw_separation_lines=false;
548 +  bool drawsignal = false;
549    
550    if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
551  
# Line 268 | Line 567 | void make_kin_plot(string variable, stri
567    //Step 2: Refine the cut
568    TCut cut;
569    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
570 <  if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
570 >  if(filename=="nJets" || filename=="nJets_inclusive" || filename=="nJets_met100" || filename=="nJets_inclusive_met100") cut=cutmass&&cutOSSF&&ibasiccut;
571 >  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive" || filename=="nJets_osof_met100" || filename=="nJets_osof_inclusive_met100") cut=cutmass&&cutOSOF&&ibasiccut;
572    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
573 <  if(filename=="mll") {
573 >  if(filename=="mll"||filename=="mll_met100") {
574          cut=cutOSSF&&cutnJets&&ibasiccut;
575          draw_separation_lines=true;
576    }
577 <  if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
578 <  if(filename=="mll_osof") {
577 >  if(filename=="mll_ee"||filename=="mll_ee_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
578 >  if(filename=="mll_mm"||filename=="mll_mm_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
579 >  if(filename=="mll_osof"||filename=="mll_osof_met100") {
580          cut=cutOSOF&&cutnJets&&ibasiccut;
581          draw_separation_lines=true;
582    }
583 <  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
584 <  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
583 >  if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
584 >  if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
585 >  if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
586    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
587    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
588    if(filename=="mll_inclusive_osof") cut=cutOSOF;
# Line 288 | Line 590 | void make_kin_plot(string variable, stri
590    if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
591    if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
592    if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
593 +  if(filename=="numVtx") cut=cutmass&&ibasiccut;
594  
595    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
596    ckin->SetLogy(logscale);
597    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
598    datahisto->SetMarkerSize(DataMarkerSize);
599 <  THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
599 >  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
600 >  else datahisto->SetMinimum(0.5);
601 >  // Custom max.
602 >  if(variable=="TMath::Abs(pfJetDphiMet[0])") datahisto->SetMaximum(1.5*datahisto->GetMaximum());
603    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
604    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
605 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
605 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
606    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
607    if(filename=="mll_osof") datahisto->SetMinimum(9);
608 +  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
609 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
610  
611 <  datahisto->SetMaximum(5.3*datahisto->GetMaximum());
304 <  datahisto->Draw("e1");
305 <  ckin->Update();
611 >  cout << "******** Cut used : " << (const char*) cut << " for plot " << filename << endl;
612    if(loadlastminmax) {
613          datahisto->SetMinimum(lastrange_min);
614          datahisto->SetMaximum(lastrange_max);
# Line 312 | Line 618 | void make_kin_plot(string variable, stri
618          }              
619    }
620  
621 +  // Draw signal by hand (for some reason I don't manage to use the sample class: it adds it to the stack!)
622 +  string signal("LM3");
623 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
624 +  int idx = signalsamples.FindSample(signal)[0];
625 +  if(drawsignal) (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
626 +  if(drawsignal) signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
627 +  if(drawsignal) signalhisto->SetLineColor(kOrange);
628 +
629 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
630 +  datahisto->Draw("e1");
631 +  ckin->Update();
632    mcstack.Draw("same");
633 +  
634    datahisto->Draw("same,e1");
635    TLegend *kinleg = allsamples.allbglegend();
636    kinleg->Draw();
# Line 355 | Line 673 | void make_kin_plot(string variable, stri
673          kinpad->SetLogy(logscale);
674          datahisto->Draw("e1");
675          mcstack.Draw("same");
676 +        if(drawsignal) signalhisto->Draw("same");
677          datahisto->Draw("same,e1");
678          datahisto->Draw("same,axis");
679          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 362 | Line 681 | void make_kin_plot(string variable, stri
681            upperboundary->Draw("same");
682          }
683            
684 +        if(drawsignal) kinleg->AddEntry("signalhisto",signal.c_str(),"l");
685          kinleg->Draw();
686          write_cut->Draw();
687          DrawPrelim();
# Line 376 | Line 696 | void make_kin_plot(string variable, stri
696          else CompleteSave(ckin,"kin/"+filename);
697    }
698    datahisto->Delete();
699 +  delete signalhisto;
700    delete ckin;
701   }
702  
703 < void make_JES_plot() {
703 > void make_JES_plot(TCut cut, string name) {
704  
705    int nbins=10;
706    float min=-0.5;
707    float max = 9.5;
708    bool logscale=true;
709    string xlabel="nJets";
389  TCut cut=cutmass&&cutOSSF&&basiccut;
710  
711    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
712    ckin->SetLogy(logscale);
713 <  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
713 >  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,data,luminosity);
714    datahisto->SetMarkerSize(DataMarkerSize);
715 <  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
716 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
717 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
715 >  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,mc,luminosity);
716 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum40p1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
717 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum40n1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
718  
719    datahisto->SetMinimum(1);
720    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 419 | Line 739 | void make_JES_plot() {
739    TLegend *kinleg = allsamples.allbglegend();
740    kinleg->AddEntry(JESunc,"JES uncertainty","f");
741    kinleg->Draw();
742 <  CompleteSave(ckin,"Systematics/JES");
742 >  CompleteSave(ckin,"Systematics/JES"+name);
743    datahisto->Delete();
744    delete ckin;
745  
# Line 427 | Line 747 | void make_JES_plot() {
747  
748   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
749   {
750 + //  switch_overunderflow(true);
751    bool dolog=true;
752    bool nolog=false;
753 +
754 +  bool doOFSF = false;
755 +  bool doKin  = true;
756 +  bool doDataComp = false;
757 +  
758 +
759    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
760 <  float mll_low=40;
760 >  float mll_low=50;
761    float mll_hi=160;
762    if(!PlottingSetup::RestrictToMassPeak) {
763 <        mll_low=10;
764 <        mll_hi=210;
763 >        mll_low=20;
764 >        mll_hi=320;
765    }
766 <  /*
767 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
768 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
769 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
770 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
771 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
772 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
773 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
774 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
775 <  make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);/*
776 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
777 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
778 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
779 <  make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
780 <  make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
781 <  make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
782 <  make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
783 <  make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
784 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
785 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);*//*
786 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
787 <  stringstream jzbcut;
788 <  jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
789 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
790 <  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);
791 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
792 <  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);
793 <  stringstream jzbcut2;
794 <  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
795 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
796 <  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);
797 <  stringstream jzbcut3;
798 <  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
799 <  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);
800 <  */
801 <  make_special_obs_pred_mll_plot(mcjzb,50);
802 <  make_special_obs_pred_mll_plot(mcjzb,100);
803 <  make_special_obs_pred_mll_plot(mcjzb,150);
804 <  make_special_obs_pred_mll_plot(mcjzb,200);
805 <  make_special_obs_pred_mll_plot(mcjzb,250);
766 >
767 >  if ( doOFSF ) {
768 >    make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
769 >
770 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
771 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
772 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
773 >
774 >    make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
775 >    make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
776 >
777 >    make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
778 >    make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
779 >    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
780 >    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
781 >    make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
782 >    make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
783 >    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
784 >    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
785 >    //  make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
786 >    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
787 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
788 >    //  make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
789 >    //  make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
790 >    make_OFSF_plots("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilc");
791 >    make_OFSF_plots("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijc");
792 >    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(l,MET)|)", "dphilco");
793 >    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(jet,MET)|)", "dphijco");
794 >  }
795 >
796 >  if ( doDataComp && !PlottingSetup::openBox ) {
797 >    TCut mllCut("");
798 >    float massmin = 15.;
799 >    float massmax = 315;
800 >    int massnbins = 60;
801 >    if ( !PlottingSetup::openBox ) {
802 >      mllCut = "mll>120";
803 >      massmin = 120;
804 >      massmax = 360;
805 >      massnbins = 14;
806 >    }
807 >
808 >    TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
809 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
810 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
811 >
812 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
813 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
814 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
815 >
816 >    make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
817 >    make_data_comparison_plot("mll", cutmass&&cutOSSF&&"met[4]>100&&met[4]<150&&pfJetGoodNum40==2", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_CR");
818 >    make_data_comparison_plot("mll", cutmass&&cutOSOF&&"met[4]>100&&met[4]<150&&pfJetGoodNum40==2", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_CR");
819 >
820 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_SF_sig");
821 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
822 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
823 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
824 >  }
825 >
826 >
827 >  if ( doKin ) {
828 >    string mllCut("");
829 >    if ( !PlottingSetup::openBox ) mllCut = "&&mll>120";
830 >
831 >    // Plots in signal region
832 > //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
833 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
834 >    make_kin_plot("mll","mll>20",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
835 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
836 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
837 >    
838 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
839 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
840 >    
841 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_met100",doPF,true);
842 >    make_kin_plot("mll","mll>20&&met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_met100",doPF,true,true);
843 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee_met100",doPF,true);
844 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm_met100",doPF,true);
845 >    
846 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
847 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
848 >
849 >    // Further inclusive invariant mass plots
850 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
851 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
852 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
853 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
854 >    
855 >    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
856 >    //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
857 >    
858 >    //make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
859 >    //make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
860 >    
861 >    // Number of jets
862 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
863 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
864 >    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
865 >    
866 >    // Others
867 >    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
868 >    //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
869 >    //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
870 >    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
871 >    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
872 >    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
873 >    make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
874 >    make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
875 >    //   stringstream jzbcut;
876 >    //   jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
877 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
878 >    //   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);
879 >    //   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);
880 >    //   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);
881 >    //   stringstream jzbcut2;
882 >    //   jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
883 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
884 >    //   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);
885 >    //   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);
886 >    //   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);
887 >    //   stringstream jzbcut3;
888 >    //   jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
889 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
890 >    //   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);
891 >    //   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);  
892 >    //   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);  
893 >    
894 >    //   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_ll",doPF,true);
895 >    //make_kin_plot("mll","met[4]>150&&id1==0",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ee} [GeV] (MET>150GeV)","mll_met150_ee",doPF,true);
896 >    //make_kin_plot("mll","met[4]>150&&id1==1",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{#mu#mu} [GeV] (MET>150GeV)","mll_met150_mm",doPF,true);
897 >  }
898 >    
899 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
900 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
901 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
902 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
903 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
904 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
905 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
906 >
907 > //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
908 > //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
909 >
910 >  switch_overunderflow(false);
911   }
912  
913   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
914                       int nbins, float xmin, float xmax, bool log,
915                       float ymin=0, float ymax=0, bool leftJustified=false ) {
916 <      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
916 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
917  
918    TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
919    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__));
920 <  if(var=="numVtx") cutWeight=TCut("1.0");
920 >  //if(var=="numVtx") cutWeight=TCut("1.0");
921    TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
922    TCut jzbMC[]  = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
923  
924    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
925    int nRegions=4;
926 <  if(!PlottingSetup::RestrictToMassPeak) {
926 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
927      nRegions=2;
928    }
929    
# Line 509 | Line 941 | void make_comp_plot( string var, string
941        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
942        ccomp->SetLogy(log);
943        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
944 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
944 >      TH1F *lm3histo  = signalsamples.Draw("lm3histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],data,luminosity,signalsamples.FindSample("LM3"));
945        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
946        datahisto->SetMarkerSize(DataMarkerSize);
947        if (ymax>ymin) datahisto->SetMaximum(ymax);
948 <      lm4histo->SetLineStyle(2);
948 >      lm3histo->SetLineStyle(2);
949        datahisto->Draw("e1");
950        mcstack.Draw("same");
951        datahisto->Draw("same,e1");
952 < //      lm4histo->Draw("hist,same");
952 >      lm3histo->Draw("hist,same");
953        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
954        if ( leftJustified ) {
955          Float_t w = kinleg->GetX2()-kinleg->GetX1();
956          kinleg->SetX1(0.2);
957          kinleg->SetX2(0.2+w);
958        }
959 < //      kinleg->AddEntry(lm4histo,"LM4","l");
959 >      kinleg->AddEntry(lm3histo,"LM3","l");
960        kinleg->Draw();
961        TText* write_variable = write_text(0.99,0.01,var);
962        write_variable->SetTextAlign(31);
# Line 533 | Line 965 | void make_comp_plot( string var, string
965        CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
966        delete datahisto;
967        delete ccomp;
968 <      delete lm4histo;
968 >      delete lm3histo;
969      }
970    cutWeight=weightbackup;
971   }
# Line 543 | Line 975 | void region_comparison_plots(string mcjz
975    dout << "Creating comparison plots for signal and control regions" << endl;
976    // Compare a few quantities in the signal region and all 7 control regions
977  
978 <  switch_overunderflow(true);  // switching overflow/underflow bins on
978 > //  switch_overunderflow(true);  // switching overflow/underflow bins on
979      
980 <  
980 >  switch_overunderflow(true);
981      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
982 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
982 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
983      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
984      float mll_low=50;float mll_high=170;
985      if(!PlottingSetup::RestrictToMassPeak) {
986 <        mll_high=200;
987 <        mll_low=50;
986 >        mll_high=300;
987 >        mll_low=20;
988      }
989 <    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
989 >    make_comp_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",jzbcut,mcjzb,datajzb,100,0,10,true);
990 >    make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
991 >
992 >    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
993      make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
994 <    make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
994 >    make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
995 >    make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
996      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
997 <    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
997 >    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,40,0.,40.,false,0,16.);
998      make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
999      make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
1000 +    make_comp_plot("eta1","#eta_1","eta1",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
1001 +    make_comp_plot("eta2","#eta_2","eta2",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
1002    }
1003  
1004    switch_overunderflow(false); // switching overflow/underflow bins off
# Line 759 | Line 1197 | vector<TF1*> do_extended_fit_to_plot(TH1
1197   //      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)
1198    TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
1199    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1200 <  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);
1200 >  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);
1201  
1202  
1203    TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
# Line 854 | Line 1292 | if you want to start from scratch (witho
1292    return return_functions;
1293   }
1294  
1295 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
1295 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1296   {
1297 <  // note: sigma is not used ATM
860 <  switch_overunderflow(true);
1297 >  
1298    bool is_data=false;
1299    bool use_signal=false;
1300    if(use_data==1) is_data=true;
1301    if(use_data==2) use_signal=true;
1302 <  int nbins=50;//100;
1303 <  if(is_data) nbins=50;
1302 >  int nbins=int(high/10);//100;
1303 >  if(is_data) nbins=int(high/10);
1304    float low=0;
1305 <  float hi=500;
1305 >  float hi=high;
1306 >  
1307 >  stringstream cutpositiveS;
1308 >  cutpositiveS << "(" << jzb << ">0)";
1309 >  TCut cutpositive(cutpositiveS.str().c_str());
1310 >  stringstream cutnegativeS;
1311 >  cutnegativeS << "(" << jzb << "<0)";
1312 >  TCut cutnegative(cutnegativeS.str().c_str());
1313    
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());
1314    
1315    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1316 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1317 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1318 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1319 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1316 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1317 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1318 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1319 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1320  
1321    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1322    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 893 | Line 1331 | void do_prediction_plot(string jzb, TCan
1331    
1332    TH1F *RcorrJZBeemmNoS;
1333  
1334 <    //these are for the ratio
1335 <  
1336 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1337 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1338 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
901 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1334 >  //these are for the ratio
1335 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1336 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1337 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1338 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1339    
1340    TH1F *JRcorrJZBSBem;
1341    TH1F *JLcorrJZBSBem;
1342    TH1F *JRcorrJZBSBeemm;
1343    TH1F *JLcorrJZBSBeemm;
1344    
1345 <  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);
1345 >  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
1346  
1347    
1348 <  if(PlottingSetup::RestrictToMassPeak) {
1349 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1350 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1351 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1352 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1348 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1349 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1350 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1351 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1352 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1353      
1354      //these are for the ratio
1355 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1356 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1357 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1358 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1355 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1356 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1357 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1358 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1359    }
1360    
1361    TH1F *lm4RcorrJZBeemm;
1362 <  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"));
1362 >  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
1363    
1364    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1365    
# Line 931 | Line 1368 | void do_prediction_plot(string jzb, TCan
1368      
1369    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1370    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
1371 <  if(PlottingSetup::RestrictToMassPeak) {
1371 >    
1372 >  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1373 >  ClearHisto(BpredSys);
1374 >    
1375 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1376      Bpred->Add(RcorrJZBem,1.0/3.);
1377      Bpred->Add(LcorrJZBem,-1.0/3.);
1378      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 953 | Line 1394 | void do_prediction_plot(string jzb, TCan
1394      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
1395      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
1396      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1397 +      
1398 +    //Systematics:
1399 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1400 +    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1401 +    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1402 +    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1403 +    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1404 +    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1405 +    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1406    } else {
1407      Bpred->Add(RcorrJZBem,1.0);
1408      Bpred->Add(LcorrJZBem,-1.0);
# Line 962 | Line 1412 | void do_prediction_plot(string jzb, TCan
1412      //these are for the ratio
1413      JBpred->Add(JRcorrJZBem,1.0);
1414      JBpred->Add(JLcorrJZBem,-1.0);
1415 +      
1416 +    //Systematics
1417 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1418 +    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1419 +    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1420 +
1421    }
1422      
1423 <  
1424 <  
1423 >  SQRT(BpredSys);
1424 >  BpredSys->Divide(JBpred);
1425 >
1426    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1427    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1428    Tpred->Add(LcorrJZBem,-1.0);
1429 <  if(PlottingSetup::RestrictToMassPeak) {
1429 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1430      Tpred->Add(RcorrJZBSBem,1.0);
1431      Tpred->Add(LcorrJZBSBem,-1.0);
1432      Tpred->Add(RcorrJZBSBeemm,1.0);
# Line 1009 | Line 1466 | void do_prediction_plot(string jzb, TCan
1466    blankback->Draw();
1467    if(use_data==1)
1468    {
1469 +    //Bpred->SetLineWidth(3); //paper style.overruled.
1470 +    //lm4RcorrJZBeemm->SetLineWidth(3); //paper style.overruled.
1471      analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
1472      kinpad->cd();//necessary because the extended fit function creates its own canvas
1473      RcorrJZBeemm->Draw("e1x0,same");
1474  
1475      Bpred->Draw("hist,same");
1476 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1476 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1477      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1478 <    lm4RcorrJZBeemm->Draw("hist,same");
1478 >    //lm4RcorrJZBeemm->Draw("hist,same");
1479      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1480      legBpred->AddEntry(Bpred,"predicted","l");
1481 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1482 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1483 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1481 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1482 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1483 > //     legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1484      legBpred->Draw();
1485      DrawPrelim();
1486  
# Line 1031 | Line 1490 | void do_prediction_plot(string jzb, TCan
1490      Bpred->SetLineWidth(2);
1491      predcomppad->cd();
1492      predcomppad->SetLogy(1);
1034    
1493      TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1494      TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1495      sidebandsemu->Add(jzbnegative,-1);
# Line 1050 | Line 1508 | void do_prediction_plot(string jzb, TCan
1508      Bpred->Draw("hist,same");
1509   //    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1510      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1511 < //    TH1F *lm4RcorrJZBeemmC = (TH1F*)lm4RcorrJZBeemm->Clone("lm4RcorrJZBeemmC");
1054 < //    lm4RcorrJZBeemmC->SetLineColor(kOrange+1);
1055 <    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1056 < //    lm4RcorrJZBeemmC->Draw("histo,same");
1511 > //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1512      lm4RcorrJZBeemm->SetLineWidth(2);
1513 <    lm4RcorrJZBeemm->Draw("histo,same");
1513 >    //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1514 > //     lm4RcorrJZBeemm->Draw("histo,same");
1515      DrawPrelim();
1516      TLegend *speciallegBpred = make_legend("",0.45,0.55);
1517 +    //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1518      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1519      speciallegBpred->AddEntry(Bpred,"Total background","l");
1520      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1521 <    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1521 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1522 >    else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1523   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1524 <    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1524 > //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1525      speciallegBpred->Draw();
1526 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1526 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1527      
1528      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1529 <    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1529 >    specialcanv->SetLogy(1);
1530 > //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1531      blankback->Draw();
1532 <    kostack.Draw("same");
1532 > //    kostack.Draw("same");
1533 >    predcomposition.Draw();
1534      Bpred->Draw("hist,same");
1535 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1535 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1536      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1537      legBpred->Draw();
1538      DrawPrelim();
1539      CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1540      Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1541      
1542 +    
1543 +    //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;
1544 +    
1545      delete speciallegBpred;
1546      delete Zjetspred;
1547      delete TTbarpred;
# Line 1087 | Line 1550 | void do_prediction_plot(string jzb, TCan
1550    }
1551    if(use_data==0) {
1552      RcorrJZBeemm->Draw("e1x0,same");
1553 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1554      Bpred->Draw("hist,same");
1555      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1556      legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1557 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1557 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1558      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1559      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1560 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1560 > //     if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1561      legBpred->Draw();
1562      DrawMCPrelim();
1563      Bpredsaveas="Bpred_MC";
# Line 1101 | Line 1565 | void do_prediction_plot(string jzb, TCan
1565    }
1566    if(use_data==2) {
1567      RcorrJZBeemm->Draw("e1x0,same");
1568 +    //Bpred->SetLineWidth(3); // paper style. overruled.
1569      Bpred->Draw("hist,same");
1570      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1571      legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
# Line 1116 | Line 1581 | void do_prediction_plot(string jzb, TCan
1581   //      CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
1582      }
1583      {
1584 +      //lm4RcorrJZBeemm->SetLineWidth(3); //paper style. overruled.
1585 +      //RcorrJZBeemmNoS->SetLineWidth(3); //paper style. overruled.
1586 +      //lm4RcorrJZBeemm->SetLineStyle(2); //paper style. overruled.
1587 +      //RcorrJZBeemmNoS->SetLineStyle(3); //paper style. overruled.
1588 +      //lm4RcorrJZBeemm->SetLineColor(kOrange+1); //paper style. overruled.
1589 +      
1590        RcorrJZBeemmNoS->SetLineStyle(2);
1591        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1592 <      legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1592 > //       legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1593        legBpred2->Draw();
1594        RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
1595        RcorrJZBeemmNoS->Draw("histo,same");
# Line 1135 | Line 1606 | void do_prediction_plot(string jzb, TCan
1606    string ytitle("ratio");
1607    if ( use_data==1 ) ytitle = "data/pred";
1608    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1609 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1609 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1610 >
1611  
1612    
1613    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1614 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1615 <  if(PlottingSetup::RestrictToMassPeak) {
1614 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1615 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1616      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1617      Bpredem->Add(RcorrJZBem);
1618      Bpredem->Add(LcorrJZBem,-1);
# Line 1195 | Line 1667 | void do_prediction_plot(string jzb, TCan
1667        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1668        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1669        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1670 <      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1670 > //       if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1671        legBpredc->Draw();
1672        CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1673      }
1674    }
1675    
1676 +  TFile *f = new TFile("tester.root","RECREATE");
1677 +  RcorrJZBeemm->Write();
1678 +  Bpred->Write();
1679 +  f->Close();
1680 +  
1681    delete RcorrJZBeemm;
1682    delete LcorrJZBeemm;
1683    delete RcorrJZBem;
# Line 1213 | Line 1690 | void do_prediction_plot(string jzb, TCan
1690  
1691    delete blankback;
1692    
1693 <  if(PlottingSetup::RestrictToMassPeak) {
1693 >  delete BpredSys;
1694 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1695      delete RcorrJZBSBem;
1696      delete LcorrJZBSBem;
1697      delete RcorrJZBSBeemm;
# Line 1225 | Line 1703 | void do_prediction_plot(string jzb, TCan
1703      delete JLcorrJZBSBeemm;
1704    }
1705    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1228  switch_overunderflow(false);
1706   }
1707  
1708   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1709 +  switch_overunderflow(true);
1710    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1711 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1712 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1713 <  do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1714 < }
1237 <
1238 < void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
1239 <  bool do_data=0;
1240 <  bool dosignal=0;
1241 <  if(is_data==1) do_data=1;
1242 <  if(is_data==2) dosignal=1;
1243 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1244 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1245 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1246 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1247 <  
1248 <  TH1F *RcorrJZBSBem;
1249 <  TH1F *LcorrJZBSBem;
1250 <  TH1F *RcorrJZBSBeemm;
1251 <  TH1F *LcorrJZBSbeemm;
1252 <  
1253 <  if(PlottingSetup::RestrictToMassPeak) {
1254 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1255 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1256 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1257 <    LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1258 <  }
1259 <  
1260 <
1261 <
1262 <
1263 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1264 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1265 <  if(PlottingSetup::RestrictToMassPeak) {
1266 <    Bpred->Add(RcorrJZBem,1.0/3);
1267 <    Bpred->Add(LcorrJZBem,-1.0/3);
1268 <    Bpred->Add(RcorrJZBSBem,1.0/3);
1269 <    Bpred->Add(LcorrJZBSBem,-1.0/3);
1270 <    Bpred->Add(RcorrJZBSBeemm,1.0/3);
1271 <    Bpred->Add(LcorrJZBSbeemm,-1.0/3);
1711 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1712 >  if ( !PlottingSetup::Approved ) {
1713 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1714 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1715    } else {
1716 <    Bpred->Add(RcorrJZBem,1.0);
1274 <    Bpred->Add(LcorrJZBem,-1.0);
1716 >    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1717    }
1718 <
1719 <  can->cd();
1278 <  can->SetLogy(0);
1279 <  Bpred->SetLineColor(kRed);
1280 <  Bpred->SetStats(0);
1281 <  if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
1282 <  TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
1283 <  JZBratioforfitting->Divide(Bpred);
1284 <  TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
1285 <  
1286 <  
1287 <  JZBratio->SetTitle("");
1288 <  JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
1289 < //  if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
1290 <  
1291 <  TF1 *pol0 = new TF1("pol0","[0]",0,1000);
1292 <  TF1 *pol0d = new TF1("pol0","[0]",0,1000);
1293 < //  straightline_fit->SetParameter(0,1);
1294 <  JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
1295 <  pol0d->SetParameter(0,pol0->GetParameter(0));
1296 <  
1297 <  JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
1298 <  JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
1299 <  if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
1300 <  JZBratio->GetYaxis()->SetNdivisions(519);
1301 <  JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
1302 <  JZBratio->GetYaxis()->CenterTitle();
1303 <  JZBratio->GetXaxis()->CenterTitle();
1304 <  JZBratio->SetMarkerSize(DataMarkerSize);
1305 <  JZBratio->Draw("AP");
1306 <  /////----------------------------
1307 <  TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
1308 <  writeresult->SetFillStyle(4000);
1309 <  writeresult->SetFillColor(kWhite);
1310 <  writeresult->SetTextFont(42);
1311 <  writeresult->SetTextSize(0.03);
1312 <  writeresult->SetTextAlign(12);
1313 <  ostringstream jzb_agreement_data_text;
1314 <  jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) <<  pol0->GetParError(0);
1315 <  if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
1316 <  if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
1317 < /*  if(is_data) writeresult->AddText("Data closure test");
1318 <  else writeresult->AddText("MC closure test");
1319 <  */
1320 <  writeresult->AddText(jzb_agreement_data_text.str().c_str());
1321 < //  writeresult->Draw("same");
1322 < //  pol0d->Draw("same");
1323 <  TF1 *topline =  new TF1("","1.5",0,1000);
1324 <  TF1 *bottomline =  new TF1("","0.5",0,1000);
1325 <  topline->SetLineColor(kBlue);
1326 <  topline->SetLineStyle(2);
1327 <  bottomline->SetLineColor(kBlue);
1328 <  bottomline->SetLineStyle(2);
1329 < //  topline->Draw("same");
1330 < //  bottomline->Draw("same");
1331 <  TF1 *oneline = new TF1("","1.0",0,1000);
1332 <  oneline->SetLineColor(kBlue);
1333 <  oneline->SetLineStyle(1);
1334 <  oneline->Draw("same");
1335 <  TLegend *phony_leg = make_legend("ratio",0.6,0.55,false);//this line is just to have the default CMS Preliminary (...) on the canvas as well.
1336 <  if(is_data==1) DrawPrelim();
1337 <  else DrawMCPrelim();
1338 <  TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
1339 <  leg->SetTextFont(42);
1340 <  leg->SetTextSize(0.04);
1341 < //   if(is_data==1) leg->SetHeader("Ratio (data)");
1342 < //   else leg->SetHeader("Ratio (MC)");
1343 <
1344 <  TString MCtitle("MC ");
1345 <  if (is_data==1) MCtitle = "";
1346 <
1347 <  leg->SetFillStyle(4000);
1348 <  leg->SetFillColor(kWhite);
1349 <  leg->SetTextFont(42);
1350 < //  leg->AddEntry(topline,"+20\% sys envelope","l");
1351 <  leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
1352 <  leg->AddEntry(oneline,"ratio = 1","l");
1353 < //  leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
1354 < //  leg->AddEntry(bottomline,"#pm50% envelope","l");
1355 <
1356 <
1357 <  //leg->Draw("same"); // no longer drawing legend
1358 <
1359 <  if(is_data==1) CompleteSave(can, "jzb_ratio_data");
1360 <  if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
1361 <  if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
1362 <  
1363 <  delete RcorrJZBeemm;
1364 <  delete LcorrJZBeemm;
1365 <  delete RcorrJZBem;
1366 <  delete LcorrJZBem;
1367 <  
1368 <  delete RcorrJZBSBem;
1369 <  delete LcorrJZBSBem;
1370 <  delete RcorrJZBSBeemm;
1371 <  delete LcorrJZBSbeemm;
1372 < }
1373 <
1374 < void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
1375 <  TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
1376 <  globalc->SetLogy(0);
1377 <  
1378 <  do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh  );
1379 <  do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh  );
1380 <  do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh  );
1718 >  delete globalcanvas;
1719 >  switch_overunderflow(false);
1720   }
1721  
1722   string give_jzb_expression(float peak, int type) {
# Line 1569 | Line 1908 | void draw_pure_jzb_histo(TCut cut,string
1908    datahisto->Draw("same,e1");
1909    
1910    TLegend *leg;
1911 <  if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1912 <  else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1913 <  else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1914 <  else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1915 <  else {
1916 <    std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1917 <    exit(-1);
1918 <      }
1911 >  if (!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
1912 >    if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1913 >    else leg = allsamples.allbglegend("Same flavor",datahisto);
1914 >  } else {
1915 >    if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1916 >    else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1917 >    else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1918 >    else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1919 >    else {
1920 >      std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1921 >      exit(-1);
1922 >    }
1923 >  }
1924    leg->Draw();
1925    string write_cut = decipher_cut(cut,"");
1926    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
# Line 1627 | Line 1971 | void produce_stretched_jzb_plots(string
1971    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1972    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1973    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1974 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1975 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1974 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1975 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1976    
1977    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1978    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1979 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1980 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1979 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1980 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1981    
1982    delete dican;
1983   }
1984    
1985  
1986   void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1987 +  switch_overunderflow(true);
1988    vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1989    
1990    if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
# Line 1652 | Line 1997 | void diboson_plots(string mcjzb, string
1997    
1998    
1999    dout << "Going to increase the cross section for diboson samples ... " << endl;
2000 <  for(int i=0;i<SamplesToBeModified.size();i++) {
2000 >  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
2001      float origxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
2002      (allsamples.collection)[SamplesToBeModified[i]].xs=origxs*stretchfactor;
2003      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 2007 | void diboson_plots(string mcjzb, string
2007    }
2008    
2009    dout << "Going to produce JZB plots" << endl;
2010 < //  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
2010 >  produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
2011    TCanvas *gloca = new TCanvas("gloca","gloca");
1667  float sigma=123456;
2012    
2013    dout << "Going to produce prediction plots" << endl;
2014 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
2015 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
2014 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
2015 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
2016    delete gloca;
2017  
2018    dout << "Going to reset the cross section for diboson samples ... " << endl;
2019 <  for(int i=0;i<SamplesToBeModified.size();i++) {
2019 >  for(int i=0;i<(int)SamplesToBeModified.size();i++) {
2020      float Upxs=(allsamples.collection)[SamplesToBeModified[i]].xs;
2021      (allsamples.collection)[SamplesToBeModified[i]].xs=(allsamples.collection)[SamplesToBeModified[i]].xs*(1.0/stretchfactor);
2022      string Upname=(allsamples.collection)[SamplesToBeModified[i]].samplename;
# Line 1680 | Line 2024 | void diboson_plots(string mcjzb, string
2024      dout << "     Reset xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " from " << Upxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ") and reset the correct name (from " << Upname << ")" << endl;
2025      
2026    }
2027 + //   switch_overunderflow(false);
2028 + }
2029 +
2030 +
2031 + void draw_normalized_data_vs_data_histo(TCut cut1, TCut cut2, string variable, string legentry1, string legentry2, string savename, TCanvas *can,vector<float> binning) {
2032 +  TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
2033 +  jzbpad->cd();
2034 +  jzbpad->SetLogy(1);
2035 +  string xlabel="JZB [GeV]";
2036 +
2037 +  TH1F *datahisto1 = allsamples.Draw("datahisto1",variable,binning, xlabel, "events",cut1,data,luminosity);
2038 +  datahisto1->SetLineColor(kRed);
2039 +  datahisto1->SetMarkerColor(kRed);
2040 +  TH1F *datahisto2 = allsamples.Draw("datahisto2",variable,binning, xlabel, "events",cut2,data,luminosity);
2041 +  datahisto2->SetLineColor(kBlue);
2042 +  datahisto2->SetMarkerColor(kBlue);
2043 +  
2044 +  datahisto2->SetMarkerSize(DataMarkerSize);
2045 +  datahisto1->DrawNormalized("e1");
2046 +  datahisto2->DrawNormalized("histo,same");
2047 +  datahisto1->DrawNormalized("same,e1");
2048 +  
2049 +  TLegend *leg = make_legend();
2050 +  leg->AddEntry(datahisto1,legentry1.c_str());
2051 +  leg->AddEntry(datahisto2,legentry2.c_str());
2052 +  leg->Draw();
2053 +  
2054 +  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
2055    
2056 +  datahisto1->Delete();
2057 +  datahisto2->Delete();
2058   }
2059 +
2060 +
2061   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2062 +  switch_overunderflow(true);
2063    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2064    float max=jzbHigh ;
2065    float min=-120;
# Line 1695 | Line 2072 | void jzb_plots(string mcjzb, string data
2072    for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
2073    for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
2074  
2075 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
2076 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
2077 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
2078 <  draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
2079 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2080 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2081 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2082 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2083 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2075 >  if ( !PlottingSetup::Approved ) {
2076 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
2077 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
2078 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
2079 >    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
2080 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2081 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2082 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2083 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2084 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2085 >    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);
2086 >    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);
2087 >    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);
2088 >
2089 >  }
2090    
2091    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
2092 <  draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2093 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2094 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2095 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2096 <
2097 < //  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);
2092 >  if ( !PlottingSetup::Approved ) {
2093 >    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2094 >    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2095 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2096 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2097 >  }
2098    delete can;
2099 +  switch_overunderflow(false);
2100   }
2101  
2102  
# Line 1766 | Line 2146 | void compute_MC_yields(string mcjzb,vect
2146    TCanvas *yica = new TCanvas("yica","yield canvas");
2147    
2148    int nRegions=4;
2149 <  if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
2149 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
2150    string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
2151    string posneg[] = {"pos","neg"};
2152    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
2153  
2154 <  for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
2154 >  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
2155      TCut jzbMC[]  = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
2156      dout << "_________________________________________________________" << endl;
2157      dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
2158 <    for(int isample=0;isample<(allsamples.collection).size();isample++) {
2158 >    for(int isample=0;isample<(int)(allsamples.collection).size();isample++) {
2159        if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << "  &  ";
2160        else dout << "Sample & ";
2161        for(int iregion=0;iregion<nRegions;iregion++) {
# Line 2034 | Line 2414 | void draw_ttbar_and_zjets_shape_for_one_
2414  
2415   void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
2416    int all_leptons=-1;
2037  int electrons_only=0;
2038  int mu_only=1;
2039  int twojetswith50gev=1;
2417    int threejetswith30gev=0;
2418   /*  
2419 +  int twojetswith50gev=1;
2420 +  int electrons_only=0;
2421 +  int mu_only=1;
2422 +
2423    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
2424    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
2425    
# Line 2052 | Line 2433 | void draw_ttbar_and_zjets_shape(string m
2433    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2434   }
2435  
2436 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2056 <  //first: colorful plots
2436 > float find_one_correction_factor(string FindKeyword, bool dodata, TCut SpecialCut, string SaveAs) {
2437    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2438    cancorr->SetLogz();
2439    cancorr->SetRightMargin(0.13);
2440 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2441 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2440 >  TCut zptforresponsepresentation(Restrmasscut&&SpecialCut&&passtrig);
2441 >
2442 >  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2443    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2444 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2444 >  niceresponseplotd->Sumw2();
2445 >  TH2F* emuResponse = (TH2F*)niceresponseplotd->Clone("emuResponse");
2446 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2447 >  for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2448 >    if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2449 >    if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2450 >    
2451 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2452 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
2453 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
2454 >  }
2455 >  niceresponseplotd->Add(emuResponse,-1);
2456 >  
2457    niceresponseplotd->SetStats(0);
2458    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2459    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2068 | Line 2461 | void find_correction_factors(string &jzb
2461    niceresponseplotd->GetYaxis()->CenterTitle();
2462    niceresponseplotd->Draw("COLZ");
2463    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2464 +  profd->Rebin(2);
2465    profd->SetMarkerSize(DataMarkerSize);
2466 <  profd->Fit("pol0","","same,e1",30,400);
2466 >  profd->Fit("pol0","","same,e1",100,400);
2467    DrawPrelim();
2468 <  TText* title = write_text(0.5,0.7,"Data");
2468 >  string stitle="Data";
2469 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2470 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2471    title->SetTextAlign(12);
2472    title->Draw();
2473    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2474 <  float datacorrection=datapol->GetParameter(0);
2475 <  stringstream dataresstring;
2476 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2477 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2474 >  float correction=datapol->GetParameter(0);
2475 >  stringstream resstring;
2476 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2477 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2478    restitle->SetTextAlign(12);
2479    restitle->SetTextSize(0.03);
2480    restitle->Draw();
2481 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2482 <  
2483 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2484 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2485 <  niceresponseplotm->SetStats(0);
2486 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2487 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2488 <  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");
2481 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2482 >  delete cancorr;
2483 >  delete niceresponseplotd;
2484 >  delete profd;
2485 >  return correction;
2486 > }
2487 >
2488 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2489    
2490 +  dout << "Computing response corrections: " << endl;
2491 +  //Step 1 : Get results
2492 +  float datacorrection=find_one_correction_factor("Data",true,"","Data");
2493 +  float mccorrection=find_one_correction_factor("DY",false,"","MC");
2494 +  
2495 +  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
2496 +  float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
2497 +  
2498 +  float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
2499 +  float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
2500 +  
2501 +  cout << "Corrections : " << endl;
2502 +  cout << "   Data : " << datacorrection << endl;
2503 +  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2504 +  cout << "   MC : " << mccorrection << endl;
2505 +  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2506    
2507 <  //Step 2: Getting the result
2115 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2507 >  //Step 2: Processing the result and making it into something useful :-)
2508    stringstream jzbvardatas;
2509 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2510 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2509 >  jzbvardatas << "(";
2510 >  
2511 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2512 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2513 >  
2514 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2515 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2516 >  
2517 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2518 >  
2519 >  if(datacorrection>=1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << datacorrection-1 << "*pt))";
2520 >  if(datacorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]+" << 1-datacorrection << "*pt))";
2521 >  
2522 >  jzbvardatas << ")";
2523    jzbvardata=jzbvardatas.str();
2524 +  
2525    stringstream jzbvarmcs;
2526 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2527 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2526 >  jzbvarmcs << "(";
2527 >  
2528 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2529 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2530 >  
2531 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2532 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2533 >  
2534 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2535 >  
2536 >  if(mccorrection>=1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << mccorrection-1 << "*pt))";
2537 >  if(mccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]+" << 1-mccorrection << "*pt))";
2538 >  
2539 >  jzbvarmcs << ")";
2540    jzbvarmc=jzbvarmcs.str();
2541 +
2542    dout << "JZB Z pt correction summary : " << endl;
2543    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2544    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2545 +  
2546   }
2547  
2548   void pick_up_events(string cut) {
# Line 2131 | Line 2550 | void pick_up_events(string cut) {
2550    allsamples.PickUpEvents(cut);
2551   }
2552  
2553 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError) {
2553 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2554    dout << "Saving configuration template!" << endl;
2555    ofstream configfile;
2556    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 2151 | Line 2570 | void save_template(string mcjzb, string
2570    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2571    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2572    configfile<<"vector<float>jzb_cuts;\n";
2573 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2574    configfile<<"float MCPeakError=-999;\n";
2575    configfile<<"float DataPeakError=-999;\n";
2576    configfile<<"}\n\n";
# Line 2160 | Line 2580 | void save_template(string mcjzb, string
2580    configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
2581    configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n";
2582    configfile<<"DataPeakError="<<DataPeakError<<";\n\n";
2583 <  for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2583 >  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";
2584    configfile<<"\n\n";
2585 <  for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2586 <  for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2587 <  for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2585 >  for(int i=0;i<(int)Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2586 >  for(int i=0;i<(int)Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2587 >  for(int i=0;i<(int)Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2588 >  configfile<<"\n\n";
2589 >  for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2590 >  for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2591 >  for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2592 >  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";
2593    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";
2594    configfile<<"\n\n";
2595    configfile<<"luminosity="<<luminosity<<";\n";
2596    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2597 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2598    
2599    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2600    
# Line 2194 | Line 2617 | void draw_all_ttbar_histos(TCanvas *can,
2617    float max=histos[0]->GetMaximum();
2618    if(manualmin>=0) min=manualmin;
2619    else {
2620 <    for(int i=1;i<histos.size();i++) {
2620 >    for(int i=1;i<(int)histos.size();i++) {
2621        float curmin=get_nonzero_minimum(histos[i]);
2622        float curmax=histos[i]->GetMaximum();
2623        if(curmin<min) min=curmin;
# Line 2205 | Line 2628 | void draw_all_ttbar_histos(TCanvas *can,
2628    histos[0]->Draw(drawoption.c_str());
2629    stringstream drawopt;
2630    drawopt << drawoption << ",same";
2631 <  for(int i=1;i<histos.size();i++) {
2631 >  for(int i=1;i<(int)histos.size();i++) {
2632      histos[i]->Draw(drawopt.str().c_str());
2633    }
2634   }
# Line 2214 | Line 2637 | void ttbar_sidebands_comparison(string m
2637    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2638    //in the case of the OFF peak analysis, we compare our control region to the real value
2639    TCut weightbackup=cutWeight;
2640 <  cutWeight="1.0";
2218 <  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2640 >  switch_overunderflow(true);
2641    
2642 +  bool doPURW=false;
2643 +  
2644 +  
2645 +  if(!doPURW) {
2646 +    dout << "Not doing PU reweighting for ttbar closure test" << endl;
2647 +    cutWeight="1.0";
2648 +    // Do it without PU re-weighting
2649 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2650 +    stringstream resultsNoPU;
2651 +    stringstream noPUdatajzb;
2652 +    stringstream noPUmcjzb;
2653 +    
2654 +    stringstream mcjzbnoPU;
2655 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2656 +    mcjzb = noPUmcjzb.str();
2657 +  }
2658 +
2659 +      
2660 +  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2661  
2662 <  TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2662 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2663    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2664    TH1F *TSem;
2665    TH1F *nTSem;
2666 <  TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2666 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2667    TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2668    TH1F *TSeemm;
2669    TH1F *nTSeemm;
2670    
2671 <  if(PlottingSetup::RestrictToMassPeak) {
2672 <    TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2673 <    nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2674 <    TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2671 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2672 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2673 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2674 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2675      nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2676    }
2677  
2678    TCanvas *tcan = new TCanvas("tcan","tcan");
2238  
2679    tcan->SetLogy(1);
2680    
2681    TZeemm->SetLineColor(kBlack);
# Line 2244 | Line 2684 | void ttbar_sidebands_comparison(string m
2684    TZem->SetMarkerColor(kRed);
2685  
2686  
2687 <  if(PlottingSetup::RestrictToMassPeak) {
2687 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2688          TSem->SetLineColor(TColor::GetColor("#00A616"));
2689          TSeemm->SetLineColor(kMagenta+2);
2690          TSem->SetMarkerColor(TColor::GetColor("#00A616"));
# Line 2254 | Line 2694 | void ttbar_sidebands_comparison(string m
2694    }
2695    
2696    vector<TH1F*> histos;
2697 +  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2698 +  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2699    histos.push_back(TZem);
2700    histos.push_back(TZeemm);
2701 <  if(PlottingSetup::RestrictToMassPeak) {
2701 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2702 >    TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2703 >    TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2704      histos.push_back(TSem);
2705      histos.push_back(TSeemm);
2706    }
2707 <  draw_all_ttbar_histos(tcan,histos,"histo",0.04);
2707 >  draw_all_ttbar_histos(tcan,histos,"histo",8);
2708    
2709    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2710    leg->AddEntry(TZeemm,"SFZP","l");
2711    leg->AddEntry(TZem,"OFZP","l");
2712 <  if(PlottingSetup::RestrictToMassPeak) {
2712 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2713      leg->AddEntry(TSeemm,"SFSB","l");
2714      leg->AddEntry(TSem,"OFSB","l");
2715    }
2716    leg->Draw("same");
2717    DrawMCPrelim(simulatedlumi);
2718    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2719 < cout << __LINE__ << endl;  
2719 >  
2720    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2277 cout << __LINE__ << endl;  
2721    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2279 cout << __LINE__ << endl;  
2722    TH1F *TSeemmcopy;
2723    TH1F *TSemcopy;
2724 <  if(PlottingSetup::RestrictToMassPeak) {
2724 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2725      TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2726      TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2727    }
2728  
2729    TZem->Divide(TZeemm);
2730    TZem->SetMarkerStyle(21);
2731 <  if(PlottingSetup::RestrictToMassPeak) {
2731 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2732      TSem->Divide(TZeemm);
2733      TSeemm->Divide(TZeemm);
2734      TSem->SetMarkerStyle(24);
2735      TSeemm->SetMarkerStyle(32);
2736 < }
2736 >  }
2737  
2738    tcan->SetLogy(0);
2739    TZem->GetYaxis()->SetRangeUser(0,2.5);
2740    TZem->GetYaxis()->SetTitle("ratio");
2741    TZem->Draw();
2742 <  if(PlottingSetup::RestrictToMassPeak) {
2742 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2743      TSem->Draw("same");
2744      TSeemm->Draw("same");
2745    }
2746    
2747 <  float linepos=0.25;
2748 <  if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2749 <  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2747 >  float linepos=emuncertONPEAK;
2748 >  if(!PlottingSetup::RestrictToMassPeak) linepos=emuncertOFFPEAK;
2749 >  
2750    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2751    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2752    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
# Line 2327 | Line 2769 | cout << __LINE__ << endl;
2769    
2770    TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
2771    leg2->AddEntry(TZem,"OFZP / SFZP","ple");
2772 <  if(PlottingSetup::RestrictToMassPeak) {
2772 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2773      leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
2774      leg2->AddEntry(TSem,"OFSB / SFZP","ple");
2775    }
# Line 2340 | Line 2782 | cout << __LINE__ << endl;
2782    DrawMCPrelim(simulatedlumi);
2783    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2784    
2785 +  
2786 +  if (0) { // Turn this off: we don't need this
2787  
2788 < ///-------------- second part: only look at the quantity we actually care about!
2789 <  TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2790 <  TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2791 <  rightsfzp->Add(leftsfzp,-1);
2792 <  TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2793 <  TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2794 <  rightofzp->Add(leftofzp,-1);
2795 <  TH1F *leftofsb;
2796 <  TH1F *rightofsb;
2797 <  TH1F *leftsfsb;
2798 <  TH1F *rightsfsb;
2799 <  if(PlottingSetup::RestrictToMassPeak) {
2800 <        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2801 <        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2802 <        rightofsb->Add(leftofsb,-1);
2803 <        leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2804 <        rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2805 <        rightsfsb->Add(leftsfsb,-1);
2806 <  }
2788 >    ///-------------- second part: only look at the quantity we actually care about!
2789 >    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2790 >    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2791 >    rightsfzp->Add(leftsfzp,-1);
2792 >    TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2793 >    TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2794 >    rightofzp->Add(leftofzp,-1);
2795 >    TH1F *leftofsb;
2796 >    TH1F *rightofsb;
2797 >    TH1F *leftsfsb;
2798 >    TH1F *rightsfsb;
2799 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2800 >      leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2801 >      rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2802 >      rightofsb->Add(leftofsb,-1);
2803 >      leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2804 >      rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2805 >      rightsfsb->Add(leftsfsb,-1);
2806 >    }
2807  
2808 <  tcan->SetLogy(1);
2809 <  rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2810 <  rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2811 <  rightsfzp->Draw("histo");
2812 <  rightofzp->Draw("histo,same");
2813 <  if(PlottingSetup::RestrictToMassPeak) {
2814 <    rightofsb->Draw("histo,same");
2815 <    rightsfsb->Draw("histo,same");
2816 <  }
2817 <  DrawMCPrelim(simulatedlumi);
2808 >    tcan->SetLogy(1);
2809 >    rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2810 >    rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2811 >    rightsfzp->Draw("histo");
2812 >    rightofzp->Draw("histo,same");
2813 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2814 >      rightofsb->Draw("histo,same");
2815 >      rightsfsb->Draw("histo,same");
2816 >    }
2817 >    DrawMCPrelim(simulatedlumi);
2818  
2819 <  TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2820 <  legA->AddEntry(rightsfzp,"SFZP","l");
2821 <  legA->AddEntry(rightofzp,"OFZP","l");
2822 <  if(PlottingSetup::RestrictToMassPeak) {
2823 <    legA->AddEntry(rightofsb,"SFSB","l");
2824 <    legA->AddEntry(rightsfsb,"OFSB","l");
2825 <  }
2826 <  legA->Draw();
2819 >    TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2820 >    legA->AddEntry(rightsfzp,"SFZP","l");
2821 >    legA->AddEntry(rightofzp,"OFZP","l");
2822 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2823 >      legA->AddEntry(rightofsb,"SFSB","l");
2824 >      legA->AddEntry(rightsfsb,"OFSB","l");
2825 >    }
2826 >    legA->Draw();
2827  
2828 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2828 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2829  
2830 <  tcan->SetLogy(0);
2831 <  rightofzp->Divide(rightsfzp);
2832 <  rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2833 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
2834 <  rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2835 <  rightofzp->Draw();
2836 <  if(PlottingSetup::RestrictToMassPeak) {
2837 <    rightofsb->Divide(rightsfzp);
2838 <    rightsfsb->Divide(rightsfzp);
2839 <    rightofsb->Draw("same");
2840 <    rightsfsb->Draw("same");
2841 <  }
2842 <
2843 <  TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2844 <  TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2845 <  TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2846 <  
2847 <  top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2848 <  bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2849 <  center2->SetLineColor(kBlue);
2850 <  
2851 <  top2->Draw("same");
2852 <  center2->Draw("same");
2853 <  bottom2->Draw("same");
2854 <
2855 <  rightofzp->SetMarkerStyle(21);
2856 <  if(PlottingSetup::RestrictToMassPeak) {
2857 <    rightofsb->SetMarkerStyle(24);
2858 <    rightsfsb->SetMarkerStyle(32);
2859 <  }
2860 <
2861 <  TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2862 <  leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2863 <  if(PlottingSetup::RestrictToMassPeak) {
2864 <        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2865 <        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2866 <  }
2867 <  leg3->AddEntry(bottom,"syst. envelope","l");
2868 <  leg3->SetX1(0.25);leg3->SetX2(0.6);
2869 <  leg3->SetY1(0.65);
2830 >    tcan->SetLogy(0);
2831 >    rightofzp->Divide(rightsfzp);
2832 >    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2833 >    rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2834 >    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2835 >    rightofzp->Draw();
2836 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2837 >      rightofsb->Divide(rightsfzp);
2838 >      rightsfsb->Divide(rightsfzp);
2839 >      rightofsb->Draw("same");
2840 >      rightsfsb->Draw("same");
2841 >    }
2842 >
2843 >    TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2844 >    TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2845 >    TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2846 >  
2847 >    top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2848 >    bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2849 >    center2->SetLineColor(kBlue);
2850 >  
2851 >    top2->Draw("same");
2852 >    center2->Draw("same");
2853 >    bottom2->Draw("same");
2854 >
2855 >    rightofzp->SetMarkerStyle(21);
2856 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2857 >      rightofsb->SetMarkerStyle(24);
2858 >      rightsfsb->SetMarkerStyle(32);
2859 >    }
2860 >
2861 >    TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2862 >    leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2863 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2864 >      leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2865 >      leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2866 >    }
2867 >    leg3->AddEntry(bottom,"syst. envelope","l");
2868 >    leg3->SetX1(0.25);leg3->SetX2(0.6);
2869 >    leg3->SetY1(0.65);
2870    
2871 <  leg3->Draw("same");
2871 >    leg3->Draw("same");
2872    
2873 <  DrawMCPrelim(simulatedlumi);
2874 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2873 >    DrawMCPrelim(simulatedlumi);
2874 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2875 >
2876 >  }
2877  
2878    delete TZem;
2879    delete nTZem;
2880    delete TZeemm;
2881    delete nTZeemm;
2882 <  if(PlottingSetup::RestrictToMassPeak) {
2882 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2883          delete TSem;
2884          delete nTSem;
2885          delete TSeemm;
# Line 2442 | Line 2888 | cout << __LINE__ << endl;
2888  
2889    delete tcan;
2890    cutWeight=weightbackup;
2891 +  switch_overunderflow(false);
2892   }
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);
2928 <  nicer_binning.push_back(400);
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 >  cout << "****************************************************************************************************************************************************************" << endl;
2936 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2937 > //  zcan->SetLogy(1);
2938 >  TCut weightbackup=cutWeight;
2939 >  
2940 >  bool UsePURW=true;
2941 >  
2942 >  
2943 >  string mcjzb;
2944 >  if(UsePURW) {
2945 >    mcjzb=mcjzbWithPUa;
2946 >    cout << "Using PURW peak positions" << endl;
2947 >  } else {
2948 >    // Do it without PU re-weighting
2949 >    cutWeight="1.0";
2950 >    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2951 >    stringstream resultsNoPU;
2952 >    stringstream noPUdatajzb;
2953 >    stringstream noPUmcjzb;
2954 >    
2955 >    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2956 >    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2957 >    
2958 >    mcjzb = noPUmcjzb.str();
2959 >    
2960 >  }
2961  
2962 <  string mcjzb = mcjzbnoPU.str();
2963 <  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2962 >  
2963 >  vector<float> binning;
2964 >  binning.push_back(0);
2965 >  binning.push_back(10);
2966 >  binning.push_back(20);
2967 >  binning.push_back(40);
2968 >  binning.push_back(60);
2969 > //   binning.push_back(50);
2970 > //   binning.push_back(60);
2971 > //   binning.push_back(70);
2972 > //   binning.push_back(80);
2973 > //   binning.push_back(90);
2974 >  binning.push_back(100);
2975  
2483  TCut weightbackup=cutWeight;
2484  cutWeight="1.0";
2485  float sbg_min=0.;
2486  float sbg_max=100.;
2487  int sbg_nbins=5;
2976    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2977    
2978    TCut kPos((mcjzb+">0").c_str());
2979    TCut kNeg((mcjzb+"<0").c_str());
2980    string var( "abs("+mcjzb+")" );
2981 +  
2982 +  TCut notTau("abs(genMID1)!=15");
2983 +  TCut ee_mm_tautau("mll>0");
2984 +  
2985  
2986 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2987 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2988 <                                  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"));
2986 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2987 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2988 >  
2989    hJZBpos->SetLineColor(kBlack);
2990    hJZBneg->SetLineColor(kRed);
2991    
2992 <  Int_t nbins = 5;
2503 <  Float_t xmax = 100.;
2504 <
2505 <  
2506 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2507 <  zcan->SetLogy(1);
2508 <
2992 >  hJZBpos->SetMinimum(1.0);
2993    hJZBpos->Draw("e1");
2994    hJZBneg->Draw("same,hist");
2995    hJZBpos->Draw("same,e1"); // So it's on top...
2996    
2997 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2997 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2998    leg->AddEntry(hJZBpos,"Observed","pe");
2999    leg->AddEntry(hJZBneg,"Predicted","l");
3000    leg->Draw("same");
3001    DrawMCPrelim(simulatedlumi);
3002 <  CompleteSave(zcan,"Systematics/zjets_prediction");
3002 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
3003    
3004    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
3005    hratio->Divide(hJZBneg);
3006    
3007 +  for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
3008 +    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
3009 +  }
3010 +  
3011    zcan->SetLogy(0);
3012    hratio->GetYaxis()->SetRangeUser(0,2.5);
3013    hratio->GetYaxis()->SetTitle("Observed/Predicted");
3014    hratio->Draw("e1");
3015    
3016 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
3017 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
3018 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
3016 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
3017 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
3018 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
3019    
3020  
3021    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2538 | Line 3026 | void zjets_prediction_comparison() {
3026    center->Draw("same");
3027    bottom->Draw("same");
3028    
3029 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
3029 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3030    leg2->AddEntry(hratio,"obs / pred","pe");
3031    leg2->AddEntry(bottom,"syst. envelope","l");
3032    leg2->Draw("same");
3033    DrawMCPrelim(simulatedlumi);
3034 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
3034 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
3035 >  
3036 >  TCut reducedNJets(cutnJets);
3037 >  
3038 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3039 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3041 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3042 >
3043 >  TH1F *RcorrJZBSBem;
3044 >  TH1F *LcorrJZBSBem;
3045 >  TH1F *RcorrJZBSBeemm;
3046 >  TH1F *LcorrJZBSBeemm;
3047 >
3048 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3049 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3050 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3052 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3053 >  }
3054 >  
3055 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3056 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3057 >    Bpred->Add(RcorrJZBem,1.0/3.);
3058 >    Bpred->Add(LcorrJZBem,-1.0/3.);
3059 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
3060 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
3061 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
3062 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
3063 >  } else {
3064 >    Bpred->Add(RcorrJZBem,1.0);
3065 >    Bpred->Add(LcorrJZBem,-1.0);
3066 >  }
3067 >  
3068 >  Bpred->SetLineColor(kRed);
3069 >
3070 >  TAUhJZBpos->SetLineColor(kBlack);
3071 >  Bpred->SetLineColor(kRed);
3072 >  
3073 >  TAUhJZBpos->SetMinimum(1.0);
3074 >  TAUhJZBpos->Draw("e1");
3075 >  Bpred->Draw("same,hist");
3076 >  TAUhJZBpos->Draw("same,e1");
3077 >  
3078 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
3079 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
3080 >  TAUleg->AddEntry(Bpred,"Predicted","l");
3081 >  TAUleg->Draw("same");
3082 >  DrawMCPrelim(simulatedlumi);
3083 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
3084 >  
3085 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
3086 >  TAUhratio->Divide(Bpred);
3087 >  
3088 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
3089 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
3090 >  }
3091 >  
3092 >  zcan->SetLogy(0);
3093 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
3094 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
3095 >  TAUhratio->Draw("e1");
3096 >  
3097 >  top->Draw("same");
3098 >  center->Draw("same");
3099 >  bottom->Draw("same");
3100 >  
3101 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3102 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3103 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
3104 >  TAUleg2->Draw("same");
3105 >  DrawMCPrelim(simulatedlumi);
3106 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
3107 >  
3108 >  delete Bpred;
3109 >  delete TAUhJZBpos;
3110 >  delete LcorrJZBeemm;
3111 >  delete RcorrJZBem;
3112 >  delete LcorrJZBem;
3113 >  
3114 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3115 >    delete RcorrJZBSBem;
3116 >    delete LcorrJZBSBem;
3117 >    delete RcorrJZBSBeemm;
3118 >    delete LcorrJZBSBeemm;
3119 >  }
3120 >  
3121    
3122    delete zcan;
3123    cutWeight=weightbackup;
# Line 2569 | Line 3143 | void sideband_assessment(string datajzb,
3143    tout << "\\begin{tabular}{l|cc}" << endl;
3144    tout << "\\hline" << endl;
3145    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
3146 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
3146 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
3147    tout << "\\end{tabular}" << endl;
3148    tout << "\\end{center}" << endl;
3149    tout << "\\end{table}" << endl;
# Line 2587 | Line 3161 | void make_table(samplecollection &coll,
3161    
3162    TCanvas *cannie = new TCanvas("cannie","cannie");
3163    
3164 <  for(int icut=0;icut<jzb_cuts.size();icut++) {
3164 >  for(int icut=0;icut<(int)jzb_cuts.size();icut++) {
3165      float currcut=jzb_cuts[icut];
3166      int nbins=1;float low=currcut;
3167      vector<int> mysample;
# Line 2602 | Line 3176 | void make_table(samplecollection &coll,
3176      TH1F *RcorrJZBSBeemm;
3177      TH1F *LcorrJZBSBeemm;
3178      
3179 <    if(PlottingSetup::RestrictToMassPeak) {
3179 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3180        RcorrJZBSBem   = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3181        LcorrJZBSBem   = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3182        RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
# Line 2610 | Line 3184 | void make_table(samplecollection &coll,
3184      }
3185      
3186      TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3187 <    if(PlottingSetup::RestrictToMassPeak) {
3187 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3188        Bpred->Add(RcorrJZBem,1.0/3.);
3189        Bpred->Add(LcorrJZBem,-1.0/3.);
3190        Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 2646 | Line 3220 | void make_table(samplecollection &coll,
3220    //prediction part
3221    if(is_data) cout << "Data prediction & ";
3222    if(subselection!="none") cout << subselection << " prediction &";
3223 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3223 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
3224    
3225    cout << endl;
3226    //observation part
3227    if(is_data) cout << "Data observation & ";
3228    if(subselection!="none") cout << subselection << " observation &";
3229 <  for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3229 >  for(int ij=0;ij<(int)jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
3230    cout << endl;
3231    cout << "_________________________________________________________________" << endl;
3232    delete cannie;
# Line 2687 | Line 3261 | void JZBSelEff(string mcjzb, TTree* even
3261    int nbins = sizeof(xbins)/sizeof(float)-1;
3262    int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
3263  
3264 <  TH1F* heff  = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3265 <  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3266 <  TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
3264 >  
3265 >  TH1F* heff  = new TH1F("heff", "JZB eff ; generator JZB [GeV]; efficiency",nbins,xbins);
3266 >  TH1F* hgen  = new TH1F("hgen", "JZB gen ; generator JZB [GeV]; efficiency",nbins,xbins);
3267 >  TH1F* hreco = new TH1F("hreco","JZB reco ; generator JZB [GeV]; efficiency",nbins,xbins);
3268  
3269    TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
3270    TCut kreco(cutmass);
# Line 2705 | Line 3280 | void JZBSelEff(string mcjzb, TTree* even
3280    TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
3281    can->SetGridx(1);
3282    can->SetGridy(1);
3283 +  can->SetLeftMargin(0.16);
3284 +  can->SetRightMargin(0.05);
3285    TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
3286 +  leg->SetBorderSize(1);
3287 +  leg->SetLineColor(kBlack);
3288 +  leg->SetTextFont(62);
3289  
3290 <  
2711 <
2712 <  for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
3290 >  for ( int icut=0; icut<(int)jzb_bins.size(); ++icut ) {
3291  
3292      ostringstream selection;
3293      selection << mcjzb << ">" << jzb_bins[icut];
# Line 2725 | Line 3303 | void JZBSelEff(string mcjzb, TTree* even
3303      }
3304    
3305      heff->GetXaxis()->SetRangeUser(min, max);
3306 + //    heff->GetXaxis()->SetLabelSize(0.05); // paper style. overruled.
3307 + //    heff->GetYaxis()->SetLabelSize(0.05); // paper style. overruled.
3308 + //    heff->GetXaxis()->SetTitleSize(0.06); // paper style. overruled.
3309 + //    heff->GetYaxis()->SetTitleSize(0.06); // paper style. overruled.
3310      heff->SetMarkerStyle(markers[icut]);
3311      heff->Fit("func","Q+","same");
3312  
# Line 2736 | Line 3318 | void JZBSelEff(string mcjzb, TTree* even
3318  
3319      // Store plot
3320      TH1F* h = (TH1F*)heff->Clone(hname);
3321 +    h->SetNdivisions(505,"X");
3322      if ( icut) h->Draw("same");
3323      else h->Draw();
3324      char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
# Line 2756 | Line 3339 | void JZBSelEff(string mcjzb, TTree* even
3339   // Calls the above function for each signal sample
3340   void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
3341   {  
3342 <  for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
3342 >  for (int isignal=0; isignal<(int)signalsamples.collection.size();isignal++) {
3343      dout << "JZB selection efficiency curve: " << std::endl;
3344      JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
3345    }
# Line 2799 | Line 3382 | void qcd_plots(string datajzb, string mc
3382    TH1F *RcorrJZBSBeemm;
3383    TH1F *LcorrJZBSBeemm;
3384    
3385 <  TH1F *RcorrJZBeemmNoS;
3385 > //  TH1F *RcorrJZBeemmNoS;
3386  
3387      //these are for the ratio
3388    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 3395 | void qcd_plots(string datajzb, string mc
3395    TH1F *JRcorrJZBSBeemm;
3396    TH1F *JLcorrJZBSBeemm;
3397    
3398 <  if(PlottingSetup::RestrictToMassPeak) {
3398 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3399      RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3400      LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3401      RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 2833 | Line 3416 | void qcd_plots(string datajzb, string mc
3416      
3417    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3418    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
3419 <  if(PlottingSetup::RestrictToMassPeak) {
3419 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3420      Bpred->Add(RcorrJZBem,1.0/3.);
3421      Bpred->Add(LcorrJZBem,-1.0/3.);
3422      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 2883 | Line 3466 | void qcd_plots(string datajzb, string mc
3466    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3467    string ytitle("ratio");
3468    if ( use_data==1 ) ytitle = "data/pred";
3469 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
3469 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
3470    
3471    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
3472    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 2903 | Line 3486 | void qcd_plots(string datajzb, string mc
3486    dout << "______________________________________________" << endl;
3487    dout << "How QCD shows up in the different regions: " << endl;
3488    dout << "OSSF: " << endl;
3489 <  if(PlottingSetup::RestrictToMassPeak) {
3489 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3490      dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3491      dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
3492    } else {
3493      dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3494    }
3495    dout << "OSOF: " << endl;
3496 <  if(PlottingSetup::RestrictToMassPeak) {
3496 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3497      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3498      dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
3499    } else {
3500      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3501    }
3502    dout << "Therefore: " << endl;
3503 <  if(PlottingSetup::RestrictToMassPeak) {
3503 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3504      dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
3505      dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
3506      dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
# Line 2930 | Line 3513 | void qcd_plots(string datajzb, string mc
3513    dout << "    Observation increases by : " << RcorrJZBeemm->Integral() << endl;
3514    
3515    dout << endl;
3516 <  for(int i=0;i<bins.size();i++) {
3516 >  for(int i=0;i<(int)bins.size();i++) {
3517      dout << " JZB > " << bins[i] << " : " << endl;
3518      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3519 <    if(PlottingSetup::RestrictToMassPeak) {
3519 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3520          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;
3521      } else {
3522          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 3530 | void qcd_plots(string datajzb, string mc
3530    if(LcorrJZBem) delete LcorrJZBem;
3531    if(RcorrJZBeemm) delete RcorrJZBeemm;
3532    if(LcorrJZBeemm) delete LcorrJZBeemm;
3533 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3534 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3535 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3536 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3533 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBem) delete RcorrJZBSBem;
3534 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBem) delete LcorrJZBSBem;
3535 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3536 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3537   }
3538  
3539   void check_ptsanity() {
# Line 2978 | Line 3561 | void check_ptsanity() {
3561    leg->SetY2(1.0);
3562    
3563    
3564 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3564 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3565      string nowname=(allsamples.collection)[isample].filename;
3566      cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
3567      individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
# Line 3002 | Line 3585 | void check_ptsanity() {
3585    ptsancan->cd(2);
3586    fpt2->Draw();
3587  
3588 <  for(int isample=0;isample<allsamples.collection.size();isample++) {
3588 >  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
3589      ptsancan->cd(1);
3590      individualpt1histos[isample]->DrawNormalized("same,histo");
3591      ptsancan->cd(2);
# Line 3018 | Line 3601 | void check_ptsanity() {
3601   void do_mlls_plot(string mcjzb) {
3602    cout << "At this point we'd plot the mll distribution" << endl;
3603    TCanvas *sigcan = new TCanvas("sigcan","sigcan");
3604 <  for(int isig=0;isig<(signalsamples.collection).size();isig++) {
3604 >  for(int isig=0;isig<(int)(signalsamples.collection).size();isig++) {
3605      if(!(signalsamples.collection)[isig].events) continue;
3606      string nowname=(signalsamples.collection)[isig].filename;
3607      TH1F *mll = signalsamples.Draw("mllhisto","mll",150,0,150, "m_{ll}", "events",cutOSSF&&cutnJets,mc,luminosity,signalsamples.FindSample(nowname));
# Line 3047 | Line 3630 | void do_mlls_plot(string mcjzb) {
3630    }
3631   }
3632  
3633 < void met_vs_jzb_plots() {
3633 > void met_vs_jzb_plots(string datajzb, string mcjzb) {
3634    
3635    TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3636    canmetjzb->SetRightMargin(0.16);
# Line 3056 | Line 3639 | void met_vs_jzb_plots() {
3639    findme.push_back("DY");
3640    findme.push_back("TTJets");
3641    findme.push_back("LM");
3642 <  
3643 <  for(int ifind=0;ifind<findme.size();ifind++) {
3642 >  /*
3643 >  for(int ifind=0;ifind<(int)findme.size();ifind++) {
3644      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3645      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3646 <    for(int isel=0;isel<selsamples.size();isel++) {
3647 <      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3648 <      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3646 >    for(int isel=0;isel<(int)selsamples.size();isel++) {
3647 >      dout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3648 >      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF&&cutnJets);
3649      }
3650      metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3651      metvsjzb->SetStats(0);
# Line 3076 | Line 3659 | void met_vs_jzb_plots() {
3659      title->Draw();
3660      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3661    }
3662 +  */
3663 +  
3664 +  dout << "About to produce MET plot for DY split up by JZB" << endl;
3665 +  
3666 +  int nbins=14;
3667 +  float low=0;
3668 +  float high=140;
3669 +  
3670 +  stringstream sLEFT;
3671 +  sLEFT << "((" << mcjzb << ")<0)";
3672 +  TCut LEFT(sLEFT.str().c_str());
3673 +  stringstream sRIGHT;
3674 +  sRIGHT << "((" << mcjzb << ")>0)";
3675 +  TCut RIGHT(sRIGHT.str().c_str());
3676 +  
3677 +  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3678 +  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3679 +  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3680 +  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3681 +  
3682 +  
3683 +  TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
3684 +  Bpred->Add(metleftO,-1);
3685 +  Bpred->Add(metrightO);
3686 +  TH1F *obs = (TH1F*)metright->Clone("obs");
3687 +  
3688 +  metleft->Add(metleftO,-1);
3689 +  metright->Add(metrightO,-1);
3690 +  
3691 +  metleft->SetLineColor(kRed);
3692 +  metright->SetLineColor(kBlack);
3693 +  TPad *metpad = new TPad("metpad","metpad",0,0,1,1);
3694 +  metpad->cd();
3695 +  metpad->SetLogy(1);
3696 +  metleft->Draw("histo");
3697 +  metright->Draw("same");
3698 +  TLegend *lg = make_legend();
3699 +  lg->SetX1(0.5);
3700 +  lg->SetY1(0.7);
3701 +  lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3702 +  lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3703 +  lg->SetHeader("DY");
3704 +  
3705 +  lg->Draw();
3706 +  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3707 +  
3708 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3709 +  metpad3->cd();
3710 +  metpad3->SetLogy(1);
3711 +  Bpred->SetLineColor(kRed);
3712 +  Bpred->Draw("histo");
3713 +  obs->SetLineColor(kBlack);
3714 +  obs->Draw("same");
3715 +  TLegend *lg2 = make_legend();
3716 +  lg2->SetX1(0.5);
3717 +  lg2->SetY1(0.7);
3718 +  lg2->AddEntry(obs,"observed","P");
3719 +  lg2->AddEntry(Bpred,"predicted","L");
3720 +  lg2->SetHeader("DY");
3721 +
3722 +  lg2->Draw();
3723 +  
3724 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
3725 +  
3726 +  TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3727 +  metpad2->cd();
3728 +  metpad2->SetLogy(1);
3729 +  
3730 +  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3731 +  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3732 +  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3733 +  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3734 +  
3735 +  metlefta->Add(metleftOa,-1);
3736 +  metrighta->Add(metrightOa,-1);
3737 +  
3738 +  metlefta->SetLineColor(kRed);
3739 +  metpad2->cd();
3740 +  metlefta->Draw("histo");
3741 +  metrighta->Draw("same");
3742 +  lg->Draw();
3743 +  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3744 +  
3745 +  delete Bpred;
3746 +  delete obs;
3747 +  
3748 +  float newhigh=300;
3749 +  int newNBins=30;
3750 +  
3751 +  TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
3752 +  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
3753 +  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
3754 +  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
3755 +  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
3756 +  
3757 +  TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
3758 +  aBpred->Add(AmetleftO,-1);
3759 +  aBpred->Add(AmetrightO);
3760 +  aBpred->SetLineColor(kRed);
3761 +  
3762 +  TH1F *aobs = (TH1F*)Ametright->Clone("aobs");
3763 +  metpad4->cd();
3764 +  metpad4->SetLogy(1);
3765 +  aobs->Draw();
3766 +  aBpred->Draw("histo,same");
3767 +  aobs->Draw("same");
3768 +  lg->SetHeader("All MC");
3769 +  lg->Draw();
3770 +  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
3771 +  
3772 +  
3773 +  delete lg;
3774 +  delete canmetjzb;
3775 +  delete metleft;
3776 +  delete metleftO;
3777 +  delete metright;
3778 +  delete metrightO;
3779   }
3780      
3781  
# Line 3083 | Line 3783 | void test() {
3783    
3784    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
3785    testcanv->cd();
3786 <  switch_overunderflow(true);
3786 > //  switch_overunderflow(true);
3787    TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
3788    switch_overunderflow(false);
3789    ptdistr->Draw();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines