#ifndef __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__ #define __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__ #include #include #include "JCompareHistograms/JTest_t.hh" #include "JCompareHistograms/JTestRuns_t.hh" /** * \author rgruiz */ namespace JCOMPAREHISTOGRAMS { /** * Implementation of the Runs 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 JRunsTest() test. */ class JTestRuns_1D: public JTest_t, public JTestRuns_t { public: JTestRuns_1D() : JTest_t("Runs_1D", "#sigma"), JTestRuns_t() {} /** * Read test parameters from input. * * \param in input stream * \return input stream */ std::istream& read(std::istream& in) override{ return in >> threshold; }; /** * Tests the statistical compatibility of two ROOT TObjects * * \param o1 First object * \param o2 Second object */ void test(TObject* o1, TObject* o2) override{ using namespace std; if (!(dynamic_cast(o1) == NULL) || !(dynamic_cast(o2) == NULL)) { ERROR("For 2D histograms call JTestRuns_2D: " << o1->GetName() << endl); } else if (!(dynamic_cast(o1) == NULL) && !(dynamic_cast(o2) == NULL)) { TH1D* h1 = dynamic_cast(o1); TH1D* h2 = dynamic_cast(o2); if(h1 -> GetNbinsX() != h2 -> GetNbinsX()) ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl); JTestResult r = JRunsTest(h1, h2, threshold, testName, resultType); results.push_back(r); } }; private: double threshold; //!< threshold value to decide if test is passed. }; } #endif