18 |
|
#include <TSystem.h> |
19 |
|
#include <TRandom3.h> |
20 |
|
|
21 |
– |
//#include "TTbar_stuff.C" |
21 |
|
using namespace std; |
22 |
|
|
23 |
|
using namespace PlottingSetup; |
37 |
|
return flipped_name.c_str(); |
38 |
|
} |
39 |
|
|
40 |
< |
void prepare_limit_datacard(string RunDirectory, TFile *f, float uJSU, float uPDF, int flipped) { |
41 |
< |
TH1F *dataob; |
42 |
< |
if(flipped) dataob = (TH1F*)f->Get("flipped_data_obs"); |
43 |
< |
else dataob = (TH1F*)f->Get("data_obs"); |
44 |
< |
TH1F *signal; |
45 |
< |
|
46 |
< |
if(flipped) signal = (TH1F*)f->Get("flipped_signal"); |
47 |
< |
else signal = (TH1F*)f->Get("signal"); |
48 |
< |
|
49 |
< |
TH1F *background1; |
50 |
< |
if(flipped) background1 = (TH1F*)f->Get("flipped_TTbarBackground"); |
51 |
< |
else background1 = (TH1F*)f->Get("TTbarBackground"); |
52 |
< |
|
53 |
< |
TH1F *background2; |
54 |
< |
if(flipped) background2 = (TH1F*)f->Get("flipped_ZJetsBackground"); |
55 |
< |
else background2 = (TH1F*)f->Get("ZJetsBackground"); |
56 |
< |
|
57 |
< |
assert(dataob); |
58 |
< |
assert(signal); |
59 |
< |
assert(background1); |
60 |
< |
assert(background2); |
40 |
> |
void EliminateNegativeEntries(TH1F *histo) { |
41 |
> |
for(int i=1;i<=histo->GetNbinsX();i++) { |
42 |
> |
if(histo->GetBinContent(i)<0) histo->SetBinContent(i,0); |
43 |
> |
} |
44 |
> |
} |
45 |
> |
|
46 |
> |
vector<float> get_expected_points(float observed,int npoints, string RunDirectory, bool doPlot=false) { |
47 |
> |
TF1 *gaus = new TF1("gaus","gaus(0)",0,10*observed); |
48 |
> |
gaus->SetParameters(1,observed,2*observed); |
49 |
> |
gaus->SetParameter(0,1/(gaus->Integral(0,10*observed))); |
50 |
> |
float currentpoint=0.01; |
51 |
> |
float stepsize=observed/100; |
52 |
> |
vector<float> points; |
53 |
> |
while(currentpoint<25*observed && points.size()<npoints) { |
54 |
> |
|
55 |
> |
if(gaus->Integral(0,currentpoint)>((points.size()+1.0)/(npoints+2.0))) { |
56 |
> |
if(Verbosity>0) dout << "Added points for calculation at " << currentpoint << " (integral is " << gaus->Integral(0,currentpoint) << ")" << endl; |
57 |
> |
points.push_back(currentpoint); |
58 |
> |
if(points.size()==npoints) break; |
59 |
> |
} |
60 |
> |
currentpoint+=stepsize; |
61 |
> |
} |
62 |
> |
if(doPlot) { |
63 |
> |
gaus->SetName("Expected limit computation points"); |
64 |
> |
gaus->SetTitle("Expected limit computation points"); |
65 |
> |
TCanvas *can = new TCanvas("can","can"); |
66 |
> |
gaus->Draw(); |
67 |
> |
TLine *lines[npoints]; |
68 |
> |
for(int i=0;i<npoints;i++) { |
69 |
> |
lines[i] = new TLine(points[i],0,points[i],gaus->GetMaximum()); |
70 |
> |
lines[i]->SetLineColor(kBlue); |
71 |
> |
lines[i]->Draw(); |
72 |
> |
} |
73 |
> |
can->SaveAs((RunDirectory+"/DistributionOfComputedPoints.png").c_str()); |
74 |
> |
delete can; |
75 |
> |
for(int i=0;i<npoints;i++) delete lines[i]; |
76 |
> |
} |
77 |
> |
delete gaus; |
78 |
> |
|
79 |
> |
return points; |
80 |
> |
} |
81 |
> |
|
82 |
> |
void prepare_MC_datacard(string RunDirectory, TFile *f, float uJSU, float uPDF) { |
83 |
> |
TH1F *dataob = (TH1F*)f->Get("data_obs"); |
84 |
> |
TH1F *signal = (TH1F*)f->Get("signal"); |
85 |
> |
assert(dataob); |
86 |
> |
assert(signal); |
87 |
> |
|
88 |
> |
write_warning(__FUNCTION__,"The following two defs for th1's are fake");TH1F *Tbackground; TH1F *Zbackground; |
89 |
> |
write_warning(__FUNCTION__,"Not correctly implemented yet for MC"); |
90 |
> |
ofstream datacard; |
91 |
> |
write_warning(__FUNCTION__,"Need to rethink systematics we want to use !"); |
92 |
> |
datacard.open ((RunDirectory+"/susydatacard.txt").c_str()); |
93 |
> |
dout << "Writing this to a file.\n"; |
94 |
> |
datacard << "imax 1\n"; // number of channels |
95 |
> |
datacard << "jmax 2\n"; // number of backgrounds (Z+Jets prediction and TTbar prediction) |
96 |
> |
datacard << "kmax *\n"; // number of nuisance parameters (sources of systematic uncertainties) |
97 |
> |
datacard << "---------------\n"; |
98 |
> |
datacard << "shapes * * limitfile.root $PROCESS $PROCESS_$SYSTEMATIC\n"; |
99 |
> |
datacard << "---------------\n"; |
100 |
> |
datacard << "bin 1\n"; |
101 |
> |
datacard << "observation "<<dataob->Integral()<<"\n"; |
102 |
> |
datacard << "------------------------------\n"; |
103 |
> |
datacard << "bin 1 1 1\n"; |
104 |
> |
datacard << "process signal TTbarBackground ZJetsBackground\n"; |
105 |
> |
datacard << "process 0 1 2\n"; |
106 |
> |
datacard << "rate "<<signal->Integral()<<" "<<Tbackground->Integral()<<" "<<Zbackground->Integral()<<"\n"; |
107 |
> |
datacard << "--------------------------------\n"; |
108 |
> |
datacard << "lumi lnN " << 1+ PlottingSetup::lumiuncert << " - - luminosity uncertainty\n"; // only affects MC -> signal! |
109 |
> |
datacard << "Stat shape - 1 - statistical uncertainty (ttbar)\n"; |
110 |
> |
datacard << "Stat shape - - 1 statistical uncertainty (zjets)\n"; |
111 |
> |
datacard << "Sys shape - 1 - systematic uncertainty on ttbar\n"; |
112 |
> |
datacard << "Sys shape - - 1 systematic uncertainty on zjets\n"; |
113 |
> |
datacard << "Stat shape 1 - - statistical uncertainty (signal)\n"; |
114 |
> |
datacard << "JES shape 1 - - uncertainty on Jet Energy Scale\n"; |
115 |
> |
datacard << "JSU lnN " << 1+uJSU << " - - JZB Scale Uncertainty\n"; |
116 |
> |
if(uPDF>0) datacard << "PDF lnN " << 1+uPDF << " - - uncertainty from PDFs\n"; |
117 |
> |
datacard.close(); |
118 |
> |
} |
119 |
> |
|
120 |
> |
void prepare_datadriven_datacard(string RunDirectory, TFile *f, float uJSU, float uPDF) { |
121 |
> |
TH1F *dataob = (TH1F*)f->Get("data_obs"); |
122 |
> |
TH1F *signal = (TH1F*)f->Get("signal"); |
123 |
> |
TH1F *Tbackground = (TH1F*)f->Get("TTbarBackground"); |
124 |
> |
TH1F *Zbackground = (TH1F*)f->Get("ZJetsBackground"); |
125 |
> |
|
126 |
> |
assert(dataob); |
127 |
> |
assert(signal); |
128 |
> |
assert(Tbackground); |
129 |
> |
assert(Zbackground); |
130 |
|
|
131 |
< |
ofstream datacard; |
132 |
< |
write_warning(__FUNCTION__,"Need to rethink systematics we want to use !"); |
133 |
< |
datacard.open ((RunDirectory+"/susydatacard.txt").c_str()); |
134 |
< |
datacard << "Writing this to a file.\n"; |
135 |
< |
datacard << "imax 1\n"; // number of channels |
136 |
< |
datacard << "jmax 2\n"; // number of backgrounds (Z+Jets prediction and TTbar prediction) |
137 |
< |
datacard << "kmax *\n"; // number of nuisance parameters (sources of systematic uncertainties) |
138 |
< |
datacard << "---------------\n"; |
139 |
< |
datacard << "shapes * * limitfile.root $PROCESS $PROCESS_$SYSTEMATIC\n"; |
140 |
< |
datacard << "---------------\n"; |
141 |
< |
datacard << "bin 1\n"; |
142 |
< |
datacard << "observation "<<dataob->Integral()<<"\n"; |
143 |
< |
datacard << "------------------------------\n"; |
144 |
< |
datacard << "bin 1 1 1\n"; |
145 |
< |
datacard << "process signal TTbarBackground ZJetsBackground\n"; |
146 |
< |
datacard << "process 0 1 2\n"; |
147 |
< |
datacard << "rate "<<signal->Integral()<<" "<<background1->Integral()<<" "<<background2->Integral()<<"\n"; |
148 |
< |
datacard << "--------------------------------\n"; |
149 |
< |
datacard << "lumi lnN " << 1+ PlottingSetup::lumiuncert << " - - luminosity uncertainty\n"; // only affects MC -> signal! |
150 |
< |
datacard << "Stat shape - 1 - statistical uncertainty (ttbar)\n"; |
151 |
< |
datacard << "Stat shape - - 1 statistical uncertainty (zjets)\n"; |
152 |
< |
datacard << "Sys shape - 1 - systematic uncertainty on ttbar\n"; |
153 |
< |
datacard << "Sys shape - - 1 systematic uncertainty on zjets\n"; |
154 |
< |
datacard << "Stat shape 1 - - statistical uncertainty (signal)\n"; |
155 |
< |
datacard << "JES shape 1 - - uncertainty on Jet Energy Scale\n"; |
156 |
< |
datacard << "JSU lnN " << 1+uJSU << " - - JZB Scale Uncertainty\n"; |
157 |
< |
if(uPDF>0) datacard << "PDF lnN " << 1+uPDF << " - - uncertainty from PDFs\n"; |
131 |
> |
|
132 |
> |
ofstream datacard; |
133 |
> |
write_warning(__FUNCTION__,"Need to rethink systematics we want to use !"); |
134 |
> |
datacard.open ((RunDirectory+"/susydatacard.txt").c_str()); |
135 |
> |
datacard << "Writing this to a file.\n"; |
136 |
> |
datacard << "imax " << dataob->GetNbinsX() << "\n"; // number of channels |
137 |
> |
datacard << "jmax 2\n"; // number of backgrounds (Z+Jets prediction and TTbar prediction) |
138 |
> |
datacard << "kmax *\n"; // number of nuisance parameters (sources of systematic uncertainties) |
139 |
> |
datacard << "---------------\n"; |
140 |
> |
datacard << "bin\t"; |
141 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << " " << dataob->GetBinLowEdge(i) << "to" << dataob->GetBinLowEdge(i)+dataob->GetBinWidth(i) << " \t"; |
142 |
> |
datacard << "\n"; |
143 |
> |
datacard << "observation\t"; |
144 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << " " << dataob->GetBinContent(i) << " \t"; |
145 |
> |
datacard<<"\n"; |
146 |
> |
datacard << "------------------------------\n"; |
147 |
> |
datacard << "bin\t"; |
148 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) { |
149 |
> |
datacard << " " << dataob->GetBinLowEdge(i) << "to" << dataob->GetBinLowEdge(i)+dataob->GetBinWidth(i) << "\t" << |
150 |
> |
" " << dataob->GetBinLowEdge(i) << "to" << dataob->GetBinLowEdge(i)+dataob->GetBinWidth(i) << "\t" << |
151 |
> |
" " << dataob->GetBinLowEdge(i) << "to" << dataob->GetBinLowEdge(i)+dataob->GetBinWidth(i) << "\t"; |
152 |
> |
} |
153 |
> |
datacard << "\n"; |
154 |
> |
datacard << "process\t"; |
155 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << "\t signal \t TTbarBackground \t ZJetsBackground"; |
156 |
> |
datacard << "\n"; |
157 |
> |
datacard << "process\t"; |
158 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << "\t 0 \t 1 \t 2"; |
159 |
> |
datacard << "\n"; |
160 |
> |
|
161 |
> |
|
162 |
> |
datacard << "rate\t"; |
163 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << "\t " << signal->GetBinContent(i) << " \t " << Tbackground->GetBinContent(i) << " \t " << Zbackground->GetBinContent(i) << "\t"; |
164 |
> |
datacard<<"\n"; |
165 |
> |
|
166 |
> |
datacard << "--------------------------------\n"; |
167 |
> |
|
168 |
> |
|
169 |
> |
datacard << "lumi lnN \t"; |
170 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << " " << 1+ PlottingSetup::lumiuncert << "\t - \t -"; |
171 |
> |
datacard << " luminosity uncertainty\n"; // only affects MC -> signal! |
172 |
> |
|
173 |
> |
// Statistical uncertainty |
174 |
> |
datacard << "Stat lnN \t"; |
175 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) { |
176 |
> |
//Signal |
177 |
> |
float central = signal->GetBinContent(i); |
178 |
> |
float up = ((TH1F*)f->Get("signal_StatDown"))->GetBinContent(i); |
179 |
> |
float down = ((TH1F*)f->Get("signal_StatUp"))->GetBinContent(i); |
180 |
> |
float suncert=0; |
181 |
> |
if(central>0) { |
182 |
> |
if(abs(up-central)>abs(down-central)) suncert=abs(up-central)/central; |
183 |
> |
else suncert=abs(central-down)/central; |
184 |
> |
} |
185 |
> |
|
186 |
> |
//TTbar |
187 |
> |
central = Tbackground->GetBinContent(i); |
188 |
> |
up = ((TH1F*)f->Get("TTbarBackground_StatUp"))->GetBinContent(i); |
189 |
> |
down = ((TH1F*)f->Get("TTbarBackground_StatDown"))->GetBinContent(i); |
190 |
> |
float tuncert=0; |
191 |
> |
if(central>0) { |
192 |
> |
if(abs(up-central)>abs(down-central)) tuncert=abs(up-central)/central; |
193 |
> |
else tuncert=abs(central-down)/central; |
194 |
> |
} |
195 |
> |
//ZJets |
196 |
> |
central = Zbackground->GetBinContent(i); |
197 |
> |
up = ((TH1F*)f->Get("ZJetsBackground_StatUp"))->GetBinContent(i); |
198 |
> |
down = ((TH1F*)f->Get("ZJetsBackground_StatDown"))->GetBinContent(i); |
199 |
> |
float zuncert=0; |
200 |
> |
if(central>0) { |
201 |
> |
if(abs(up-central)>abs(down-central)) zuncert=abs(up-central)/central; |
202 |
> |
else zuncert=abs(central-down)/central; |
203 |
> |
} |
204 |
> |
datacard << " " << 1+suncert << " \t " << 1+tuncert << "\t " << 1+zuncert << " \t "; |
205 |
> |
} |
206 |
> |
|
207 |
> |
datacard << " statistical uncertainty\n"; |
208 |
> |
|
209 |
> |
// Statistical uncertainty |
210 |
> |
datacard << "Sys lnN \t"; |
211 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) { |
212 |
> |
float central = Tbackground->GetBinContent(i); |
213 |
> |
float up = ((TH1F*)f->Get("TTbarBackground_SysUp"))->GetBinContent(i); |
214 |
> |
float down = ((TH1F*)f->Get("TTbarBackground_SysDown"))->GetBinContent(i); |
215 |
> |
float tuncert=0; |
216 |
> |
if(central>0) { |
217 |
> |
if(abs(up-central)>abs(down-central)) tuncert=abs(up-central)/central; |
218 |
> |
else tuncert=abs(central-down)/central; |
219 |
> |
} |
220 |
> |
central = Zbackground->GetBinContent(i); |
221 |
> |
up = ((TH1F*)f->Get("ZJetsBackground_SysUp"))->GetBinContent(i); |
222 |
> |
down = ((TH1F*)f->Get("ZJetsBackground_SysDown"))->GetBinContent(i); |
223 |
> |
float zuncert=0; |
224 |
> |
if(central>0) { |
225 |
> |
if(abs(up-central)>abs(down-central)) zuncert=abs(up-central)/central; |
226 |
> |
else zuncert=abs(central-down)/central; |
227 |
> |
} |
228 |
> |
datacard << " - \t " << 1+tuncert << "\t " << 1+zuncert << " \t "; |
229 |
> |
} |
230 |
> |
|
231 |
> |
datacard << " systematic uncertainty\n"; |
232 |
> |
|
233 |
> |
|
234 |
> |
float JESup = ((TH1F*)f->Get("signal_JESUp"))->Integral(); |
235 |
> |
float JESdn = ((TH1F*)f->Get("signal_JESDown"))->Integral(); |
236 |
> |
float central = signal->Integral(); |
237 |
> |
float uJES=0; |
238 |
> |
if(abs(JESup-central)>abs(JESdn-central)) uJES=abs(JESup-central)/central; |
239 |
> |
else uJES=abs(central-JESdn)/central; |
240 |
> |
datacard << "JES lnN"; |
241 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << " " << 1+uJES << "\t - \t - \t"; |
242 |
> |
datacard << "uncertainty on Jet Energy Scale\n"; |
243 |
> |
|
244 |
> |
datacard << "JSU lnN "; |
245 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << " " << 1+uJSU << "\t - \t - \t"; |
246 |
> |
datacard << "JZB Scale Uncertainty\n"; |
247 |
> |
|
248 |
> |
if(uPDF>0) { |
249 |
> |
datacard << "PDF lnN "; |
250 |
> |
for(int i=1;i<=dataob->GetNbinsX();i++) datacard << " " << 1+uPDF << "\t - \t - \t"; |
251 |
> |
datacard << "uncertainty from PDFs\n"; |
252 |
> |
} |
253 |
> |
|
254 |
> |
datacard.close(); |
255 |
> |
} |
256 |
> |
|
257 |
> |
void prepare_limit_datacard(string RunDirectory, TFile *f, float uJSU, float uPDF) { |
258 |
|
|
259 |
< |
// datacard << "peak shape 1 1 uncertainty on signal resolution. |
260 |
< |
datacard.close(); |
259 |
> |
if(FullMCAnalysis) { |
260 |
> |
//dealing with MC analysis - need to use shapes. |
261 |
> |
prepare_MC_datacard(RunDirectory,f,uJSU,uPDF); |
262 |
> |
} else { |
263 |
> |
//doing mutibin analysis |
264 |
> |
prepare_datadriven_datacard(RunDirectory,f,uJSU,uPDF); |
265 |
> |
} |
266 |
> |
|
267 |
|
} |
268 |
|
|
269 |
|
float QuickDrawNevents=0; |
296 |
|
return histo; |
297 |
|
} |
298 |
|
|
299 |
< |
/*void do_stat_up(TH1F *h, float sign=1.0) { |
300 |
< |
for(int i=1;i<=h->GetNbinsX();i++) { |
301 |
< |
h->SetBinContent(i,h->GetBinContent(i)+sign*h->GetBinError(i)); |
128 |
< |
} |
129 |
< |
h->Write(); |
299 |
> |
TH2F* empty2d(string hname) { |
300 |
> |
TH2F *h = new TH2F(hname.c_str(),hname.c_str(),1000,0,1000,1000,0,1000); |
301 |
> |
return h; |
302 |
|
} |
303 |
|
|
304 |
< |
void do_stat_dn(TH1F *h) { |
305 |
< |
do_stat_up(h,-1.0); |
306 |
< |
}*/ |
307 |
< |
|
308 |
< |
void SQRT(TH1F *h) { |
309 |
< |
for (int i=1;i<=h->GetNbinsX();i++) { |
310 |
< |
h->SetBinContent(i,TMath::Sqrt(h->GetBinContent(i))); |
311 |
< |
} |
304 |
> |
TH2F* QuickDraw2d(TTree *events, string hname, string variable, string xlabel, string ylabel, TCut cut, string addcut, bool dataormc, float luminosity, map < pair<float, float>, map<string, float> > &xsec) { |
305 |
> |
TH2F *histo = empty2d(hname); |
306 |
> |
histo->Sumw2(); |
307 |
> |
stringstream drawcommand; |
308 |
> |
drawcommand << variable << ":mll>>" << hname; |
309 |
> |
if(SUSYScanSpace::SUSYscantype!=mSUGRA) { |
310 |
> |
events->Draw(drawcommand.str().c_str(),(essentialcut&&cut&&addcut.c_str())*cutWeight); |
311 |
> |
} else { |
312 |
> |
float totalxs=0; |
313 |
> |
for(int i=0;i<12;i++) { |
314 |
> |
stringstream drawcommand2; |
315 |
> |
drawcommand2 << variable << ">>+" << hname; |
316 |
> |
stringstream mSUGRAweight; |
317 |
> |
float xs = XSForProcessViaAddCutWrapper(addcut,xsec,i); |
318 |
> |
totalxs+=xs; |
319 |
> |
mSUGRAweight << "(0.5*(2*(process==" << i << "))*" << xs << ")"; |
320 |
> |
events->Draw(drawcommand2.str().c_str(),(essentialcut&&cut&&addcut.c_str())*cutWeight*mSUGRAweight.str().c_str()); |
321 |
> |
} |
322 |
> |
histo->Scale(1.0/totalxs); // to get back to 1 /pb normalization |
323 |
> |
} |
324 |
> |
events->Draw("eventNum",addcut.c_str(),"goff"); |
325 |
> |
float nevents = events->GetSelectedRows(); |
326 |
> |
QuickDrawNevents=nevents; |
327 |
> |
histo->Scale(luminosity/nevents); // this will give a histogram which is normalized to 1 pb so that any limit will be with respect to 1 pb |
328 |
> |
|
329 |
> |
return histo; |
330 |
|
} |
331 |
|
|
332 |
|
TH1F* Multiply(TH1F *h1, TH1F *h2) { |
337 |
|
return h; |
338 |
|
} |
339 |
|
|
340 |
+ |
|
341 |
+ |
string ReduceNumericHistoName(string origname) { |
342 |
+ |
int pos = origname.find("__h_"); |
343 |
+ |
if(pos == -1) return origname; |
344 |
+ |
return origname.substr(0,pos); |
345 |
+ |
} |
346 |
+ |
|
347 |
+ |
|
348 |
+ |
|
349 |
+ |
void generate_mc_shapes(bool dotree, TTree *signalevents, string mcjzb,string datajzb,vector<float> binning, TCut weight, TCut JetCut, string addcut, string identifier, map < pair<float, float>, map<string, float> > &xsec) { |
350 |
+ |
//weight can be varied to take care of efficiency errors (weightEffUp, weightEffDown) |
351 |
+ |
vector<float> mbinning; |
352 |
+ |
mbinning.push_back(-8000); |
353 |
+ |
for(int i=binning.size()-1;i>=0;i--) mbinning.push_back(-binning[i]); |
354 |
+ |
mbinning.push_back(0); |
355 |
+ |
for(int i=0;i<binning.size();i++) mbinning.push_back(binning[i]); |
356 |
+ |
mbinning.push_back(8000); |
357 |
+ |
|
358 |
+ |
|
359 |
+ |
TCanvas *shapecan = new TCanvas("shapecan","shapecan"); |
360 |
+ |
TH1F* Signal; |
361 |
+ |
|
362 |
+ |
stringstream sInverseCutWeight; |
363 |
+ |
sInverseCutWeight << "(1.0/" << (const char*)cutWeight<<")"; |
364 |
+ |
TCut InverseCutWeight(sInverseCutWeight.str().c_str()); |
365 |
+ |
if(weight==cutWeight) InverseCutWeight = TCut("1.0"); |
366 |
+ |
if(!dotree) { |
367 |
+ |
//dealing with ALL MC samples (when we save the standard file) |
368 |
+ |
THStack McPredicted = allsamples.DrawStack("McPred",mcjzb,mbinning, "JZB [GeV]", "events", ((cutmass&&cutOSSF&&JetCut)*(weight*InverseCutWeight)),mc,luminosity); |
369 |
+ |
int nhists = McPredicted.GetHists()->GetEntries(); |
370 |
+ |
for (int i = 0; i < nhists; i++) { |
371 |
+ |
TH1* hist = static_cast<TH1*>(McPredicted.GetHists()->At(i)); |
372 |
+ |
// cout << hist->GetName() << " : " << hist->Integral() << endl; |
373 |
+ |
// cout << " " << ReduceNumericHistoName(hist->GetName()) << endl; |
374 |
+ |
if(identifier=="StatUp") { |
375 |
+ |
float appliedweight = hist->Integral() / hist->GetEntries(); |
376 |
+ |
for(int ibin=1;ibin<=hist->GetNbinsX();ibin++) hist->SetBinContent(ibin,hist->GetBinContent(ibin)+appliedweight*TMath::Sqrt(hist->GetBinContent(ibin)/appliedweight)); |
377 |
+ |
} |
378 |
+ |
if(identifier=="StatDown") { |
379 |
+ |
float appliedweight = hist->Integral() / hist->GetEntries(); |
380 |
+ |
for(int ibin=1;ibin<=hist->GetNbinsX();ibin++) hist->SetBinContent(ibin,hist->GetBinContent(ibin)-appliedweight*TMath::Sqrt(hist->GetBinContent(ibin)/appliedweight)); |
381 |
+ |
} |
382 |
+ |
hist->SetName(("mc_"+ReduceNumericHistoName(hist->GetName())+"_"+identifier).c_str()); |
383 |
+ |
hist->Write(); |
384 |
+ |
} |
385 |
+ |
} else { |
386 |
+ |
string histoname="mc_signal"; |
387 |
+ |
if(identifier!="") histoname=histoname+"_"+identifier; |
388 |
+ |
Signal = QuickDraw(signalevents,histoname,mcjzb,binning,"JZB", "events",((cutmass&&cutOSSF&&JetCut&&basiccut))*(weight*InverseCutWeight),addcut,mc,luminosity,xsec); |
389 |
+ |
if(identifier=="StatUp") { |
390 |
+ |
float appliedweight = Signal->Integral() / Signal->GetEntries(); |
391 |
+ |
for(int ibin=1;ibin<=Signal->GetNbinsX();ibin++) Signal->SetBinContent(ibin,Signal->GetBinContent(ibin)+appliedweight*TMath::Sqrt(Signal->GetBinContent(ibin)/appliedweight)); |
392 |
+ |
} |
393 |
+ |
if(identifier=="StatDown") { |
394 |
+ |
float appliedweight = Signal->Integral() / Signal->GetEntries(); |
395 |
+ |
for(int ibin=1;ibin<=Signal->GetNbinsX();ibin++) Signal->SetBinContent(ibin,Signal->GetBinContent(ibin)-appliedweight*TMath::Sqrt(Signal->GetBinContent(ibin)/appliedweight)); |
396 |
+ |
} |
397 |
+ |
Signal->Write(); |
398 |
+ |
} |
399 |
+ |
|
400 |
+ |
/* |
401 |
+ |
* |
402 |
+ |
* Jet energy scale (easy, use different JetCut) |
403 |
+ |
* JZB Scale Uncertainty (will be a number - signal only) |
404 |
+ |
* Efficiency (will be weightEffUp, weightEffDown) |
405 |
+ |
* PDFs (signal only) -> Will be a number yet again, computed in the traditional way |
406 |
+ |
*/ |
407 |
+ |
delete shapecan; |
408 |
+ |
|
409 |
+ |
} |
410 |
+ |
|
411 |
+ |
|
412 |
|
void generate_shapes_for_systematic(bool signalonly, bool dataonly,TFile *limfile, TTree *signalevents, string identifier, string mcjzb, string datajzb, int JES,vector<float> binning, TCanvas *limcan, string addcut, map < pair<float, float>, map<string, float> > &xsec) { |
413 |
|
|
414 |
|
binning.push_back(8000); |
438 |
|
} |
439 |
|
|
440 |
|
if(signalonly) { |
441 |
< |
cout << "Processing a signal with mcjzb: " << mcjzb << " (identifier: " << identifier << ")" << endl; |
441 |
> |
dout << "Processing a signal with mcjzb: " << mcjzb << " (identifier: '" << identifier << "')" << endl; |
442 |
|
TH1F *ZOSSFP = QuickDraw(signalevents,"ZOSSFP",mcjzb,binning, "JZB", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
181 |
– |
TH1F *ZOSOFP = QuickDraw(signalevents,"ZOSOFP",mcjzb,binning, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
443 |
|
TH1F *ZOSSFN = QuickDraw(signalevents,"ZOSSFN","-"+mcjzb,binning, "JZB", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
444 |
< |
TH1F *ZOSOFN = QuickDraw(signalevents,"ZOSOFN","-"+mcjzb,binning, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
444 |
> |
TH1F *ZOSOFP; |
445 |
> |
TH1F *ZOSOFN; |
446 |
> |
|
447 |
> |
TH2F *ZOSSFP2d = QuickDraw2d(signalevents,"ZOSSFP2d",mcjzb, "JZB", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
448 |
> |
TH2F *ZOSSFN2d = QuickDraw2d(signalevents,"ZOSSFN2d","-"+mcjzb,"JZB", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
449 |
> |
TH2F *ZOSOFP2d; |
450 |
> |
TH2F *ZOSOFN2d; |
451 |
> |
|
452 |
> |
if(!PlottingSetup::FullMCAnalysis) { |
453 |
> |
ZOSOFP = QuickDraw(signalevents,"ZOSOFP",mcjzb,binning, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
454 |
> |
ZOSOFN = QuickDraw(signalevents,"ZOSOFN","-"+mcjzb,binning, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
455 |
> |
|
456 |
> |
ZOSOFP2d = QuickDraw2d(signalevents,"ZOSOFP2d",mcjzb, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
457 |
> |
ZOSOFN2d = QuickDraw2d(signalevents,"ZOSOFN2d","-"+mcjzb, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,addcut,mc,luminosity,xsec); |
458 |
> |
} |
459 |
|
|
460 |
|
TH1F *SBOSSFP; |
461 |
|
TH1F *SBOSOFP; |
462 |
|
TH1F *SBOSSFN; |
463 |
|
TH1F *SBOSOFN; |
464 |
|
|
465 |
< |
if(PlottingSetup::RestrictToMassPeak) { |
465 |
> |
TH2F *SBOSSFP2d; |
466 |
> |
TH2F *SBOSOFP2d; |
467 |
> |
TH2F *SBOSSFN2d; |
468 |
> |
TH2F *SBOSOFN2d; |
469 |
> |
|
470 |
> |
if(PlottingSetup::RestrictToMassPeak&&!PlottingSetup::FullMCAnalysis) { |
471 |
|
SBOSSFP = QuickDraw(signalevents,"SBOSSFP",mcjzb,binning, "JZB", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
472 |
|
SBOSOFP = QuickDraw(signalevents,"SBOSOFP",mcjzb,binning, "JZB", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
473 |
|
SBOSSFN = QuickDraw(signalevents,"SBOSSFN","-"+mcjzb,binning, "JZB", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
474 |
|
SBOSOFN = QuickDraw(signalevents,"SBOSOFN","-"+mcjzb,binning, "JZB", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
475 |
+ |
|
476 |
+ |
SBOSSFP2d = QuickDraw2d(signalevents,"SBOSSFP2d",mcjzb,"JZB", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
477 |
+ |
SBOSOFP2d = QuickDraw2d(signalevents,"SBOSOFP2d",mcjzb,"JZB", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
478 |
+ |
SBOSSFN2d = QuickDraw2d(signalevents,"SBOSSFN2d","-"+mcjzb,"JZB", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
479 |
+ |
SBOSOFN2d = QuickDraw2d(signalevents,"SBOSOFN2d","-"+mcjzb,"JZB", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,addcut,mc,luminosity,xsec); |
480 |
|
} |
481 |
|
|
482 |
|
string signalname="signal"; |
483 |
< |
if(identifier!="") { |
199 |
< |
signalname="signal_"+identifier; |
200 |
< |
} |
483 |
> |
if(identifier!="") signalname="signal_"+identifier; |
484 |
|
|
485 |
|
TH1F *Lobs = new TH1F("Lobs","Lobs",binning.size()-1,&binning[0]); |
486 |
|
TH1F *Lpred = new TH1F("Lpred","Lpred",binning.size()-1,&binning[0]); |
487 |
|
|
488 |
+ |
TH2F *Lobs2d = empty2d("Lobs2d"); |
489 |
+ |
TH2F *Lpred2d = empty2d("Lobs2d"); |
490 |
+ |
|
491 |
|
TH1F *flippedLobs = new TH1F("flippedLobs","flippedLobs",binning.size()-1,&binning[0]); |
492 |
|
TH1F *flippedLpred = new TH1F("flippedLpred","flippedLpred",binning.size()-1,&binning[0]); |
493 |
|
|
494 |
+ |
TH2F *flippedLobs2d = empty2d("flippedLobs2d"); |
495 |
+ |
TH2F *flippedLpred2d = empty2d("flippedLpred2d"); |
496 |
+ |
|
497 |
|
Lobs->Add(ZOSSFP); |
498 |
< |
Lpred->Add(ZOSSFN); |
498 |
> |
Lobs2d->Add(ZOSSFP2d); |
499 |
> |
if(!PlottingSetup::FullMCAnalysis) { |
500 |
> |
Lpred->Add(ZOSSFN); |
501 |
> |
Lpred2d->Add(ZOSSFN2d); |
502 |
> |
} |
503 |
|
|
504 |
< |
cout << "SITUATION FOR SIGNAL: " << endl; |
505 |
< |
cout << " OSSF JZB> 0 : " << ZOSSFP->Integral() << " JZB < 0 :" << ZOSSFN->Integral() << endl; |
506 |
< |
cout << " OSOF JZB> 0 : " << ZOSOFP->Integral() << " JZB < 0 :" << ZOSOFN->Integral() << endl; |
507 |
< |
if(PlottingSetup::RestrictToMassPeak) { |
508 |
< |
cout << " OSSF SB JZB> 0 : " << SBOSSFP->Integral() << " JZB < 0 :" << SBOSSFN->Integral() << endl; |
509 |
< |
cout << " OSOF SB JZB> 0 : " << SBOSOFP->Integral() << " JZB < 0 :" << SBOSOFN->Integral() << endl; |
504 |
> |
dout << "SITUATION FOR SIGNAL: " << endl; |
505 |
> |
if(PlottingSetup::FullMCAnalysis) { |
506 |
> |
dout << " OSSF JZB> 0 : " << ZOSSFP->Integral() << endl; |
507 |
> |
} else { |
508 |
> |
dout << " OSSF JZB> 0 : " << ZOSSFP->Integral() << " JZB < 0 :" << ZOSSFN->Integral() << endl; |
509 |
> |
dout << " OSOF JZB> 0 : " << ZOSOFP->Integral() << " JZB < 0 :" << ZOSOFN->Integral() << endl; |
510 |
> |
|
511 |
> |
if(PlottingSetup::RestrictToMassPeak&&!PlottingSetup::FullMCAnalysis) { |
512 |
> |
dout << " OSSF SB JZB> 0 : " << SBOSSFP->Integral() << " JZB < 0 :" << SBOSSFN->Integral() << endl; |
513 |
> |
dout << " OSOF SB JZB> 0 : " << SBOSOFP->Integral() << " JZB < 0 :" << SBOSOFN->Integral() << endl; |
514 |
> |
} |
515 |
|
} |
218 |
– |
|
516 |
|
|
517 |
|
flippedLobs->Add(ZOSSFN); |
518 |
< |
flippedLpred->Add(ZOSSFP); |
518 |
> |
flippedLobs2d->Add(ZOSSFN2d); |
519 |
|
|
520 |
< |
if(PlottingSetup::RestrictToMassPeak) { |
521 |
< |
Lpred->Add(ZOSOFP,1.0/3); |
522 |
< |
Lpred->Add(ZOSOFN,-1.0/3); |
523 |
< |
Lpred->Add(SBOSSFP,1.0/3); |
524 |
< |
Lpred->Add(SBOSSFN,-1.0/3); |
525 |
< |
Lpred->Add(SBOSOFP,1.0/3); |
526 |
< |
Lpred->Add(SBOSOFN,-1.0/3); |
527 |
< |
|
528 |
< |
//flipped prediction |
529 |
< |
flippedLpred->Add(ZOSOFP,-1.0/3); |
530 |
< |
flippedLpred->Add(ZOSOFN,1.0/3); |
531 |
< |
flippedLpred->Add(SBOSSFP,-1.0/3); |
532 |
< |
flippedLpred->Add(SBOSSFN,1.0/3); |
533 |
< |
flippedLpred->Add(SBOSOFP,-1.0/3); |
534 |
< |
flippedLpred->Add(SBOSOFN,1.0/3); |
535 |
< |
|
536 |
< |
} else { |
537 |
< |
Lpred->Add(ZOSOFP,1.0); |
538 |
< |
Lpred->Add(ZOSOFN,-1.0); |
539 |
< |
|
540 |
< |
//flipped prediction |
541 |
< |
flippedLpred->Add(ZOSOFP,-1.0); |
542 |
< |
flippedLpred->Add(ZOSOFN,1.0); |
520 |
> |
if(!PlottingSetup::FullMCAnalysis) { |
521 |
> |
flippedLpred->Add(ZOSSFP); |
522 |
> |
flippedLpred2d->Add(ZOSSFP2d); |
523 |
> |
} |
524 |
> |
|
525 |
> |
if(!PlottingSetup::FullMCAnalysis) { |
526 |
> |
if(PlottingSetup::RestrictToMassPeak) { |
527 |
> |
Lpred->Add(ZOSOFP,1.0/3); |
528 |
> |
Lpred->Add(ZOSOFN,-1.0/3); |
529 |
> |
Lpred->Add(SBOSSFP,1.0/3); |
530 |
> |
Lpred->Add(SBOSSFN,-1.0/3); |
531 |
> |
Lpred->Add(SBOSOFP,1.0/3); |
532 |
> |
Lpred->Add(SBOSOFN,-1.0/3); |
533 |
> |
|
534 |
> |
//flipped prediction |
535 |
> |
flippedLpred->Add(ZOSOFP,-1.0/3); |
536 |
> |
flippedLpred->Add(ZOSOFN,1.0/3); |
537 |
> |
flippedLpred->Add(SBOSSFP,-1.0/3); |
538 |
> |
flippedLpred->Add(SBOSSFN,1.0/3); |
539 |
> |
flippedLpred->Add(SBOSOFP,-1.0/3); |
540 |
> |
flippedLpred->Add(SBOSOFN,1.0/3); |
541 |
> |
|
542 |
> |
//2d stuff: regular |
543 |
> |
Lpred2d->Add(ZOSOFP2d,1.0/3); |
544 |
> |
Lpred2d->Add(ZOSOFN2d,-1.0/3); |
545 |
> |
Lpred2d->Add(SBOSSFP2d,1.0/3); |
546 |
> |
Lpred2d->Add(SBOSSFN2d,-1.0/3); |
547 |
> |
Lpred2d->Add(SBOSOFP2d,1.0/3); |
548 |
> |
Lpred2d->Add(SBOSOFN2d,-1.0/3); |
549 |
> |
|
550 |
> |
//3d stuff: flipped prediction |
551 |
> |
flippedLpred2d->Add(ZOSOFP2d,-1.0/3); |
552 |
> |
flippedLpred2d->Add(ZOSOFN2d,1.0/3); |
553 |
> |
flippedLpred2d->Add(SBOSSFP2d,-1.0/3); |
554 |
> |
flippedLpred2d->Add(SBOSSFN2d,1.0/3); |
555 |
> |
flippedLpred2d->Add(SBOSOFP2d,-1.0/3); |
556 |
> |
flippedLpred2d->Add(SBOSOFN2d,1.0/3); |
557 |
> |
} else { |
558 |
> |
Lpred->Add(ZOSOFP,1.0); |
559 |
> |
Lpred->Add(ZOSOFN,-1.0); |
560 |
> |
|
561 |
> |
//flipped prediction |
562 |
> |
flippedLpred->Add(ZOSOFP,-1.0); |
563 |
> |
flippedLpred->Add(ZOSOFN,1.0); |
564 |
> |
|
565 |
> |
//2d stuff |
566 |
> |
Lpred2d->Add(ZOSOFP2d,1.0); |
567 |
> |
Lpred2d->Add(ZOSOFN2d,-1.0); |
568 |
> |
|
569 |
> |
//flipped prediction |
570 |
> |
flippedLpred2d->Add(ZOSOFP2d,-1.0); |
571 |
> |
flippedLpred2d->Add(ZOSOFN2d,1.0); |
572 |
> |
} |
573 |
|
} |
574 |
|
|
575 |
|
TH1F *signal = (TH1F*)Lobs->Clone("signal"); |
576 |
< |
signal->Add(Lpred,-1); |
576 |
> |
TH1F *signal2d = (TH1F*)Lobs2d->Clone("signal2d"); |
577 |
> |
|
578 |
> |
if(!PlottingSetup::FullMCAnalysis) signal->Add(Lpred,-1); |
579 |
|
signal->SetName(signalname.c_str()); |
580 |
|
signal->SetTitle(signalname.c_str()); |
581 |
|
signal->Write(); |
582 |
|
|
583 |
+ |
if(!PlottingSetup::FullMCAnalysis) signal2d->Add(Lpred2d,-1); |
584 |
+ |
signal2d->SetName((signalname+"2d").c_str()); |
585 |
+ |
signal2d->SetTitle((signalname+"2d").c_str()); |
586 |
+ |
signal2d->Write(); |
587 |
+ |
|
588 |
|
TH1F *flippedsignal = (TH1F*)flippedLobs->Clone(); |
589 |
< |
flippedsignal->Add(flippedLpred,-1); |
589 |
> |
if(!PlottingSetup::FullMCAnalysis) flippedsignal->Add(flippedLpred,-1); |
590 |
|
flippedsignal->SetName(("flipped_"+signalname).c_str()); |
591 |
|
flippedsignal->Write(); |
592 |
|
|
593 |
+ |
TH2F *flippedsignal2d = (TH2F*)flippedLobs2d->Clone(); |
594 |
+ |
if(!PlottingSetup::FullMCAnalysis) flippedsignal2d->Add(flippedLpred,-1); |
595 |
+ |
flippedsignal2d->SetName(("flipped2d_"+signalname).c_str()); |
596 |
+ |
flippedsignal2d->Write(); |
597 |
+ |
|
598 |
|
if(identifier=="") { |
599 |
|
TH1F *signalStatUp = (TH1F*)signal->Clone(); |
600 |
|
signalStatUp->SetName(((string)signal->GetName()+"_StatUp").c_str()); |
604 |
|
signalStatDn->SetName(((string)signal->GetName()+"_StatDown").c_str()); |
605 |
|
signalStatDn->SetTitle(((string)signal->GetTitle()+"_StatDown").c_str()); |
606 |
|
|
607 |
+ |
TH2F *signalStatUp2d = (TH2F*)signal->Clone(); |
608 |
+ |
signalStatUp2d->SetName(((string)signal2d->GetName()+"_StatUp").c_str()); |
609 |
+ |
signalStatUp2d->SetTitle(((string)signal2d->GetTitle()+"_StatUp").c_str()); |
610 |
+ |
|
611 |
+ |
TH2F *signalStatDn2d = (TH2F*)signal->Clone(); |
612 |
+ |
signalStatDn2d->SetName(((string)signal2d->GetName()+"_StatDown").c_str()); |
613 |
+ |
signalStatDn2d->SetTitle(((string)signal2d->GetTitle()+"_StatDown").c_str()); |
614 |
+ |
|
615 |
+ |
|
616 |
|
for(int i=1;i<=signalStatDn->GetNbinsX();i++) { |
617 |
< |
float staterr = TMath::Sqrt(Lpred->GetBinContent(i) + Lobs->GetBinContent(i)); |
618 |
< |
cout << "Stat err in bin " << i << " : " << staterr << endl; |
619 |
< |
cout << " prediction: " << Lpred->GetBinContent(i) << " , observation: " << Lobs->GetBinContent(i) << " --> signal: " << signal->GetBinContent(i) << endl; |
620 |
< |
cout << " we obtain : " << signal->GetBinContent(i)-staterr << " , " << signal->GetBinContent(i)+staterr << endl; |
621 |
< |
signalStatDn->SetBinContent(i,signal->GetBinContent(i)-staterr); |
617 |
> |
float staterr; |
618 |
> |
if(!PlottingSetup::FullMCAnalysis) staterr = TMath::Sqrt(Lpred->GetBinContent(i) + Lobs->GetBinContent(i)); |
619 |
> |
else staterr = TMath::Sqrt(Lobs->GetBinContent(i)); |
620 |
> |
|
621 |
> |
if(!PlottingSetup::FullMCAnalysis) { |
622 |
> |
dout << "Stat err in bin " << i << " : " << staterr << endl; |
623 |
> |
dout << " prediction: " << Lpred->GetBinContent(i) << " , observation: " << Lobs->GetBinContent(i) << " --> signal: " << signal->GetBinContent(i) << endl; |
624 |
> |
dout << " we obtain : " << signal->GetBinContent(i)-staterr << " , " << signal->GetBinContent(i)+staterr << endl; |
625 |
> |
} |
626 |
> |
if(signal->GetBinContent(i)-staterr>0) signalStatDn->SetBinContent(i,signal->GetBinContent(i)-staterr); |
627 |
> |
else signalStatDn->SetBinContent(i,0); |
628 |
|
signalStatUp->SetBinContent(i,signal->GetBinContent(i)+staterr); |
629 |
|
signal->SetBinError(i,staterr); |
630 |
|
} |
631 |
|
|
632 |
+ |
for(int i=1;i<=signalStatDn->GetNbinsX();i++) { |
633 |
+ |
for(int j=1;j<=signalStatDn->GetNbinsY();j++) { |
634 |
+ |
float staterr; |
635 |
+ |
if(!PlottingSetup::FullMCAnalysis) staterr = TMath::Sqrt(Lpred2d->GetBinContent(i,j) + Lobs2d->GetBinContent(i,j)); |
636 |
+ |
else staterr = TMath::Sqrt(Lobs2d->GetBinContent(i,j)); |
637 |
+ |
|
638 |
+ |
if(!PlottingSetup::FullMCAnalysis) { |
639 |
+ |
dout << "Stat err in bin " << i << ", " << j << " : " << staterr << endl; |
640 |
+ |
dout << " prediction: " << Lpred2d->GetBinContent(i,j) << " , observation: " << Lobs2d->GetBinContent(i,j) << " --> signal: " << signal2d->GetBinContent(i,j) << endl; |
641 |
+ |
dout << " we obtain : " << signal2d->GetBinContent(i,j)-staterr << " , " << signal2d->GetBinContent(i,j)+staterr << endl; |
642 |
+ |
} |
643 |
+ |
if(signal2d->GetBinContent(i,j)-staterr>0) signalStatDn2d->SetBinContent(i,j,signal2d->GetBinContent(i,j)-staterr); |
644 |
+ |
else signalStatDn2d->SetBinContent(i,j,0); |
645 |
+ |
signalStatUp2d->SetBinContent(i,signal2d->GetBinContent(i,j)+staterr); |
646 |
+ |
signal2d->SetBinError(i,j,staterr); |
647 |
+ |
} |
648 |
+ |
} |
649 |
+ |
|
650 |
+ |
//----------------------------------- ******** GOTTEN HERE *******--------------------------------------- |
651 |
+ |
|
652 |
|
signalStatDn->Write(); |
653 |
|
signalStatUp->Write(); |
654 |
|
|
664 |
|
flippedsignalStatDn->SetTitle(((string)flippedsignal->GetTitle()+"_StatDown").c_str()); |
665 |
|
|
666 |
|
for(int i=1;i<=flippedsignalStatDn->GetNbinsX();i++) { |
667 |
< |
float staterr = TMath::Sqrt(flippedLpred->GetBinContent(i) + flippedLobs->GetBinContent(i)); |
668 |
< |
flippedsignalStatDn->SetBinContent(i,flippedsignal->GetBinContent(i)-staterr); |
667 |
> |
float staterr; |
668 |
> |
if(!PlottingSetup::FullMCAnalysis) staterr = TMath::Sqrt(flippedLpred->GetBinContent(i) + flippedLobs->GetBinContent(i)); |
669 |
> |
else staterr = TMath::Sqrt(flippedLobs->GetBinContent(i)); |
670 |
> |
if(flippedsignal->GetBinContent(i)-staterr>0) flippedsignalStatDn->SetBinContent(i,flippedsignal->GetBinContent(i)-staterr); |
671 |
> |
else flippedsignalStatDn->SetBinContent(i,0); |
672 |
|
flippedsignalStatUp->SetBinContent(i,flippedsignal->GetBinContent(i)+staterr); |
673 |
|
flippedsignal->SetBinError(i,staterr); |
674 |
|
} |
700 |
|
|
701 |
|
|
702 |
|
if(dataonly) { |
703 |
< |
cout << "Processing data with datajzb: " << datajzb << endl; |
703 |
> |
dout << "Processing data with datajzb: " << datajzb << endl; |
704 |
|
TH1F *ZOSSFP = allsamples.Draw("ZOSSFP",datajzb,binning, "JZB", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,data,luminosity); |
705 |
|
TH1F *ZOSOFP = allsamples.Draw("ZOSOFP",datajzb,binning, "JZB", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,data,luminosity); |
706 |
|
TH1F *ZOSSFN = allsamples.Draw("ZOSSFN","-"+datajzb,binning, "JZB", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,data,luminosity); |
834 |
|
SQRT(predstaterr); |
835 |
|
TH1F *bgStatUp = (TH1F*)pred->Clone("background_StatUp"); |
836 |
|
bgStatUp->Add(predstaterr); |
837 |
+ |
EliminateNegativeEntries(bgStatUp); |
838 |
|
bgStatUp->Write(); |
839 |
|
TH1F *bgStatDn = (TH1F*)pred->Clone("background_StatDown"); |
840 |
|
bgStatDn->Add(predstaterr,-1); |
841 |
+ |
EliminateNegativeEntries(bgStatDn); |
842 |
|
bgStatDn->Write(); |
843 |
|
// delete bgStatDn; |
844 |
|
// delete bgStatUp; |
855 |
|
SQRT(flippedpredstaterr); |
856 |
|
TH1F *fbgStatUp = (TH1F*)flippedpred->Clone("flipped_background_StatUp"); |
857 |
|
fbgStatUp->Add(predstaterr); |
858 |
+ |
EliminateNegativeEntries(fbgStatUp); |
859 |
|
fbgStatUp->Write(); |
860 |
|
TH1F *fbgStatDn = (TH1F*)flippedpred->Clone("flipped_background_StatDown"); |
861 |
|
fbgStatDn->Add(predstaterr,-1); |
862 |
+ |
EliminateNegativeEntries(fbgStatDn); |
863 |
|
fbgStatDn->Write(); |
864 |
|
// delete fbgStatDn; |
865 |
|
// delete fbgStatUp; |
872 |
|
SQRT(Tpredstaterr); |
873 |
|
TH1F *TpredStatUp = (TH1F*)Tpred->Clone("TTbarBackground_StatUp"); |
874 |
|
TpredStatUp->Add(Tpredstaterr); |
875 |
+ |
EliminateNegativeEntries(TpredStatUp); |
876 |
|
TpredStatUp->Write(); |
877 |
|
TH1F *TpredStatDn = (TH1F*)Tpred->Clone("TTbarBackground_StatDown"); |
878 |
|
TpredStatDn->Add(Tpredstaterr,-1); |
879 |
+ |
EliminateNegativeEntries(TpredStatDn); |
880 |
|
TpredStatDn->Write(); |
881 |
|
// delete TpredStatDn; |
882 |
|
// delete TpredStatUp; |
889 |
|
SQRT(fTpredstaterr); |
890 |
|
TH1F *fTpredStatUp = (TH1F*)flippedTpred->Clone("flipped_TTbarBackground_StatUp"); |
891 |
|
fTpredStatUp->Add(fTpredstaterr); |
892 |
+ |
EliminateNegativeEntries(fTpredStatUp); |
893 |
|
fTpredStatUp->Write(); |
894 |
|
TH1F *fTpredStatDn = (TH1F*)flippedTpred->Clone("flipped_TTbarBackground_StatDown"); |
895 |
|
fTpredStatDn->Add(fTpredstaterr,-1); |
896 |
+ |
EliminateNegativeEntries(fTpredStatDn); |
897 |
|
fTpredStatDn->Write(); |
898 |
|
// delete fTpredStatDn; |
899 |
|
// delete fTpredStatUp; |
907 |
|
SQRT(Zpredstaterr); |
908 |
|
TH1F *ZpredStatUp = (TH1F*)Zpred->Clone("ZJetsBackground_StatUp"); |
909 |
|
ZpredStatUp->Add(Zpredstaterr); |
910 |
+ |
EliminateNegativeEntries(ZpredStatUp); |
911 |
|
ZpredStatUp->Write(); |
912 |
|
TH1F *ZpredStatDn = (TH1F*)Zpred->Clone("ZJetsBackground_StatDown"); |
913 |
|
ZpredStatDn->Add(Zpredstaterr,-1); |
914 |
+ |
EliminateNegativeEntries(ZpredStatDn); |
915 |
|
ZpredStatDn->Write(); |
916 |
|
// delete ZpredStatDn; |
917 |
|
// delete ZpredStatUp; |
924 |
|
SQRT(fTpredstaterr); |
925 |
|
TH1F *fZpredStatUp = (TH1F*)flippedZpred->Clone("flipped_ZJetsBackground_StatUp"); |
926 |
|
fZpredStatUp->Add(fZpredstaterr); |
927 |
+ |
EliminateNegativeEntries(fZpredStatUp); |
928 |
|
fZpredStatUp->Write(); |
929 |
|
TH1F *fZpredStatDn = (TH1F*)flippedZpred->Clone("flipped_ZJetsBackground_StatDown"); |
930 |
|
fZpredStatDn->Add(fZpredstaterr,-1); |
931 |
+ |
EliminateNegativeEntries(fZpredStatDn); |
932 |
|
fZpredStatDn->Write(); |
933 |
|
// delete fZpredStatDn; |
934 |
|
// delete fZpredStatUp; |
948 |
|
SQRT(predsyserr); |
949 |
|
TH1F *bgSysUp = (TH1F*)pred->Clone("background_SysUp"); |
950 |
|
bgSysUp->Add(predsyserr); |
951 |
+ |
EliminateNegativeEntries(bgSysUp); |
952 |
|
bgSysUp->Write(); |
953 |
|
TH1F *bgSysDn = (TH1F*)pred->Clone("background_SysDown"); |
954 |
|
bgSysDn->Add(predsyserr,-1); |
955 |
+ |
EliminateNegativeEntries(bgSysDn); |
956 |
|
bgSysDn->Write(); |
957 |
|
delete predsyserr; |
958 |
|
|
968 |
|
SQRT(fpredsyserr); |
969 |
|
TH1F *fbgSysUp = (TH1F*)flippedpred->Clone("flipped_background_SysUp"); |
970 |
|
fbgSysUp->Add(fpredsyserr); |
971 |
+ |
EliminateNegativeEntries(fbgSysUp); |
972 |
|
fbgSysUp->Write(); |
973 |
|
TH1F *fbgSysDn = (TH1F*)flippedpred->Clone("flipped_background_SysDown"); |
974 |
|
fbgSysDn->Add(fpredsyserr,-1); |
975 |
+ |
EliminateNegativeEntries(fbgSysDn); |
976 |
|
fbgSysDn->Write(); |
977 |
|
delete fpredsyserr; |
978 |
|
|
985 |
|
SQRT(Tpredsyserr); |
986 |
|
TH1F *TpredSysUp = (TH1F*)Tpred->Clone("TTbarBackground_SysUp"); |
987 |
|
TpredSysUp->Add(Tpredsyserr); |
988 |
+ |
EliminateNegativeEntries(TpredSysUp); |
989 |
|
TpredSysUp->Write(); |
990 |
|
TH1F *TpredSysDn = (TH1F*)Tpred->Clone("TTbarBackground_SysDown"); |
991 |
|
TpredSysDn->Add(Tpredsyserr,-1); |
992 |
+ |
EliminateNegativeEntries(TpredSysDn); |
993 |
|
TpredSysDn->Write(); |
994 |
|
delete Tpredsyserr; |
995 |
|
|
1001 |
|
SQRT(fTpredsyserr); |
1002 |
|
TH1F *fTpredSysUp = (TH1F*)flippedTpred->Clone("flipped_TTbarBackground_SysUp"); |
1003 |
|
fTpredSysUp->Add(fTpredsyserr); |
1004 |
+ |
EliminateNegativeEntries(fTpredSysUp); |
1005 |
|
fTpredSysUp->Write(); |
1006 |
|
TH1F *fTpredSysDn = (TH1F*)flippedTpred->Clone("flipped_TTbarBackground_SysDown"); |
1007 |
|
fTpredSysDn->Add(fTpredsyserr,-1); |
1008 |
+ |
EliminateNegativeEntries(fTpredSysDn); |
1009 |
|
fTpredSysDn->Write(); |
1010 |
|
delete fTpredsyserr; |
1011 |
|
|
1020 |
|
SQRT(Zpredsyserr); |
1021 |
|
TH1F *ZpredSysUp = (TH1F*)Zpred->Clone("ZJetsBackground_SysUp"); |
1022 |
|
ZpredSysUp->Add(Zpredsyserr); |
1023 |
+ |
EliminateNegativeEntries(ZpredSysUp); |
1024 |
|
ZpredSysUp->Write(); |
1025 |
|
TH1F *ZpredSysDn = (TH1F*)Zpred->Clone("ZJetsBackground_SysDown"); |
1026 |
|
ZpredSysDn->Add(Zpredsyserr,-1); |
1027 |
+ |
EliminateNegativeEntries(ZpredSysDn); |
1028 |
|
ZpredSysDn->Write(); |
1029 |
|
delete Zpredsyserr; |
1030 |
|
|
1037 |
|
SQRT(fZpredsyserr); |
1038 |
|
TH1F *fZpredSysUp = (TH1F*)flippedZpred->Clone("flipped_ZJetsBackground_SysUp"); |
1039 |
|
fZpredSysUp->Add(fZpredsyserr); |
1040 |
+ |
EliminateNegativeEntries(fZpredSysUp); |
1041 |
|
fZpredSysUp->Write(); |
1042 |
|
TH1F *fZpredSysDn = (TH1F*)flippedZpred->Clone("flipped_ZJetsBackground_SysDown"); |
1043 |
|
fZpredSysDn->Add(fZpredsyserr,-1); |
1044 |
+ |
EliminateNegativeEntries(fZpredSysDn); |
1045 |
|
fZpredSysDn->Write(); |
1046 |
|
delete fZpredsyserr; |
1047 |
|
} |
1048 |
|
|
1049 |
|
/*if(identifier=="") { |
1050 |
|
for(int i=0;i<binning.size()-1;i++) { |
1051 |
< |
cout << "[ " << binning[i] << " , " << binning[i+1] << "] : O " << obs->GetBinContent(i+1) << " P " << pred->GetBinContent(i+1) << " (Z: " << Zpred->GetBinContent(i+1) << " , T: " << Tpred->GetBinContent(i+1) << ")" << endl; |
1051 |
> |
dout << "[ " << binning[i] << " , " << binning[i+1] << "] : O " << obs->GetBinContent(i+1) << " P " << pred->GetBinContent(i+1) << " (Z: " << Zpred->GetBinContent(i+1) << " , T: " << Tpred->GetBinContent(i+1) << ")" << endl; |
1052 |
|
} |
1053 |
|
}*/ |
1054 |
|
delete ZOSSFP; |
1063 |
|
delete SBOSOFN; |
1064 |
|
} |
1065 |
|
} |
1066 |
< |
|
1066 |
> |
|
1067 |
> |
|
1068 |
> |
//----------------------------------- ******** GOTTEN HERE *******--------------------------------------- |
1069 |
> |
|
1070 |
> |
|
1071 |
> |
|
1072 |
> |
|
1073 |
> |
|
1074 |
|
} |
1075 |
|
|
1076 |
< |
ShapeDroplet LimitsFromShapes(bool asymptotic, float firstGuess, TTree *events, string addcut, string name, string mcjzb, string datajzb, vector<float> jzbbins, float jzbpeakerrormc, float jzbpeakerrordata) { |
1076 |
> |
void DoFullCls(string RunDirectory,float firstGuess) { |
1077 |
> |
vector<float> epoints = get_expected_points(firstGuess,25,RunDirectory,true);//get 20 points; |
1078 |
> |
ofstream RealScript; |
1079 |
> |
dout << "Going to write the full CLs script to " << RunDirectory << "/LimitScript.sh" << endl; |
1080 |
> |
RealScript.open ((RunDirectory+"/LimitScript.sh").c_str()); |
1081 |
> |
RealScript << "#!/bin/bash \n"; |
1082 |
> |
RealScript << "\n"; |
1083 |
> |
RealScript << "RunDirectory=" << RunDirectory << "\n"; |
1084 |
> |
RealScript << "CMSSWDirectory=" << PlottingSetup::CMSSW_dir << "\n"; |
1085 |
> |
RealScript << "ORIGTMP=$TMP\n"; |
1086 |
> |
RealScript << "ORIGTMPDIR=$TMPDIR\n"; |
1087 |
> |
RealScript << "export TMP=" << RunDirectory << "\n"; |
1088 |
> |
RealScript << "export TMPDIR=" << RunDirectory << "\n"; |
1089 |
> |
RealScript << "\n"; |
1090 |
> |
RealScript << "echo \"Going to compute limit in $RunDirectory\"\n"; |
1091 |
> |
RealScript << "ORIGDIR=`pwd`\n"; |
1092 |
> |
RealScript << "\n"; |
1093 |
> |
RealScript << "pushd $CMSSWDirectory\n"; |
1094 |
> |
RealScript << "cd ~/final_production_2011/CMSSW_4_2_8/src/HiggsAnalysis/\n"; |
1095 |
> |
RealScript << "origscramarch=$SCRAM_ARCH\n"; |
1096 |
> |
RealScript << "origbase=$CMSSW_BASE\n"; |
1097 |
> |
RealScript << "export SCRAM_ARCH=slc5_amd64_gcc434\n"; |
1098 |
> |
RealScript << "eval `scram ru -sh`\n"; |
1099 |
> |
RealScript << "\n"; |
1100 |
> |
RealScript << "mkdir -p $RunDirectory\n"; |
1101 |
> |
RealScript << "cd $RunDirectory\n"; |
1102 |
> |
RealScript << "echo `pwd`\n"; |
1103 |
> |
RealScript << "mkdir -p FullCLs\n"; |
1104 |
> |
RealScript << "cd FullCLs\n"; |
1105 |
> |
RealScript << "\n"; |
1106 |
> |
RealScript << "combineEXE=\"${CMSSW_BASE}/bin/${SCRAM_ARCH}/combine\"\n"; |
1107 |
> |
RealScript << "\n"; |
1108 |
> |
RealScript << "dobreak=0\n"; |
1109 |
> |
RealScript << "npoints=0\n"; |
1110 |
> |
RealScript << "time for i in {"; |
1111 |
> |
RealScript << epoints[0]/4 << ","; // adding a VERY VERY low point just to be totally safe |
1112 |
> |
RealScript << epoints[0]/2 << ","; // adding a VERY low point just to be safe |
1113 |
> |
for(int i=0;i<epoints.size();i++) RealScript << epoints[i] << ","; |
1114 |
> |
RealScript << 2*epoints[epoints.size()-1] << ","; // adding a VERY high point just to be safe |
1115 |
> |
RealScript << 4*epoints[epoints.size()-1]; // adding a VERY VERY high point just to be totally safe |
1116 |
> |
RealScript << "}; do \n"; |
1117 |
> |
RealScript << "let \"npoints = npoints +1\"\n"; |
1118 |
> |
RealScript << "if [[ $dobreak -gt 0 ]]; then \n"; |
1119 |
> |
RealScript << " continue \n"; |
1120 |
> |
RealScript << "fi \n"; |
1121 |
> |
RealScript << "echo -e \" Going to compute CLs for $i \\n\"\n"; |
1122 |
> |
RealScript << "echo $(date +%d%b%Y,%H:%M:%S)\n"; |
1123 |
> |
RealScript << "time " << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/Utilities/TimeOut \"$combineEXE ../susydatacard.txt -M HybridNew --freq -T 500 --clsAcc 0 -v 0 -n TestPoint --saveHybridResult --saveToys -s -1 -i 8 --singlePoint $i >/dev/null 2>/dev/null\"\n"; |
1124 |
> |
// RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq -T 500 --clsAcc 0 -v 0 -n TestPoint --saveHybridResult --saveToys -s -1 -i 8 --singlePoint $i >/dev/null 2>/dev/null \n"; |
1125 |
> |
RealScript << "errorsize=$?\n"; |
1126 |
> |
RealScript << "rm " << RunDirectory << "/rstat* 2>/dev/null \n"; |
1127 |
> |
RealScript << "if [[ $errorsize -gt 0 ]]; then \n"; |
1128 |
> |
RealScript << " echo \"Apparently something went wrong (had to be aborted)\"\n"; |
1129 |
> |
RealScript << " if [[ $npoints -gt 10 ]]; then \n"; |
1130 |
> |
RealScript << " dobreak=1 \n"; |
1131 |
> |
RealScript << " fi \n"; |
1132 |
> |
RealScript << "fi \n"; |
1133 |
> |
RealScript << "done\n"; |
1134 |
> |
|
1135 |
> |
RealScript << "\n"; |
1136 |
> |
RealScript << "hadd -f FullCLs.root higgsCombine*.root\n"; |
1137 |
> |
RealScript << "mkdir originalFiles\n"; |
1138 |
> |
RealScript << "mv higgsCombine* originalFiles\n"; |
1139 |
> |
RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq --grid=FullCLs.root\n"; |
1140 |
> |
RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq --grid=FullCLs.root --expectedFromGrid 0.5\n"; |
1141 |
> |
RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq --grid=FullCLs.root --expectedFromGrid 0.84\n"; |
1142 |
> |
RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq --grid=FullCLs.root --expectedFromGrid 0.16\n"; |
1143 |
> |
RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq --grid=FullCLs.root --expectedFromGrid 0.975\n"; |
1144 |
> |
RealScript << "$combineEXE ../susydatacard.txt -M HybridNew --freq --grid=FullCLs.root --expectedFromGrid 0.025\n"; |
1145 |
> |
RealScript << "\n"; |
1146 |
> |
RealScript << "hadd FinalResult.root higgsCombineTest.HybridNew*\n"; |
1147 |
> |
RealScript << "\n"; |
1148 |
> |
RealScript << "g++ " << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/ShapeLimits/ReadAndSave.C -o ReadAndSave.exec `root-config --glibs --cflags` \n"; |
1149 |
> |
RealScript << "./ReadAndSave.exec FinalResult.root " << RunDirectory << "/FullCLsShapeDropletResult.txt \n"; |
1150 |
> |
RealScript << "\n"; |
1151 |
> |
RealScript << "rm " << RunDirectory << "/rstat* \n"; |
1152 |
> |
RealScript << "\n"; |
1153 |
> |
RealScript << "#####\n"; |
1154 |
> |
RealScript << "echo \"Finalizing ...\"\n"; |
1155 |
> |
RealScript << "cd $ORIGDIR\n"; |
1156 |
> |
RealScript << "echo $ORIGDIR\n"; |
1157 |
> |
RealScript << "ls -ltrh ../SandBox/ | grep combine\n"; |
1158 |
> |
RealScript << "export SCRAM_ARCH=$origscramarch\n"; |
1159 |
> |
RealScript << "export TMP=$ORIGTMP\n"; |
1160 |
> |
RealScript << "export TMPDIR=$ORIGTMPDIR\n"; |
1161 |
> |
RealScript << "exit 0\n"; |
1162 |
> |
RealScript << "\n"; |
1163 |
> |
RealScript.close(); |
1164 |
> |
gSystem->Exec(("bash "+RunDirectory+"/LimitScript.sh").c_str()); |
1165 |
> |
} |
1166 |
> |
|
1167 |
> |
|
1168 |
> |
ShapeDroplet LimitsFromShapes(float low_fullCLs, float high_CLs, TTree *events, string addcut, string name, string mcjzb, string datajzb, vector<float> jzbbins, float jzbpeakerrormc, float jzbpeakerrordata) { |
1169 |
|
map < pair<float, float>, map<string, float> > xsec; |
1170 |
|
if(SUSYScanSpace::SUSYscantype==mSUGRA) xsec=getXsec(PlottingSetup::cbafbasedir+"/"+mSUGRAxsFile); |
1171 |
|
|
1179 |
|
|
1180 |
|
ensure_directory_exists(RunDirectory); |
1181 |
|
|
1182 |
< |
TFile *datafile = new TFile("../StoredShapes.root","READ"); |
1182 |
> |
TFile *datafile = new TFile((PlottingSetup::cbafbasedir+"/DistributedModelCalculations/StoredShapes.root").c_str()); |
1183 |
|
if(datafile->IsZombie()) { |
1184 |
|
write_error(__FUNCTION__,"Fatal error: The stored shapes are not available!"); |
1185 |
|
assert(!datafile->IsZombie()); |
1186 |
|
} |
1187 |
< |
cout << "Run Directory: " << RunDirectory << endl; |
1187 |
> |
dout << "Run Directory: " << RunDirectory << endl; |
1188 |
|
TFile *limfile = new TFile((RunDirectory+"/PRElimitfile.root").c_str(),"RECREATE"); |
1189 |
|
|
1190 |
|
TIter nextkey(datafile->GetListOfKeys()); |
1202 |
|
bool dataonly=false; |
1203 |
|
|
1204 |
|
generate_shapes_for_systematic(signalonly,dataonly,limfile,events,"",mcjzb,datajzb,noJES,jzbbins,limcan,addcut,xsec); |
705 |
– |
// generate_shapes_for_systematic(signalonly,dataonly,limfile,events,"peakUp",newjzbexpression(mcjzb,jzbpeakerrormc),newjzbexpression(datajzb,jzbpeakerrordata),noJES,jzbbins,limcan,addcut,xsec); |
706 |
– |
// generate_shapes_for_systematic(signalonly,dataonly,limfile,events,"peakDown",newjzbexpression(mcjzb,-jzbpeakerrormc),newjzbexpression(datajzb,-jzbpeakerrordata),noJES,jzbbins,limcan,addcut,xsec); |
1205 |
|
generate_shapes_for_systematic(signalonly,dataonly,limfile,events,"JESUp",mcjzb,datajzb,JESup,jzbbins,limcan,addcut,xsec); |
1206 |
|
generate_shapes_for_systematic(signalonly,dataonly,limfile,events,"JESDown",mcjzb,datajzb,JESdown,jzbbins,limcan,addcut,xsec); |
1207 |
|
|
1215 |
|
bool docomplicatedmSUGRAxsreweighting=false; //if you modify this value please also adapt it in Systematics.C not only here in ShapeLimit.C |
1216 |
|
|
1217 |
|
MCefficiency(events,mceff,mcefferr,flipped,mcjzb,requireZ,Neventsinfile,SUSYScanSpace::SUSYscantype,xsec,addcut,-1); |
1218 |
< |
if(mceff<0) flipped=1; |
1218 |
> |
if(mceff<0) { |
1219 |
> |
flipped=1; |
1220 |
> |
write_info(__FUNCTION__,"Doing flipping!"); |
1221 |
> |
} |
1222 |
|
doJZBscale(events,SUSYScanSpace::SUSYscantype==mSUGRA&&docomplicatedmSUGRAxsreweighting,xsec,scaledown,scaleup,scalesyst,JZBScaleUncert,informalname,flipped,requireZ,addcut); |
1223 |
|
float PDFuncert=0; |
1224 |
|
int NPdfs = get_npdfs(events); |
1264 |
|
obj->Write(); |
1265 |
|
} |
1266 |
|
|
1267 |
< |
prepare_limit_datacard(RunDirectory,final_limfile,JZBscale,PDFuncert,flipped); |
1267 |
> |
prepare_limit_datacard(RunDirectory,final_limfile,JZBscale,PDFuncert); |
1268 |
|
|
1269 |
|
final_limfile->Close(); |
1270 |
|
limfile->Close(); |
1271 |
|
dout << "Info: Shape root file and datacard have been generated in " << RunDirectory << endl; |
1272 |
|
stringstream command; |
1273 |
< |
if(asymptotic) { |
1274 |
< |
if(firstGuess>0) command << "bash CreateModel.sh " << RunDirectory << " susydatacard.txt" << " 1 0 0 " << firstGuess; // ASYMPTOTIC LIMITS WITH FIRST GUESS |
1275 |
< |
else command << "bash CreateModel.sh " << RunDirectory << " susydatacard.txt" << " 0 0 0 0"; // ASYMPTOTIC LIMITS |
1276 |
< |
} |
1277 |
< |
else command << "bash CreateModel.sh " << RunDirectory << " susydatacard.txt" << " 2 0 " << int(0.5 * firstGuess) << " " << int(2*firstGuess); // ASYMPTOTIC LIMITS |
1273 |
> |
string DropletLocation; |
1274 |
> |
int CreatedModelFileExitCode; |
1275 |
> |
//---------------------------------------------------------------- |
1276 |
> |
//do an asymptotic limit first |
1277 |
> |
command << "bash " << PlottingSetup::cbafbasedir<< "/DistributedModelCalculations/ShapeLimits/CreateModel.sh " << RunDirectory << " susydatacard.txt" << " 0 0 0 0"; // ASYMPTOTIC LIMITS |
1278 |
|
dout <<"Going to run : " << command.str() << endl; |
1279 |
< |
int CreatedModelFileExitCode = gSystem->Exec(command.str().c_str()); |
1280 |
< |
cout << "exit code of limit algorithm (CreateModel.sh) : " << CreatedModelFileExitCode << endl; |
1281 |
< |
assert(CreatedModelFileExitCode==0); |
1279 |
> |
CreatedModelFileExitCode = gSystem->Exec(command.str().c_str()); |
1280 |
> |
dout << "exit code of limit algorithm (CreateModel.sh) : " << CreatedModelFileExitCode << endl; |
1281 |
> |
if(!(CreatedModelFileExitCode==0)) { |
1282 |
> |
write_warning(__FUNCTION__,"Something bad happened. It looks like a shape analysis is not the way to go. "); |
1283 |
> |
ShapeDroplet beta; |
1284 |
> |
beta.observed=-12345; // this is the flag to say watch out something went wrong with the signal ... |
1285 |
> |
beta.SignalIntegral=1; |
1286 |
> |
return beta; |
1287 |
> |
} |
1288 |
> |
DropletLocation=RunDirectory+"/ShapeDropletResult.txt"; |
1289 |
> |
ShapeDroplet beta; |
1290 |
> |
beta.readDroplet(DropletLocation); |
1291 |
> |
float obsLimit = beta.observed/SignalIntegral; |
1292 |
> |
dout << "Checking if the obtained limit (" << beta.observed << " / " << SignalIntegral << " = " << beta.observed/SignalIntegral << " is in [" << low_fullCLs << " , " << high_CLs << "]" << endl; |
1293 |
> |
if(obsLimit<high_CLs && obsLimit>low_fullCLs) { |
1294 |
> |
//if(PlottingSetup::scantype!=mSUGRA||(obsLimit<high_CLs && obsLimit>low_fullCLs)) { |
1295 |
> |
dout << " It is! Full CLs ahead!" << endl; |
1296 |
> |
DoFullCls(RunDirectory,beta.observed); |
1297 |
> |
DropletLocation=RunDirectory+"/FullCLsShapeDropletResult.txt"; |
1298 |
> |
} else { |
1299 |
> |
dout << " It is not ... happy with asymptotic limits." << endl; |
1300 |
> |
} |
1301 |
> |
//---------------------------------------------------------------- |
1302 |
|
ShapeDroplet alpha; |
1303 |
< |
alpha.readDroplet(RunDirectory+"/ShapeDropletResult.txt"); |
1303 |
> |
alpha.readDroplet(DropletLocation); |
1304 |
|
alpha.PDF=PDFuncert; |
1305 |
|
alpha.JSU=JZBscale; |
1306 |
|
alpha.SignalIntegral=SignalIntegral; |
1307 |
|
dout << "Done reading limit information from droplet" << endl; |
1308 |
|
dout << alpha << endl; |
1309 |
< |
|
1309 |
> |
|
1310 |
|
dout << "Everything is saved in " << RunDirectory << endl; |
1311 |
< |
dout << "Will transfer model and datacard over for possible post-processing" << endl; |
1312 |
< |
dout << " 1) Make sure models directory exists ... " << std::flush; |
1313 |
< |
gSystem->Exec("mkdir -p models/"); |
793 |
< |
dout << " ok!" << endl; |
794 |
< |
dout << " 2) Deleting any previous model files with the same name ... " << std::flush; |
795 |
< |
stringstream delcommand; |
796 |
< |
delcommand << "rm models/model_" << name << ".root"; |
797 |
< |
gSystem->Exec(delcommand.str().c_str()); |
798 |
< |
stringstream delcommand2; |
799 |
< |
delcommand2 << "rm models/model_" << name << ".txt"; |
800 |
< |
gSystem->Exec(delcommand2.str().c_str()); |
801 |
< |
dout << " ok!" << endl; |
802 |
< |
dout << " 3) Transfering the new model files ... " << std::flush; |
803 |
< |
stringstream copycommand; |
804 |
< |
copycommand << "cp " << RunDirectory << "/model.root models/model_" << name << ".root"; |
805 |
< |
gSystem->Exec(copycommand.str().c_str()); |
806 |
< |
stringstream copycommand2; |
807 |
< |
copycommand2 << "cp " << RunDirectory << "/susydatacard.txt models/model_" << name << ".txt"; |
808 |
< |
gSystem->Exec(copycommand2.str().c_str()); |
809 |
< |
stringstream copycommand3; |
810 |
< |
copycommand3 << "cp " << RunDirectory << "/limitfile.root models/model_" << name << "_histo.root"; |
811 |
< |
gSystem->Exec(copycommand3.str().c_str()); |
812 |
< |
dout << " ok!" << endl; |
813 |
< |
dout << " 4) Removing original working directory (" << RunDirectory << ") ... " << std::flush; |
814 |
< |
write_warning(__FUNCTION__,"Watch out : need to uncomment the line below to remove the original working directory again"); |
815 |
< |
// gSystem->Exec(("rm -r "+RunDirectory).c_str()); |
1311 |
> |
dout << "Cleaning up ... " << std::flush; |
1312 |
> |
write_warning(__FUNCTION__,"NOT CLEANING UP"); |
1313 |
> |
// gSystem->Exec(("rm -rf "+RunDirectory).c_str()); |
1314 |
|
dout << " ok!" << endl; |
1315 |
|
delete limcan; |
1316 |
|
return alpha; |
1317 |
|
} |
1318 |
|
|
1319 |
< |
void PrepareDataShapes(string datajzb, vector<float> jzbbins, float jzbpeakerrordata) { |
1320 |
< |
// dout << "Generating data shape templates ... " << endl; |
1319 |
> |
void PrepareDataShapes(string mcjzb, string datajzb, vector<float> jzbbins, float jzbpeakerrordata) { |
1320 |
> |
dout << "Preparing data shapes ... " << endl; |
1321 |
|
map < pair<float, float>, map<string, float> > xsec; |
1322 |
|
TFile *datafile = new TFile("../DistributedModelCalculations/StoredShapes.root","RECREATE"); |
1323 |
|
TCanvas *limcan = new TCanvas("limcan","Canvas for calculating limits"); |
1324 |
|
TTree *faketree; |
1325 |
|
bool dataonly=true; |
1326 |
|
bool signalonly=false; |
1327 |
< |
string mcjzb="JZBforMCinPrepareDataShapes";//this string is not used. |
830 |
< |
float jzbpeakerrormc=0; |
1327 |
> |
|
1328 |
|
generate_shapes_for_systematic(signalonly,dataonly,datafile,faketree,"",mcjzb,datajzb,noJES,jzbbins,limcan,"",xsec); |
1329 |
< |
// don't need these effects for obs & pred, only for signal! |
1330 |
< |
// generate_shapes_for_systematic(signalonly,dataonly,datafile,faketree,"peakUp",newjzbexpression(mcjzb,jzbpeakerrormc),newjzbexpression(datajzb,jzbpeakerrordata),noJES,jzbbins,limcan,"",xsec); |
1331 |
< |
// generate_shapes_for_systematic(signalonly,dataonly,datafile,faketree,"peakDown",newjzbexpression(mcjzb,-jzbpeakerrormc),newjzbexpression(datajzb,-jzbpeakerrordata),noJES,jzbbins,limcan,"",xsec); |
1332 |
< |
// generate_shapes_for_systematic(signalonly,dataonly,datafile,faketree,"JESUp",mcjzb,datajzb,JESup,jzbbins,limcan,"",xsec); |
1333 |
< |
// generate_shapes_for_systematic(signalonly,dataonly,datafile,faketree,"JESDown",mcjzb,datajzb,JESdown,jzbbins,limcan,"",xsec); |
1329 |
> |
|
1330 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,cutWeight,cutnJets,"","",xsec); |
1331 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,cutWeight,cutnJetsJESup,"","JESUp",xsec); |
1332 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,cutWeight,cutnJetsJESdown,"","JESDown",xsec); |
1333 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,TCut("weightEffUp"),cutnJets,"","EffUp",xsec); |
1334 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,TCut("weightEffDown"),cutnJets,"","EffDown",xsec); |
1335 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,cutWeight,cutnJets,"","StatUp",xsec); |
1336 |
> |
generate_mc_shapes(false,faketree,mcjzb,datajzb,jzbbins,cutWeight,cutnJets,"","StatDown",xsec); |
1337 |
> |
|
1338 |
|
datafile->Close(); |
1339 |
+ |
|
1340 |
|
} |
1341 |
|
|