168 |
|
|
169 |
|
} |
170 |
|
|
171 |
< |
vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, bool doobserved=false) { |
172 |
< |
float sigma95=0.0,sigma95A=0.0; |
173 |
< |
int nuisancemodel=1; |
171 |
> |
vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, string plotfilename, bool doobserved) { |
172 |
> |
float sigma95=-9.9,sigma95A=-9.9; |
173 |
> |
int nuisancemodel=0; |
174 |
> |
/* |
175 |
> |
USAGE OF ROOSTATS_CL95 |
176 |
> |
" Double_t limit = roostats_cl95(ilum, slum, eff, seff, bck, sbck, n, gauss = false, nuisanceModel, method, plotFileName, seed); \n" |
177 |
> |
" LimitResult expected_limit = roostats_clm(ilum, slum, eff, seff, bck, sbck, ntoys, nuisanceModel, method, seed); \n" |
178 |
> |
" Double_t average_limit = roostats_cla(ilum, slum, eff, seff, bck, sbck, nuisanceModel, method, seed); \n" |
179 |
> |
" \n" |
180 |
> |
" |
181 |
> |
" Double_t obs_limit = limit.GetObservedLimit(); \n" |
182 |
> |
" Double_t exp_limit = limit.GetExpectedLimit(); \n" |
183 |
> |
" Double_t exp_up = limit.GetOneSigmaHighRange(); \n" |
184 |
> |
" Double_t exp_down = limit.GetOneSigmaLowRange(); \n" |
185 |
> |
" Double_t exp_2up = limit.GetTwoSigmaHighRange(); \n" |
186 |
> |
" Double_t exp_2down = limit.GetTwoSigmaLowRange(); \n" |
187 |
> |
*/ |
188 |
> |
if(mceff<=0) { |
189 |
> |
write_warning(__FUNCTION__,"Cannot compute upper limit in this configuration as the efficiency is negative:"); |
190 |
> |
dout << "mc efficiency=" << mceff << " +/- " << mcefferr; |
191 |
> |
vector<float> sigmas; |
192 |
> |
sigmas.push_back(-1); |
193 |
> |
sigmas.push_back(-1); |
194 |
> |
return sigmas; |
195 |
> |
} else { |
196 |
> |
int nlimittoysused=1; |
197 |
> |
//if(doobserved) nlimittoysused=nlimittoys; |
198 |
> |
nlimittoysused=nlimittoys; |
199 |
|
dout << "Now calling : CL95(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl; |
200 |
|
sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel); |
201 |
+ |
|
202 |
+ |
/* dout << "Now calling : roostats_cl95(" << luminosity << "," << lumiuncert*luminosity << ","<<mceff <<","<<mcefferr<<","<<Npred[ibin]<<","<<Nprederr[ibin] << ",n=" << nlimittoysused << ",gauss=" << false << ",nuisanceModel="<<nuisancemodel<<",method="<<limitmethod<<",plotfilename="<<plotfilename<<",seed=0) " << endl; |
203 |
+ |
/* dout << "Now calling : roostats_limit(" << luminosity << "," << lumiuncert*luminosity << ","<<mceff <<","<<mcefferr<<","<<Npred[ibin]<<","<<Nprederr[ibin] << ",n=" << nlimittoysused << ",gauss=" << false << ", nuisanceModel="<<nuisancemodel<<",method="<<limitmethod<<",plotfilename="<<plotfilename<<",seed=1) " << endl; |
204 |
+ |
LimitResult limit = roostats_limit(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0); |
205 |
+ |
dout << "Now interpreting and saving results ... " << endl; |
206 |
+ |
vector<float> sigmas; |
207 |
+ |
sigmas.push_back(limit.GetExpectedLimit());//expected |
208 |
+ |
sigmas.push_back(limit.GetObservedLimit());//observed |
209 |
+ |
//up to here for backward compatibility |
210 |
+ |
sigmas.push_back(limit.GetOneSigmaHighRange());//expected, up |
211 |
+ |
sigmas.push_back(limit.GetTwoSigmaHighRange());//expected, 2 up |
212 |
+ |
sigmas.push_back(limit.GetOneSigmaLowRange());//expected, down |
213 |
+ |
sigmas.push_back(limit.GetTwoSigmaLowRange());//expected, 2 down |
214 |
+ |
*/ |
215 |
+ |
// float limit = roostats_cl95(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0); |
216 |
|
if(doobserved) { |
217 |
|
dout << "Now calling : CLA(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl; |
218 |
|
sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel); |
219 |
|
} |
220 |
+ |
// vector<float> sigmas; |
221 |
+ |
// sigmas.push_back(limit); |
222 |
|
vector<float> sigmas; |
223 |
|
sigmas.push_back(sigma95); |
224 |
|
sigmas.push_back(sigma95A); |
225 |
|
return sigmas; |
226 |
+ |
|
227 |
+ |
|
228 |
+ |
} |
229 |
+ |
write_warning(__FUNCTION__,"STILL MISSING SIGMAS, LIMITS, EVERYTHING ..."); |
230 |
|
} |
231 |
|
|
232 |
|
void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts, string mcjzb, bool doobserved) { |
247 |
|
float staterr=uncertainties[isample*jzbcuts.size()+ibin][2]; |
248 |
|
float systerr=uncertainties[isample*jzbcuts.size()+ibin][3]; |
249 |
|
float toterr =uncertainties[isample*jzbcuts.size()+ibin][4]; |
250 |
< |
float observed,null,result; |
205 |
< |
fill_result_histos(observed, null,null,null,null,null,null,null,mcjzb,JZBcutat,(int)5,result,(signalsamples.FindSample(signalsamples.collection[isample].filename)),signalsamples); |
206 |
< |
observed-=result;//this is the actual excess we see! |
207 |
< |
float expected=observed/luminosity; |
250 |
> |
float observed,observederr,null,result; |
251 |
|
|
252 |
+ |
// fill_result_histos(observed,observederr, null,null,null,null,null,null,null,mcjzb,JZBcutat,14000,(int)5,result,(signalsamples.FindSample(signalsamples.collection[isample].filename)),signalsamples); |
253 |
+ |
// observed-=result;//this is the actual excess we see! |
254 |
+ |
// float expected=observed/luminosity; |
255 |
+ |
string plotfilename=(string)(TString(signalsamples.collection[isample].samplename)+TString("___JZB_geq_")+TString(any2string(JZBcutat))+TString(".png")); |
256 |
|
dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl; |
257 |
< |
vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,doobserved); |
257 |
> |
vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,plotfilename,doobserved); |
258 |
|
|
259 |
|
if(doobserved) { |
260 |
< |
rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")"); |
260 |
> |
// rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")"); |
261 |
> |
rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(signalsamples.collection[isample].xs)+")"); |
262 |
|
vrows.push_back(sigmas[0]); |
263 |
|
vrows.push_back(sigmas[1]); |
264 |
< |
vrows.push_back(expected); |
264 |
> |
// vrows.push_back(expected); |
265 |
> |
vrows.push_back(signalsamples.collection[isample].xs); |
266 |
|
} |
267 |
|
else { |
268 |
< |
rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")"); |
268 |
> |
// rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")"); |
269 |
> |
rows.push_back(any2string(sigmas[0])); |
270 |
|
vrows.push_back(sigmas[0]); |
271 |
< |
vrows.push_back(expected); |
271 |
> |
vrows.push_back(signalsamples.collection[isample].xs); |
272 |
> |
// vrows.push_back(expected); |
273 |
|
} |
274 |
|
}//end of bin loop |
275 |
|
limits.push_back(rows); |
276 |
|
vlimits.push_back(vrows); |
277 |
|
}//end of sample loop |
278 |
< |
dout << endl << endl << "PAS table 3: " << endl << endl; |
278 |
> |
dout << endl << endl << endl << "_________________________________________________________________________________________________" << endl << endl; |
279 |
> |
dout << endl << endl << "PAS table 3: (notation: limit [95%CL])" << endl << endl; |
280 |
|
dout << "\t"; |
281 |
|
for (int irow=0;irow<jzbcuts.size();irow++) { |
282 |
|
dout << jzbcuts[irow] << "\t"; |
284 |
|
dout << endl; |
285 |
|
for(int irow=0;irow<limits.size();irow++) { |
286 |
|
for(int ientry=0;ientry<limits[irow].size();ientry++) { |
287 |
< |
dout << limits[irow][ientry] << "\t"; |
287 |
> |
if (limits[irow][ientry]>0) dout << limits[irow][ientry] << "\t"; |
288 |
> |
else dout << " (N/A) \t"; |
289 |
|
} |
290 |
|
dout << endl; |
291 |
|
} |
292 |
|
|
293 |
|
if(!doobserved) { |
294 |
< |
dout << endl << endl << "LIMITS: " << endl; |
295 |
< |
dout << "\t"; |
294 |
> |
dout << endl << endl << "LIMITS: (Tex)" << endl; |
295 |
> |
tout << "\\begin{table}[hbtp]" << endl; |
296 |
> |
tout << "\\renewcommand{\arraystretch}{1.3}" << endl; |
297 |
> |
tout << "\\begin{center}" << endl; |
298 |
> |
tout << "\\caption{Observed upper limits on the cross section of different LM benchmark points " << (ConsiderSignalContaminationForLimits?" (accounting for signal contamination)":" (not accounting for signal contamination)") << "}\\label{tab:lmresults}" << endl; |
299 |
> |
tout << "" << endl; |
300 |
> |
tout << "\\begin{tabular}{ | l | "; |
301 |
> |
for (int irow=0;irow<jzbcuts.size();irow++) tout << " l |"; |
302 |
> |
tout << "} " << endl << " \\hline " << endl << "& \t "; |
303 |
|
for (int irow=0;irow<jzbcuts.size();irow++) { |
304 |
< |
dout << jzbcuts[irow] << "\t"; |
304 |
> |
tout << "JZB $>$ " << jzbcuts[irow] << " GeV & \t "; |
305 |
|
} |
306 |
< |
dout << endl; |
306 |
> |
tout << " \\\\ \\hline " << endl; |
307 |
|
for(int irow=0;irow<limits.size();irow++) { |
308 |
< |
dout << limits[irow][0] << "\t"; |
308 |
> |
tout << limits[irow][0] << " \t"; |
309 |
|
for(int ientry=0;ientry<jzbcuts.size();ientry++) { |
310 |
< |
dout << Round(vlimits[irow][2*ientry] / vlimits[irow][2*ientry+1],3)<< "\t"; |
310 |
> |
if(vlimits[irow][2*ientry]>0) tout << " & " << Round(vlimits[irow][2*ientry],2) << " \t (" << Round(vlimits[irow][2*ientry] / vlimits[irow][2*ientry+1],3)<< "x \\sigma ) \t"; |
311 |
> |
else tout << " & ( N / A ) \t"; |
312 |
> |
// dout << Round(vlimits[irow][2*ientry],3) << " / " << Round(vlimits[irow][2*ientry+1],3)<< "\t"; |
313 |
|
} |
314 |
< |
dout << endl; |
314 |
> |
tout << " \\\\ \\hline " << endl; |
315 |
|
} |
316 |
+ |
tout << "\\end{tabular}" << endl; |
317 |
+ |
tout << " \\end{tabular}"<< endl; |
318 |
+ |
tout << "\\end{center}"<< endl; |
319 |
+ |
tout << "\\end{table} "<< endl; |
320 |
+ |
|
321 |
|
}//do observed |
322 |
|
|
323 |
|
dout << endl << endl << "Final selection efficiencies with total statistical and systematic errors, and corresponding observed and expected upper limits (UL) on ($\\sigma\\times$ BR $\\times$ acceptance) for the LM4 and LM8 scenarios, in the different regions. The last column contains the predicted ($\\sigma \\times $BR$\\times$ acceptance) at NLO obtained from Monte Carlo simulation." << endl; |
324 |
< |
dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t Prediction [pb]" << endl; |
324 |
> |
dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t \\sigma [pb]" << endl; |
325 |
|
for(int icut=0;icut<jzbcuts.size();icut++) { |
326 |
< |
dout << "Region with JZB>" << jzbcuts[icut] << endl; |
326 |
> |
dout << "Region with JZB>" << jzbcuts[icut] << (ConsiderSignalContaminationForLimits?" (accounting for signal contamination)":" (not accounting for signal contamination)") << endl; |
327 |
|
for(int isample=0;isample<signalsamples.collection.size();isample++) { |
328 |
< |
dout << limits[icut][0] << "\t" << Round(100*uncertainties[isample*jzbcuts.size()+icut][1],1) << "+/-" << Round(100*uncertainties[isample*jzbcuts.size()+icut][2],1) << " (stat) +/- " << Round(100*uncertainties[isample*jzbcuts.size()+icut][3],1) << " (syst) \t" << Round((vlimits[isample][2*icut]),3) << "\t" << Round(vlimits[isample][2*icut+1],3) << endl; |
328 |
> |
dout << limits[isample][0] << "\t" << Round(100*uncertainties[isample*jzbcuts.size()+icut][1],3) << "+/-" << Round(100*uncertainties[isample*jzbcuts.size()+icut][2],3) << " (stat) +/- " << Round(100*uncertainties[isample*jzbcuts.size()+icut][3],3) << " (syst) \t" << Round((vlimits[isample][2*icut]),3) << "\t" << Round(vlimits[isample][2*icut+1],3) << endl; |
329 |
|
} |
330 |
|
dout << endl; |
331 |
|
} |
332 |
|
|
333 |
< |
write_warning("compute_upper_limits_from_counting_experiment","Still need to update the script"); |
333 |
> |
write_warning(__FUNCTION__,"Still need to update the script"); |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
< |
//********************************************************************** new : Limits using SHAPES *********************************** |
338 |
> |
/********************************************************************** new : Limits using SHAPES *********************************** |
339 |
> |
|
340 |
> |
|
341 |
> |
SSSSSSSSSSSSSSS hhhhhhh |
342 |
> |
SS:::::::::::::::Sh:::::h |
343 |
> |
S:::::SSSSSS::::::Sh:::::h |
344 |
> |
S:::::S SSSSSSSh:::::h |
345 |
> |
S:::::S h::::h hhhhh aaaaaaaaaaaaa ppppp ppppppppp eeeeeeeeeeee ssssssssss |
346 |
> |
S:::::S h::::hh:::::hhh a::::::::::::a p::::ppp:::::::::p ee::::::::::::ee ss::::::::::s |
347 |
> |
S::::SSSS h::::::::::::::hh aaaaaaaaa:::::ap:::::::::::::::::p e::::::eeeee:::::eess:::::::::::::s |
348 |
> |
SS::::::SSSSS h:::::::hhh::::::h a::::app::::::ppppp::::::pe::::::e e:::::es::::::ssss:::::s |
349 |
> |
SSS::::::::SS h::::::h h::::::h aaaaaaa:::::a p:::::p p:::::pe:::::::eeeee::::::e s:::::s ssssss |
350 |
> |
SSSSSS::::S h:::::h h:::::h aa::::::::::::a p:::::p p:::::pe:::::::::::::::::e s::::::s |
351 |
> |
S:::::S h:::::h h:::::h a::::aaaa::::::a p:::::p p:::::pe::::::eeeeeeeeeee s::::::s |
352 |
> |
S:::::S h:::::h h:::::ha::::a a:::::a p:::::p p::::::pe:::::::e ssssss s:::::s |
353 |
> |
SSSSSSS S:::::S h:::::h h:::::ha::::a a:::::a p:::::ppppp:::::::pe::::::::e s:::::ssss::::::s |
354 |
> |
S::::::SSSSSS:::::S h:::::h h:::::ha:::::aaaa::::::a p::::::::::::::::p e::::::::eeeeeeee s::::::::::::::s |
355 |
> |
S:::::::::::::::SS h:::::h h:::::h a::::::::::aa:::ap::::::::::::::pp ee:::::::::::::e s:::::::::::ss |
356 |
> |
SSSSSSSSSSSSSSS hhhhhhh hhhhhhh aaaaaaaaaa aaaap::::::pppppppp eeeeeeeeeeeeee sssssssssss |
357 |
> |
p:::::p |
358 |
> |
p:::::p |
359 |
> |
p:::::::p |
360 |
> |
p:::::::p |
361 |
> |
p:::::::p |
362 |
> |
ppppppppp |
363 |
> |
|
364 |
> |
|
365 |
> |
*********************************************************************** new : Limits using SHAPES ***********************************/ |
366 |
> |
|
367 |
|
|
368 |
|
void limit_shapes_for_systematic_effect(TFile *limfile, string identifier, string mcjzb, string datajzb, int JES,vector<float> binning, TCanvas *limcan) { |
369 |
|
dout << "Creatig shape templates ... "; |
509 |
|
limfile->Close(); |
510 |
|
write_info("prepare_limits","limitfile.root and datacard.txt have been generated. You can now use them to calculate limits!"); |
511 |
|
|
512 |
< |
} |
512 |
> |
} |