Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTest_t.hh
Go to the documentation of this file.
1 #ifndef __JTEST_T__
2 #define __JTEST_T__
3 
4 #include <iostream>
5 
6 #include <TROOT.h>
7 #include <TObject.h>
8 #include <TH1.h>
9 #include <TH2.h>
10 using namespace JPP;
11 using namespace std;
12 
13 /*
14  * \author rgruiz
15  */
16 
18 {
19 public:
21  name (" "),
22  parameter (" "),
23  passed (false),
24  value (-9999.0)
25  {};
26 
27  JResultTitle(string Name, string Parameter, bool Passed, double Value):
28  name (Name),
29  parameter (Parameter),
30  passed (Passed),
31  value (Value)
32  {
33  passed_h = passed ? "PASSED" : "FAILED";
34  };
35 
36  /*
37  * Read test parameters from input.
38  *
39  * \param in input stream
40  * \return input stream
41  */
42  std::istream& read(std::istream& in) {
43  in >> name >> passed_h >> parameter >> value;
44  passed = (passed_h == "PASSED") ? 1 : 0;
45  return in;
46  };
47 
48  string getTitle(){
49  return MAKE_STRING(name << (passed ? " PASSED " : " FAILED ") << parameter << " " << value);
50  }
51 
52  string name; /*!< Test name. */
53  string parameter; /*!< Name of the parameter used to evaluate the test. */
54  bool passed; /*!< Test result. True if test passed. */
55  string passed_h; /*!< Human readable version of "passed". */
56  double value; /*!< Value of the parameter used to evaluate the test.*/
57 };
58 
59 
60 /*
61  * Structure containing the result of the test. It contains a bool and a message to print
62  */
63 struct JTestResult{
64  bool passed; /*!< Test result. True if test passed. */
65  string message; /*!< Human readable message with test result. */
66  TObject* obj; /*!< Graphical output summarising the test. */
67 };
68 
69 /*
70  * Interface to read input and write output for TObject tests.
71  */
72 class JTest_t
73 {
74 
75 public:
76 
78 
79  /*
80  * Read test parameters from input.
81  *
82  * \param in input stream
83  * \return input stream
84  */
85  virtual std::istream& read (std::istream& in) = 0;
86 
87  /*
88  * Write test result to output.
89  *
90  * \param out output stream
91  * \return output stream
92  */
93  virtual std::ostream& write(std::ostream& out) = 0;
94 
95  /*
96  * Tests the statistical compatibility of two ROOT TObjects
97  */
98  virtual void test(TObject* o1, TObject* o2) = 0;
99 
100  /*
101  * Writes the result to root file
102  * \param f The file
103  * \param name Name of the object.
104  */
105  virtual void save(TFile* f , string path) = 0;
106 
107  /*
108  * Clear results
109  */
110  virtual void clear() = 0;
111 
112 };
113 
114 #endif
bool passed
Definition: JTest_t.hh:54
bool read(Vec &v, std::istream &is)
Read a Vec(tor) from a stream.
Definition: io_ascii.hh:139
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
Definition: JRoot.hh:19
JResultTitle()
Definition: JTest_t.hh:20
std::istream & read(std::istream &in)
Definition: JTest_t.hh:42
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
then JPizza f
Definition: JPizza.sh:46
do cat driver txt<< EOFevent ev_configure{RC_EVT%< ev_configure.txt > RC_DWRT path
double value
Definition: JTest_t.hh:56
vector< JTestResult > results
Definition: JTest_t.hh:77
string getTitle()
Definition: JTest_t.hh:48
string name
Definition: JTest_t.hh:52
string message
Definition: JTest_t.hh:65
then echo n User name
Definition: JCookie.sh:45
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
Definition: io_ascii.hh:152
JResultTitle(string Name, string Parameter, bool Passed, double Value)
Definition: JTest_t.hh:27
bool passed
Definition: JTest_t.hh:64
TObject * obj
Definition: JTest_t.hh:66
string passed_h
Definition: JTest_t.hh:55
string parameter
Definition: JTest_t.hh:53