139 size_t numberOfTests;
157 "douplets of signal and background histograms, "
158 <<
"each of which defined by <file name>:<histogram name>");
160 zap[
'n'] =
make_field(numberOfTests,
"number of tests");
162 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
163 zap[
'B'] =
make_field(boost,
"boost livetime of experiment") = 1.0;
164 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
165 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
166 zap[
'A'] =
make_field(add,
"add remnant signal and noise");
168 "signal and background nuisances, "
169 <<
"each of which defined by <type> (values), \n"
171 zap[
'x'] =
make_field(X,
"x-axis likelihood histogram") = histogram_type(110, -10.0, +100.0);
172 zap[
'Q'] =
make_field(Q,
"minimal likelihood ratio") = 0.0;
179 catch(
const exception& error) {
180 FATAL(error.what() << endl);
186 JExperiment::setSNR(SNR);
188 for (
const auto& i : setup) {
193 dynamic_cast<TH1*
>(ps)->Scale(boost);
194 dynamic_cast<TH1*
>(pb)->Scale(boost);
196 STATUS(printer(
"Signal:", ps) << endl);
197 STATUS(printer(
"Background:", pb) << endl);
214 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
221 TH1D hl(
"hl", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
222 TH1D hn(
"hn", NULL, 100, -15.0, +15.0);
234 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
239 const size_t n = p * numberOfTests;
253 for (
size_t i = 0; i != n; ++i) {
254 storage.
put(px(nb).likelihood);
260 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
262 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
263 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
266 STATUS(
"Poisson: " << setw(3) << mb <<
' ' <<
SCIENTIFIC(12,3) << Ps <<
' ' << setw(8) << storage.size() << endl);
268 storage([&hl](
const data_type x) { hl.Fill(x); });
274 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
279 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
281 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::nanoseconds(1) <<
" [ns]" << endl);
284 cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) << x <<
' ' <<
SCIENTIFIC(12,3) << p << endl;
286 }
else if (P.size() > 0 && Q > 0.0) {
288 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
290 const double signal = discovery<float, 100>(px, Q, P[0], numberOfTests);
292 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
294 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
296 cout <<
"Signal strength: " <<
FIXED(9,5) << signal << endl;
298 }
else if (P.size() > 0 || Q > 0.0) {
303 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
305 for (
size_t i = 0; i != numberOfTests; ++i) {
306 storage.
put(px().likelihood);
309 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
311 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
312 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
315 storage([&hl](
const data_type x) { hl.Fill(x); });
321 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
333 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
335 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::microseconds(1) <<
" [us]" << endl);
338 if (P.size() == 1) { cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) << x <<
' ' <<
SCIENTIFIC(12,3) << p << endl; }
339 if (Q > 0.0) { cout <<
"Maximal probability: " <<
SCIENTIFIC(12,3) << p <<
' ' <<
FIXED(9,5) << x << endl; }
345 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
349 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
351 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(storage.size()) <<
" [ns]" << endl);
353 for (
const auto& result : storage) {
356 << setw(3) << result.ns <<
' '
357 << setw(3) << result.nb <<
' '
358 <<
FIXED(12,5) << result.likelihood <<
' '
359 <<
FIXED(12,5) << result.signal << endl);
361 hl.Fill(result.likelihood);
362 hn.Fill(result.signal - result.ns);