1 #ifndef __JCOMPAREHISTOGRAMS__JTESTZERO__
2 #define __JCOMPAREHISTOGRAMS__JTESTZERO__
8 #include "Math/Error.h"
9 #include "Math/ProbFuncMathCore.h"
10 #include "Math/SpecFuncMathCore.h"
28 namespace JCOMPAREHISTOGRAMS {}
29 namespace JPP {
using namespace JCOMPAREHISTOGRAMS; }
31 namespace JCOMPAREHISTOGRAMS {
53 JTest_t(
"Zero",
"failure_fraction")
68 const TH1* h1 =
dynamic_cast<const TH1*
>(o1);
69 const TH1* h2 =
dynamic_cast<const TH1*
>(o2);
71 if (h1 == NULL || h2 == NULL) {
72 THROW(JValueOutOfRange,
"JTestChi2::test(): Could not cast given TObjects to TH2.");
75 const int nx1 = h1->GetNbinsX();
76 const int nx2 = h2->GetNbinsX();
77 const int ny1 = h1->GetNbinsY();
78 const int ny2 = h2->GetNbinsY();
79 const int nz1 = h1->GetNbinsZ();
80 const int nz2 = h2->GetNbinsZ();
82 if(nx1 != nx2 || ny1 != ny2 || nz1 != nz2) {
83 THROW(JValueOutOfRange,
"JTestZero::test(): Histograms with different binning. The objects: " <<
84 h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
87 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
95 for (
int i=1 ;
i<nx1+1 ; ++
i) {
96 for (
int j=1 ;
j<ny1+1 ; ++
j) {
97 for (
int k=1 ;
k<nz1+1 ; ++
k) {
99 const int Nbin = h3->GetBin(
i,
j,
k);
101 const double m = h1->GetBinContent(
i,
j,
k);
102 const double n = h2->GetBinContent(
i,
j,
k);
104 const double p1 = 1 - ROOT::Math::poisson_cdf(m,1);
105 const double p2 = 1 - ROOT::Math::poisson_cdf(n,1);
121 h3->SetTitle(title.
getTitle().c_str());
123 const int Ndims = h3->GetDimension();
127 }
else if (Ndims == 2) {
146 std::istream&
read(std::istream&
in)
override
152 if (threshold < 0.0 || threshold > 1.0) {
153 THROW(JValueOutOfRange,
"JTestZero::read(): Invalid threshold value " <<
threshold);
156 if (outliersThreshold < 0.0 || outliersThreshold > 1.0) {
then usage $script< detector file > minrun maxrun report nIn case of failures
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
Interface to read input and write output for TObject tests.
std::string getTitle() const
Returns a standard string to be used as title of a graphical root object.
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
Auxiliary class to handle file name, ROOT directory and object name.
void test(const TObject *o1, const TObject *o2) override
Bin-by-bin comparison for ROOT histograms, of compatibility with a Poisson pdf of parameter 1...
#define MAKE_STRING(A)
Make string.
double outliersThreshold
Fraction of bins allowed to fail.
double threshold
threshold p-value to decide if test is passed.
const std::string resultType
test result type
const std::string testName
test name
std::istream & read(std::istream &in) override
Read test parameters from input.
Auxiliary class to define a range between two values.
Implementation of a bin-by-bin compatibility test for histograms with low bin contents.
Structure containing the result of the test.
JTestZero()
Default constructor.
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