Implementation of the a test to check if two 1D histograms are the same.
More...
#include <JTestIdentical_1D.hh>
|
| JTestIdentical_1D () |
| Default constructor. More...
|
|
std::istream & | read (std::istream &in) override |
| Read test parameters from input. More...
|
|
std::ostream & | write (std::ostream &out, std::string delimiter=" ", bool onlyFailures=false) const override |
| Write test result to output. More...
|
|
void | test (TObject *o1, TObject *o2) override |
| Applies test for two ROOT TH1 histograms. More...
|
|
virtual void | save (TFile *f, std::string path, bool onlyFailures=false) override |
| Writes the test result to root file. More...
|
|
void | clear () override |
| Clear results. More...
|
|
std::string | getName () override |
| Get test name. More...
|
|
std::string | getParameter () override |
| Get parameter name. More...
|
|
template<class T > |
JTestResult | JIdenticalTest (T *h1, T *h2, double tolerance, std::string testName, std::string parameterName) |
| Bin-by-Bin test of two histograms, that verifies whether the histograms are the same. More...
|
|
Implementation of the a test to check if two 1D histograms are the same.
- Author
- rgruiz
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.
The input parameter tolerance(), is used to evaluate whether the test is passed or failed.
The test is run by the method JIdenticalTest().
Definition at line 19 of file JTestIdentical_1D.hh.
JTestIdentical_1D::JTestIdentical_1D |
( |
| ) |
|
|
inline |
std::istream& JTestIdentical_1D::read |
( |
std::istream & |
in | ) |
|
|
inlineoverridevirtual |
Read test parameters from input.
- Parameters
-
- Returns
- input stream
Implements JTest_t.
Definition at line 36 of file JTestIdentical_1D.hh.
double tolerance
tolerance value to accept the difference as acceptable.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
std::ostream& JTestIdentical_1D::write |
( |
std::ostream & |
out, |
|
|
std::string |
delimiter = " " , |
|
|
bool |
onlyFailures = false |
|
) |
| const |
|
inlineoverridevirtual |
Write test result to output.
- Parameters
-
out | output stream |
delimiter | field delimiter |
onlyFailures | If true, write only failures. |
- Returns
- output stream
Implements JTest_t.
Definition at line 48 of file JTestIdentical_1D.hh.
52 out << std::scientific << std::setprecision(2) << (
r->passed ?
JPP::GREEN :
JPP::RED) <<
r->print(delimiter) << std::endl;
54 out << std::scientific << std::setprecision(2) << (
r->passed ?
JPP::GREEN :
JPP::RED) <<
r->print(delimiter) << std::endl;
std::vector< JTestResult > results
Applies test for two ROOT TH1 histograms.
- Parameters
-
o1 | First histogram |
o2 | Second histogram |
Implements JTest_t.
Definition at line 66 of file JTestIdentical_1D.hh.
70 if (!(dynamic_cast<TH2*>(o1) == NULL) || !(dynamic_cast<TH2*>(o2) == NULL)) {
71 ERROR(
"For 2D histograms call JTestIdentical_2D: " << o1->GetName() << endl);
73 }
else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(
dynamic_cast<TH1*
>(o2) == NULL)) {
75 TH1D*
h1 =
dynamic_cast<TH1D*
>(o1);
76 TH1D* h2 =
dynamic_cast<TH1D*
>(o2);
78 if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
79 ERROR(
"Histograms with different bining. The objects: " << h1 -> GetName() <<
" can not be compared." << endl);
std::vector< JTestResult > results
const std::string name
test name.
then for HISTOGRAM in h0 h1
double tolerance
tolerance value to accept the difference as acceptable.
Structure containing the result of the test.
const std::string parameter
parameter name.
virtual void JTestIdentical_1D::save |
( |
TFile * |
f, |
|
|
std::string |
path, |
|
|
bool |
onlyFailures = false |
|
) |
| |
|
inlineoverridevirtual |
Writes the test result to root file.
- Parameters
-
f | A ROOT file |
path | Path in root file. |
onlyFailures | If true, write only failures. |
Implements JTest_t.
Definition at line 93 of file JTestIdentical_1D.hh.
101 if (
f -> GetDirectory(
path.c_str())==0)
f->mkdir(
path.c_str());
106 if (
f -> GetDirectory(
path.c_str())==0)
f->mkdir(
path.c_str());
std::vector< JTestResult > results
do cat driver txt<< EOFevent ev_configure{RC_EVT%< ev_configure.txt > RC_DWRT path
void JTestIdentical_1D::clear |
( |
| ) |
|
|
inlineoverridevirtual |
std::string JTestIdentical_1D::getName |
( |
| ) |
|
|
inlineoverridevirtual |
std::string JTestIdentical_1D::getParameter |
( |
| ) |
|
|
inlineoverridevirtual |
template<class T >
JTestResult JTestIdentical_t::JIdenticalTest |
( |
T * |
h1, |
|
|
T * |
h2, |
|
|
double |
tolerance, |
|
|
std::string |
testName, |
|
|
std::string |
parameterName |
|
) |
| |
|
inlineinherited |
Bin-by-Bin test of two histograms, that verifies whether the histograms are the same.
For each bin, the test calculates the difference, and compares it with a tolerance passed as an argument.
The test is passed if the difference is smaller than the tolerance for every bin.
The template parameter can be TH1X, TH2X or TH3X.
- Parameters
-
h1 | First object |
h2 | Second object |
tolerance | tolerance value for the bin-by-bin differences |
parameterName | Name of the parameter used to test the histograms |
testName | Name of the test used to compare the histograms |
- Returns
- Test result.
Definition at line 39 of file JTestIdentical_t.hh.
44 if(
h1 -> GetNbinsX() != h2 -> GetNbinsX() ||
h1 -> GetNbinsY() != h2 -> GetNbinsY() ||
h1 -> GetNbinsZ() != h2 -> GetNbinsZ())
45 ERROR(
"Histograms with different bining. The objects: " <<
h1 -> GetName() <<
" can not be compared." << endl);
47 T* h3 = (
T*)
h1->Clone(
h1->GetName()==h2->GetName() ?
55 double maxDifference = 0.0;
57 for (
int i=0 ; i <
h1->GetNbinsX() ; ++i){
58 for (
int j=0 ;
j<
h1->GetNbinsY() ; ++
j){
59 for (
int k=0 ;
k<
h1->GetNbinsY() ; ++
k){
61 double d =
h1->GetBinContent(i+1,
j+1,
k+1) - h2->GetBinContent(i+1,
j+1,
k+1);
63 if (fabs(d) > maxDifference)
64 maxDifference = fabs(d);
65 if (fabs(d) > tolerance)
71 JResultTitle title(testName, parameterName, passed , maxDifference);
73 h3->SetTitle(title.getTitle().c_str());
76 string (
h1->GetDirectory()->GetPath()).append(
h1->GetName()),
77 string (h2->GetDirectory()->GetPath()).append(h2->GetName()),
78 h1->GetDirectory()->GetFile()->GetName(),
79 h2->GetDirectory()->GetFile()->GetName(),
80 parameterName, maxDifference, tolerance, h3, passed);
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
then fatal No sound hydrophone file $HYDROPHONE_TXT fi JGraph f $HYDROPHONE_TXT o $HYDROPHONE_ROOT sort gr k
#define MAKE_CSTRING(A)
Make C-string.
then for HISTOGRAM in h0 h1
Structure containing the result of the test.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
std::string to_string(const T &value)
Convert value to string.
double JTestIdentical_1D::tolerance |
|
private |
const std::string JTestIdentical_1D::name = "Identical_1D" |
|
private |
const std::string JTestIdentical_1D::parameter = "Difference" |
|
private |
Buffer to store results of multiple tests.
Definition at line 251 of file JTest_t.hh.
The documentation for this class was generated from the following file: