56 const TH2* h1 =
dynamic_cast<const TH2*
>(o1);
57 const TH2* h2 =
dynamic_cast<const TH2*
>(o2);
59 if (h1 == NULL || h2 == NULL) {
65 const char*
const h3name = (h1->GetName() == h2->GetName() ?
74 const int nSlices1 = h1->GetNbinsX();
75 const int nSlices2 = h2->GetNbinsX();
77 if (nSlices1 != nSlices2) {
78 THROW(
JValueOutOfRange,
"JTestChi2_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
83 h3 = h1->ProjectionX(h3name);
85 for (
int i=1 ; i<=nSlices1 ; ++i){
87 const std::string sliceName =
MAKE_STRING(h3->GetName() <<
"_" << to_string(i));
89 const TH1* s1 = h1->ProjectionY(sliceName.c_str(),i,i);
90 const TH1* s2 = h2->ProjectionY(sliceName.c_str(),i,i);
92 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
94 const double chi2 = s1->Chi2Test(s2 ,
options.c_str());
96 const bool failed = (
options.find(
"CHI2") != std::string::npos ?
100 if (failed) nFailures++;
102 h3->SetBinContent(i,chi2);
107 const int nSlices1 = h1->GetNbinsY();
108 const int nSlices2 = h2->GetNbinsY();
110 if (nSlices1 != nSlices2) {
111 THROW(
JValueOutOfRange,
"JTestChi2_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
116 h3 = h1->ProjectionY(h3name);
118 for (
int i=1 ; i<=nSlices1 ; ++i){
120 const std::string sliceName =
MAKE_STRING(h3->GetName() <<
"_" << to_string(i));
122 const TH1* s1 = h1->ProjectionX(sliceName.c_str(),i,i);
123 const TH1* s2 = h2->ProjectionX(sliceName.c_str(),i,i);
125 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
127 const double chi2 = s1->Chi2Test (s2 ,
options.c_str());
129 const bool failed = (
options.find(
"CHI2") != std::string::npos ?
133 if (failed) nFailures++;
135 h3->SetBinContent(i,chi2);
143 h3->SetTitle(title.
getTitle().c_str());