Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRunByRun.hh
Go to the documentation of this file.
1 #ifndef __JSUPPORT__JRUNBYRUN__
2 #define __JSUPPORT__JRUNBYRUN__
3 
7 #include "JLang/JStringStream.hh"
8 #include "Jeep/JProperties.hh"
9 #include "JSystem/JStat.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JSUPPORT {}
17 namespace JPP { using namespace JSUPPORT; }
18 
19 namespace JSUPPORT {
20 
22 
23 
24  /**
25  * Auxiliary class to select summary data (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file(s).
26  *
27  * The use case of this class primarily is for the run-by-run mode of JTriggerEfficiency.cc.\n
28  * The two parameters of the JSUPPORT::JRandomSampler class should then be set
29  * to sufficiently cover the contents of raw data file(s) and to minimise possible biases.\n
30  * The values can also be tuned to reduce the overhead of accessing the data in the input file(s).\n
31  */
32  struct JRunByRun :
33  public JMultipleFileSampler<JDAQSummaryslice, JRandomSampler>
34  {
35  /**
36  * Default constructor.
37  */
40  {}
41 
42 
43  /**
44  * Check validity of run by run options.
45  *
46  * \return true if okay; else false
47  */
48  inline bool is_valid() const
49  {
50  return !(*this)->getFilelist().empty();
51  }
52 
53 
54  /**
55  * Read run by run options from input.
56  *
57  * \param in input stream
58  * \param object run by run options
59  * \return input stream
60  */
61  friend inline std::istream& operator>>(std::istream& in, JRunByRun& object)
62  {
63  using namespace std;
64  using namespace JPP;
65 
66  JStringStream is(in);
67 
68  if (getFileStatus(is.str().c_str())) {
69  is.load();
70  }
71 
72  getProperties(object).read(is);
73 
74  return in;
75  }
76 
77 
78  /**
79  * Write run by run options to output.
80  *
81  * \param out output stream
82  * \param object run by run options
83  * \return output stream
84  */
85  friend inline std::ostream& operator<<(std::ostream& out, const JRunByRun& object)
86  {
87  return getProperties(object).write(out);
88  }
89 
90  protected:
91  /**
92  * Get properties of this class.
93  *
94  * \param object class object
95  * \return properties
96  */
97  template<class T>
98  static inline JProperties getProperties(T& object)
99  {
100  JProperties properties;
101 
102  properties["file"] = object->getFilelist();
103  properties["sampler"] = object.getSampler();
104 
105  return properties;
106  }
107  };
108 }
109 
110 #endif
Auxiliary class to select summary data (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file...
Definition: JRunByRun.hh:32
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:679
void load()
Load data from file with name corresponding to current contents.
bool is_valid() const
Check validity of run by run options.
Definition: JRunByRun.hh:48
Utility class to parse parameter values.
Definition: JProperties.hh:497
JRewindableObjectIterator< T > & in
is
Definition: JDAQCHSM.chsm:167
Utility class to parse parameter values.
Template class for randomly sampling from a JLANG::JRewindableObjectIterator using a JLANG::JObjectSa...
std::ostream & write(std::ostream &out) const
Write the current parameter values.
Definition: JProperties.hh:847
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
Wrapper class around STL stringstream class to facilitate optional loading of data from file...
JRunByRun()
Default constructor.
Definition: JRunByRun.hh:38
Auxiliary class to sample from a list of files.
friend std::istream & operator>>(std::istream &in, JRunByRun &object)
Read run by run options from input.
Definition: JRunByRun.hh:61
friend std::ostream & operator<<(std::ostream &out, const JRunByRun &object)
Write run by run options to output.
Definition: JRunByRun.hh:85
static JProperties getProperties(T &object)
Get properties of this class.
Definition: JRunByRun.hh:98
File status.