Tests the statistical compatibility of two ROOT 2D histograms.
47 {
50
51 const TH1* h1 = dynamic_cast<const TH1*>(o1);
52 const TH1* h2 = dynamic_cast<const TH1*>(o2);
53
54 if (h1 == NULL || h2 == NULL) {
56 }
57
58 const int nx1 = h1->GetNbinsX();
59 const int nx2 = h2->GetNbinsX();
60 const int ny1 = h1->GetNbinsY();
61 const int ny2 = h2->GetNbinsY();
62 const int nz1 = h1->GetNbinsZ();
63 const int nz2 = h2->GetNbinsZ();
64
65 const double M = h1->GetSumOfWeights();
66 const double N = h2->GetSumOfWeights();
67
68 if(nx1 != nx2 || ny1 != ny2 || nz1 != nz2 || M == 0 || N == 0) {
69 THROW(
JValueOutOfRange,
"JTestChi2_t::JChi2TestBin_2D(): Histograms with different binning or with zero entries.");
70 }
71
72 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
75
76 h3->Reset();
77
78 double outliers = 0;
79
80 for (int i=1 ; i<nx1 ; ++i) {
81 for (
int j=1 ;
j<ny1 ; ++
j) {
82 for (int k=1 ; k<nz1 ; ++k) {
83
84 const double m = h1->GetBinContent(i,j,k);
85 const double n = h2->GetBinContent(i,j,k);
86
87 const double em = h1->GetBinError(i,j,k);
88 const double en = h2->GetBinError(i,j,k);
89
90 if (n > 0.0 && m > 0.0 && em > 0.0 && en > 0.0) {
91
92 const double delta = N*m - M*
n;
93 const double sigma = M*M*en*en + N*N*em*em;
94 const double chi2 = delta*delta /
sigma;
95
97 outliers += 1./(nx1*ny1);
98 }
99
100 h3->SetBinContent(i,j,k,chi2);
101 }
102 }
103 }
104 }
105
107
109
110 h3->SetTitle(title.getTitle().c_str());
111
112 const int Ndims = h3->GetDimension();
113
114 if (Ndims == 1) {
116 } else if (Ndims == 2) {
118 }
119
124
125 this->push_back(r);
126 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
#define MAKE_STRING(A)
Make string.
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
double outliersThreshold
fraction of bins allowed to fail the test.
double chi2Threshold
threshold chi2-value to decide if test is passed for a bin.
const std::string resultType
test result type
const std::string testName
test name
Auxiliary class to handle file name, ROOT directory and object name.
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Structure containing the result of the test.