Jpp
16.0.0-rc.1
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JGizmo
JTestChi2.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
6
#include "TROOT.h"
7
#include "TFile.h"
8
#include "TH1.h"
9
#include "TProfile.h"
10
11
#include "
JGizmo/JRootObjectID.hh
"
12
#include "
JGizmo/JGizmoToolkit.hh
"
13
14
#include "
Jeep/JParser.hh
"
15
#include "
Jeep/JMessage.hh
"
16
17
18
/**
19
* \file
20
* Auxiliary program for chi2 test of 1D histograms.
21
* \author mdejong
22
*/
23
int
main
(
int
argc,
char
**argv)
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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JGIZMO::getObject
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
Definition:
JGizmoToolkit.hh:156
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
TObject
Definition:
JRoot.hh:19
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
JTOOLS::result
return result
Definition:
JPolint.hh:743
NOTICE
#define NOTICE(A)
Definition:
JMessage.hh:64
JGizmoToolkit.hh
debug
int debug
debug level
Definition:
JSirene.cc:63
JRootObjectID.hh
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
P
then $DIR JPlotNPE PDG P
Definition:
JPlotNPE-PDG.sh:62
Generated by
1.8.5