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       double N = 1 + 2*p*q/(p+q) ;
 
   80       double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
   85       (fabs(
d) > threshold ? passed = 
false : passed = 
true);
 
   87       JResultTitle title(testName, parameterName , passed , fabs(
d));
 
   89       h3->SetTitle(title.
getTitle().c_str());    
 
   94                      parameterName, fabs(
d), threshold, h3, passed);
 
  116     JTestResult JRunsTestSlice(TH2* 
h1, TH2* h2, 
double threshold, 
double failuresThreshold, std::string testName, std::string parameterName, 
char slice) {
 
  125       if(slice == 
'x' || slice == 
'X'){
 
  127         int nSlices1 = h1->GetNbinsX();
 
  128         int nSlices2 = h2->GetNbinsX();
 
  130         TH1* h3 = h1->ProjectionX(h1->GetName()==h2->GetName() ?
 
  134         if(nSlices1 != nSlices2)
 
  135           ERROR(
"Histograms with different binning. The objects: " << h1->GetName() << 
" and " << h2->GetName() << 
" can not be compared." << endl);
 
  137         for (
int i=1 ; i<=nSlices1 ; ++i){
 
  141           TH1D* s1 = h1->ProjectionY (sliceName.c_str(),i,i);
 
  142           TH1D* s2 = h2->ProjectionY (sliceName.c_str(),i,i);
 
  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) );
 
  173           (fabs(d) > threshold ? passed = 
false : passed = 
true);
 
  175           if (!passed) nFailures++;
 
  177           h3->SetBinContent(i,fabs(d));
 
  183         (nFailures/nSlices1 > failuresThreshold ? passed = 
false : passed = 
true);
 
  185         JResultTitle title(testName, parameterName, passed , nFailures);
 
  187         h3->SetTitle(title.
getTitle().c_str());
 
  192                         parameterName, nFailures, failuresThreshold, h3, passed);
 
  194       }
else if (slice == 
'y' || slice == 
'Y'){
 
  196         int nSlices1 = h1->GetNbinsX();
 
  197         int nSlices2 = h2->GetNbinsX();
 
  199         TH1* h3 = h1->ProjectionY(h1->GetName()==h2->GetName() ?
 
  203         if(nSlices1 != nSlices2)
 
  204           ERROR(
"Histograms with different binning. The objects: " << h1->GetName() << 
" and " << h2->GetName() << 
" can not be compared." << endl);
 
  206         for (
int i=1 ; i<=nSlices1 ; ++i){
 
  210           TH1D* s1 = h1->ProjectionX (sliceName.c_str(),i,i);
 
  211           TH1D* s2 = h2->ProjectionX (sliceName.c_str(),i,i);
 
  213           double R = s1->Integral();
 
  214           double T = s2->Integral();
 
  220           bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
 
  224           for (
int i = 2 ; i<s1->GetNbinsX() ; ++i){
 
  226             bool b = ((T/
R)*s1->GetBinContent(i) - s2->GetBinContent(i)) < 0;
 
  236           double N = 1 + 2*p*q/(p+q) ;
 
  237           double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
  242           (fabs(d) > threshold ? passed = 
false : passed = 
true);
 
  244           if (!passed) nFailures++;
 
  246           h3->SetBinContent(i,fabs(d));
 
  252         (nFailures/nSlices1 > failuresThreshold ? passed = 
false : passed = 
true);
 
  254         JResultTitle title(testName, parameterName, passed , nFailures);
 
  256         h3->SetTitle(title.
getTitle().c_str());
 
  261                           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. 
 
then for HISTOGRAM in h0 h1
 
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 usage $script[distance] fi case set_variable 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.