Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRunByRun.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JRUNBYRUN__
2 #define __JTRIGGER__JRUNBYRUN__
3 
4 #include <sstream>
5 
10 #include "JLang/JMultiEquals.hh"
11 #include "JLang/JStringStream.hh"
12 #include "Jeep/JProperties.hh"
13 #include "JSystem/JStat.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JTRIGGER {}
21 namespace JPP { using namespace JTRIGGER; }
22 
23 namespace JTRIGGER {
24 
31  using JLANG::JMultiEquals;
32  using JLANG::JTYPELIST;
33 
34 
35  /**
36  * Auxiliary class to handle run by run options.
37  */
38  struct JRunByRun :
39  public JMultipleFileSampler<JDAQSummaryslice, JRandomSampler>,
40  public JMultiEquals<JRunByRun, JTYPELIST< JMultipleFileScanner<> >::typelist>
41  {
42  /**
43  * Default constructor.
44  */
47  range_Hz()
48  {}
49 
50 
51  /**
52  * Check validity of run by run options.
53  *
54  * \return true if okay; else false
55  */
56  inline bool is_valid()
57  {
58  return !this->template get<JMultipleFileScanner<>,true>().empty();
59  }
60 
61 
62  /**
63  * Read run by run options from input.
64  *
65  * \param in input stream
66  * \param object run by run options
67  * \return input stream
68  */
69  friend inline std::istream& operator>>(std::istream& in, JRunByRun& object)
70  {
71  using namespace std;
72  using namespace JPP;
73 
74  JStringStream is(in);
75 
76  if (getFileStatus(is.str().c_str())) {
77  is.load();
78  }
79 
80  getProperties(object).read(is);
81 
82  return in;
83  }
84 
85 
86  /**
87  * Write run by run options to output.
88  *
89  * \param out output stream
90  * \param object run by run options
91  * \return output stream
92  */
93  friend inline std::ostream& operator<<(std::ostream& out, const JRunByRun& object)
94  {
95  return getProperties(object).write(out);
96  }
97 
98 
100 
101  protected:
102  /**
103  * Get properties of this class.
104  *
105  * \return properties
106  */
107  template<class T>
108  static inline JProperties getProperties(T& object)
109  {
110  JProperties properties;
111 
112  properties["file"] = object.template get<JMultipleFileScanner<>,true>();
113  properties["sampler"] = object.getSampler();
114  properties["range_Hz"] = object.range_Hz;
115 
116  return properties;
117  }
118  };
119 }
120 
121 #endif
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:665
friend std::istream & operator>>(std::istream &in, JRunByRun &object)
Read run by run options from input.
Definition: JRunByRun.hh:69
JPMTRateRange range_Hz
Definition: JRunByRun.hh:99
Data structure for range of PMT rates.
Auxiliary class to handle run by run options.
Definition: JRunByRun.hh:38
Utility class to parse parameter values.
Definition: JProperties.hh:484
JRewindableObjectIterator< T > & in
friend std::ostream & operator<<(std::ostream &out, const JRunByRun &object)
Write run by run options to output.
Definition: JRunByRun.hh:93
bool is_valid()
Check validity of run by run options.
Definition: JRunByRun.hh:56
Utility class to parse parameter values.
Template definition of auxiliary base class for composite data structures composed of base classes wi...
Definition: JMultiEquals.hh:31
static JProperties getProperties(T &object)
Get properties of this class.
Definition: JRunByRun.hh:108
Template class for randomly sampling from a JRewindableObjectIterator.
std::ostream & write(std::ostream &out) const
Write the current parameter values.
Definition: JProperties.hh:833
JRunByRun()
Default constructor.
Definition: JRunByRun.hh:45
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:377
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
General purpose class for object reading from a list of file names.
Auxiliary class to sample from a list of files.
File status.