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  * This class is used in e.g. JTriggerEfficiency.cc in run-by-run mode to select summary data
39  * (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file(s).\n
40  * The two parameters of the JSUPPORT::JRandomSampler class should therefore be set
41  * to sufficiently cover the contents of raw data file(s) and to minimise possible biases.\n
42  * The values can also be tuned to reduce the overhead of accessing the data in the input file(s).\n
43  *
44  * The range of acceptable rates (JRunByRun::range_Hz) was originally used to define "working" PMTs.\n
45  * With the use of the hardware high-rate veto and FIFO (almost) full information, this criterion is redundant.\n
46  * Note that the range is applied to the rate of photo-electrons (i.e. before the application of QE, etc.).\n
47  * It is therefore recommended to set this range sufficiently wide to avoid interference
48  * with the simulation of the PMT response.
49  */
50  struct JRunByRun :
51  public JMultipleFileSampler<JDAQSummaryslice, JRandomSampler>,
52  public JMultiEquals<JRunByRun, JTYPELIST< JMultipleFileScanner<> >::typelist>
53  {
54  /**
55  * Default constructor.
56  */
59  range_Hz()
60  {}
61 
62 
63  /**
64  * Check validity of run by run options.
65  *
66  * \return true if okay; else false
67  */
68  inline bool is_valid()
69  {
70  return !this->template get<JMultipleFileScanner<>,true>().empty();
71  }
72 
73 
74  /**
75  * Read run by run options from input.
76  *
77  * \param in input stream
78  * \param object run by run options
79  * \return input stream
80  */
81  friend inline std::istream& operator>>(std::istream& in, JRunByRun& object)
82  {
83  using namespace std;
84  using namespace JPP;
85 
86  JStringStream is(in);
87 
88  if (getFileStatus(is.str().c_str())) {
89  is.load();
90  }
91 
92  getProperties(object).read(is);
93 
94  return in;
95  }
96 
97 
98  /**
99  * Write run by run options to output.
100  *
101  * \param out output stream
102  * \param object run by run options
103  * \return output stream
104  */
105  friend inline std::ostream& operator<<(std::ostream& out, const JRunByRun& object)
106  {
107  return getProperties(object).write(out);
108  }
109 
110 
112 
113  protected:
114  /**
115  * Get properties of this class.
116  *
117  * \return properties
118  */
119  template<class T>
120  static inline JProperties getProperties(T& object)
121  {
122  JProperties properties;
123 
124  properties["file"] = object.template get<JMultipleFileScanner<>,true>();
125  properties["sampler"] = object.getSampler();
126  properties["range_Hz"] = object.range_Hz;
127 
128  return properties;
129  }
130  };
131 }
132 
133 #endif
JTRIGGER::JRunByRun::range_Hz
JPMTRateRange range_Hz
Definition: JRunByRun.hh:111
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:81
JTRIGGER::JRunByRun::getProperties
static JProperties getProperties(T &object)
Get properties of this class.
Definition: JRunByRun.hh:120
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:105
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:154
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:57
JTRIGGER::JRunByRun
Auxiliary class to handle run by run options.
Definition: JRunByRun.hh:50
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:25
JStat.hh
JLANG::JStringStream::load
void load()
Load data from file with name corresponding to current contents.
Definition: JStringStream.hh:48
JTRIGGER::JRunByRun::is_valid
bool is_valid()
Check validity of run by run options.
Definition: JRunByRun.hh:68
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 JLANG::JRewindableObjectIterator using a JLANG::JObjectSa...
Definition: JRandomSampler.hh:33
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
JLANG::JStringStream
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
Definition: JStringStream.hh:22
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JRandomSampler.hh