1#ifndef __JCOMPAREHISTOGRAMS__JTESTSLICE2D__
2#define __JCOMPAREHISTOGRAMS__JTESTSLICE2D__
45 mfp1(&TH2::ProjectionX),
46 mfp2(&TH2::ProjectionY),
71 if (h1 == NULL || h2 == NULL) {
80 nSlices1 = h1->GetNbinsX();
81 nSlices2 = h2->GetNbinsX();
85 nSlices1 = h1->GetNbinsY();
86 nSlices2 = h2->GetNbinsY();
89 if (nSlices1 != nSlices2) {
90 THROW(
JValueOutOfRange,
"JTestSlice2D::configure(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared");
106 const char*
const name =
"projection",
107 const Int_t firstBin = 0,
108 const Int_t lastBin = -1,
109 const Option_t* option =
"")
const
113 TH1* hp = (h.*
mfp1)(name, firstBin, lastBin, option);
134 const char*
const name =
"projection",
135 const Int_t firstBin = 0,
136 const Int_t lastBin = -1,
137 const Option_t* option =
"")
const
141 TH1* hp = (h.*
mfp2)(name, firstBin, lastBin, option);
162 const TH2* h1 =
dynamic_cast<const TH2*
>(o1);
163 const TH2* h2 =
dynamic_cast<const TH2*
>(o2);
167 const char*
const h3name = (h1->GetName() == h2->GetName() ?
173 const int nSlices = h3.GetNbinsX();
177 for (
int i=1 ; i<=nSlices ; ++i){
179 const std::string sliceName =
MAKE_STRING(h3.GetName() <<
"_" << to_string(i));
184 if (!(s1.GetSumOfWeights() > 0 && s2.GetSumOfWeights() > 0)) {
continue; }
190 if (!result1D.
passed) nFailures++;
199 h3.SetTitle(title.
getTitle().c_str());
219 std::istream&
read(std::istream& in)
override
229 catch (
const std::exception& error) {
230 THROW(
JValueOutOfRange,
"JTestSlice2D::read(): Could not read 1D test variant parameters due to the following error:" << endl << error.what());
244 mfp1 = &TH2::ProjectionX;
245 mfp2 = &TH2::ProjectionY;
247 mfp1 = &TH2::ProjectionY;
248 mfp2 = &TH2::ProjectionX;
260 typedef TH1D* (TH2::*
pFunction)(
const char*, Int_t, Int_t, Option_t*)
const;
#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.
Abstract base class for 2D slice tests.
void check(const TH1 *h1, const TH1 *h2) const
Check if given input histograms have equal binning.
pFunction mfp1
Pointer to TH2 member method for projections onto the sliced axis.
pFunction mfp2
Pointer to TH2 member method for projections onto the non-sliced axis.
JTestSlice2D(const std::string &testName, const std::string &resultType, JTest_t *p)
Constructor.
TH1 & getProjectionOntoSlicedAxis(const TH2 &h, const char *const name="projection", const Int_t firstBin=0, const Int_t lastBin=-1, const Option_t *option="") const
Get projection of given 2D histogram onto sliced axis.
std::unique_ptr< JTest_t > pTest1D
Unique pointer to 1D test variant.
TH1 & getProjection(const TH2 &h, const char *const name="projection", const Int_t firstBin=0, const Int_t lastBin=-1, const Option_t *option="") const
Get projection of given 2D histogram onto non-sliced axis.
std::istream & read(std::istream &in) override
Read test parameters from input.
char slice
Axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
TH1D *(TH2::*) pFunction(const char *, Int_t, Int_t, Option_t *) const
Type definition of pointer to TH2 member function for projection.
void test(const TObject *o1, const TObject *o2) override
Tests the statistical compatibility of two ROOT TObjects.
double threshold
threshold value to decide if test has passed.
double failuresThreshold
threshold value to decide if test has passed.
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 cast operation.
Exception for null pointer operation.
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.