1 #ifndef __JCOMPAREHISTOGRAMS__JTESTIDENTICAL__
2 #define __JCOMPAREHISTOGRAMS__JTESTIDENTICAL__
37 JTest_t(
"Identical",
"Difference")
52 const TH1* h1 =
dynamic_cast<const TH1*
>(o1);
53 const TH1* h2 =
dynamic_cast<const TH1*
>(o2);
55 if (h1 == NULL || h2 == NULL) {
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);
66 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
74 double maxDifference = 0.0;
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){
80 const double d = h1->GetBinContent(i,
j,k) - h2->GetBinContent(i,
j,k);
82 if (fabs(d) > maxDifference) { maxDifference = fabs(d); }
83 if (fabs(d) >
tolerance) { passed =
false; }
90 h3->SetTitle(title.
getTitle().c_str());
92 const int Ndims = h3->GetDimension();
96 }
else if (Ndims == 2) {
115 std::istream&
read(std::istream& in)
override
#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...
std::string getTitle() const
Returns a standard string to be used as title of a graphical root object.
Implementation of the a test to check if two 1D histograms are the same.
std::istream & read(std::istream &in) override
Read test parameters from input.
double tolerance
tolerance value to accept the difference as acceptable.
JTestIdentical()
Default constructor.
void test(const TObject *o1, const TObject *o2) override
Applies test for two ROOT TH1 histograms.
Interface to read input and write output for TObject tests.
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.