Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JRunByRun.hh
Go to the documentation of this file.
1#ifndef __JSUPPORT__JRUNBYRUN__
2#define __JSUPPORT__JRUNBYRUN__
3
8#include "Jeep/JProperties.hh"
9#include "JSystem/JStat.hh"
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JSUPPORT {}
17namespace JPP { using namespace JSUPPORT; }
18
19namespace 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 */
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
Utility class to parse parameter values.
File status.
Utility class to parse parameter values.
std::ostream & write(std::ostream &out) const
Write the current parameter values.
bool read(const JEquation &equation)
Read equation.
JRewindableObjectIterator< T > & in
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
void load()
Load data from file with name corresponding to current contents.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Support classes and methods for experiment specific I/O.
static JStat getFileStatus
Function object for file status.
Definition JStat.hh:173
Auxiliary class to sample from a list of files.
Template class for randomly sampling from a JLANG::JRewindableObjectIterator using a JLANG::JObjectSa...
Auxiliary class to select summary data (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file...
Definition JRunByRun.hh:34
bool is_valid() const
Check validity of run by run options.
Definition JRunByRun.hh:48
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
friend std::istream & operator>>(std::istream &in, JRunByRun &object)
Read run by run options from input.
Definition JRunByRun.hh:61
JRunByRun()
Default constructor.
Definition JRunByRun.hh:38