Jpp
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
JTRIGGER::JRunByRun::range_Hz
JPMTRateRange range_Hz
Definition: JRunByRun.hh:99
JDETECTOR::JPMTRateRange
Data structure for range of PMT rates.
Definition: JPMTRateRange.hh:22
JTRIGGER::JRunByRun::operator>>
friend std::istream & operator>>(std::istream &in, JRunByRun &object)
Read run by run options from input.
Definition: JRunByRun.hh:69
JTRIGGER::JRunByRun::getProperties
static JProperties getProperties(T &object)
Get properties of this class.
Definition: JRunByRun.hh:108
JMultipleFileSampler.hh
JTRIGGER::JRunByRun::operator<<
friend std::ostream & operator<<(std::ostream &out, const JRunByRun &object)
Write run by run options to output.
Definition: JRunByRun.hh:93
JLANG::JTYPELIST
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:377
JEEP::JProperties::read
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:677
JLANG::JObjectSampler::in
JRewindableObjectIterator< T > & in
Definition: JObjectSampler.hh:144
JDAQSummaryslice.hh
JPMTRateRange.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTRIGGER::JRunByRun::JRunByRun
JRunByRun()
Default constructor.
Definition: JRunByRun.hh:45
JTRIGGER::JRunByRun
Auxiliary class to handle run by run options.
Definition: JRunByRun.hh:38
JMultiEquals.hh
JSYSTEM::getFileStatus
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
JStringStream.hh
KM3NETDAQ::JDAQSummaryslice
Data summary slice.
Definition: JDAQSummaryslice.hh:31
JStat.hh
JTRIGGER::JRunByRun::is_valid
bool is_valid()
Check validity of run by run options.
Definition: JRunByRun.hh:56
JLANG::JMultiEquals
Template definition of auxiliary base class for composite data structures composed of base classes wi...
Definition: JMultiEquals.hh:31
JSUPPORT::JMultipleFileSampler
Auxiliary class to sample from a list of files.
Definition: JMultipleFileSampler.hh:28
JSUPPORT::JRandomSampler
Template class for randomly sampling from a JRewindableObjectIterator.
Definition: JRandomSampler.hh:28
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JEEP::JProperties
Utility class to parse parameter values.
Definition: JProperties.hh:496
JEEP::JProperties::write
std::ostream & write(std::ostream &out) const
Write the current parameter values.
Definition: JProperties.hh:845
std
Definition: jaanetDictionary.h:36
JProperties.hh
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JRandomSampler.hh