#ifndef __JCOMPAREHISTOGRAMS__JTESTSIGNIFICANCE_2D__ #define __JCOMPAREHISTOGRAMS__JTESTSIGNIFICANCE_2D__ #include #include #include "JCompareHistograms/JTest_t.hh" #include "JCompareHistograms/JTestSignificance_t.hh" /** * \author bofearraigh * \author rgruiz */ namespace JCOMPAREHISTOGRAMS { /** * Significance test applied to 2D histograms */ class JTestSignificance_2D: public JTest_t, public JTestSignificance_t { public: /** * Default constructor. */ JTestSignificance_2D() : JTest_t("Significance_2D", "Significance"), JTestSignificance_t() {} /** * Read test parameters from input. * * \param in input stream * \return input stream */ std::istream& read(std::istream& in) override{ return in >> threshold >> K; }; /** * Applies Significance 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)) { TH2D* h1 = dynamic_cast(o1); TH2D* h2 = dynamic_cast(o2); if (h1 -> GetNbinsX() != h2 -> GetNbinsX() || h1 -> GetNbinsY() != h2 -> GetNbinsY()) ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl); if (K<0) K = h2->GetEntries()/h1->GetEntries(); JTestResult r = JSignificanceTest(h1, h2, threshold, K, testName, resultType); results.push_back(r); } }; private: double threshold; //!< threshold p-value to decide if test is passed. double K; //!< normalization factor between histograms. }; } #endif