139 size_t numberOfTests;
156 "douplets of signal and background histograms, "
157 <<
"each of which defined by <file name>:<histogram name>");
159 zap[
'n'] =
make_field(numberOfTests,
"number of tests");
161 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
162 zap[
'B'] =
make_field(boost,
"boost livetime of experiment") = 1.0;
163 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
164 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
166 "signal and background nuisances, "
167 <<
"each of which defined by <type> (values), \n"
168 <<
"\twhere <type> can be:"
170 zap[
'x'] =
make_field(X,
"x-axis likelihood histogram") = histogram_type(110, -10.0, +100.0);
171 zap[
'Q'] =
make_field(Q,
"minimal likelihood ratio") = 0.0;
178 catch(
const exception& error) {
179 FATAL(error.what() << endl);
185 JExperiment::setSNR(SNR);
187 for (
const auto& i : setup) {
192 dynamic_cast<TH1*
>(ps)->Scale(boost);
193 dynamic_cast<TH1*
>(pb)->Scale(boost);
195 STATUS(printer(
"Signal:", ps) << endl);
196 STATUS(printer(
"Background:", pb) << endl);
209 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
216 TH1D hl(
"hl", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
217 TH1D hn(
"hn", NULL, 100, -15.0, +15.0);
229 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
234 const size_t n = p * numberOfTests;
248 for (
size_t i = 0; i != n; ++i) {
249 storage.
put(px(nb).likelihood);
255 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
257 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
258 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
261 STATUS(
"Poisson: " << setw(3) << mb <<
' ' <<
SCIENTIFIC(12,3) << Ps <<
' ' << setw(8) << storage.size() << endl);
263 storage([&hl](
const data_type x) { hl.Fill(x); });
269 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
274 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
276 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::nanoseconds(1) <<
" [ns]" << endl);
279 cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) << x <<
' ' <<
SCIENTIFIC(12,3) << p << endl;
281 }
else if (P.size() > 0 && Q > 0.0) {
283 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
285 const double signal = discovery<float, 100>(px, Q, P[0], numberOfTests);
287 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
289 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
291 cout <<
"Signal strength: " <<
FIXED(9,5) << signal << endl;
293 }
else if (P.size() > 0 || Q > 0.0) {
298 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
300 for (
size_t i = 0; i != numberOfTests; ++i) {
301 storage.
put(px().likelihood);
304 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
306 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
307 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
310 storage([&hl](
const data_type x) { hl.Fill(x); });
316 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
328 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
330 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::microseconds(1) <<
" [us]" << endl);
333 if (P.size() == 1) { cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) << x <<
' ' <<
SCIENTIFIC(12,3) << p << endl; }
334 if (Q > 0.0) { cout <<
"Maximal probability: " <<
SCIENTIFIC(12,3) << p <<
' ' <<
FIXED(9,5) << x << endl; }
340 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
344 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
346 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(storage.size()) <<
" [ns]" << endl);
348 for (
const auto& result : storage) {
351 << setw(3) << result.ns <<
' '
352 << setw(3) << result.nb <<
' '
353 <<
FIXED(12,5) << result.likelihood <<
' '
354 <<
FIXED(12,5) << result.signal << endl);
356 hl.Fill(result.likelihood);
357 hn.Fill(result.signal - result.ns);