Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestChi2_2D.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTCHI2_2D__
2 #define __JCOMPAREHISTOGRAMS__JTESTCHI2_2D__
3 
4 #include <istream>
5 #include <ostream>
8 
9 
10 /**
11  * \author rgruiz
12  */
13 namespace JCOMPAREHISTOGRAMS {
14 
15  /**
16  * Implementation of the Chi2 test for 2D histograms.\n
17  * 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
18  * The parameter slice() can have the values x, X, y or Y. The histograms are sliced along the corresponding axis, and the JChi2Test() test is applied to each slice.\n
19  * The input parameter threshold(), is used to evaluate whether the test is passed or failed for each slice.\n
20  * The evaluation is done by comparing the threshold() value with the result produced by JChi2Test(). The output of JChi2Test() is a p-value.\n
21  * The parameter threshold() should therefore be a real value between 0 and 1.
22  */
23  class JTestChi2_2D:
24  public JTest_t,
25  public JTestChi2_t
26  {
27  public:
28 
29  /**
30  * Default constructor.
31  */
33  JTest_t("Chi2_2D", "p-Value(chi2)"),
34  JTestChi2_t()
35  {}
36 
37  /**
38  * Read test parameters from input.
39  *
40  * \param in input stream
41  * \return input stream
42  */
43  std::istream& read(std::istream& in) override{
44  return in >> threshold >> failuresThreshold >> slice >> options;
45  };
46 
47  /**
48  * Applies Chi2 test for two ROOT TH2 histograms.
49  *
50  * \param o1 First histogram
51  * \param o2 Second histogram
52  */
53  void test(TObject* o1, TObject* o2) override{
54 
55  using namespace std;
56  using namespace JPP;
57 
58  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
59 
60  TH2D* h1 = dynamic_cast<TH2D*>(o1);
61  TH2D* h2 = dynamic_cast<TH2D*>(o2);
62 
63  if(slice == 'x' || slice == 'X' || slice == 'y' || slice == 'Y'){
64 
66 
67  results.push_back(r);
68 
69  } else {
70  ERROR ("Slice option should be: x, X, y or Y, and not " << slice);
71  }
72 
73  } else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
74  ERROR("For 1D histograms call JChi2_1D: " << o1->GetName() << endl);
75  }
76  };
77 
78  private:
79  double threshold; //!< threshold p-value to decide if test is passed.
80  double failuresThreshold; //!< threshold p-value to decide if test is passed.
81  char slice; //!< axis to slice.
82  std::string options; //!< options for the ROOT chi2 test.
83  };
84 }
85 
86 #endif
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
JTestResult JChi2TestSlice(TH2 *h1, TH2 *h2, double threshold, double failuresThreshold, std::string testName, std::string parameterName, std::string options, char slice)
Chi2 test for sliced 2D histograms.
Definition: JTestChi2_t.hh:115
std::istream & read(std::istream &in) override
Read test parameters from input.
Definition: JTestChi2_2D.hh:43
Definition: JRoot.hh:19
data_type r[M+1]
Definition: JPolint.hh:779
double failuresThreshold
threshold p-value to decide if test is passed.
Definition: JTestChi2_2D.hh:80
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
JTestChi2_2D()
Default constructor.
Definition: JTestChi2_2D.hh:32
std::string options
options for the ROOT chi2 test.
Definition: JTestChi2_2D.hh:82
#define ERROR(A)
Definition: JMessage.hh:66
then awk string
const std::string resultType
result type
Definition: JTest_t.hh:167
const std::string testName
test name
Definition: JTest_t.hh:166
double threshold
threshold p-value to decide if test is passed.
Definition: JTestChi2_2D.hh:76
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 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
void test(TObject *o1, TObject *o2) override
Applies Chi2 test for two ROOT TH2 histograms.
Definition: JTestChi2_2D.hh:53
Implementation of the different Chi2-related tests.
Definition: JTestChi2_t.hh:21
Implementation of the Chi2 test for 2D histograms.
Definition: JTestChi2_2D.hh:23