Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestKolmogorovSlice.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_SLICE__
2 #define __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_SLICE__
3 
4 #include <istream>
5 #include <ostream>
6 #include "TMath.h"
9 
10 
11 /**
12  * \author rgruiz
13  */
14 namespace JCOMPAREHISTOGRAMS {
15 
16  /**
17  * Implementation of the Kolmogorov test for 2D histograms.\n
18  * This class is derived from the abstract class JTest_t(). For a general description of the implementation of this and other tests derived from JTest_t(), see its documentation.\n
19  * This test compares two 2D histograms. If the parameter slice() equals x, X y or Y, the histograms are sliced along the corresponding axis, and the JKolmogorovTest() test is applied to each slice.\n
20  * If slice() equals n or N, the histograms are not sliced, and JKolmogorovTest2D() is applied.\n
21  * The input parameter threshold(), is used to evaluate whether the test is passed or failed for each slice or for the full 2D distribution.\n
22  * The evaluation is done by comparing the threshold() value with the result produced by JKolmogorovTest() or JKolmogorovTest2D(), which is a p-value.\n
23  * The parameter threshold() should therefore be a real value between 0 and 1.
24  */
26  public JTest_t,
27  public JTestKolmogorov_t
28  {
29  public:
30  /**
31  * Default constructor.
32  */
34  JTest_t("KS_Slice", "p-Value(KS)"),
36  {}
37 
38  /**
39  * Read test parameters from input.
40  *
41  * \param in input stream
42  * \return input stream
43  */
44  std::istream& read(std::istream& in) override{
45  return in >> threshold >> slice >> failuresThreshold;
46  };
47 
48  /**
49  * Applies Kolmogorov test for two ROOT TH2 histograms.
50  *
51  * \param o1 First histogram
52  * \param o2 Second histogram
53  */
54  void test(TObject* o1, TObject* o2) override {
55 
56  using namespace std;
57  using namespace JPP;
58 
59  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
60 
61  TH2D* h1 = dynamic_cast<TH2D*>(o1);
62  TH2D* h2 = dynamic_cast<TH2D*>(o2);
63 
64  if(slice == 'x' || slice == 'X' || slice == 'y' || slice == 'Y'){
65 
67 
68  results.push_back(r);
69 
70  } else {
71  ERROR ("Slice option should be: x, X, y or Y, and not " + slice);
72  }
73 
74  } else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
75  ERROR("For 1D histograms call JTestKolmogorov_1D: " << o1->GetName() << endl);
76  }
77  };
78 
79  private:
80  double threshold; //!< threshold p-value to decide if test is passed.
81  double failuresThreshold; //!< threshold p-value to decide if test is passed.
82  char slice; //!< axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
83  };
84 }
85 
86 #endif
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
void test(TObject *o1, TObject *o2) override
Applies Kolmogorov test for two ROOT TH2 histograms.
double failuresThreshold
threshold p-value to decide if test is passed.
Implementation of the different Kolmogorov-related tests.
Definition: JRoot.hh:19
Implementation of the Kolmogorov test for 2D histograms.
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
data_type r[M+1]
Definition: JPolint.hh:742
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
#define ERROR(A)
Definition: JMessage.hh:66
JTestResult JKolmogorovTestSlice(TH2 *h1, TH2 *h2, double threshold, double failuresThreshold, std::string testName, std::string parameterName, char slice)
Kolmogorov test for sliced 2D histograms.
const std::string resultType
result type
Definition: JTest_t.hh:167
const std::string testName
test name
Definition: JTest_t.hh:166
Structure containing the result of the test.
Definition: JTestResult.hh:27
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
char slice
axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
double threshold
threshold p-value to decide if test is passed.
std::istream & read(std::istream &in) override
Read test parameters from input.