180{
183
185
189 size_t numberOfTests;
190 double Fs;
191 double Fb;
192 size_t M;
193 double SNR;
194 histogram_type X;
197
198 try {
199
202
204 "inputs for 1st data period: signal and background histograms for generation and evaluation,\n"
205 << "\texposure boost, and signal and background nuisances, provided as\n"
206 << "\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"
208 << "\t Can be called repeatedly to add multiple datasets to this period");
210 "inputs for 2nd data period: signal and background histograms for generation and evaluation,\n"
211 << "\texposure boost, and signal and background nuisances, provided as\n"
212 << "\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"
214 << "\t Can be called repeatedly to add multiple datasets to this period");
217 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
218 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
219 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
220 zap[
'n'] =
make_field(numberOfTests,
"number of tests / PEs");
221 zap[
'x'] =
make_field(X,
"x-axis for likelihood histogram") = histogram_type(200, 0, +20.0);
224
225 zap(argc, argv);
226 }
227 catch(const exception& error) {
228 FATAL(error.what() << endl);
229 }
230
231
232 seed.set(gRandom);
233 JExperiment::setSNR(SNR);
234
235
236 cout << "**Setting up 1st period**" << endl;
237 experiment_group pxg_1(setup_vec1, Fs, Fb, M);
238 cout << "**Setting up 2nd period**" << endl;
239 experiment_group pxg_2(setup_vec2, Fs, Fb, M);
240
242
243 TH2D h2d_nllr("h2d_nllr", "Negative Log-Likelihood Ratio; NLLR 1st period; NLLR total",
244 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
245 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
246 TH2D h2d_nllr_constr("h2d_nllr_constr", "Negative Log-Likelihood Ratio (filtered); NLLR 1st period; NLLR total",
247 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
248 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
249
250 size_t nexp_passfilter = 0;
251 for (size_t nexp =0; nexp != numberOfTests; ++nexp) {
252 if (nexp%100000 == 0) {
253 cout << "Done " << nexp << " pseudo-experiments out of " << numberOfTests << endl;
254 }
255
259
260 for (
const auto& px : pxg_1.px_vec) { px.
run(aspera); }
261 result_1 = aspera();
262
263 for (
const auto& px : pxg_2.px_vec) { px.
run(aspera); }
264 result_A = aspera();
265
268 if (NLLR_1 < 0) {
269 NLLR_1 = 0;
270 }
271 if (NLLR_A < 0) {
272 NLLR_A = 0;
273 }
274
275 h2d_nllr.Fill(NLLR_1, NLLR_A, 1./numberOfTests);
276 if( result_1.
signal * pxg_1.signal_weight > 1) {
277 nexp_passfilter++;
278 h2d_nllr_constr.Fill(NLLR_1, NLLR_A, 1./numberOfTests);
279 }
280
281 }
282
283 cout << nexp_passfilter << " PEs pass the first period filter, out of " << numberOfTests << endl;
284
285 h2d_nllr.Write();
286 h2d_nllr_constr.Write();
287 out.Write();
288 out.Close();
289}
#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.
dictionary_type & getDictionary()
Get dictionary.
Pseudo experiment using CDF for combined generation and likelihood evaluation.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
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.