Jpp  17.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestRuns_1D.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__
2 #define __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__
3 
4 #include <istream>
5 #include <ostream>
8 
9 
10 /**
11  * \author rgruiz
12  */
13 namespace JCOMPAREHISTOGRAMS {
14 
15  /**
16  * Implementation of the Runs test for 1D 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  * This test uses the input parameter threshold() to evaluate whether the test is passed or failed.\n
19  * The evaluation is done by comparing the threshold value with the result of the JRunsTest() test.
20  */
21  class JTestRuns_1D:
22  public JTest_t,
23  public JTestRuns_t
24  {
25  public:
26 
28  JTest_t("Runs_1D", "#sigma"),
29  JTestRuns_t()
30  {}
31 
32  /**
33  * Read test parameters from input.
34  *
35  * \param in input stream
36  * \return input stream
37  */
38  std::istream& read(std::istream& in) override{
39  return in >> threshold;
40  };
41 
42  /**
43  * Tests the statistical compatibility of two ROOT TObjects
44  *
45  * \param o1 First object
46  * \param o2 Second object
47  */
48  void test(TObject* o1, TObject* o2) override{
49 
50  using namespace std;
51 
52  if (!(dynamic_cast<TH2*>(o1) == NULL) || !(dynamic_cast<TH2*>(o2) == NULL)) {
53  ERROR("For 2D histograms call JTestRuns_2D: " << o1->GetName() << endl);
54 
55  } else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
56 
57  TH1D* h1 = dynamic_cast<TH1D*>(o1);
58  TH1D* h2 = dynamic_cast<TH1D*>(o2);
59 
60  if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
61  ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl);
62 
64 
65  results.push_back(r);
66  }
67  };
68 
69  private:
70  double threshold; //!< threshold value to decide if test is passed.
71  };
72 }
73 
74 #endif
JTestResult JRunsTest(TH1 *h1, TH1 *h2, double threshold, std::string testName, std::string parameterName)
Implements the Wald-Wolfowitx runs test: https://en.wikipedia.org/wiki/Wald%E2%80%93Wolfowitz_runs_te...
Definition: JTestRuns_t.hh:40
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
void test(TObject *o1, TObject *o2) override
Tests the statistical compatibility of two ROOT TObjects.
Definition: JTestRuns_1D.hh:48
std::istream & read(std::istream &in) override
Read test parameters from input.
Definition: JTestRuns_1D.hh:38
Definition: JRoot.hh:19
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
#define ERROR(A)
Definition: JMessage.hh:66
Implementation of the Runs test for 1D histograms.
Definition: JTestRuns_1D.hh:21
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 different Runs-related tests.
Definition: JTestRuns_t.hh:20
double threshold
threshold value to decide if test is passed.
Definition: JTestRuns_1D.hh:67
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