Jpp  16.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestRuns_2D.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTRUNS_2D__
2 #define __JCOMPAREHISTOGRAMS__JTESTRUNS_2D__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JLang/JException.hh"
8 
11 
12 
13 /**
14  * \author rgruiz
15  */
16 namespace JCOMPAREHISTOGRAMS {
17 
18  /**
19  * Implementation of the Chi2 test for 2D histograms.\n
20  * 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
21  * The parameter slice() can have the values x, X, y or Y. The histograms are sliced along the corresponding axis, and the JRunsTest() test is applied to each slice.\n
22  * This test uses the input parameter threshold() to evaluate whether the test is passed or failed for each slice.\n
23  * The evaluation is done by comparing the threshold value with the result of the JRunsTest() test.\n
24  * The results for each slice are stored in the results buffer (see JTest_t().)
25  */
26  class JTestRuns_2D:
27  public JTest_t,
28  public JTestRuns_t
29  {
30  public:
31 
33  JTest_t("Runs_2D", "#sigma"),
34  JTestRuns_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 
45  in >> threshold >> slice;
46 
47  if (!(slice == 'x' || slice == 'X' || slice == 'y' || slice == 'Y')) {
48  THROW(JLANG::JValueOutOfRange, "JTestRuns_2D::read(): Invalid slice option \'" << slice << "\'");
49  }
50 
51  return in;
52  };
53 
54  /**
55  * Tests the statistical compatibility of two ROOT TObjects
56  *
57  * \param o1 First object
58  * \param o2 Second object
59  */
60  void test(TObject* o1, TObject* o2) override{
61 
62  using namespace std;
63  using namespace JPP;
64 
65  if (!(slice == 'x' || slice == 'X' || slice == 'y' || slice == 'Y')) {
66  THROW(JLANG::JValueOutOfRange, "JTestRuns_2D::test(): Invalid slice option \'" << slice << "\'");
67  }
68 
69  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
70 
71  TH2D* h1 = dynamic_cast<TH2D*>(o1);
72  TH2D* h2 = dynamic_cast<TH2D*>(o2);
73 
75 
76  results.push_back(r);
77 
78  } else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
79  THROW(JLANG::JValueOutOfRange, "JTestRuns_2D::test(): For 1D histograms call JChi2_1D: " << o1->GetName() << endl);
80  }
81  };
82 
83  private:
84  double threshold; //!< threshold value to decide if test is passed.
85  double failuresThreshold; //!< threshold value to decide if test is passed.
86  char slice; //!< Axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
87  };
88 }
89 
90 #endif
Exceptions.
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Definition: JRoot.hh:19
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
data_type r[M+1]
Definition: JPolint.hh:758
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
std::istream & read(std::istream &in) override
Read test parameters from input.
Definition: JTestRuns_2D.hh:43
const std::string resultType
result type
Definition: JTest_t.hh:167
double threshold
threshold value to decide if test is passed.
Definition: JTestRuns_2D.hh:81
const std::string testName
test name
Definition: JTest_t.hh:166
Implementation of the different Runs-related tests.
Definition: JTestRuns_t.hh:20
Structure containing the result of the test.
Definition: JTestResult.hh:27
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
double failuresThreshold
threshold value to decide if test is passed.
Definition: JTestRuns_2D.hh:85
JTestResult JRunsTestSlice(TH2 *h1, TH2 *h2, double threshold, double failuresThreshold, std::string testName, std::string parameterName, char slice)
Runs test for sliced 2D histograms.
Definition: JTestRuns_t.hh:116
char slice
Axis to slice. x or X for x-axis, y or Y for y-axis, n or N for None.
Definition: JTestRuns_2D.hh:86
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:42
Implementation of the Chi2 test for 2D histograms.
Definition: JTestRuns_2D.hh:26
void test(TObject *o1, TObject *o2) override
Tests the statistical compatibility of two ROOT TObjects.
Definition: JTestRuns_2D.hh:60