Jpp 20.0.0-rc.6
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 "JGizmo/JGizmoToolkit.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 119 of file JRealExperiment.cc.

120{
121 using namespace std;
122 using namespace JPP;
123
125 double SNR;
126 int debug;
127
128 try {
129
130 JParser<> zap;
131
132 zap['E'] = make_field(setup,
133 "triplets of data, signal and background histograms, "\
134 "each of which defined by <file name>:<histogram name>");
135 zap['R'] = make_field(SNR, "signal-to-noise ratio") = 0.0;
136 zap['d'] = make_field(debug) = 1;
137
138 zap(argc, argv);
139 }
140 catch(const exception& error) {
141 FATAL(error.what() << endl);
142 }
143
144
145 JExperiment::setSNR(SNR);
146
148
149 for (const auto& i : setup) {
150
151 const TObject* pd = getObject(i.Hd);
152 const TObject* ps = getObject(i.Hs);
153 const TObject* pb = getObject(i.Hb);
154
155 STATUS(printer("Data:", pd) << endl);
156 STATUS(printer("Signal:", ps) << endl);
157 STATUS(printer("Background:", pb) << endl);
158
159 rx.add(pd, ps, pb);
160 }
161
162
163 const JRealExperiment::fit_type result = rx();
164
165
166 cout << "signal: " << FIXED(9,3) << rx.getSignal() << "/" << setw(6) << rx.size() << endl;
167 cout << "derivative: " << FIXED(9,3) << rx.getDerivative(0.0) << endl;
168
169 if (debug >= debug_t) {
170
171 size_t n = 0;
172
173 for (double x : rx) {
174
175 cout << SCIENTIFIC(12,3) << 1.0/x << ((n + 1)%10 == 0 ? "\n" : " ");
176
177 n += 1;
178 }
179 cout << endl;
180 }
181
182 cout << "result: "
183 << FIXED(12,5) << result.likelihood << ' '
184 << FIXED(12,5) << result.signal << endl;
185}
#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
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 data structure for floating point format specification.
Definition JManip.hh:488