136{
139
142
145 size_t numberOfTests;
146 double Fs;
147 double Fb;
148 size_t M;
149 double SNR;
150 histogram_type X;
152 double P;
155
156 try {
157
159
161
163 "douplets of signal and background histograms and doublets of signal and background nuisances, \n"
164 << "\teach of which defined by <file name>:<histogram name> and <type> (values), respectively, \n"
168 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
169 zap[
'n'] =
make_field(numberOfTests,
"number of tests");
170 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
171 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
172 zap[
'x'] =
make_field(X,
"x-axis likelihood histogram") = histogram_type(110, -10.0, +100.0);
173 zap[
'Q'] =
make_field(Q,
"minimal likelihood ratio") = 0.0;
174 zap[
'P'] =
make_field(P,
"maximal probability") = 0.0;
177
178 zap(argc, argv);
179 }
180 catch(const exception& error) {
181 FATAL(error.what() << endl);
182 }
183
184
185 seed.set(gRandom);
186
187 JExperiment::setSNR(SNR);
188
189
191
192 for (const auto& i : setup) {
193
198
199 STATUS(printer(
"Signal for generation:", pS) << endl);
200 STATUS(printer(
"Background for generation:", pB) << endl);
201 STATUS(printer(
"Signal for evaluation:", ps) << endl);
202 STATUS(printer(
"Background for evaluation:", pb) << endl);
203
205
206 pi.nuisance = i.nuisance;
207
208 px.push_back(pi);
209 }
210
212
213 if (M != 0) {
215 }
216
219 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
220
221
223
224 out << *gRandom;
225
226 TH1D hl("hl", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
227 TH1D hn("hn", NULL, 100, -15.0, +15.0);
228
229
230 if (P > 0.0 && Q > 0.0) {
231
232 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
233
234 const double signal = discovery<float, 100>(px, Q, P, numberOfTests);
235
236 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
237
238 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
239
240 cout <<
"Signal strength: " <<
FIXED(9,5) << signal << endl;
241
242 } else if (P > 0.0 || Q > 0.0) {
243
245
246 {
247 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
248
249 for (size_t i = 0; i != numberOfTests; ++i) {
250 storage.
put(px().likelihood);
251 }
252
253 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
254
255 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
256 }
257
258 storage([&hl](
const data_type x) { hl.Fill(x); });
259
261 double p = 0.0;
262
263 {
264 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
265
266 if (P > 0.0) {
269 }
270
271 if (Q > 0.0) {
274 }
275
276 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
277
278 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::microseconds(1) <<
" [us]" << endl);
279 }
280
281 if (P > 0.0) { cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) <<
x <<
' ' <<
SCIENTIFIC(12,3) << p << endl; }
282 if (Q > 0.0) { cout <<
"Maximal probability: " <<
SCIENTIFIC(12,3) << p <<
' ' <<
FIXED(9,5) <<
x << endl; }
283
284 } else {
285
287
288 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
289
290 px(storage);
291
292 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
293
294 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(storage.size()) <<
" [ns]" << endl);
295
296 for (const auto& result : storage) {
297
299 << setw(3) <<
result.ns <<
' '
300 << setw(3) <<
result.nb <<
' '
303
304 hl.Fill(
result.likelihood);
306 }
307 }
308
309 out.Write();
310 out.Close();
311}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
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).
Auxiliary data structure for floating point format specification.
Auxiliary container for statistical analysis of a large number of positive (or zero) values.
double getProbability(const T value) const
Get maximal probability corresponding given minimal value.
T getValue(const double P) const
Get minimal value corresponding given maximal probability.
void put(const T value)
Add value to container.
Auxiliary data structure to fit signal strength using likelihood ratio for multiple pseudo experiment...
double getSignal() const
Get total signal.
virtual void set(const double fS, const double fB=1.0) override
Set scaling factors of signal and background strengths.
void configure(size_t N)
Configure lookup tables.
double getBackground() const
Get total background.
dictionary_type & getDictionary()
Get dictionary.
Pseudo experiment using CDF for combined generation and likelihood evaluation.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Template definition of random value generator.
Auxiliary data structure for floating point format specification.