Jpp 20.0.0-rc.8
the software that should make you happy
Loading...
Searching...
No Matches
JRealExperiment.cc File Reference

Test application for pseudo experiment generation and likelihood ratio evaluations. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <exception>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TH3D.h"
#include "TRandom3.h"
#include "JAstronomy/JRealExperiment.hh"
#include "JAstronomy/JPseudoExperiment.hh"
#include "JAstronomy/JAstronomyToolkit.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JContainer.hh"
#include "Jeep/JParser.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Test application for pseudo experiment generation and likelihood ratio evaluations.

Author
mdejong

Definition in file JRealExperiment.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 124 of file JRealExperiment.cc.

125{
126 using namespace std;
127 using namespace JPP;
128
130 size_t numberOfTests;
131 double SNR;
132 int debug;
133
134 try {
135
136 JParser<> zap;
137
138 zap['E'] = make_field(setup,
139 "triplets of data, signal and background histograms, "\
140 "each of which defined by <file name>:<histogram name>");
141 zap['n'] = make_field(numberOfTests, "number of tests for upper limit calculation") = 0;
142 zap['R'] = make_field(SNR, "signal-to-noise ratio") = 0.0;
143 zap['d'] = make_field(debug) = 1;
144
145 zap(argc, argv);
146 }
147 catch(const exception& error) {
148 FATAL(error.what() << endl);
149 }
150
151
152 JExperiment::setSNR(SNR);
153
156
157 for (const auto& i : setup) {
158
159 const TObject* pd = getObject(i.Hd);
160 const TObject* ps = getObject(i.Hs);
161 const TObject* pb = getObject(i.Hb);
162
163 STATUS(printer("Data:", pd) << endl);
164 STATUS(printer("Signal:", ps) << endl);
165 STATUS(printer("Background:", pb) << endl);
166
167 rx.add(pd, ps, pb);
168 px.add(ps, pb);
169 }
170
171
172 const JRealExperiment::fit_type result = rx();
173
174
175 cout << "signal: " << FIXED(9,3) << rx.getSignal() << "/" << setw(6) << rx.size() << endl;
176 cout << "derivative: " << FIXED(9,3) << rx.getDerivative(0.0) << endl;
177
178 if (debug >= debug_t) {
179
180 size_t n = 0;
181
182 for (double x : rx) {
183
184 cout << SCIENTIFIC(12,3) << 1.0/x << ((n + 1)%10 == 0 ? "\n" : " ");
185
186 n += 1;
187 }
188 cout << endl;
189 }
190
191 cout << "result: "
192 << FIXED(12,5) << result.likelihood << ' '
193 << FIXED(12,5) << result.signal << endl;
194
195 if (numberOfTests != 0) {
196
197 const double Q = 0.9; // probability limit
198
199 const double mu = px.getSignalStrengthForUpperLimit(rx, Q, numberOfTests);
200
201 cout << "upper limit: " << FIXED(12,5) << mu << endl;
202 }
203}
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
double getSignal() const
Get total signal strength.
Definition JAspera.hh:236
double getDerivative(const double p) const
Get derivative of likelihood for given signal strength.
Definition JAspera.hh:96
double getSignalStrengthForUpperLimit(const JAspera &aspera, const double Q, const size_t numberOfTests, const double precision=1.0e-4)
Get signal strength given result of experiment and probability of upper limit.
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.
Real experiment using PDF of signal and background.
void add(const TObject *pd, const TObject *ps, const TObject *pb)
Add objects with data and PDFs of signal and background.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition JContainer.hh:42
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488