Jpp  18.0.1-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestKolmogorov_2D.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_2D__
2 #define __JCOMPAREHISTOGRAMS__JTESTKOLMOGOROV_2D__
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_2D", "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;
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 
65  results.push_back(r);
66 
67  }else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
68  ERROR("For 1D histograms call JTestKolmogorov_1D: " << o1->GetName() << endl);
69  }
70  };
71 
72  private:
73  double threshold; //!< threshold p-value to decide if test is passed.
74  };
75 }
76 
77 #endif
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
Implementation of the different Kolmogorov-related tests.
Definition: JRoot.hh:19
std::istream & read(std::istream &in) override
Read test parameters from input.
data_type r[M+1]
Definition: JPolint.hh:779
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
void test(TObject *o1, TObject *o2) override
Applies Kolmogorov test for two ROOT TH2 histograms.
#define ERROR(A)
Definition: JMessage.hh:66
const std::string resultType
result type
Definition: JTest_t.hh:167
const std::string testName
test name
Definition: JTest_t.hh:166
Implementation of the Kolmogorov test for 2D histograms.
double threshold
threshold p-value to decide if test is passed.
Structure containing the result of the test.
Definition: JTestResult.hh:27
JTestResult JKolmogorovTest2D(TH2 *h1, TH2 *h2, double threshold, std::string testName, std::string parameterName)
Kolmogorov test for 2D histograms.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46