Tests the statistical compatibility of two ROOT TObjects.
49 {
52
53 const TH1* h1 = dynamic_cast<const TH1*>(o1);
54 const TH1* h2 = dynamic_cast<const TH1*>(o2);
55
56 if (h1 == NULL || h2 == NULL) {
58 }
59
60 if (h1->GetDimension() != 1 || h2->GetDimension() != 1) {
62 }
63
64 if(h1->GetNbinsX() != h2->GetNbinsX()) {
66 h1->GetName() << " and " << h2->GetName() << " can not be compared." << endl);
67 }
68
69 const double R = h1->Integral();
70 const double T = h2->Integral();
71
72 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
75
76 for (int i=1 ; i<h1->GetNbinsX() ; ++i) {
77 h3->SetBinContent(i, (T/R)*h1->GetBinContent(i) - h2->GetBinContent(i));
78 }
79
80 bool a = ((T/R)*h1->GetBinContent(1) - h2->GetBinContent(1)) < 0;
81
83 double p = (
a ? 1 : 0);
84 double q = (
a ? 0 : 1);
85
86 for (int i = 2 ; i<h1->GetNbinsX() ; ++i){
87
88 const bool b = ((T/R)*h1->GetBinContent(i) - h2->GetBinContent(i)) < 0;
89
90 (b ? ++p : ++q);
91
92 if (b != a){
95 }
96 }
97
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;
101
102 const bool passed = (fabs(d) <
threshold);
103
105
106 h3->SetTitle(title.getTitle().c_str());
108
113
114 this->push_back(r);
115 }
#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...
double threshold
threshold value to decide if test is passed.
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.