Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
JNs.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <cmath>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TH1D.h"
9
10#include "JLang/JManip.hh"
12
13#include "Jeep/JParser.hh"
14
15
16/**
17 * Auxiliary program to determine number of signal events for given background and number of standard deviations.
18 */
19int main(int argc, char* argv[])
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
I/O manipulators.
Auxiliary methods for mathematics.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
int main(int argc, char *argv[])
Auxiliary program to determine number of signal events for given background and number of standard de...
Definition JNs.cc:19
Utility class to parse command line options.
#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
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488