135{
138
141
144 size_t numberOfTests;
145 double Fs;
146 double Fb;
147 histogram_type X;
149 double P;
152
153 try {
154
156
158
160 "douplets of signal and background histograms and doublets of signal and background nuisances, \n"
161 << "\teach of which defined by <file name>:<histogram name> and <type> (values), respectively, \n"
165 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
166 zap[
'n'] =
make_field(numberOfTests,
"number of tests");
167 zap[
'x'] =
make_field(X,
"x-axis likelihood histogram") = histogram_type(110, -10.0, +100.0);
168 zap[
'Q'] =
make_field(Q,
"minimal likelihood ratio") = 0.0;
169 zap[
'P'] =
make_field(P,
"maximal probability") = 0.0;
172
173 zap(argc, argv);
174 }
175 catch(const exception& error) {
176 FATAL(error.what() << endl);
177 }
178
179
180 seed.set(gRandom);
181
182
184
185 for (const auto& i : setup) {
186
191
192 STATUS(printer(
"Signal for generation:", pS) << endl);
193 STATUS(printer(
"Background for generation:", pB) << endl);
194 STATUS(printer(
"Signal for evaluation:", ps) << endl);
195 STATUS(printer(
"Background for evaluation:", pb) << endl);
196
198
199 pi.nuisance = i.nuisance;
200
201 px.push_back(pi);
202 }
203
205
208 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
209
210
212
213 out << *gRandom;
214
215 TH1D hl("hl", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
216 TH1D hn("hn", NULL, 100, -15.0, +15.0);
217
218
219 if (P > 0.0 || Q > 0.0) {
220
222
223 {
224 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
225
226 for (size_t i = 0; i != numberOfTests; ++i) {
227 storage.put(px().likelihood);
228 }
229
230 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
231
232 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
233 }
234
235 for (const auto& result : storage) {
236 for (
const auto x :
result.second) {
237 hl.Fill(x);
238 }
239 }
240
241 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
242
243 if (P > 0.0) {
244
245 const double x = storage.getValue(P);
246 const double p = storage.getProbability(x);
247
248 cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) <<
x <<
' ' <<
SCIENTIFIC(12,3) << p << endl;
249 }
250
251 if (Q > 0.0) {
252
253 const double p = storage.getProbability(Q);
254 const double x = storage.getValue(p);
255
256 cout <<
"Maximal probability: " <<
SCIENTIFIC(12,3) << p <<
' ' <<
FIXED(9,5) <<
x << endl;
257 }
258
259 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
260
261 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::microseconds(1) <<
" [us]" << endl);
262
263 } else {
264
266
267 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
268
269 px(storage);
270
271 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
272
273 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(storage.size()) <<
" [ns]" << endl);
274
275 for (const auto& result : storage) {
276
278 << setw(3) <<
result.ns <<
' '
279 << setw(3) <<
result.nb <<
' '
282
283 hl.Fill(
result.likelihood);
285 }
286 }
287
288 out.Write();
289 out.Close();
290}
#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 data structure to fit signal strength using likelihood ratio for multiple pseudo experiment...
void set(const double fS, const double fB)
Set scaling factors of signal and background strengths.
double getSignal() const
Get total signal.
double getBackground() const
Get total background.
const dictionary_type & getDictionary() const
Get dictionary.
Pseudo experiment using CDF for combined generation and likelihood evaluation.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
Auxiliary container for statistical analysis of a large number of values.
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.