36 struct experiment_type {
48 friend inline std::istream&
operator>>(std::istream& in, experiment_type& experiment)
50 return in >> experiment.Hs
62 friend inline std::ostream&
operator<<(std::ostream& out,
const experiment_type& experiment)
64 return out << experiment.Hs <<
' '
80 printer(
const char*
const title,
93 friend inline std::ostream&
operator<<(std::ostream& out,
const printer& printer)
98 out << setw(16) << left << printer.title << right;
100 if (printer.ps != NULL) {
102 out <<
' ' << setw(16) << left << printer.ps->GetName() << right;
104 const TH1* h1 =
dynamic_cast<const TH1*
>(printer.ps);
107 out <<
' ' <<
FIXED(10,3) << h1->GetSumOfWeights();
115 const char*
const title;
136 size_t numberOfTests;
150 "douplets of signal and background histograms, "
151 <<
"each of which defined by <file name>:<histogram name>");
153 zap[
'n'] =
make_field(numberOfTests,
"number of tests");
154 zap[
'B'] =
make_field(boost,
"boost livetime of experiment") = 1.0;
155 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
156 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
157 zap[
'x'] =
make_field(X,
"x-axis signal histogram") = histogram_type(100, -1.0e3, +1.0e3);
158 zap[
'p'] =
make_field(precision,
"precision") = 1.0e-4;
164 catch(
const exception& error) {
165 FATAL(error.what() << endl);
171 JExperiment::setSNR(SNR);
173 const double Q = 0.9;
174 const double MUMIN = 1.0e-10;
175 const double MUMAX = 1.0e+10;
176 const size_t N = numberOfTests * 5;
180 for (
const auto& i : setup) {
185 dynamic_cast<TH1*
>(ps)->Scale(boost);
186 dynamic_cast<TH1*
>(pb)->Scale(boost);
188 STATUS(printer(
"Signal:", ps) << endl);
189 STATUS(printer(
"Background:", pb) << endl);
200 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
207 TH1D h0(
"h0", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
208 TH1D h1(
"h1", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
215 const JPseudoExperiment::h0_type mu_0(px, numberOfTests);
217 for (
const double x : mu_0) {
224 for (
size_t i = 0; i != numberOfTests; ++i) {
226 if ((i*10) < numberOfTests || (i*10)%numberOfTests == 0) {
238 DEBUG(
"pseudo experiment " << setw(3) << aspera.size() <<
' ' <<
FIXED(12,5) << result.signal <<
' ' <<
FIXED(12,5) << result.likelihood << endl);
242 if (mu_0.getFractionBelow(result.signal) > 1.0 - Q) {
248 for ( ; ; mumax *= 2.0) {
258 if (ps < 1.0 - Q || mumax > MUMAX) {
268 for ( ; ; mumin *= 0.5) {
278 if (ps > 1.0 - Q || mumin < MUMIN) {
292 else if (mumax > MUMAX)
298 mu = 0.5 * (mumin + mumax);
308 if (fabs(ps - (1.0 - Q)) <= precision) {
324 for (
const double x : mu_up) {
328 sort(mu_up.begin(), mu_up.end());
330 cout <<
"<mu> " <<
FIXED(7,3) << mu_up[mu_up.size() / 2] << endl;
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Auxiliary methods for mathematics.
#define DEBUG(A)
Message macros.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int main(int argc, char **argv)
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
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.
double getTestStatisticForUpperLimit(const double ps) const
Get test statistic for given signal strength.
double getProbabilityForUpperLimit(const double ps, const double ts, const size_t nx) const
Get probability for given pseudo experiment and signal strength to exceed minimal test statistic for ...
Pseudo experiment using CDF for combined generation and likelihood evaluation.
void add(const TObject *ps, const TObject *pb)
Add objects with PDFs of signal and background.
virtual stats_type run(JAspera &out) const
Generate pseudo experiment and transfer values to fit method.
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.
double getBackground() const
Get total background.
void configure(size_t N)
Configure lookup tables.
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.