189{
192
194
198 size_t numberOfTests;
199 double Fs;
200 double Fb;
201 size_t M;
202 double SNR;
203 histogram_type X;
206
207 try {
208
211
213 "inputs for 1st data period: signal and background histograms for generation and evaluation,\n"
214 << "\texposure boost, and signal and background nuisances, provided as\n"
215 << "\t'<file>:<hgen_s name> <file>:<hgen_b name> <file>:<heval_s name> <file>:<heval_b name> <boost> <type_s> (values) <type_b> (values)' \n"
216 <<
"\twhere <type> can be:" <<
get_keys(nuisance_helper) <<
"\n."
217 << "\t Can be called repeatedly to add multiple datasets to this period");
219 "inputs for 2nd data period: signal and background histograms for generation and evaluation,\n"
220 << "\texposure boost, and signal and background nuisances, provided as\n"
221 << "\t'<file>:<hgen_s name> <file>:<hgen_b name> <file>:<heval_s name> <file>:<heval_b name> <boost> <type_s> (values) <type_b> (values)' \n"
222 <<
"\twhere <type> can be:" <<
get_keys(nuisance_helper) <<
"\n."
223 << "\t Can be called repeatedly to add multiple datasets to this period");
226 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
227 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
228 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
229 zap[
'n'] =
make_field(numberOfTests,
"number of tests / PEs");
230 zap[
'x'] =
make_field(X,
"x-axis for likelihood histogram") = histogram_type(200, 0, +20.0);
233
234 zap(argc, argv);
235 }
236 catch(const exception& error) {
237 FATAL(error.what() << endl);
238 }
239
240
241 seed.set(gRandom);
242
243 JExperiment::setSNR(SNR);
244
245 cout << "**Setting up 1st period**" << endl;
246 experiment_group pxg_1(setup_vec1, Fs, Fb, M);
247 cout << "**Setting up 2nd period**" << endl;
248 experiment_group pxg_2(setup_vec2, Fs, Fb, M);
249
251
252 TH2D h2d_nllr("h2d_nllr", "Negative Log-Likelihood Ratio; NLLR 1st period; NLLR total",
253 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
254 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
255 TH2D h2d_nllr_constr("h2d_nllr_constr", "Negative Log-Likelihood Ratio (filtered); NLLR 1st period; NLLR total",
256 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
257 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
258
259 size_t nexp_passfilter = 0;
260
261 for (size_t nexp =0; nexp != numberOfTests; ++nexp) {
262 if (nexp%100000 == 0) {
263 cout << "Done " << nexp << " pseudo-experiments out of " << numberOfTests << endl;
264 }
265
269
270 for (
const auto& px : pxg_1.px_vec) { px.
run(aspera); }
271 result_1 = aspera();
272
273 for (
const auto& px : pxg_2.px_vec) { px.
run(aspera); }
274 result_A = aspera();
275
278
279 if (NLLR_1 < 0) {
280 NLLR_1 = 0;
281 }
282
283 if (NLLR_A < 0) {
284 NLLR_A = 0;
285 }
286
287 h2d_nllr.Fill(NLLR_1, NLLR_A, 1./numberOfTests);
288
289 if( result_1.
signal * pxg_1.signal_weight > 1) {
290 nexp_passfilter++;
291 h2d_nllr_constr.Fill(NLLR_1, NLLR_A, 1./numberOfTests);
292 }
293 }
294
295 cout << nexp_passfilter << " PEs pass the first period filter, out of " << numberOfTests << endl;
296
297 h2d_nllr.Write();
298 h2d_nllr_constr.Write();
299
300 out.Write();
301 out.Close();
302}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double signal
signal strength
double likelihood
likelihood
Auxiliary data structure to fit signal strength using likelihood ratio.
Pseudo experiment using CDF for combined generation and likelihood evaluation.
virtual stats_type run(JAspera &out) const
Generate pseudo experiment and transfer values to fit method.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Template definition of random value generator.