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;
144 size_t numberOfTests;
159 "douplets of signal and background histograms and doublets of signal and background nuisances, \n"
160 <<
"\teach of which defined by <file name>:<histogram name> and <type> (values), respectively, \n"
163 zap[
'n'] =
make_field(numberOfTests,
"number of tests");
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[
'x'] =
make_field(X,
"x-axis likelihood histogram") = histogram_type(100, -1.0e3, +1.0e3);
167 zap[
'p'] =
make_field(precision,
"precision") = 1.0e-4;
173 catch(
const exception& error) {
174 FATAL(error.what() << endl);
180 JExperiment::setSNR(SNR);
182 const double Q = 0.9;
183 const double MUMIN = 1.0e-10;
184 const double MUMAX = 1.0e+10;
185 const size_t N = numberOfTests * 5;
189 for (
const auto& i : setup) {
191 const TObject* pS = getObject(i.HS);
192 const TObject* pB = getObject(i.HB);
193 const TObject* ps = getObject(i.Hs);
194 const TObject* pb = getObject(i.Hb);
196 STATUS(printer(
"Signal for generation:", pS) << endl);
197 STATUS(printer(
"Background for generation:", pB) << endl);
198 STATUS(printer(
"Signal for evaluation:", ps) << endl);
199 STATUS(printer(
"Background for evaluation:", pb) << endl);
214 STATUS(
"Number of tests: " << setw(10) << numberOfTests << endl);
221 TH1D h0(
"h0", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
222 TH1D h1(
"h1", NULL, X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
229 const JPseudoExperiment::h0_type mu_0(px, numberOfTests);
231 for (
const double x : mu_0) {
238 for (
size_t i = 0; i != numberOfTests; ++i) {
240 if ((i*10) < numberOfTests || (i*10)%numberOfTests == 0) {
252 DEBUG(
"pseudo experiment " << setw(3) << aspera.size() <<
' ' <<
FIXED(12,5) << result.signal <<
' ' <<
FIXED(12,5) << result.likelihood << endl);
256 if (mu_0.getFractionBelow(result.signal) > 1.0 - Q) {
262 for ( ; ; mumax *= 2.0) {
272 if (ps < 1.0 - Q || mumax > MUMAX) {
282 for ( ; ; mumin *= 0.5) {
292 if (ps > 1.0 - Q || mumin < MUMIN) {
306 else if (mumax > MUMAX)
312 mu = 0.5 * (mumin + mumax);
322 if (fabs(ps - (1.0 - Q)) <= precision) {
338 for (
const double x : mu_up) {
342 sort(mu_up.begin(), mu_up.end());
344 cout <<
"<mu> " <<
FIXED(7,3) << mu_up[mu_up.size() / 2] << endl;
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.
double getTestStatisticForUpperLimit(const double ps) const
Get test statistic for given signal strength.
Auxiliary data structure to fit signal strength using likelihood ratio for multiple pseudo experiment...
virtual stats_type run(JAspera &out) const
Generate pseudo experiment and transfer S/N 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.
void configure(size_t N)
Configure lookup tables.
double getBackground() const
Get total background.
dictionary_type & getDictionary()
Get dictionary.
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.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
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.