Bin-by-bin comparison for ROOT histograms, of compatibility with a Poisson pdf of parameter 1.
64 {
67
68 const TH1* h1 = dynamic_cast<const TH1*>(o1);
69 const TH1* h2 = dynamic_cast<const TH1*>(o2);
70
71 if (h1 == NULL || h2 == NULL) {
73 }
74
75 const int nx1 = h1->GetNbinsX();
76 const int nx2 = h2->GetNbinsX();
77 const int ny1 = h1->GetNbinsY();
78 const int ny2 = h2->GetNbinsY();
79 const int nz1 = h1->GetNbinsZ();
80 const int nz2 = h2->GetNbinsZ();
81
82 if(nx1 != nx2 || ny1 != ny2 || nz1 != nz2) {
84 h1->GetName() << " and " << h2->GetName() << " can not be compared." << endl);
85 }
86
87 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
90
91 h3->Reset();
92
93 double failures = 0;
94
95 for (int i=1 ; i<nx1+1 ; ++i) {
96 for (
int j=1 ;
j<ny1+1 ; ++
j) {
97 for (int k=1 ; k<nz1+1 ; ++k) {
98
99 const int Nbin = h3->GetBin(i,j,k);
100
101 const double m = h1->GetBinContent(i,j,k);
102 const double n = h2->GetBinContent(i,j,k);
103
104 const double p1 = 1 - ROOT::Math::poisson_cdf(m,1);
105 const double p2 = 1 - ROOT::Math::poisson_cdf(n,1);
106
109
110 failures+=1./(nx1*ny1);
111 h3->Fill(Nbin);
112 }
113 }
114 }
115 }
116
118
120
121 h3->SetTitle(title.getTitle().c_str());
122
123 const int Ndims = h3->GetDimension();
124
125 if (Ndims == 1) {
127 } else if (Ndims == 2) {
129 }
130
135
136 this->push_back(r);
137 }
#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.
double threshold
threshold p-value to decide if test is passed.
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.