#ifndef __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_2D__ #define __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_2D__ #include #include #include "TMath.h" #include "JCompareHistograms/JTest_t.hh" #include "JCompareHistograms/JTestKolmogorov_t.hh" /** * \author rgruiz */ namespace JCOMPAREHISTOGRAMS { /** * Implementation of the Kolmogorov test for 2D histograms.\n * This class is derived from the abstract class JTest_t(). For a general description of the implementation of this and other tests derived from JTest_t(), see its documentation.\n * This test compares two 2D histograms. If the parameter slice() equals x, X y or Y, the histograms are sliced along the corresponding axis, and the JKolmogorovTest() test is applied to each slice.\n * If slice() equals n or N, the histograms are not sliced, and JKolmogorovTest2D() is applied.\n * The input parameter threshold(), is used to evaluate whether the test is passed or failed for each slice or for the full 2D distribution.\n * The evaluation is done by comparing the threshold() value with the result produced by JKolmogorovTest() or JKolmogorovTest2D(), which is a p-value.\n * The parameter threshold() should therefore be a real value between 0 and 1. */ class JTestKolmogorov_2D: public JTest_t, public JTestKolmogorov_t { public: /** * Default constructor. */ JTestKolmogorov_2D() : JTest_t("KS_2D", "p-Value(KS)"), JTestKolmogorov_t() {} /** * Read test parameters from input. * * \param in input stream * \return input stream */ std::istream& read(std::istream& in) override{ return in >> threshold; }; /** * Applies Kolmogorov test for two ROOT TH2 histograms. * * \param o1 First histogram * \param o2 Second histogram */ void test(TObject* o1, TObject* o2) override{ using namespace std; using namespace JPP; if (!(dynamic_cast(o1) == NULL) && !(dynamic_cast(o2) == NULL)) { TH2D* h1 = dynamic_cast(o1); TH2D* h2 = dynamic_cast(o2); JTestResult r = JKolmogorovTest2D(h1,h2,threshold, testName, resultType); results.push_back(r); }else if (!(dynamic_cast(o1) == NULL) && !(dynamic_cast(o2) == NULL)) { ERROR("For 1D histograms call JTestKolmogorov_1D: " << o1->GetName() << endl); } }; private: double threshold; //!< threshold p-value to decide if test is passed. }; } #endif