Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
JTestSignificance_t Class Reference

#include <JTestSignificance_t.hh>

Inheritance diagram for JTestSignificance_t:
JTestSignificance_1D JTestSignificance_2D

Public Member Functions

 JTestSignificance_t ()
 Default constructor. More...
 
template<class T >
JTestResult JSignificanceTest (T *h1, T *h2, double threshold, double K, std::string testName, std::string parameterName)
 Significance test for histograms. More...
 

Detailed Description

Author
bofearraigh
rgruiz

Compares two histograms $ H_a $ and $ H_b $ by calculating the average bin significance

\[ S = \frac{1}{N} \cdot \sum_{i=0}^{N} \frac{|a_i - K \cdot b_i|}{\sqrt{\sigma ^2(a_i) + K^2 \cdot \sigma ^2(b_i)}} \]

where:

A threshold value for $ S $ is used to tag the test as passed or failed.

Definition at line 29 of file JTestSignificance_t.hh.

Constructor & Destructor Documentation

JTestSignificance_t::JTestSignificance_t ( )
inline

Default constructor.

Definition at line 36 of file JTestSignificance_t.hh.

36 {}

Member Function Documentation

template<class T >
JTestResult JTestSignificance_t::JSignificanceTest ( T h1,
T h2,
double  threshold,
double  K,
std::string  testName,
std::string  parameterName 
)
inline

Significance test for histograms.


Parameters
h1First object
h2Second object
threshold
KNormalisation parameter
parameterNameName of the parameter used to test the histograms
testNameName of the test used to compare the histograms
Returns
Test result.

Definition at line 51 of file JTestSignificance_t.hh.

51  {
52 
53  using namespace std;
54  using namespace JPP;
55 
56  if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
57  ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl);
58 
59 
60  T* h3 = (T*)h1->Clone(h1->GetName()==h2->GetName() ?
61  MAKE_CSTRING(to_string(h1->GetName())) :
62  MAKE_CSTRING(to_string(h1->GetName()) + "_VS_" + to_string(h2->GetName())));
63 
64  h3->Add(h2,-1*K);
65 
66  double S = 0;
67 
68  for (int i=0 ; i < h1->GetNbinsX() ; ++i){
69  for (int j=0 ; j< h1->GetNbinsY() ; ++j){
70  for (int k=0 ; k< h1->GetNbinsY() ; ++k){
71 
72  double a = h1->GetBinContent(i+1,j+1,k+1);
73  double b = h2->GetBinContent(i+1,j+1,k+1);
74 
75  if(a!=0 || b!=0){
76  S += fabs((a - K*b)/sqrt(a + K*K*b));
77  }
78  }
79  }
80  }
81 
82  S /= (h1->GetNbinsX()*h1->GetNbinsY()*h1->GetNbinsZ());
83 
84  bool passed;
85 
86  (S < threshold ? passed = false : passed = true);
87 
88  JResultTitle title(testName, parameterName, passed, S);
89 
90  h3->SetTitle(title.getTitle().c_str());
91 
92  JTestResult r (testName,
93  string (h1->GetDirectory()->GetPath()).append(h1->GetName()),
94  string (h2->GetDirectory()->GetPath()).append(h2->GetName()),
95  h1->GetDirectory()->GetFile()->GetName(),
96  h2->GetDirectory()->GetFile()->GetName(),
97  parameterName, S , threshold, h3, passed);
98 
99  return r;
100  };
static const uint32_t K[64]
Definition: crypt.cc:77
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
Definition: JTest_t.hh:22
then fatal No sound hydrophone file $HYDROPHONE_TXT fi JGraph f $HYDROPHONE_TXT o $HYDROPHONE_ROOT sort gr k
#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
do set_variable OUTPUT_DIRECTORY $WORKDIR T
#define ERROR(A)
Definition: JMessage.hh:66
do set_variable SIGMA_NS set_variable OUTLIERS set_variable OUTPUT_FILE matrix[${ALPHA_DEG}\deg\] root $JPP JMatrixNZ a $DETECTOR f $INPUT_FILE o $OUTPUT_FILE S
Definition: JMatrixNZ.sh:56
then $JPP_DIR software JCalibrate JCalibrateToT a
Definition: JTuneHV.sh:108
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: