Jpp test-rotations-old-57-g407471f53
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 progrom 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 progrom 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 const double STDEV_MIN = 1.0;
45 const double STDEV_MAX = 7.0;
46
47 if (stdev < STDEV_MIN || stdev > STDEV_MAX) {
48 FATAL("Number of standard deviations out of range [" << STDEV_MIN << "," << STDEV_MAX << "]" << endl);
49 }
50
51 const double P = getP(stdev);
52
53 cout << "probability: " << SCIENTIFIC(12,3) << P << endl;
54
55
56 TFile out(outputFile.c_str(), "recreate");
57
58 TH1D h0("h0", NULL, 500, -2.0, 2.0);
59 TH1D h1("h1", NULL, 500, -2.0, 2.0);
60
61 for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
62
63 const double x = pow(10.0, h1.GetXaxis()->GetBinCenter(ix));
64
65 const size_t n = getNs(x, P);
66 const double f = getFs(x, P, precision);
67
68 DEBUG(" x = " << FIXED(7,3) << x
69 << " n = " << FIXED(7,3) << n - x
70 << " f = " << FIXED(7,3) << f - x << endl);
71
72 h1.SetBinContent(ix, n - x);
73 h1.SetBinContent(ix, f - x);
74 }
75
76 out.Write();
77 out.Close();
78}
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 progrom 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