168 |
|
|
169 |
|
} |
170 |
|
|
171 |
< |
vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, bool doobserved=false) { |
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=1; |
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; |
193 |
|
sigmas.push_back(-1); |
194 |
|
return sigmas; |
195 |
|
} else { |
196 |
< |
dout << "Now calling : CL95(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl; |
196 |
> |
int nlimittoysused=1; |
197 |
> |
if(doobserved) nlimittoysused=nlimittoys; |
198 |
> |
/* dout << "Now calling : CL95(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl; |
199 |
|
sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel); |
200 |
< |
if(doobserved) { |
201 |
< |
dout << "Now calling : CLA(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl; |
202 |
< |
sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel); |
203 |
< |
} |
200 |
> |
*/ |
201 |
> |
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; |
202 |
> |
LimitResult limit = roostats_limit(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,1); |
203 |
> |
|
204 |
|
vector<float> sigmas; |
205 |
+ |
sigmas.push_back(limit.GetExpectedLimit());//expected |
206 |
+ |
sigmas.push_back(limit.GetObservedLimit());//observed |
207 |
+ |
//up to here for backward compatibility |
208 |
+ |
sigmas.push_back(limit.GetOneSigmaHighRange());//expected, up |
209 |
+ |
sigmas.push_back(limit.GetTwoSigmaHighRange());//expected, 2 up |
210 |
+ |
sigmas.push_back(limit.GetOneSigmaLowRange());//expected, down |
211 |
+ |
sigmas.push_back(limit.GetTwoSigmaLowRange());//expected, 2 down |
212 |
+ |
// if(doobserved) { |
213 |
+ |
// dout << "Now calling : CLA(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl; |
214 |
+ |
// sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel); |
215 |
+ |
// } |
216 |
+ |
|
217 |
+ |
/* vector<float> sigmas; |
218 |
|
sigmas.push_back(sigma95); |
219 |
< |
sigmas.push_back(sigma95A); |
219 |
> |
sigmas.push_back(sigma95A);*/ |
220 |
|
return sigmas; |
221 |
+ |
|
222 |
+ |
|
223 |
|
} |
224 |
+ |
write_warning(__FUNCTION__,"STILL MISSING SIGMAS, LIMITS, EVERYTHING ..."); |
225 |
|
} |
226 |
|
|
227 |
|
void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts, string mcjzb, bool doobserved) { |
247 |
|
// 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); |
248 |
|
// observed-=result;//this is the actual excess we see! |
249 |
|
// float expected=observed/luminosity; |
250 |
< |
|
250 |
> |
string plotfilename=(string)(TString(signalsamples.collection[isample].samplename)+TString("___JZB_geq_")+TString(any2string(JZBcutat))); |
251 |
|
dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl; |
252 |
< |
vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,doobserved); |
252 |
> |
vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,plotfilename,doobserved); |
253 |
|
|
254 |
|
if(doobserved) { |
255 |
|
// rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")"); |