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