1 #ifndef __JTESTRUNS_T__ 
    2 #define __JTESTRUNS_T__ 
   39     if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
 
   40       ERROR(
"Histograms with different bining. The objects: " << h1 -> GetName() << 
" can not be compared." << endl);
 
   42     double R = h1->Integral();
 
   43     double T = h2->Integral();
 
   45     TH2D* h3 = (TH2D*)h1->Clone(h1->GetName()==h2->GetName() ?
 
   49     for (
int i=1 ; i<h1->GetNbinsX() ; ++i) {
 
   50       h3->SetBinContent(i , (
T/
R)*h1->GetBinContent(i) - h2->GetBinContent(i)); 
 
   57     bool a = ((
T/
R)*h1->GetBinContent(1) - h2->GetBinContent(1)) < 0;
 
   61     for (
int i = 2 ; i<h1->GetNbinsX() ; ++i){
 
   63       bool b = ((
T/
R)*h1->GetBinContent(i) - h2->GetBinContent(i)) < 0;
 
   73     double N = 1 + 2*p*q/(p+q) ;
 
   74     double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
   79     (fabs(
d) > threshold ? passed = 
false : passed = 
true);
 
   81     JResultTitle title(testName, parameterName , passed , fabs(
d));
 
   83     h3->SetTitle(title.
getTitle().c_str());    
 
   86                    string (h1->GetDirectory()->GetPath()).append(h1->GetName()),
 
   87                    string (h2->GetDirectory()->GetPath()).append(h2->GetName()),
 
   88                    h1->GetDirectory()->GetFile()->GetName(),
 
   89                    h2->GetDirectory()->GetFile()->GetName(),
 
   90                    parameterName, fabs(
d), threshold, h3, passed);
 
  112   JTestResult JRunsTestSlice(TH2* 
h1, TH2* h2, 
double threshold, 
double failuresThreshold, std::string testName, std::string parameterName, 
char slice) {
 
  121     if(slice == 
'x' || slice == 
'X'){
 
  123       int nSlices1 = h1->GetNbinsX();
 
  124       int nSlices2 = h2->GetNbinsX();
 
  126       TH1* h3 = h1->ProjectionX(h1->GetName()==h2->GetName() ?
 
  130       if(nSlices1 != nSlices2)
 
  131         ERROR(
"Histograms with different binning. The objects: " << h1->GetName() << 
" and " << h2->GetName() << 
" can not be compared." << endl);
 
  133       for (
int i=1 ; i<=nSlices1 ; ++i){
 
  137         TH1D* s1 = h1->ProjectionY (sliceName.c_str(),i,i);
 
  138         TH1D* s2 = h2->ProjectionY (sliceName.c_str(),i,i);
 
  140         double R = s1->Integral();
 
  141         double T = s2->Integral();
 
  147         bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
 
  151         for (
int i = 2 ; i<s1->GetNbinsX() ; ++i){
 
  153           bool b = ((T/
R)*s1->GetBinContent(i) - s2->GetBinContent(i)) < 0;
 
  163         double N = 1 + 2*p*q/(p+q) ;
 
  164         double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
  169         (fabs(d) > threshold ? passed = 
false : passed = 
true);
 
  171         if (!passed) nFailures++;
 
  173         h3->SetBinContent(i,fabs(d));
 
  179       (nFailures/nSlices1 > failuresThreshold ? passed = 
false : passed = 
true);
 
  181       JResultTitle title(testName, parameterName, passed , nFailures);
 
  183       h3->SetTitle(title.
getTitle().c_str());
 
  186                         string (h1->GetDirectory()->GetPath()).append(h1->GetName()),
 
  187                         string (h2->GetDirectory()->GetPath()).append(h2->GetName()),
 
  188                         h1->GetDirectory()->GetFile()->GetName(),
 
  189                         h2->GetDirectory()->GetFile()->GetName(),
 
  190                         parameterName, nFailures, failuresThreshold, h3, passed);
 
  192     }
else if (slice == 
'y' || slice == 
'Y'){
 
  194       int nSlices1 = h1->GetNbinsX();
 
  195       int nSlices2 = h2->GetNbinsX();
 
  197       TH1* h3 = h1->ProjectionY(h1->GetName()==h2->GetName() ?
 
  201       if(nSlices1 != nSlices2)
 
  202         ERROR(
"Histograms with different binning. The objects: " << h1->GetName() << 
" and " << h2->GetName() << 
" can not be compared." << endl);
 
  204       for (
int i=1 ; i<=nSlices1 ; ++i){
 
  208         TH1D* s1 = h1->ProjectionX (sliceName.c_str(),i,i);
 
  209         TH1D* s2 = h2->ProjectionX (sliceName.c_str(),i,i);
 
  211         double R = s1->Integral();
 
  212         double T = s2->Integral();
 
  218         bool a = ((T/
R)*s1->GetBinContent(1) - s2->GetBinContent(1)) < 0;
 
  222         for (
int i = 2 ; i<s1->GetNbinsX() ; ++i){
 
  224           bool b = ((T/
R)*s1->GetBinContent(i) - s2->GetBinContent(i)) < 0;
 
  234         double N = 1 + 2*p*q/(p+q) ;
 
  235         double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
 
  240         (fabs(d) > threshold ? passed = 
false : passed = 
true);
 
  242         if (!passed) nFailures++;
 
  244         h3->SetBinContent(i,fabs(d));
 
  250       (nFailures/nSlices1 > failuresThreshold ? passed = 
false : passed = 
true);
 
  252       JResultTitle title(testName, parameterName, passed , nFailures);
 
  254       h3->SetTitle(title.
getTitle().c_str());
 
  257                         string (h1->GetDirectory()->GetPath()).append(h1->GetName()),
 
  258                         string (h2->GetDirectory()->GetPath()).append(h2->GetName()),
 
  259                         h1->GetDirectory()->GetFile()->GetName(),
 
  260                         h2->GetDirectory()->GetFile()->GetName(),
 
  261                         parameterName, nFailures, failuresThreshold, h3, passed);
 
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
 
JTestResult JRunsTestSlice(TH2 *h1, TH2 *h2, double threshold, double failuresThreshold, std::string testName, std::string parameterName, char slice)
Runs test for sliced 2D histograms. 
 
#define MAKE_CSTRING(A)
Make C-string. 
 
then for HISTOGRAM in h0 h1
 
Structure containing the result of the test. 
 
#define MAKE_STRING(A)
Make string. 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
std::string getTitle()
Returns a standard string to be used as title of a graphical root object. 
 
JTestRuns_t()
Default constructor. 
 
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR set_variable NORTH set_variable EAST set_variable SOUTH set_variable WEST set_variable WORKDIR tmp set_variable R set_variable CT set_variable YMAX set_variable YMIN if do_usage *then usage $script[distance] fi case set_variable R
 
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
 
alias put_queue eval echo n
 
Implementation of the different Runs-related tests. 
 
std::string to_string(const T &value)
Convert value to string. 
 
then usage $script[input file[working directory[option]]] nWhere option can be N
 
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...