Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
JNs.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JLang/JManip.hh"
#include "JMath/JMathSupportkit.hh"
#include "Jeep/JParser.hh"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 Auxiliary program to determine number of signal events for given background and number of standard deviations.
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Auxiliary program to determine number of signal events for given background and number of standard deviations.

Definition at line 19 of file JNs.cc.

20{
21 using namespace std;
22 using namespace JPP;
23
24 string outputFile;
25 double stdev;
26 double precision;
27 int debug;
28
29 try {
30
31 JParser<> zap("Auxiliary program to determine number of signal events for given background and number of standard deviations.");
32
33 zap['o'] = make_field(outputFile) = "poisson.root";
34 zap['s'] = make_field(stdev);
35 zap['p'] = make_field(precision);
36 zap['d'] = make_field(debug) = 2;
37
38 zap(argc, argv);
39 }
40 catch(const exception &error) {
41 FATAL(error.what() << endl);
42 }
43
44
45 const double STDEV_MIN = 1.0;
46 const double STDEV_MAX = 7.0;
47
48 if (stdev < STDEV_MIN || stdev > STDEV_MAX) {
49 FATAL("Number of standard deviations out of range [" << STDEV_MIN << "," << STDEV_MAX << "]" << endl);
50 }
51
52 const double P = getP(stdev);
53
54 cout << "probability (single-sided Gauss): " << SCIENTIFIC(12,3) << P << endl;
55
56
57 TFile out(outputFile.c_str(), "recreate");
58
59 TH1D h0("h0", NULL, 500, -2.0, 2.0);
60 TH1D h1("h1", NULL, 500, -2.0, 2.0);
61
62 for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
63
64 const double x = pow(10.0, h1.GetXaxis()->GetBinCenter(ix));
65
66 const size_t n = getNs(x, P);
67 const double f = getFs(x, P, precision);
68
69 DEBUG(" x = " << FIXED(7,3) << x
70 << " n = " << FIXED(7,3) << n - x
71 << " f = " << FIXED(7,3) << f - x << endl);
72
73 h0.SetBinContent(ix, n - x);
74 h1.SetBinContent(ix, f - x);
75 }
76
77 out.Write();
78 out.Close();
79}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#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
double getP(const double expval, bool hit)
Get Poisson probability to observe a hit or not for given expectation value for the number of hits.
size_t getNs(const double background, const double P)
Get minimal number of events to exceed Poisson probability given number of background events.
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
double getFs(const double background, const double P, const double precision)
Get minimal number of events to exceed Poisson probability given number of background events.
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
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488