#ifndef __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_1D__ #define __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_1D__ #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 1D 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 uses the input parameter threshold() to evaluate whether the test is passed or failed.\n * The evaluation is done by comparing the threshold value with the result of the JKolmogorovTest() test. This is a p-value.\n * The parameter threshold should therefore be a real value between 0 and 1. */ class JTestKolmogorov_1D: public JTest_t, public JTestKolmogorov_t { public: /** * Default constructor. */ JTestKolmogorov_1D() : JTest_t("KS_1D", "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 TH1 histograms. * * \param o1 First histogram * \param o2 Second histogram */ void test(TObject* o1, TObject* o2) override{ using namespace std; if (!(dynamic_cast(o1) == NULL) || !(dynamic_cast(o2) == NULL)) { ERROR("For 2D histograms call JTestKolmogorov_2D: " << o1->GetName() << endl); } else if (!(dynamic_cast(o1) == NULL) && !(dynamic_cast(o2) == NULL)) { TH1D* h1 = dynamic_cast(o1); TH1D* h2 = dynamic_cast(o2); JTestResult r = JKolmogorovTest(h1, h2, threshold, testName, resultType); results.push_back(r); } }; private: double threshold; //!< threshold p-value to decide if test is passed. }; } #endif