Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Member Functions | Protected Attributes | Friends | List of all members
JCOMPAREHISTOGRAMS::JTest_t Class Referenceabstract

Interface to read input and write output for TObject tests. More...

#include <JTest_t.hh>

Inheritance diagram for JCOMPAREHISTOGRAMS::JTest_t:
std::vector< JTestResult > JCOMPAREHISTOGRAMS::JTestChi2 JCOMPAREHISTOGRAMS::JTestChi2_Bin JCOMPAREHISTOGRAMS::JTestChi2_Slice2D JCOMPAREHISTOGRAMS::JTestIdentical JCOMPAREHISTOGRAMS::JTestKolmogorov_1D JCOMPAREHISTOGRAMS::JTestKolmogorov_2D JCOMPAREHISTOGRAMS::JTestKolmogorov_Slice2D JCOMPAREHISTOGRAMS::JTestPoissonLogLikelihoodRatio JCOMPAREHISTOGRAMS::JTestPoissonLogLikelihoodRatioBeestonBarlow JCOMPAREHISTOGRAMS::JTestRuns_1D JCOMPAREHISTOGRAMS::JTestRuns_Slice2D JCOMPAREHISTOGRAMS::JTestSignificance JCOMPAREHISTOGRAMS::JTestZero

Public Member Functions

 JTest_t (const std::string &testName, const std::string &resultType)
 Constructor. More...
 
virtual void test (const TObject *o1, const TObject *o2)=0
 Tests compatibility between two TObjects. More...
 
virtual std::istream & read (std::istream &in)=0
 Read test parameters from input. More...
 
virtual std::ostream & write (std::ostream &out, const char delimiter=' ', const bool onlyFailures=false) const
 Write test result to output. More...
 
virtual void save (TFile *f, const std::string &path, const bool onlyFailures=false) const
 Writes the test result to root file. More...
 
const std::string & getTestName () const
 Get test name. More...
 
const std::string & getResultType () const
 Get result type. More...
 

Protected Attributes

const std::string testName
 test name More...
 
const std::string resultType
 test result type More...
 

Friends

std::istream & operator>> (std::istream &in, JTest_t &test)
 Read test parameters from input. More...
 
std::ostream & operator<< (std::ostream &out, const JTest_t &test)
 Write test result to output. More...
 

Detailed Description

Interface to read input and write output for TObject tests.


This is an abstract class from which the different tests are derived.
All tests have in common the methods from this interface.
For each test, the parameters are passed through an istream, and parsed by the read() method.
For each test, the different results are stored in the internal results buffer.
The write() method is used to print a message with the result of the test.
The save() method is used to save a graphical output with the test results into a .root file.
For a list of available tests see JTestDictionary()

Definition at line 40 of file JTest_t.hh.

Constructor & Destructor Documentation

◆ JTest_t()

JCOMPAREHISTOGRAMS::JTest_t::JTest_t ( const std::string &  testName,
const std::string &  resultType 
)
inline

Constructor.

Parameters
testNametest name
resultTyperesult type

Definition at line 51 of file JTest_t.hh.

52  :
55  {}
const std::string resultType
test result type
Definition: JTest_t.hh:181
const std::string testName
test name
Definition: JTest_t.hh:180

Member Function Documentation

◆ test()

virtual void JCOMPAREHISTOGRAMS::JTest_t::test ( const TObject o1,
const TObject o2 
)
pure virtual

◆ read()

virtual std::istream& JCOMPAREHISTOGRAMS::JTest_t::read ( std::istream &  in)
pure virtual

◆ write()

virtual std::ostream& JCOMPAREHISTOGRAMS::JTest_t::write ( std::ostream &  out,
const char  delimiter = ' ',
const bool  onlyFailures = false 
) const
inlinevirtual

Write test result to output.

Parameters
outoutput stream
delimiterfield delimiter
onlyFailuresif true, write only failures.
Returns
output stream

Definition at line 84 of file JTest_t.hh.

87  {
88  using namespace std;
89  using namespace JPP;
90 
91  for (vector<JTestResult>::const_iterator r = this->begin() ; r != this->end() ; ++r) {
92 
93  if (onlyFailures && r->passed) { continue; }
94 
95  print(out, *r, delimiter, true);
96  }
97 
98  return out;
99  }
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
data_type r[M+1]
Definition: JPolint.hh:868
Definition: JSTDTypes.hh:14

◆ save()

virtual void JCOMPAREHISTOGRAMS::JTest_t::save ( TFile *  f,
const std::string &  path,
const bool  onlyFailures = false 
) const
inlinevirtual

Writes the test result to root file.

Parameters
fA ROOT file
pathPath in root file.
onlyFailuresIf true, write only failures.

Definition at line 108 of file JTest_t.hh.

111  {
112  using namespace std;
113  using namespace JPP;
114 
115  if (f->GetDirectory(path.c_str())==0) {
116  f->mkdir(path.c_str());
117  }
118 
119  f->cd(path.c_str());
120 
121  for (vector<JTestResult>::const_iterator r = this->begin() ; r != this->end() ; ++r) {
122 
123  if (onlyFailures && r->passed) { continue; }
124 
125  r->obj->Write();
126  }
127  }

◆ getTestName()

const std::string& JCOMPAREHISTOGRAMS::JTest_t::getTestName ( ) const
inline

Get test name.

Returns
test name

Definition at line 135 of file JTest_t.hh.

136  {
137  return testName;
138  }

◆ getResultType()

const std::string& JCOMPAREHISTOGRAMS::JTest_t::getResultType ( ) const
inline

Get result type.

Returns
result type

Definition at line 146 of file JTest_t.hh.

147  {
148  return resultType;
149  }

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  in,
JTest_t test 
)
friend

Read test parameters from input.

Parameters
ininput stream
testtest
Returns
input stream

Definition at line 159 of file JTest_t.hh.

160  {
161  return test.read(in);
162  }
virtual void test(const TObject *o1, const TObject *o2)=0
Tests compatibility between two TObjects.

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JTest_t test 
)
friend

Write test result to output.

Parameters
outoutput stream
testtest
Returns
output stream

Definition at line 172 of file JTest_t.hh.

173  {
174  return test.write(out);
175  }

Member Data Documentation

◆ testName

const std::string JCOMPAREHISTOGRAMS::JTest_t::testName
protected

test name

Definition at line 180 of file JTest_t.hh.

◆ resultType

const std::string JCOMPAREHISTOGRAMS::JTest_t::resultType
protected

test result type

Definition at line 181 of file JTest_t.hh.


The documentation for this class was generated from the following file: