Applies Chi2 test for two ROOT TH2 histograms. 
   52    {
   55 
   56      const TH2* h1 = dynamic_cast<const TH2*>(o1);
   57      const TH2* h2 = dynamic_cast<const TH2*>(o2);
   58    
   59      if (h1 == NULL || h2 == NULL) {
   61      }
   62 
   63      TH1* h3 = NULL;
   64 
   65      const char* const h3name = (h1->GetName() == h2->GetName() ?
   68        
   69      int  nFailures = 0;
   70      int  nSlices   = 0;
   71    
   73    
   74        const int nSlices1 = h1->GetNbinsX();
   75        const int nSlices2 = h2->GetNbinsX();
   76 
   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);
 
   79        }
   80 
   81        nSlices = nSlices1;
   82        
   83        h3 = h1->ProjectionX(h3name);
   84        
   85        for (int i=1 ; i<=nSlices1 ; ++i){
   86 
   88             
   89          const TH1* s1 = h1->ProjectionY(sliceName.c_str(),i,i);
   90          const TH1* s2 = h2->ProjectionY(sliceName.c_str(),i,i);
   91 
   92          if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) { continue; }
   93 
   94          const double chi2 = s1->Chi2Test(s2 , 
options.c_str());
 
   95 
   96          const bool failed = (
options.find(
"CHI2") != std::string::npos ?
 
   99 
  100          if (failed) nFailures++;
  101        
  102          h3->SetBinContent(i,chi2); 
  103        }
  104            
  106           
  107        const int nSlices1 = h1->GetNbinsY();
  108        const int nSlices2 = h2->GetNbinsY();
  109 
  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);
 
  112        }
  113 
  114        nSlices = nSlices1;
  115 
  116        h3 = h1->ProjectionY(h3name);
  117 
  118        for (int i=1 ; i<=nSlices1 ; ++i){
  119             
  121 
  122          const TH1* s1 = h1->ProjectionX(sliceName.c_str(),i,i);
  123          const TH1* s2 = h2->ProjectionX(sliceName.c_str(),i,i);
  124 
  125          if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) { continue; }    
  126 
  127          const double chi2 = s1->Chi2Test (s2 , 
options.c_str());
 
  128 
  129          const bool failed = (
options.find(
"CHI2") != std::string::npos ?
 
  132 
  133          if (failed) nFailures++;
  134        
  135          h3->SetBinContent(i,chi2);
  136        }
  137      }
  138 
  140 
  142      
  143      h3->SetTitle(title.getTitle().c_str());
  145      
  150      
  151      this->push_back(r);
  152    }
#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 p-value to decide if test is passed.
 
std::string options
options for the ROOT chi2 test.
 
double failuresThreshold
threshold p-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.
 
std::string to_string(const T &value)
Convert value to string.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Structure containing the result of the test.