#ifndef __JCOMPAREHISTOGRAMS__JTESTSIGNIFICANCE_1D__ #define __JCOMPAREHISTOGRAMS__JTESTSIGNIFICANCE_1D__ #include #include #include "JCompareHistograms/JTest_t.hh" #include "JCompareHistograms/JTestSignificance_t.hh" /** * \author bofearraigh * \author rgruiz */ namespace JCOMPAREHISTOGRAMS { /** * Significance test applied to 1D histograms */ class JTestSignificance_1D: public JTest_t, public JTestSignificance_t { public: /** * Default constructor. */ JTestSignificance_1D() : JTest_t("Significance_1D", "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)) { ERROR("For 2D histograms call JTestSignificance_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); 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