33 struct experiment_type {
49 friend inline std::istream&
operator>>(std::istream& in, experiment_type& experiment)
51 return in >> experiment.HS
55 >> experiment.nuisance;
66 friend inline std::ostream&
operator<<(std::ostream& out,
const experiment_type& experiment)
68 return out << experiment.HS <<
' '
69 << experiment.HB <<
' '
70 << experiment.Hs <<
' '
71 << experiment.Hb <<
' '
72 << experiment.nuisance;
87 printer(
const char*
const title,
100 friend inline std::ostream&
operator<<(std::ostream& out,
const printer& printer)
105 out << setw(16) << left << printer.title << right;
107 if (printer.ps != NULL) {
109 out <<
' ' << setw(16) << left << printer.ps->GetName() << right;
111 const TH1* h1 =
dynamic_cast<const TH1*
>(printer.ps);
114 out <<
' ' <<
FIXED(10,3) << h1->GetSumOfWeights();
122 const char*
const title;
144 size_t numberOfTests;
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;
175 catch(
const exception& error) {
176 FATAL(error.what() << endl);
185 for (
const auto& i : setup) {
187 const TObject* pS = getObject(i.HS);
188 const TObject* pB = getObject(i.HB);
189 const TObject* ps = getObject(i.Hs);
190 const TObject* pb = getObject(i.Hb);
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);
208 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
215 TH1D hl(
"hl", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
216 TH1D hn(
"hn", NULL, 100, -15.0, +15.0);
219 if (P > 0.0 || Q > 0.0) {
224 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
226 for (
size_t i = 0; i != numberOfTests; ++i) {
227 storage.
put(px().likelihood);
230 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
232 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(numberOfTests) <<
" [ns]" << endl);
235 for (
const auto& result : storage) {
236 for (
const auto x : result.second) {
241 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
245 const double x = storage.
getValue(P);
248 cout <<
"Minimal likelihood ratio: " <<
FIXED(9,5) << x <<
' ' <<
SCIENTIFIC(12,3) << p << endl;
254 const double x = storage.
getValue(p);
256 cout <<
"Maximal probability: " <<
SCIENTIFIC(12,3) << p <<
' ' <<
FIXED(9,5) << x << endl;
259 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
261 STATUS(
"Time to result: " << setw(6) << (t1 - t0) / chrono::microseconds(1) <<
" [us]" << endl);
267 const chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();
271 const chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
273 STATUS(
"Average time: " << setw(6) << (t1 - t0) / chrono::nanoseconds(storage.size()) <<
" [ns]" << endl);
275 for (
const auto& result : storage) {
278 << setw(3) << result.ns <<
' '
279 << setw(3) << result.nb <<
' '
280 <<
FIXED(12,5) << result.likelihood <<
' '
281 <<
FIXED(12,5) << result.signal << endl);
283 hl.Fill(result.likelihood);
284 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 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.
double getProbability(const double value) const
Get maximal probability corresponding given minimal value.
void put(const T value)
Add value to container.
T getValue(const double P) const
Get minimal value corresponding given maximal probability.
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.