1 #ifndef __JCOMPAREHISTOGRAMS__JTESTRUNS_T__ 
    2 #define __JCOMPAREHISTOGRAMS__JTESTRUNS_T__ 
   13 namespace JCOMPAREHISTOGRAMS {
 
   45       if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
 
   46         ERROR(
"Histograms with different bining. The objects: " << h1 -> GetName() << 
" can not be compared." << endl);
 
   48       double R = h1->Integral();
 
   49       double T = h2->Integral();
 
   51       TH2D* h3 = (TH2D*)h1->Clone(h1->GetName()==h2->GetName() ?
 
   55       for (
int i=1 ; i<h1->GetNbinsX() ; ++i) {
 
   56         h3->SetBinContent(i , (
T/
R)*h1->GetBinContent(i) - h2->GetBinContent(i)); 
 
   63       bool a = ((
T/
R)*h1->GetBinContent(1) - h2->GetBinContent(1)) < 0;
 
   67       for (
int i = 2 ; i<h1->GetNbinsX() ; ++i){
 
   69         bool b = ((
T/
R)*h1->GetBinContent(i) - h2->GetBinContent(i)) < 0;
 
   79       const double N = 1 + 2*p*q/(p+q) ;
 
   80       const double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
   81       const double d = (
n-
N)/s;
 
   83       const bool passed = (fabs(
d) > threshold ? 
false : 
true);
 
   85       JResultTitle title(testName, parameterName , passed , fabs(
d));
 
   87       h3->SetTitle(title.
getTitle().c_str());    
 
   92                      parameterName, fabs(
d), threshold, h3, passed);
 
  123       if(slice == 
'x' || slice == 
'X'){
 
  125         int nSlices1 = h1->GetNbinsX();
 
  126         int nSlices2 = h2->GetNbinsX();
 
  128         TH1* h3 = h1->ProjectionX(
MAKE_CSTRING(h1->GetName() << 
"_VS_" <<
 
  129                                                h2->GetName() << 
"_RunsTestSliceX"));
 
  131         if (nSlices1 != nSlices2) {
 
  132           ERROR(
"Histograms with different binning. The objects: " << h1->GetName() << 
" and " << h2->GetName() << 
" can not be compared." << endl);
 
  135         for (
int i=1 ; i<=nSlices1 ; ++i){
 
  139           TH1D* s1 = h1->ProjectionY (sliceName.c_str(),i,i);
 
  140           TH1D* s2 = h2->ProjectionY (sliceName.c_str(),i,i);
 
  142           if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) { 
continue; }
 
  144           double R = s1->Integral();
 
  145           double T = s2->Integral();
 
  151           bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
 
  155           for (
int i = 2 ; i<s1->GetNbinsX() ; ++i){
 
  157             bool b = ((T/
R)*s1->GetBinContent(i) - s2->GetBinContent(i)) < 0;
 
  167           double N = 1 + 2*p*q/(p+q) ;
 
  168           double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
  171           bool passed = (fabs(d) > threshold ? 
false : 
true);
 
  173           if (!passed) nFailures++;
 
  175           h3->SetBinContent(i,fabs(d));
 
  179         bool passed = (nFailures/nSlices1 > failuresThreshold ? 
false : 
true);
 
  181         JResultTitle title(testName, parameterName, passed , nFailures);
 
  183         h3->SetTitle(title.
getTitle().c_str());
 
  188                         parameterName, nFailures, failuresThreshold, h3, passed);
 
  190       }
else if (slice == 
'y' || slice == 
'Y'){
 
  192         int nSlices1 = h1->GetNbinsX();
 
  193         int nSlices2 = h2->GetNbinsX();
 
  195         TH1* h3 = h1->ProjectionY(h1->GetName()==h2->GetName() ?
 
  199         if(nSlices1 != nSlices2) {
 
  200           ERROR(
"Histograms with different binning. The objects: " << h1->GetName() << 
" and " << h2->GetName() << 
" can not be compared." << endl);
 
  203         for (
int i=1 ; i<=nSlices1 ; ++i){
 
  207           TH1D* s1 = h1->ProjectionX (sliceName.c_str(),i,i);
 
  208           TH1D* s2 = h2->ProjectionX (sliceName.c_str(),i,i);
 
  210           if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) { 
continue; }
 
  212           double R = s1->Integral();
 
  213           double T = s2->Integral();
 
  219           bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
 
  223           for (
int i = 2 ; i<s1->GetNbinsX() ; ++i){
 
  225             bool b = ((T/
R)*s1->GetBinContent(i) - s2->GetBinContent(i)) < 0;
 
  235           double N = 1 + 2*p*q/(p+q) ;
 
  236           double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
  239           bool passed = (fabs(d) > threshold ? 
false : 
true);
 
  241           if (!passed) nFailures++;
 
  243           h3->SetBinContent(i,fabs(d));
 
  247         bool passed = (nFailures/nSlices1 > failuresThreshold ? 
false : 
true);
 
  249         JResultTitle title(testName, parameterName, passed , nFailures);
 
  251         h3->SetTitle(title.
getTitle().c_str());
 
  256                           parameterName, nFailures, failuresThreshold, h3, passed);
 
JTestResult JRunsTest(TH1 *h1, TH1 *h2, double threshold, std::string testName, std::string parameterName)
Implements the Wald-Wolfowitx runs test: https://en.wikipedia.org/wiki/Wald%E2%80%93Wolfowitz_runs_te...
 
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
 
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
 
#define MAKE_CSTRING(A)
Make C-string. 
 
Auxiliary class to handle file name, ROOT directory and object name. 
 
#define MAKE_STRING(A)
Make string. 
 
JTestRuns_t()
Default constructor. 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
Implementation of the different Runs-related tests. 
 
then JCookie sh JDataQuality D $DETECTOR_ID R
 
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. 
 
JTestResult JRunsTestSlice(TH2 *h1, TH2 *h2, double threshold, double failuresThreshold, std::string testName, std::string parameterName, char slice)
Runs test for sliced 2D histograms. 
 
std::string getTitle()
Returns a standard string to be used as title of a graphical root object.