1 #ifndef __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_SLICE2D__
2 #define __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_SLICE2D__
41 JTest_t(
"KS_Slice2D",
"p-Value(KS)")
56 const TH2* h1 =
dynamic_cast<const TH2*
>(o1);
57 const TH2* h2 =
dynamic_cast<const TH2*
>(o2);
59 if (h1 == NULL || h2 == NULL) {
65 const char*
const h3name = (h1->GetName() == h2->GetName() ?
74 const int nSlices1 = h1->GetNbinsX();
75 const int nSlices2 = h2->GetNbinsX();
77 if (nSlices1 != nSlices2) {
78 THROW(
JValueOutOfRange,
"JTestKolmogorov_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
83 h3 = h1->ProjectionX(h3name);
85 for (
int i=1 ; i<=nSlices1 ; ++i) {
89 const TH1* s1 = h1->ProjectionY (sliceName.c_str(),i,i);
90 const TH1* s2 = h2->ProjectionY (sliceName.c_str(),i,i);
92 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
94 const double p = s1 -> KolmogorovTest (s2);
98 h3->SetBinContent(i,p);
103 const int nSlices1 = h1->GetNbinsY();
104 const int nSlices2 = h2->GetNbinsY();
106 if (nSlices1 != nSlices2) {
107 THROW(
JValueOutOfRange,
"JTestKolmogorov_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
112 h3 = h1->ProjectionY(h3name);
114 for (
int i=1 ; i<=nSlices1 ; ++i){
118 const TH1* s1 = h1->ProjectionX (sliceName.c_str(),i,i);
119 const TH1* s2 = h2->ProjectionX (sliceName.c_str(),i,i);
121 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
123 const double p = s1 -> KolmogorovTest (s2);
127 h3->SetBinContent(i,p);
135 h3->SetTitle(title.
getTitle().c_str());
153 std::istream&
read(std::istream& in)
override
159 if (threshold < 0.0 || threshold > 1.0) {
163 if (failuresThreshold < 0.0 || failuresThreshold > 1.0) {
#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 Kolmogorov test for 2D histograms.
JTestKolmogorov_Slice2D()
Default constructor.
double failuresThreshold
threshold p-value to decide if test is passed.
std::istream & read(std::istream &in) override
Read test parameters from input.
double threshold
threshold p-value to decide if test is passed.
void test(const TObject *o1, const TObject *o2) override
Applies Kolmogorov test for two ROOT TH2 histograms.
char slice
axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
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.
std::string to_string(const T &value)
Convert value to string.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Structure containing the result of the test.