Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTestChi2.cc File Reference

Auxiliary program for chi2 test of 1D histograms. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1.h"
#include "TProfile.h"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program for chi2 test of 1D histograms.

Author
mdejong

Definition in file JTestChi2.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 23 of file JTestChi2.cc.

24{
25 using namespace std;
26 using namespace JPP;
27
28 JRootObjectID inputFileA;
29 JRootObjectID inputFileB;
30 string option;
31 double P;
32 int debug;
33
34 try {
35
36 JParser<> zap("Auxiliary program for chi2 test of 1D histograms.");
37
38 zap['a'] = make_field(inputFileA, "measurement histogram, e.g: <file name>:<object name>");
39 zap['b'] = make_field(inputFileA, "reference histogram, e.g: <file name>:<object name>");
40 zap['O'] = make_field(option) =
41 "UU", "UW", "WW",
42 "UUUF", "UWUF", "WWUF", // with underflows
43 "UUOF", "UWOF", "WWOF", // with overflows
44 "UUUFOF", "UWUFOF", "WWUFOF"; // with underflows and overflows
45 zap['P'] = make_field(P, "minimal p-value") = 0.0;
46 zap['d'] = make_field(debug) = 1;
47
48 zap(argc, argv);
49 }
50 catch(const exception &error) {
51 FATAL(error.what() << endl);
52 }
53
54
55 TObject* ha = getObject(inputFileA);
56 TObject* hb = getObject(inputFileA);
57
58 if (ha == NULL) { FATAL("No object at " << inputFileA << endl); };
59 if (hb == NULL) { FATAL("No object at " << inputFileB << endl); };
60
61 TH1* h1a = NULL;
62 TH1* h1b = NULL;
63
64 if (h1a == NULL && dynamic_cast<TProfile*>(ha) != NULL) { h1a = dynamic_cast<TProfile*>(ha)->ProjectionX(); }
65 if (h1b == NULL && dynamic_cast<TProfile*>(hb) != NULL) { h1b = dynamic_cast<TProfile*>(hb)->ProjectionX(); }
66
67 if (h1a == NULL && dynamic_cast<TH1*>(ha) != NULL) { h1a = dynamic_cast<TH1*>(ha); }
68 if (h1b == NULL && dynamic_cast<TH1*>(hb) != NULL) { h1b = dynamic_cast<TH1*>(hb); }
69
70 if (h1a == NULL) { FATAL("Object at " << inputFileA << " is not TH1." << endl); };
71 if (h1b == NULL) { FATAL("Object at " << inputFileB << " is not TH1." << endl); };
72
73 const Double_t result = h1a->Chi2Test(h1b, option.c_str());
74
75 NOTICE("Result " << result << endl);
76
77 if (P > 0.0) {
78 ASSERT(result >= P);
79 }
80
81 return 0;
82}
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define NOTICE(A)
Definition JMessage.hh:64
#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
Auxiliary class to handle file name, ROOT directory and object name.
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).