Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestSignificance_2D.hh
Go to the documentation of this file.
1 #ifndef __JCOMPAREHISTOGRAMS__JTESTSIGNIFICANCE_2D__
2 #define __JCOMPAREHISTOGRAMS__JTESTSIGNIFICANCE_2D__
3 
4 #include <istream>
5 #include <ostream>
8 
9 
10 /**
11  * \author bofearraigh
12  * \author rgruiz
13  */
14 namespace JCOMPAREHISTOGRAMS {
15 
16  /**
17  * Significance test applied to 2D histograms
18  */
20  public JTest_t,
21  public JTestSignificance_t
22  {
23  public:
24 
25  /**
26  * Default constructor.
27  */
29  JTest_t("Significance_2D", "Significance"),
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 >> threshold >> K;
41  };
42 
43  /**
44  * Applies Significance test for two ROOT TH1 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 
58  if (h1 -> GetNbinsX() != h2 -> GetNbinsX() || h1 -> GetNbinsY() != h2 -> GetNbinsY())
59  ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl);
60 
61  if (K<0)
62  K = h2->GetEntries()/h1->GetEntries();
63 
64  JTestResult r = JSignificanceTest<TH2D>(h1, h2, threshold, K, testName, resultType);
65 
66  results.push_back(r);
67  }
68  };
69 
70  private:
71  double threshold; //!< threshold p-value to decide if test is passed.
72  double K; //!< normalization factor between histograms.
73  };
74 }
75 
76 #endif
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:46
Definition: JRoot.hh:19
double K
normalization factor between histograms.
Significance test applied to 2D histograms.
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
void test(TObject *o1, TObject *o2) override
Applies Significance test for two ROOT TH1 histograms.
std::istream & read(std::istream &in) override
Read test parameters from input.
#define ERROR(A)
Definition: JMessage.hh:66
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 threshold
threshold p-value to decide if test is passed.