1#ifndef __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__
2#define __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__
53 const TH1* h1 =
dynamic_cast<const TH1*
>(o1);
54 const TH1* h2 =
dynamic_cast<const TH1*
>(o2);
56 if (h1 == NULL || h2 == NULL) {
60 if (h1->GetDimension() != 1 || h2->GetDimension() != 1) {
64 if(h1->GetNbinsX() != h2->GetNbinsX()) {
66 h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
69 const double R = h1->Integral();
70 const double T = h2->Integral();
72 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
76 for (
int i=1 ; i<h1->GetNbinsX() ; ++i) {
77 h3->SetBinContent(i, (T/R)*h1->GetBinContent(i) - h2->GetBinContent(i));
80 bool a = ((T/R)*h1->GetBinContent(1) - h2->GetBinContent(1)) < 0;
83 double p = (a ? 1 : 0);
84 double q = (a ? 0 : 1);
86 for (
int i = 2 ; i<h1->GetNbinsX() ; ++i){
88 const bool b = ((T/R)*h1->GetBinContent(i) - h2->GetBinContent(i)) < 0;
98 const double N = 1 + 2*p*q/(p+q) ;
99 const double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
100 const double d = (n-N)/s;
102 const bool passed = (fabs(d) <
threshold);
106 h3->SetTitle(title.
getTitle().c_str());
124 std::istream&
read(std::istream& in)
override
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
#define MAKE_STRING(A)
Make string.
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
std::string getTitle() const
Returns a standard string to be used as title of a graphical root object.
Implementation of the Runs test for 1D histograms.
std::istream & read(std::istream &in) override
Read test parameters from input.
JTestRuns_1D()
Default constructor.
void test(const TObject *o1, const TObject *o2) override
Tests the statistical compatibility of two ROOT TObjects.
double threshold
threshold value to decide if test is passed.
Interface to read input and write output for TObject tests.
const std::string resultType
test result type
const std::string testName
test name
Auxiliary class to handle file name, ROOT directory and object name.
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Structure containing the result of the test.