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.23 by buchmann, Thu Jun 7 08:16:28 2012 UTC vs.
Revision 1.39 by buchmann, Mon Jul 16 04:42:37 2012 UTC

# Line 28 | Line 28 | void todo() {
28    dout << "Info : The pt requirement is currently set to " << (const char*) passtrig << endl;
29    dout << "Info : The mll requirement is currently set to " << (const char*) cutmass << endl;
30    dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
31 +  dout << "Info : The weight applied to all MC is " << (const char*) cutWeight << endl;
32   }  
33  
34 < void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
34 >
35 >
36 > void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, 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    
42 +  int nbins=100;
43 +  if(PlottingSetup::DoBTag) nbins=25;
44 +  
45    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
46 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
47 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
48 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
49 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
46 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,mc, luminosity);
47 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,data, luminosity);
48 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,mc, luminosity);
49 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,data, luminosity);
50    TH1F *rawttbarjzbeemmMC;
51  
52    if(method==doKM) {
53      //we only need this histo for the KM fitting...
54 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
55 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
56 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
54 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
55 >    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
56 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
57 >    delete rawttbarjzbeemmMC;
58    }
59    else {
60      TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
# Line 55 | Line 62 | void find_peaks(float &MCPeak,float &MCP
62      reducedMC->Add(rawJZBemMC,-1);
63      reducedData->Add(rawJZBemData,-1);
64      //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
65 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
66 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
67 <    
65 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
66 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
67 >    delete reducedMC;
68 >    delete reducedData;
69    }
70  
71    // Revert to original PU reweighting
# Line 65 | Line 73 | void find_peaks(float &MCPeak,float &MCP
73      
74   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
75   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
76 <  dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 <  result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
78 <  dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 <  result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
76 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
78 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
80 >  delete rawJZBeemmData;
81 >  delete rawJZBeemmMC;
82 >  delete rawJZBemData;
83 >  delete rawJZBemMC;
84    delete tempcan;
85   }
86  
87 < void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
87 > void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb)
88 > {
89 >  
90 >  bool DoInvidualeemmPeaks=false;
91 >  
92 >  float mcpeak, datapeak;
93 >  float mcpeakerr, datapeakerr;
94 >  
95 >  float mceepeak,mcmmpeak;
96 >  float mceepeakerr,mcmmpeakerr;
97 >  
98 >  float datammpeak,dataeepeak;
99 >  float datammpeakerr,dataeepeakerr;
100 >  
101 >  float mcSigma, dataSigma;
102 >  
103 >  dout << "Finding global peak : " << endl;
104 >  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma, dataSigma,result,doPUreweighting,"");
105 >  
106 >  if(DoInvidualeemmPeaks) {
107 >    dout << "Finding peak for electrons : " << endl;
108 >    find_one_peak_combination(TCut("id1==0"),mceepeak,mceepeakerr, dataeepeak,dataeepeakerr,mcSigma, dataSigma,result,doPUreweighting,"_ele");
109 >    dout << "Finding peak for muons : " << endl;
110 >    find_one_peak_combination(TCut("id1==1"),mcmmpeak,mcmmpeakerr, datammpeak,datammpeakerr,mcSigma, dataSigma,result,doPUreweighting,"_mu");
111 >    
112 >    datajzb << "(" << jzbvariabledata;
113 >    mcjzb << "(" << jzbvariablemc;
114 >    
115 >    if(dataeepeak>0) datajzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
116 >    else datajzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
117 >    
118 >    if(datammpeak>0) datajzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
119 >    else datajzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
120 >    
121 >    if(datapeak>0) datajzb << "- (id1!=id2)*" << TMath::Abs(datapeak) << " ";
122 >    else datajzb << "+ (id1!=id2)*" << TMath::Abs(datapeak) << " ";
123 >    
124 >    datajzb << ")";
125 >    
126 >    if(mceepeak>0) mcjzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
127 >    else mcjzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
128 >    
129 >    if(mcmmpeak>0) mcjzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
130 >    else mcjzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
131 >    
132 >    if(mcpeak>0) mcjzb << "- (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
133 >    else mcjzb << "+ (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
134 >    
135 >    mcjzb << ")";
136 >  } else {
137 >    datajzb << "(" << jzbvariabledata;
138 >      mcjzb << "(" << jzbvariablemc;
139 >    
140 >    if(datapeak>0) datajzb << "- " << TMath::Abs(datapeak) << " ";
141 >    else datajzb << "+ " << TMath::Abs(datapeak) << " ";
142 >    
143 >    datajzb << ")";
144 >    
145 >    if(mcpeak>0) mcjzb << "- " << TMath::Abs(mcpeak) << " ";
146 >    else mcjzb << "+ " << TMath::Abs(mcpeak) << " ";
147 >    
148 >    mcjzb << ")";
149 >  }
150 >  
151 >  
152 > }
153 >
154 > void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold) {
155    float min=70.0;
156    float max=115.0;
157    if(!PlottingSetup::RestrictToMassPeak) {
158 <    min=10;
159 <    max=150;
158 >    min=20;
159 >    max=200;
160    }
161    int nbins=int((max-min)/5);
162    
163    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
164    
165    stringstream largerzeroS;
166 <  largerzeroS << "(" << mcjzb << ">" << jzbthreshold << ")";
167 <  TCut largerzero(largerzeroS.str().c_str());
166 >  largerzeroS << "(" << datajzb << ">" << jzbthreshold << ")";
167 >  TCut largerzeroD(largerzeroS.str().c_str());
168    
169    stringstream smallerzeroS;
170 <  smallerzeroS << "(" << mcjzb << "<-" << jzbthreshold << ")";
171 <  TCut smallerzero(smallerzeroS.str().c_str());
172 <  
173 <  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,data,luminosity);
174 <  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,mc,luminosity);
175 <  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,data,luminosity);
176 <  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,data,luminosity);
177 <  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,data,luminosity);
170 >  smallerzeroS << "(" << datajzb << "<-" << jzbthreshold << ")";
171 >  TCut smallerzeroD(smallerzeroS.str().c_str());
172 >
173 >
174 >  stringstream largerzeroMS;
175 >  largerzeroMS << "(" << mcjzb << ">" << jzbthreshold << ")";
176 >  TCut largerzeroM(largerzeroMS.str().c_str());
177 >  
178 >  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroD,data,luminosity);
179 >  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroM,mc,luminosity);
180 >  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzeroD,data,luminosity);
181 >  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzeroD,data,luminosity);
182 >  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzeroD,data,luminosity);
183  
184    TH1F *RcorrJZBSBem;
185    TH1F *LcorrJZBSBem;
# Line 105 | Line 189 | void make_special_obs_pred_mll_plot(stri
189   //  TH1F *RcorrJZBeemmNoS;
190  
191    if(PlottingSetup::RestrictToMassPeak) {
192 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,data, luminosity);
193 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,data, luminosity);
194 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,data, luminosity);
195 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,data, luminosity);
192 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
193 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
194 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
195 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzeroD,data, luminosity);
196    }
197    
198    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
# Line 140 | Line 224 | void make_special_obs_pred_mll_plot(stri
224    stringstream saveas;
225    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
226    CompleteSave(ckin,saveas.str());
227 +  
228 +  
229 +  
230 +  RcorrJZBeemm->Draw();
231 +  Bpred->Draw("histo,same");
232 +  RcorrJZBeemm->Draw("same");
233 +  
234 +  TLegend *leg2 = make_legend();
235 +  leg2->SetX1(0.58);
236 +  leg2->AddEntry(RcorrJZBeemm,"observed (data)","l");
237 +  leg2->AddEntry(Bpred,"predicted (data)","l");
238 +  leg2->Draw("same");
239 +  
240 +  saveas.str("");
241 +  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
242 +  CompleteSave(ckin,saveas.str());
243 +  
244 +  
245  
246    delete RcorrJZBeemm;
247    delete LcorrJZBeemm;
# Line 281 | Line 383 | void make_kin_plot(string variable, stri
383          draw_separation_lines=true;
384    }
385    if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
386 <  if(Contains(filename,"mll_aboveJZB100")) cut=cutOSSF&&cutnJets&&ibasiccut;
386 >  if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
387 >  if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
388 >  if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
389    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
390    if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
391    if(filename=="mll_inclusive_osof") cut=cutOSOF;
# Line 393 | Line 497 | void make_JES_plot() {
497    TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
498    datahisto->SetMarkerSize(DataMarkerSize);
499    THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
500 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
501 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
500 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNump1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
501 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNumn1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
502  
503    datahisto->SetMinimum(1);
504    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 461 | Line 565 | void do_kinematic_plots(string mcjzb, st
565    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
566    stringstream jzbcut;
567    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
568 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
569 <  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);
570 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
571 <  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);
568 >  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
569 >  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);
570 >  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);
571 >  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);
572    stringstream jzbcut2;
573    jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
574 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
575 <  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);
574 >  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
575 >  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);
576 >  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);
577 >  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);
578    stringstream jzbcut3;
579    jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
580 <  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);
580 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
581 >  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);
582 >  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);  
583 >  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);  
584 >  
585 >  
586 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
587 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
588 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
589 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
590 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
591 >  make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
592    
593 <  make_special_obs_pred_mll_plot(mcjzb,0);
477 <  make_special_obs_pred_mll_plot(mcjzb,50);
478 <  make_special_obs_pred_mll_plot(mcjzb,100);
479 <  make_special_obs_pred_mll_plot(mcjzb,150);
480 <  make_special_obs_pred_mll_plot(mcjzb,200);
481 <  make_special_obs_pred_mll_plot(mcjzb,250);
593 >  make_JES_plot();
594   }
595  
596   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 512 | Line 624 | void make_comp_plot( string var, string
624        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
625        ccomp->SetLogy(log);
626        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
627 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
627 >      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM"));
628        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
629        datahisto->SetMarkerSize(DataMarkerSize);
630        if (ymax>ymin) datahisto->SetMaximum(ymax);
# Line 546 | Line 658 | void region_comparison_plots(string mcjz
658    dout << "Creating comparison plots for signal and control regions" << endl;
659    // Compare a few quantities in the signal region and all 7 control regions
660  
661 <  switch_overunderflow(true);  // switching overflow/underflow bins on
661 > //  switch_overunderflow(true);  // switching overflow/underflow bins on
662      
663    
664      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
# Line 857 | Line 969 | if you want to start from scratch (witho
969    return return_functions;
970   }
971  
972 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
972 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
973   {
974 <  // note: sigma is not used ATM
863 <  switch_overunderflow(true);
974 > //  switch_overunderflow(true);
975    bool is_data=false;
976    bool use_signal=false;
977    if(use_data==1) is_data=true;
# Line 870 | Line 981 | void do_prediction_plot(string jzb, TCan
981    float low=0;
982    float hi=500;
983    
873  stringstream largerzeroS;
874  largerzeroS << "("<<jzb<<">0)";
875  TCut largerzero(largerzeroS.str().c_str());
876  stringstream smallerzeroS;
877  smallerzeroS << "("<<jzb<<"<0)";
878  TCut smallerzero(smallerzeroS.str().c_str());
879  
984    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
985 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
986 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
987 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
988 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
985 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
986 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
987 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
988 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
989  
990    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
991    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 898 | Line 1002 | void do_prediction_plot(string jzb, TCan
1002  
1003      //these are for the ratio
1004    
1005 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1006 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1007 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1008 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1005 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1006 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1007 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1008 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1009    
1010    TH1F *JRcorrJZBSBem;
1011    TH1F *JLcorrJZBSBem;
1012    TH1F *JRcorrJZBSBeemm;
1013    TH1F *JLcorrJZBSBeemm;
1014    
1015 <  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);
1015 >  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
1016  
1017    
1018    if(PlottingSetup::RestrictToMassPeak) {
1019 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1020 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1021 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1022 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1019 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1020 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1021 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1022 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1023      
1024      //these are for the ratio
1025 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1026 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1027 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzero,is_data, luminosity,use_signal);
1028 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzero,is_data, luminosity,use_signal);
1025 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1026 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1027 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1028 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1029    }
1030    
1031    TH1F *lm4RcorrJZBeemm;
1032 <  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"));
1032 >  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
1033    
1034    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1035    
# Line 935 | Line 1039 | void do_prediction_plot(string jzb, TCan
1039    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1040    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
1041      
1042 <  TH1F *BpredSys = (TH1F*)LcorrJZBeemm->Clone("Bpredsys");
1042 >  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1043    ClearHisto(BpredSys);
940    write_error(__FUNCTION__,"Implemented systematic error but NOT drawing it yet. Need to still implement drawing, particularly in ratio.");
1044      
1045    if(PlottingSetup::RestrictToMassPeak) {
1046      Bpred->Add(RcorrJZBem,1.0/3.);
# Line 963 | Line 1066 | void do_prediction_plot(string jzb, TCan
1066      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1067        
1068      //Systematics:
1069 <    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1070 <    AddSquared(BpredSys,RcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1071 <    AddSquared(BpredSys,LcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1072 <    AddSquared(BpredSys,RcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1073 <    AddSquared(BpredSys,LcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1074 <    AddSquared(BpredSys,RcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1075 <    AddSquared(BpredSys,LcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1069 >    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1070 >    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1071 >    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1072 >    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1073 >    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1074 >    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1075 >    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1076    } else {
1077      Bpred->Add(RcorrJZBem,1.0);
1078      Bpred->Add(LcorrJZBem,-1.0);
# Line 981 | Line 1084 | void do_prediction_plot(string jzb, TCan
1084      JBpred->Add(JLcorrJZBem,-1.0);
1085        
1086      //Systematics
1087 <    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1088 <    AddSquared(BpredSys,RcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1089 <    AddSquared(BpredSys,LcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1087 >    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1088 >    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1089 >    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1090  
1091    }
1092      
1093    SQRT(BpredSys);
1094 +  BpredSys->Divide(JBpred);
1095  
1096    
1097    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
# Line 1045 | Line 1149 | void do_prediction_plot(string jzb, TCan
1149      lm4RcorrJZBeemm->Draw("hist,same");
1150      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1151      legBpred->AddEntry(Bpred,"predicted","l");
1152 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1153 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1154 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1152 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1153 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1154 >    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1155      legBpred->Draw();
1156      DrawPrelim();
1157  
# Line 1086 | Line 1190 | void do_prediction_plot(string jzb, TCan
1190      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1191      speciallegBpred->AddEntry(Bpred,"Total background","l");
1192      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1193 <    speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1193 >    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1194 >    else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1195   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1196      speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1197      speciallegBpred->Draw();
1198 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1198 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1199      
1200      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1201 <    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1201 >    specialcanv->SetLogy(1);
1202 > //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
1203      blankback->Draw();
1204 <    kostack.Draw("same");
1204 > //    kostack.Draw("same");
1205 >    predcomposition.Draw();
1206      Bpred->Draw("hist,same");
1207 <    analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1207 >    //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1208      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1209      legBpred->Draw();
1210      DrawPrelim();
1211      CompleteSave(specialcanv,subdir+"Bpred_Data_____PredictionCompositioninMC");
1212      Bpred->SetLineWidth((int)CurrentBpredLineWidth);
1213      
1214 +    
1215 +    //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;
1216 +    
1217      delete speciallegBpred;
1218      delete Zjetspred;
1219      delete TTbarpred;
# Line 1168 | Line 1278 | void do_prediction_plot(string jzb, TCan
1278    string ytitle("ratio");
1279    if ( use_data==1 ) ytitle = "data/pred";
1280    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1281 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1281 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle,BpredSys);//not extending the y range anymore up to 4
1282  
1283    
1284    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1285 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1285 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1286    if(PlottingSetup::RestrictToMassPeak) {
1287      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1288      Bpredem->Add(RcorrJZBem);
# Line 1234 | Line 1344 | void do_prediction_plot(string jzb, TCan
1344      }
1345    }
1346    
1347 +  TFile *f = new TFile("tester.root","RECREATE");
1348 +  RcorrJZBeemm->Write();
1349 +  Bpred->Write();
1350 +  f->Close();
1351 +  
1352    delete RcorrJZBeemm;
1353    delete LcorrJZBeemm;
1354    delete RcorrJZBem;
# Line 1246 | Line 1361 | void do_prediction_plot(string jzb, TCan
1361  
1362    delete blankback;
1363    
1364 +  delete BpredSys;
1365    if(PlottingSetup::RestrictToMassPeak) {
1366      delete RcorrJZBSBem;
1367      delete LcorrJZBSBem;
# Line 1263 | Line 1379 | void do_prediction_plot(string jzb, TCan
1379  
1380   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1381    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1382 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1382 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1383    if ( !PlottingSetup::Approved ) {
1384 <    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1385 <    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1384 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1385 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1386    } else {
1387      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1388    }
# Line 1701 | Line 1817 | void diboson_plots(string mcjzb, string
1817    dout << "Going to produce JZB plots" << endl;
1818    produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1819    TCanvas *gloca = new TCanvas("gloca","gloca");
1704  float sigma=123456;
1820    
1821    dout << "Going to produce prediction plots" << endl;
1822 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1823 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1822 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1823 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1824    delete gloca;
1825  
1826    dout << "Going to reset the cross section for diboson samples ... " << endl;
# Line 1719 | Line 1834 | void diboson_plots(string mcjzb, string
1834    }
1835    
1836   }
1837 +
1838 +
1839 + void draw_normalized_data_vs_data_histo(TCut cut1, TCut cut2, string variable, string legentry1, string legentry2, string savename, TCanvas *can,vector<float> binning) {
1840 +  TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
1841 +  jzbpad->cd();
1842 +  jzbpad->SetLogy(1);
1843 +  string xlabel="JZB [GeV]";
1844 +
1845 +  TH1F *datahisto1 = allsamples.Draw("datahisto1",variable,binning, xlabel, "events",cut1,data,luminosity);
1846 +  datahisto1->SetLineColor(kRed);
1847 +  datahisto1->SetMarkerColor(kRed);
1848 +  TH1F *datahisto2 = allsamples.Draw("datahisto2",variable,binning, xlabel, "events",cut2,data,luminosity);
1849 +  datahisto2->SetLineColor(kBlue);
1850 +  datahisto2->SetMarkerColor(kBlue);
1851 +  
1852 +  datahisto2->SetMarkerSize(DataMarkerSize);
1853 +  datahisto1->DrawNormalized("e1");
1854 +  datahisto2->DrawNormalized("histo,same");
1855 +  datahisto1->DrawNormalized("same,e1");
1856 +  
1857 +  TLegend *leg = make_legend();
1858 +  leg->AddEntry(datahisto1,legentry1.c_str());
1859 +  leg->AddEntry(datahisto2,legentry2.c_str());
1860 +  leg->Draw();
1861 +  
1862 +  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
1863 +  
1864 +  datahisto1->Delete();
1865 +  datahisto2->Delete();
1866 + }
1867 +
1868 +
1869   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1870    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
1871    float max=jzbHigh ;
# Line 1742 | Line 1889 | void jzb_plots(string mcjzb, string data
1889      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1890      if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
1891      if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1892 +    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);
1893 +    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);
1894 +    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);
1895 +
1896    }
1897    
1898    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
# Line 2088 | Line 2239 | void draw_ttbar_and_zjets_shape(string m
2239    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2240   }
2241  
2242 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2092 <  //first: colorful plots
2242 > float find_one_correction_factor(string FindKeyword, bool dodata, TCut SpecialCut, string SaveAs) {
2243    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2244    cancorr->SetLogz();
2245    cancorr->SetRightMargin(0.13);
2246 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2247 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2248 <  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2249 <  TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2250 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2246 >  TCut zptbasecutforresponsepresentation("pt<600&&((sumJetPt[1]/pt)<5.0)"&&SpecialCut&&passtrig);
2247 >    
2248 > //  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)"&&SpecialCut&&passtrig);
2249 >  if(PlottingSetup::DoBTag) zptbasecutforresponsepresentation=zptbasecutforresponsepresentation&&PlottingSetup::bTagRequirement;
2250 >    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2251 >    TH2F *niceresponseplotd_SFSB = new TH2F("niceresponseplotd_SFSB","",100,0,600,100,0,5);
2252 >    TH2F *niceresponseplotd_OFSB = new TH2F("niceresponseplotd_OFSB","",100,0,600,100,0,5);
2253 >    TH2F *niceresponseplotd_OFZP = new TH2F("niceresponseplotd_OFZP","",100,0,600,100,0,5);
2254 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2255 >  for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2256 >    if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2257 >    if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2258 >    
2259 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2260 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptbasecutforresponsepresentation&&cutmass&&cutOSSF)*cutWeight);
2261 > //    if(PlottingSetup::RestrictToMassPeak) (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd_OFSB",(zptbasecutforresponsepresentation&&sidebandcut&&cutOSOF)*cutWeight);
2262 > //    if(PlottingSetup::RestrictToMassPeak) (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd_SFSB",(zptbasecutforresponsepresentation&&sidebandcut&&cutOSSF)*cutWeight);
2263 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd_OFZP",(zptbasecutforresponsepresentation&&cutmass&&cutOSOF)*cutWeight);
2264 >  }
2265 >    
2266 >    if(PlottingSetup::RestrictToMassPeak) {
2267 > //        dout << "About to correct the 2D map (containing " << niceresponseplotd->Integral() << ") with different 2D maps: " << endl;
2268 > //        dout << "   OFZP: " << niceresponseplotd_OFZP->Integral() << ")" << endl;
2269 > //        dout << "   SFSB: " << niceresponseplotd_SFSB->Integral() << ")" << endl;
2270 > //        dout << "   OFSB: " << niceresponseplotd_OFSB->Integral() << ")" << endl;
2271 > //        niceresponseplotd->Add(niceresponseplotd_SFSB,-1.0/3);
2272 > //        niceresponseplotd->Add(niceresponseplotd_OFSB,-1.0/3);
2273 > //        niceresponseplotd->Add(niceresponseplotd_OFZP,-1.0/3);
2274 >        niceresponseplotd->Add(niceresponseplotd_OFZP,-1.0);
2275 >    } else {
2276 >        niceresponseplotd->Add(niceresponseplotd_OFZP,-1.0);
2277 >    }
2278 >    
2279    niceresponseplotd->SetStats(0);
2280    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2281    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2106 | Line 2284 | void find_correction_factors(string &jzb
2284    niceresponseplotd->Draw("COLZ");
2285    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2286    profd->SetMarkerSize(DataMarkerSize);
2287 <  profd->Fit("pol0","","same,e1",100,400);
2287 >  profd->Fit("pol0","E","same,e1",100,400); //use MINOS
2288    DrawPrelim();
2289 <  TText* title = write_text(0.5,0.7,"Data");
2289 >  string stitle="Data";
2290 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2291 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2292    title->SetTextAlign(12);
2293    title->Draw();
2294    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2295 <  float datacorrection=datapol->GetParameter(0);
2296 <  stringstream dataresstring;
2297 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2298 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2295 >  float correction=datapol->GetParameter(0);
2296 >  stringstream resstring;
2297 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2298 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2299    restitle->SetTextAlign(12);
2300    restitle->SetTextSize(0.03);
2301    restitle->Draw();
2302 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2303 <  
2304 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2305 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation*cutWeight);
2306 <  niceresponseplotm->SetStats(0);
2307 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2308 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2309 <  niceresponseplotm->GetXaxis()->CenterTitle();
2310 <  niceresponseplotm->GetYaxis()->CenterTitle();
2311 <  niceresponseplotm->Draw("COLZ");
2132 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2133 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2134 <  profm->SetMarkerSize(DataMarkerSize);
2135 <  profm->Fit("pol0","","same,e1",100,400);
2136 <  DrawMCPrelim();
2137 <  title = write_text(0.5,0.7,"MC simulation");
2138 <  title->SetTextAlign(12);
2139 <  title->Draw();
2140 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
2141 <  float mccorrection=mcpol->GetParameter(0);
2142 <  stringstream mcresstring;
2143 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
2144 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
2145 <  mcrestitle->SetTextAlign(12);
2146 <  mcrestitle->SetTextSize(0.03);
2147 <  mcrestitle->Draw();
2148 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2302 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2303 >  delete cancorr;
2304 >  delete niceresponseplotd;
2305 >  delete niceresponseplotd_OFZP;
2306 >  delete niceresponseplotd_OFSB;
2307 >  delete niceresponseplotd_SFSB;
2308 >  return correction;
2309 > }
2310 >
2311 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2312    
2313 +  dout << "Computing response corrections: " << endl;
2314 +  //Step 1 : Get results
2315 +  float datacorrection=find_one_correction_factor("Data",true,"","Data");
2316 +  float mccorrection=find_one_correction_factor("DY",false,"","MC");
2317 +  
2318 +  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
2319 +  float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
2320 +  
2321 +  float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
2322 +  float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
2323 +  
2324 +  cout << "Corrections : " << endl;
2325 +  cout << "   Data : " << datacorrection << endl;
2326 +  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2327 +  cout << "   MC : " << mccorrection << endl;
2328 +  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2329    
2330 <  //Step 2: Getting the result
2152 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2330 >  //Step 2: Processing the result and making it into something useful :-)
2331    stringstream jzbvardatas;
2332 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2333 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2332 >  jzbvardatas << "(";
2333 >  
2334 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2335 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2336 >  
2337 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2338 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2339 >  
2340 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2341 >  
2342 >  if(datacorrection>=1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << datacorrection-1 << "*pt))";
2343 >  if(datacorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]+" << 1-datacorrection << "*pt))";
2344 >  
2345 >  jzbvardatas << ")";
2346    jzbvardata=jzbvardatas.str();
2347 +  
2348    stringstream jzbvarmcs;
2349 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2350 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2349 >  jzbvarmcs << "(";
2350 >  
2351 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2352 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2353 >  
2354 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2355 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2356 >  
2357 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2358 >  
2359 >  if(mccorrection>=1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << mccorrection-1 << "*pt))";
2360 >  if(mccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]+" << 1-mccorrection << "*pt))";
2361 >  
2362 >  jzbvarmcs << ")";
2363    jzbvarmc=jzbvarmcs.str();
2364 +
2365    dout << "JZB Z pt correction summary : " << endl;
2366    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2367    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2368 +  
2369   }
2370  
2371   void pick_up_events(string cut) {
# Line 2254 | Line 2459 | void ttbar_sidebands_comparison(string m
2459    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2460    //in the case of the OFF peak analysis, we compare our control region to the real value
2461    TCut weightbackup=cutWeight;
2257 //  cutWeight="1.0";
2258  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2462    
2463 +  bool doPURW=false;
2464 +  
2465 +  
2466 +  if(!doPURW) {
2467 +    cutWeight="1.0";
2468 +    // Do it without PU re-weighting
2469 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2470 +    stringstream resultsNoPU;
2471 +    stringstream noPUdatajzb;
2472 +    stringstream noPUmcjzb;
2473 +    
2474 +    stringstream mcjzbnoPU;
2475 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2476 +    mcjzb = noPUmcjzb.str();
2477 +  }
2478 +
2479 +    
2480 +    
2481 +    
2482 +    
2483 +    
2484 +  float simulatedlumi = luminosity; //in pb please - adjust to your likings
2485  
2486    TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2487    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
# Line 2294 | Line 2519 | void ttbar_sidebands_comparison(string m
2519    }
2520    
2521    vector<TH1F*> histos;
2522 +  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2523 +  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2524    histos.push_back(TZem);
2525    histos.push_back(TZeemm);
2526    if(PlottingSetup::RestrictToMassPeak) {
2527 +    TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2528 +    TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2529      histos.push_back(TSem);
2530      histos.push_back(TSeemm);
2531    }
# Line 2339 | Line 2568 | void ttbar_sidebands_comparison(string m
2568      TSeemm->Draw("same");
2569    }
2570    
2571 <  float linepos=0.25;
2572 <  if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
2573 <  if(!PlottingSetup::RestrictToMassPeak) linepos=0.1; //sys uncertainty for iJZB
2571 >  float linepos=emuncertONPEAK;
2572 >  if(!PlottingSetup::RestrictToMassPeak) linepos=emuncertOFFPEAK;
2573 >  
2574    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2575    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2576    TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
# Line 2423 | Line 2652 | void ttbar_sidebands_comparison(string m
2652    tcan->SetLogy(0);
2653    rightofzp->Divide(rightsfzp);
2654    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2655 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
2655 >  rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2656    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2657    rightofzp->Draw();
2658    if(PlottingSetup::RestrictToMassPeak) {
# Line 2483 | Line 2712 | void ttbar_sidebands_comparison(string m
2712  
2713   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
2714    vector<float> nicer_binning;
2715 <  nicer_binning.push_back(-125);
2715 >  
2716 > /*  nicer_binning.push_back(-400);
2717 >  nicer_binning.push_back(-250);
2718 >  nicer_binning.push_back(-200);
2719 >  nicer_binning.push_back(-150);
2720 >  nicer_binning.push_back(-100);
2721 >  nicer_binning.push_back(-50);
2722 >  nicer_binning.push_back(-20);
2723 >  
2724 >  nicer_binning.push_back(0);
2725 >  nicer_binning.push_back(20);
2726 >  nicer_binning.push_back(50);
2727 >  nicer_binning.push_back(100);
2728 >  nicer_binning.push_back(150);
2729 >  nicer_binning.push_back(200);
2730 >  nicer_binning.push_back(250);
2731 >  nicer_binning.push_back(400);*/
2732 >  
2733    nicer_binning.push_back(-100);
2488  nicer_binning.push_back(-75);
2734    nicer_binning.push_back(-50);
2735    nicer_binning.push_back(-25);
2736    nicer_binning.push_back(0);
# Line 2500 | Line 2745 | void ttbar_sidebands_comparison(string m
2745    nicer_binning.push_back(230);
2746    nicer_binning.push_back(280);
2747    nicer_binning.push_back(400);
2748 +  
2749    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2750   }
2751  
2752  
2753 < void zjets_prediction_comparison(string mcjzbWithPU) {
2753 > void zjets_prediction_comparison(string mcjzbWithPUa) {
2754    TCanvas *zcan = new TCanvas("zcan","zcan");  
2755 <  zcan->SetLogy(1);
2755 > //  zcan->SetLogy(1);
2756    TCut weightbackup=cutWeight;
2757 +  
2758 +  bool UsePURW=false;
2759 +  
2760 +  
2761 +  string mcjzb;
2762 +  if(UsePURW) {
2763 +    mcjzb=mcjzbWithPUa;
2764 +  } else {
2765 +    // Do it without PU re-weighting
2766 +    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2767 +    stringstream resultsNoPU;
2768 +    stringstream noPUdatajzb;
2769 +    stringstream noPUmcjzb;
2770 +    
2771 +    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2772 +    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2773 +    
2774 +    mcjzb = noPUmcjzb.str();
2775 +    
2776 +    cutWeight="1.0";
2777 +  }
2778  
2779 < /*
2780 <  // Do it without PU re-weighting
2781 <  float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2782 <  stringstream resultsNoPU;
2783 <
2784 <  stringstream mcjzbnoPU;
2785 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2786 <  if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2787 <  else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2788 <
2789 <  string mcjzb = mcjzbnoPU.str();
2790 <  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2779 >  
2780 >  vector<float> binning;
2781 >  binning.push_back(0);
2782 >  binning.push_back(10);
2783 >  binning.push_back(20);
2784 > //  binning.push_back(30);
2785 >  binning.push_back(40);
2786 > //   binning.push_back(50);
2787 > //   binning.push_back(60);
2788 > //   binning.push_back(70);
2789 > //   binning.push_back(80);
2790 > //   binning.push_back(90);
2791 >  binning.push_back(100);
2792  
2525  cutWeight="1.0";
2526 */
2527  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2528  float sbg_min=0.;
2529  float sbg_max=100.;
2530  int sbg_nbins=5;
2793    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2794    
2795    TCut kPos((mcjzb+">0").c_str());
2796    TCut kNeg((mcjzb+"<0").c_str());
2797    string var( "abs("+mcjzb+")" );
2798 +  
2799 +  TCut notTau("abs(genMID1)!=15");
2800 +  TCut ONLYTau("mll>20");
2801 +  
2802  
2803 <  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2804 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2805 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2803 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2804 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2805 >  
2806    hJZBpos->SetLineColor(kBlack);
2807    hJZBneg->SetLineColor(kRed);
2808    
2809 <
2809 >  hJZBpos->SetMinimum(1.0);
2810    hJZBpos->Draw("e1");
2811    hJZBneg->Draw("same,hist");
2812    hJZBpos->Draw("same,e1"); // So it's on top...
2813    
2814 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2814 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2815    leg->AddEntry(hJZBpos,"Observed","pe");
2816    leg->AddEntry(hJZBneg,"Predicted","l");
2817    leg->Draw("same");
2818    DrawMCPrelim(simulatedlumi);
2819 <  CompleteSave(zcan,"Systematics/zjets_prediction");
2819 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
2820    
2821    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
2822    hratio->Divide(hJZBneg);
2823    
2824 +  for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
2825 +    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
2826 +  }
2827 +  
2828    zcan->SetLogy(0);
2829    hratio->GetYaxis()->SetRangeUser(0,2.5);
2830    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2831    hratio->Draw("e1");
2832    
2833 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
2834 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
2835 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
2833 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
2834 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2835 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
2836    
2837  
2838    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2573 | Line 2843 | void zjets_prediction_comparison(string
2843    center->Draw("same");
2844    bottom->Draw("same");
2845    
2846 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
2846 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
2847    leg2->AddEntry(hratio,"obs / pred","pe");
2848    leg2->AddEntry(bottom,"syst. envelope","l");
2849    leg2->Draw("same");
2850    DrawMCPrelim(simulatedlumi);
2851 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
2851 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
2852 >  
2853 >  TCut reducedNJets(cutnJets);
2854 >  
2855 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2856 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2857 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2858 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2859 >
2860 >  TH1F *RcorrJZBSBem;
2861 >  TH1F *LcorrJZBSBem;
2862 >  TH1F *RcorrJZBSBeemm;
2863 >  TH1F *LcorrJZBSBeemm;
2864 >
2865 >  if(PlottingSetup::RestrictToMassPeak) {
2866 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2867 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2868 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2869 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2870 >  }
2871 >  
2872 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
2873 >  if(PlottingSetup::RestrictToMassPeak) {
2874 >    Bpred->Add(RcorrJZBem,1.0/3.);
2875 >    Bpred->Add(LcorrJZBem,-1.0/3.);
2876 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
2877 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
2878 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
2879 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
2880 >  } else {
2881 >    Bpred->Add(RcorrJZBem,1.0);
2882 >    Bpred->Add(LcorrJZBem,-1.0);
2883 >  }
2884 >  
2885 >  Bpred->SetLineColor(kRed);
2886 >
2887 >  TAUhJZBpos->SetLineColor(kBlack);
2888 >  Bpred->SetLineColor(kRed);
2889 >  
2890 >  TAUhJZBpos->SetMinimum(1.0);
2891 >  TAUhJZBpos->Draw("e1");
2892 >  Bpred->Draw("same,hist");
2893 >  TAUhJZBpos->Draw("same,e1");
2894 >  
2895 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
2896 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
2897 >  TAUleg->AddEntry(Bpred,"Predicted","l");
2898 >  TAUleg->Draw("same");
2899 >  DrawMCPrelim(simulatedlumi);
2900 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
2901 >  
2902 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
2903 >  TAUhratio->Divide(Bpred);
2904 >  
2905 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
2906 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
2907 >  }
2908 >  
2909 >  zcan->SetLogy(0);
2910 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
2911 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
2912 >  TAUhratio->Draw("e1");
2913 >  
2914 >  top->Draw("same");
2915 >  center->Draw("same");
2916 >  bottom->Draw("same");
2917 >  
2918 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
2919 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
2920 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
2921 >  TAUleg2->Draw("same");
2922 >  DrawMCPrelim(simulatedlumi);
2923 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
2924 >  
2925 >  delete Bpred;
2926 >  delete TAUhJZBpos;
2927 >  delete LcorrJZBeemm;
2928 >  delete RcorrJZBem;
2929 >  delete LcorrJZBem;
2930 >  
2931 >  if(PlottingSetup::RestrictToMassPeak) {
2932 >    delete RcorrJZBSBem;
2933 >    delete LcorrJZBSBem;
2934 >    delete RcorrJZBSBeemm;
2935 >    delete LcorrJZBSBeemm;
2936 >  }
2937 >  
2938    
2939    delete zcan;
2940    cutWeight=weightbackup;
# Line 2604 | Line 2960 | void sideband_assessment(string datajzb,
2960    tout << "\\begin{tabular}{l|cc}" << endl;
2961    tout << "\\hline" << endl;
2962    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
2963 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
2963 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
2964    tout << "\\end{tabular}" << endl;
2965    tout << "\\end{center}" << endl;
2966    tout << "\\end{table}" << endl;
# Line 2927 | Line 3283 | void qcd_plots(string datajzb, string mc
3283    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3284    string ytitle("ratio");
3285    if ( use_data==1 ) ytitle = "data/pred";
3286 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
3286 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
3287    
3288    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
3289    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 3127 | Line 3483 | void test() {
3483    
3484    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
3485    testcanv->cd();
3486 <  switch_overunderflow(true);
3486 > //  switch_overunderflow(true);
3487    TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
3488    switch_overunderflow(false);
3489    ptdistr->Draw();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines