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 
9 #include "JLang/JMultiEquals.hh"
10 #include "JLang/JStringStream.hh"
11 #include "Jeep/JProperties.hh"
12 #include "JSystem/JStat.hh"
13 
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JTRIGGER {}
20 namespace JPP { using namespace JTRIGGER; }
21 
22 namespace JTRIGGER {
23 
28  using JLANG::JMultiEquals;
29  using JLANG::JTYPELIST;
30 
31 
32  /**
33  * Auxiliary class to handle run by run options.
34  *
35  * This class is used in e.g. JTriggerEfficiency.cc in run-by-run mode to select summary data
36  * (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file(s).\n
37  * The two parameters of the JSUPPORT::JRandomSampler class should therefore be set
38  * to sufficiently cover the contents of raw data file(s) and to minimise possible biases.\n
39  * The values can also be tuned to reduce the overhead of accessing the data in the input file(s).\n
40  *
41  * The range of acceptable rates (JRunByRun::range_Hz) was originally used to define "working" PMTs.\n
42  * With the use of the hardware high-rate veto and FIFO (almost) full information, this criterion is redundant.\n
43  * Note that the range is applied to the rate of photo-electrons (i.e.\ before the application of QE, etc.).\n
44  * It is therefore recommended to set this range sufficiently wide to avoid interference
45  * with the simulation of the PMT response.
46  */
47  struct JRunByRun :
48  public JMultipleFileSampler<JDAQSummaryslice, JRandomSampler>,
49  public JMultiEquals<JRunByRun, JTYPELIST< JMultipleFileScanner<> >::typelist>
50  {
51  /**
52  * Default constructor.
53  */
56  {}
57 
58 
59  /**
60  * Check validity of run by run options.
61  *
62  * \return true if okay; else false
63  */
64  inline bool is_valid()
65  {
66  return !this->template get<JMultipleFileScanner<>,true>().empty();
67  }
68 
69 
70  /**
71  * Read run by run options from input.
72  *
73  * \param in input stream
74  * \param object run by run options
75  * \return input stream
76  */
77  friend inline std::istream& operator>>(std::istream& in, JRunByRun& object)
78  {
79  using namespace std;
80  using namespace JPP;
81 
82  JStringStream is(in);
83 
84  if (getFileStatus(is.str().c_str())) {
85  is.load();
86  }
87 
88  getProperties(object).read(is);
89 
90  return in;
91  }
92 
93 
94  /**
95  * Write run by run options to output.
96  *
97  * \param out output stream
98  * \param object run by run options
99  * \return output stream
100  */
101  friend inline std::ostream& operator<<(std::ostream& out, const JRunByRun& object)
102  {
103  return getProperties(object).write(out);
104  }
105 
106  protected:
107  /**
108  * Get properties of this class.
109  *
110  * \return properties
111  */
112  template<class T>
113  static inline JProperties getProperties(T& object)
114  {
115  JProperties properties;
116 
117  properties["file"] = object.template get<JMultipleFileScanner<>,true>();
118  properties["sampler"] = object.getSampler();
119 
120  return properties;
121  }
122  };
123 }
124 
125 #endif
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:677
friend std::istream & operator>>(std::istream &in, JRunByRun &object)
Read run by run options from input.
Definition: JRunByRun.hh:77
void load()
Load data from file with name corresponding to current contents.
Auxiliary class to handle run by run options.
Definition: JRunByRun.hh:47
Utility class to parse parameter values.
Definition: JProperties.hh:496
JRewindableObjectIterator< T > & in
friend std::ostream & operator<<(std::ostream &out, const JRunByRun &object)
Write run by run options to output.
Definition: JRunByRun.hh:101
bool is_valid()
Check validity of run by run options.
Definition: JRunByRun.hh:64
is
Definition: JDAQCHSM.chsm:167
Utility class to parse parameter values.
Template definition of auxiliary base class for data structures composed of multiple base classes wit...
Definition: JMultiEquals.hh:32
static JProperties getProperties(T &object)
Get properties of this class.
Definition: JRunByRun.hh:113
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:845
JRunByRun()
Default constructor.
Definition: JRunByRun.hh:54
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
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...
General purpose class for object reading from a list of file names.
Auxiliary class to sample from a list of files.
File status.