#ifndef __JCOMPAREHISTOGRAMS__JTESTCHI2_BIN__ #define __JCOMPAREHISTOGRAMS__JTESTCHI2_BIN__ #include #include #include "JCompareHistograms/JTest_t.hh" #include "JCompareHistograms/JTestChi2_t.hh" /** * \author rgruiz */ namespace JCOMPAREHISTOGRAMS { /** * Implementation of a bin-by-bin Chi2 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 * The test is run by the method JChi2TestBin_2D(). */ class JTestChi2_Bin: public JTest_t, public JTestChi2_t { public: /** * Default constructor. */ JTestChi2_Bin() : JTest_t("Chi2_Bin", "Outliers[%]"), JTestChi2_t() {} /** * Read test parameters from input. * * \param in input stream * \return input stream */ std::istream& read(std::istream& in) override{ return in >> outliersThreshold >> chi2Threshold; }; /** * Tests the statistical compatibility of two ROOT 2D histograms * * \param o1 First histogram * \param o2 Second histogram * * \return Test result */ void test(TObject* o1, TObject* o2) override{ using namespace std; if (!(dynamic_cast(o1) == NULL) && !(dynamic_cast(o2) == NULL)) { TH2D* h1 = dynamic_cast(o1); TH2D* h2 = dynamic_cast(o2); JTestResult r = JChi2TestBin_2D(h1, h2, outliersThreshold, chi2Threshold, testName, resultType); results.push_back(r); } }; private: double chi2Threshold; //!< threshold p-value to decide if test is passed for a bin. double outliersThreshold; //!< fraction of bins allowed to fail the test. }; } #endif