Applies test for two ROOT TH1 histograms.
48 {
51
52 const TH1* h1 = dynamic_cast<const TH1*>(o1);
53 const TH1* h2 = dynamic_cast<const TH1*>(o2);
54
55 if (h1 == NULL || h2 == NULL) {
57 }
58
59 if(h1->GetNbinsX() != h2->GetNbinsX() ||
60 h1->GetNbinsY() != h2->GetNbinsY() ||
61 h1->GetNbinsZ() != h2->GetNbinsZ()) {
63 h1->GetName() << " and " << h2->GetName() << " can not be compared." << endl);
64 }
65
66 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
69
70 h3->Add(h2,-1);
71
72 bool passed = true;
73
74 double maxDifference = 0.0;
75
76 for (int i=1 ; i <= h1->GetNbinsX() && passed ; ++i){
77 for (
int j=1 ;
j <= h1->GetNbinsY() && passed ; ++
j){
78 for (int k=1 ; k <= h1->GetNbinsZ() && passed ; ++k){
79
80 const double d = h1->GetBinContent(i,j,k) - h2->GetBinContent(i,j,k);
81
82 if (fabs(d) > maxDifference) { maxDifference = fabs(d); }
83 if (fabs(d) >
tolerance) { passed =
false; }
84 }
85 }
86 }
87
89
90 h3->SetTitle(title.getTitle().c_str());
91
92 const int Ndims = h3->GetDimension();
93
94 if (Ndims == 1) {
96 } else if (Ndims == 2) {
98 }
99
104
105 this->push_back(r);
106 }
#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 tolerance
tolerance value to accept the difference as acceptable.
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.