34 struct experiment_type {
50 friend inline std::istream&
operator>>(std::istream& in, experiment_type& experiment)
52 return in >> experiment.HS
56 >> experiment.nuisance;
67 friend inline std::ostream&
operator<<(std::ostream& out,
const experiment_type& experiment)
69 return out << experiment.HS <<
' '
70 << experiment.HB <<
' '
71 << experiment.Hs <<
' '
72 << experiment.Hb <<
' '
73 << experiment.nuisance;
88 printer(
const char*
const title,
101 friend inline std::ostream&
operator<<(std::ostream& out,
const printer& printer)
106 out << setw(16) << left << printer.title << right;
108 if (printer.ps != NULL) {
110 out <<
' ' << setw(16) << left << printer.ps->GetName() << right;
112 const TH1* h1 =
dynamic_cast<const TH1*
>(printer.ps);
115 out <<
' ' <<
FIXED(10,3) << h1->GetSumOfWeights();
123 const char*
const title;
145 size_t numberOfTests;
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;
180 catch(
const exception& error) {
181 FATAL(error.what() << endl);
187 JExperiment::setSNR(SNR);
192 for (
const auto& i : setup) {
194 const TObject* pS = getObject(i.HS);
195 const TObject* pB = getObject(i.HB);
196 const TObject* ps = getObject(i.Hs);
197 const TObject* pb = getObject(i.Hb);
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);
219 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
226 TH1D hl(
"hl", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
227 TH1D hn(
"hn", NULL, 100, -15.0, +15.0);
230 if (P > 0.0 && Q > 0.0) {
232 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
234 const double signal = discovery<float, 100>(px, Q, P, numberOfTests);
236 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
238 STATUS(
"Total time: " << setw(8) << (t1 - t0) / chrono::milliseconds(1) <<
" [ms]" << endl);
240 cout <<
"Signal strength: " <<
FIXED(9,5) << signal << endl;
242 }
else if (P > 0.0 || Q > 0.0) {
247 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
249 for (
size_t i = 0; i != numberOfTests; ++i) {
250 storage.
put(px().likelihood);
253 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
255 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
258 storage([&hl](
const data_type x) { hl.Fill(x); });
264 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
276 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
278 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::microseconds(1) <<
" [us]" << endl);
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; }
288 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
292 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
294 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(storage.size()) <<
" [ns]" << endl);
296 for (
const auto& result : storage) {
299 << setw(3) << result.ns <<
' '
300 << setw(3) << result.nb <<
' '
301 <<
FIXED(12,5) << result.likelihood <<
' '
302 <<
FIXED(12,5) << result.signal << endl);
304 hl.Fill(result.likelihood);
305 hn.Fill(result.signal - result.ns);
int main(int argc, char **argv)
Set of pseudo experments.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
#define DEBUG(A)
Message macros.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Auxiliary class to handle file name, ROOT directory and object name.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.
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.