1 #ifndef __JCOMPAREHISTOGRAMS__JTESTIDENTICAL__
2 #define __JCOMPAREHISTOGRAMS__JTESTIDENTICAL__
17 namespace JCOMPAREHISTOGRAMS {}
18 namespace JPP {
using namespace JCOMPAREHISTOGRAMS; }
20 namespace JCOMPAREHISTOGRAMS {
36 JTest_t(
"Identical",
"Difference")
51 const TH1* h1 =
dynamic_cast<const TH1*
>(o1);
52 const TH1* h2 =
dynamic_cast<const TH1*
>(o2);
54 if (h1 == NULL || h2 == NULL) {
55 THROW(JValueOutOfRange,
"JTestIdentical::test(): Could not cast given TObjects to TH1.");
58 if(h1->GetNbinsX() != h2->GetNbinsX() ||
59 h1->GetNbinsY() != h2->GetNbinsY() ||
60 h1->GetNbinsZ() != h2->GetNbinsZ()) {
61 THROW(JValueOutOfRange,
"JTestIdentical::test(): Histograms with different bining. The objects: " <<
62 h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
65 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
73 double maxDifference = 0.0;
75 for (
int i=1 ;
i <= h1->GetNbinsX() && passed ; ++
i){
76 for (
int j=1 ;
j <= h1->GetNbinsY() && passed ; ++
j){
77 for (
int k=1 ;
k <= h1->GetNbinsZ() && passed ; ++
k){
79 const double d = h1->GetBinContent(
i,
j,
k) - h2->GetBinContent(
i,
j,
k);
81 if (fabs(d) > maxDifference) { maxDifference = fabs(d); }
82 if (fabs(d) >
tolerance) { passed =
false; }
89 h3->SetTitle(title.
getTitle().c_str());
91 const int Ndims = h3->GetDimension();
95 }
else if (Ndims == 2) {
114 std::istream&
read(std::istream&
in)
override
121 THROW(JValueOutOfRange,
"JTestIdentical::read(): Invalid tolerance value " <<
tolerance);
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...
void test(const TObject *o1, const TObject *o2) override
Applies test for two ROOT TH1 histograms.
#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.
#define MAKE_STRING(A)
Make string.
double tolerance
tolerance value to accept the difference as acceptable.
std::istream & read(std::istream &in) override
Read test parameters from input.
Implementation of the a test to check if two 1D histograms are the same.
const std::string resultType
test result type
const std::string testName
test name
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
JTestIdentical()
Default constructor.
Structure containing the result of the test.
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