Tests the statistical compatibility of two ROOT TObjects.
52 const TH2* h1 =
dynamic_cast<const TH2*
>(o1);
53 const TH2* h2 =
dynamic_cast<const TH2*
>(o2);
55 if (h1 == NULL || h2 == NULL) {
56 THROW(JValueOutOfRange,
"JTestKolmogorov_Slice2D::test(): Could not cast given TObjects to TH2.");
61 const char*
const h3name = (h1->GetName() == h2->GetName() ?
70 const int nSlices1 = h1->GetNbinsX();
71 const int nSlices2 = h2->GetNbinsX();
73 if (nSlices1 != nSlices2) {
74 THROW(JValueOutOfRange,
"JTestRuns_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
79 h3 = h1->ProjectionX(h3name);
81 for (
int i=1 ;
i<=nSlices1 ; ++
i){
85 const TH1* s1 = h1->ProjectionY (sliceName.c_str(),
i,
i);
86 const TH1* s2 = h2->ProjectionY (sliceName.c_str(),
i,
i);
88 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
90 const double R = s1->Integral();
91 const double T = s2->Integral();
93 bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
96 double p = (a ? 1 : 0);
97 double q = (a ? 0 : 1);
99 for (
int i = 2 ;
i<s1->GetNbinsX() ; ++
i){
101 const bool b = ((T/
R)*s1->GetBinContent(
i) - s2->GetBinContent(
i)) < 0;
111 const double N = 1 + 2*p*q/(p+q) ;
112 const double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
113 const double d = (n-
N)/s;
117 h3->SetBinContent(
i,fabs(d));
122 const int nSlices1 = h1->GetNbinsX();
123 const int nSlices2 = h2->GetNbinsX();
125 if (nSlices1 != nSlices2) {
126 THROW(JValueOutOfRange,
"JTestRuns_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
131 h3 = h1->ProjectionY(h3name);
133 for (
int i=1 ;
i<=nSlices1 ; ++
i){
137 const TH1* s1 = h1->ProjectionX (sliceName.c_str(),
i,
i);
138 const TH1* s2 = h2->ProjectionX (sliceName.c_str(),
i,
i);
140 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
142 const double R = s1->Integral();
143 const double T = s2->Integral();
145 bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
148 double p = (a ? 1 : 0);
149 double q = (a ? 0 : 1);
151 for (
int i = 2 ;
i<s1->GetNbinsX() ; ++
i){
153 const bool b = ((T/
R)*s1->GetBinContent(
i) - s2->GetBinContent(
i)) < 0;
163 const double N = 1 + 2*p*q/(p+q) ;
164 const double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
165 const double d = (n-
N)/s;
169 h3->SetBinContent(
i,fabs(d));
177 h3->SetTitle(title.getTitle().c_str());
181 JRootObjectID(
MAKE_STRING(h1->GetDirectory()->GetPath() << h1->GetName())),
182 JRootObjectID(
MAKE_STRING(h2->GetDirectory()->GetPath() << h1->GetName())),
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
#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.
double failuresThreshold
threshold value to decide if test is passed.
char slice
Axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
const std::string resultType
test result type
const std::string testName
test name
then JCookie sh JDataQuality D $DETECTOR_ID R
double threshold
threshold value to decide if test is passed.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
std::string to_string(const T &value)
Convert value to string.
Structure containing the result of the test.