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
JTestChi2_Bin.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTCHI2_BIN__
2 #define __JCOMPAREHISTOGRAMS__JTESTCHI2_BIN__
3 
4 #include <istream>
5 #include <ostream>
8 
9 
10 /**
11  * \author rgruiz
12  */
13 namespace JCOMPAREHISTOGRAMS {
14 
15  /**
16  * Implementation of a bin-by-bin 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 test is run by the method JChi2TestBin_2D().
19  */
20  class JTestChi2_Bin:
21  public JTest_t,
22  public JTestChi2_t
23  {
24  public:
25  /**
26  * Default constructor.
27  */
29  JTest_t("Chi2_Bin", "Outliers[%]"),
30  JTestChi2_t()
31  {}
32 
33  /**
34  * Read test parameters from input.
35  *
36  * \param in input stream
37  * \return input stream
38  */
39  std::istream& read(std::istream& in) override{
40  return in >> outliersThreshold >> chi2Threshold;
41  };
42 
43  /**
44  * Tests the statistical compatibility of two ROOT 2D histograms
45  *
46  * \param o1 First histogram
47  * \param o2 Second histogram
48  */
49  void test(TObject* o1, TObject* o2) override{
50 
51  using namespace std;
52 
53  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
54 
55  TH2D* h1 = dynamic_cast<TH2D*>(o1);
56  TH2D* h2 = dynamic_cast<TH2D*>(o2);
57 
59  results.push_back(r);
60  }
61  };
62 
63  private:
64  double chi2Threshold; //!< threshold p-value to decide if test is passed for a bin.
65  double outliersThreshold; //!< fraction of bins allowed to fail the test.
66  };
67 }
68 
69 #endif
void test(TObject *o1, TObject *o2) override
Tests the statistical compatibility of two ROOT 2D histograms.
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
JTestResult JChi2TestBin_2D(TH2 *h1, TH2 *h2, double outliersThreshold, double chi2Threshold, std::string testName, std::string parameterName)
Bin-by-Bin Chi2 comparison of 2D histograms.
Definition: JTestChi2_t.hh:231
Definition: JRoot.hh:19
data_type r[M+1]
Definition: JPolint.hh:779
JTestChi2_Bin()
Default constructor.
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
double chi2Threshold
threshold p-value to decide if test is passed for a bin.
Implementation of a bin-by-bin Chi2 test for 2D histograms.
const std::string resultType
result type
Definition: JTest_t.hh:167
const std::string testName
test name
Definition: JTest_t.hh:166
std::istream & read(std::istream &in) override
Read test parameters from input.
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 outliersThreshold
fraction of bins allowed to fail the test.
Implementation of the different Chi2-related tests.
Definition: JTestChi2_t.hh:21