Jpp  16.0.2
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
JCOMPAREHISTOGRAMS::JTestZero_t Class Reference

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

#include <JTestZero_t.hh>

Inheritance diagram for JCOMPAREHISTOGRAMS::JTestZero_t:
JCOMPAREHISTOGRAMS::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.

Definition at line 28 of file JTestZero_t.hh.

Constructor & Destructor Documentation

JCOMPAREHISTOGRAMS::JTestZero_t::JTestZero_t ( )
inline

Default constructor.

Definition at line 35 of file JTestZero_t.hh.

35 {}

Member Function Documentation

JTestResult JCOMPAREHISTOGRAMS::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 54 of file JTestZero_t.hh.

54  {
55 
56  using namespace std;
57  using namespace JPP;
58 
59  int nx1 = h1->GetNbinsX();
60  int nx2 = h2->GetNbinsX();
61  int ny1 = h1->GetNbinsY();
62  int ny2 = h2->GetNbinsY();
63 
64  if(nx1 != nx2 || ny1 != ny2)
65  ERROR("Histograms with different binning. The objects: " << h1->GetName() << " can not be compared." << endl);
66 
67  TH2D* h3 = (TH2D*)h1->Clone(h1->GetName()==h2->GetName() ?
68  MAKE_CSTRING(to_string(h1->GetName())) :
69  MAKE_CSTRING(to_string(h1->GetName()) + "_VS_" + to_string(h2->GetName())));
70  h3->Reset();
71 
72  double failures = 0;
73 
74  for (int i=1 ; i<nx1+1 ; ++i){
75  for (int j=1 ; j<ny1+1 ; ++j){
76 
77  double m = h1 -> GetBinContent(i,j);
78  double n = h2 -> GetBinContent(i,j);
79 
80  double p1 = 1 - ROOT::Math::poisson_cdf(m,1);
81  double p2 = 1 - ROOT::Math::poisson_cdf(n,1);
82 
83  if ((p1 > threshold && p2 < threshold) ||
84  (p1 < threshold && p2 > threshold)){
85  h3->Fill(i,j);
86  failures+=1./(nx1*ny1);
87  }
88  }
89  }
90 
91  bool passed;
92 
93  (failures > outliersThreshold ? passed = false : passed = true);
94 
95  JResultTitle title(testName, parameterName, passed , failures);
96 
97  h3->SetTitle(title.getTitle().c_str());
98 
99  JTestResult r (testName,
100  JRootObjectID(MAKE_STRING(h1->GetDirectory()->GetPath() << h1->GetName())),
101  JRootObjectID(MAKE_STRING(h2->GetDirectory()->GetPath() << h1->GetName())),
102  parameterName, failures, threshold, h3, passed);
103 
104  return r;
105  };
TPaveText * p1
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
data_type r[M+1]
Definition: JPolint.hh:758
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:142
const int n
Definition: JPolint.hh:676
#define ERROR(A)
Definition: JMessage.hh:66
p2
Definition: module-Z:fit.sh:74
std::string to_string(const T &value)
Convert value to string.
int j
Definition: JPolint.hh:682

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