Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
JTestZero_t Class Reference

Implementation of the Zeros test for histograms with expected low bin contents. More...

#include <JTestZero_t.hh>

Inheritance diagram for JTestZero_t:
JTestZero

Public Member Functions

 JTestZero_t ()
 Default constructor. More...
 
JTestResult JTestZero_2D (TH2 *h1, TH2 *h2, double outliersThreshold, double threshold, std::string testName, std::string parameterName)
 Bin-by-Bin test for 2D histograms where a very low number of entries is expected. More...
 

Detailed Description

Implementation of the Zeros test for histograms with expected low bin contents.

Author
rgruiz

Definition at line 20 of file JTestZero_t.hh.

Constructor & Destructor Documentation

JTestZero_t::JTestZero_t ( )
inline

Default constructor.

Definition at line 27 of file JTestZero_t.hh.

27 {}

Member Function Documentation

JTestResult JTestZero_t::JTestZero_2D ( TH2 *  h1,
TH2 *  h2,
double  outliersThreshold,
double  threshold,
std::string  testName,
std::string  parameterName 
)
inline

Bin-by-Bin test for 2D histograms where a very low number of entries is expected.


The test loops over all the bins of both histograms and performs the following operations.
-Calculates the probability that the observed bin content for histogram A is obtained from a Poisson of parameter 1.
-Compares the previous result with the threshold value given as an input parameter. The result is true if the probability is higher than the threshold.
-Calculates the probability that the observed bin content for histogram B is obtained from a Poisson of parameter 1.
-Compares the previous result with the threshold value given as an input parameter. The result is true if the probability is higher than the threshold.
-Compares the results from both bins: If both are true, or both are false, the test is passed. If one is true and the other is false, the test is failed.
At the end of the loop, a failure fraction is computed and compared to the outliersThreshold parameter. If the failure fraction is above the threshold, the test is failed.

Parameters
h1First object
h2Second object
outliersThresholdFraction of incompatible bins allowed.
thresholdPoisson p-value
parameterNameName of the parameter used to test the histograms
testNameName of the test used to compare the histograms

Definition at line 46 of file JTestZero_t.hh.

46  {
47 
48  using namespace std;
49  using namespace JPP;
50 
51  int nx1 = h1->GetNbinsX();
52  int nx2 = h2->GetNbinsX();
53  int ny1 = h1->GetNbinsY();
54  int ny2 = h2->GetNbinsY();
55 
56  if(nx1 != nx2 || ny1 != ny2)
57  ERROR("Histograms with different binning. The objects: " << h1->GetName() << " can not be compared." << endl);
58 
59  TH2D* h3 = (TH2D*)h1->Clone(h1->GetName()==h2->GetName() ?
60  MAKE_CSTRING(to_string(h1->GetName())) :
61  MAKE_CSTRING(to_string(h1->GetName()) + "_VS_" + to_string(h2->GetName())));
62  h3->Reset();
63 
64  double failures = 0;
65 
66  for (int i=1 ; i<nx1+1 ; ++i){
67  for (int j=1 ; j<ny1+1 ; ++j){
68 
69  double m = h1 -> GetBinContent(i,j);
70  double n = h2 -> GetBinContent(i,j);
71 
72  double p1 = 1 - ROOT::Math::poisson_cdf(m,1);
73  double p2 = 1 - ROOT::Math::poisson_cdf(n,1);
74 
75  if ((p1 > threshold && p2 < threshold) ||
76  (p1 < threshold && p2 > threshold)){
77  h3->Fill(i,j);
78  failures+=1./(nx1*ny1);
79  }
80  }
81  }
82 
83  bool passed;
84 
85  (failures > outliersThreshold ? passed = false : passed = true);
86 
87  JResultTitle title(testName, parameterName, passed , failures);
88 
89  h3->SetTitle(title.getTitle().c_str());
90 
91  JTestResult r (testName,
92  string (h1->GetDirectory()->GetPath()).append(h1->GetName()),
93  string (h2->GetDirectory()->GetPath()).append(h2->GetName()),
94  h1->GetDirectory()->GetFile()->GetName(),
95  h2->GetDirectory()->GetFile()->GetName(),
96  parameterName, failures, threshold, h3, passed);
97 
98  return r;
99  };
TPaveText * p1
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
Definition: JTest_t.hh:22
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
data_type r[M+1]
Definition: JPolint.hh:742
Structure containing the result of the test.
Definition: JTest_t.hh:164
#define ERROR(A)
Definition: JMessage.hh:66
p2
Definition: module-Z:fit.sh:72
alias put_queue eval echo n
Definition: qlib.csh:19
std::string to_string(const T &value)
Convert value to string.
int j
Definition: JPolint.hh:666

The documentation for this class was generated from the following file: