Jpp
JRunQuality.cc
Go to the documentation of this file.
1 #include <string>
2 #include <exception>
3 
6 #include "JLang/JNullStream.hh"
7 #include "JLang/JLangToolkit.hh"
8 
10 #include "JROOT/JRootStreamer.hh"
11 
12 #include "JDB/JDB.hh"
13 #include "JDB/JDBToolkit.hh"
14 #include "JDB/JRunQuality.hh"
15 
16 
17 namespace JDATABASE {
18 
19  /**
20  * Put value at given key.
21  *
22  * \param key key
23  * \param value value
24  */
25  void JRunQuality::put(const std::string& key,
26  const std::string& value)
27  {
28  using namespace std;
29  using namespace JPP;
30 
31  const JEquationParameters parameters(":", "\n", "", "");
32 
33  JRootReader reader(null, parameters, JRootDictionary::getInstance());
34  JRootReadableClass cls(*this);
35 
36  const string buffer = replace(key, "-", "_");
37 
38  for (string::size_type il = 0, ir = 0; ir != string::npos && cls.is_valid(); il = ir + 1) {
39  ir = buffer.substr(il).find(parameters.getDefaultDivision());
40  cls = cls.find(buffer.substr(il, ir - il).c_str());
41  }
42 
43  if (cls.is_valid()) {
44 
45  JRedirectString redirect(reader, value);
46 
47  reader.getObject(cls);
48  }
49  }
50 
51 
52  /**
53  * Read data quality from result set.
54  *
55  * \param rs result set
56  * \param quality quality
57  * \return true if read; else false
58  */
59  bool operator>>(ResultSet& rs, JRunQuality& quality)
60  {
61  using namespace std;
62  using namespace JPP;
63 
64  quality.run = -1;
65 
66  for (JRunSummaryNumbers parameters; ; ) {
67 
68  bool has_next = false;
69 
70  try {
71  has_next = (rs >> parameters);
72  }
73  catch(const exception& error) {
74  has_next = false;
75  }
76 
77  if (parameters.RUN != quality.run || !has_next) {
78 
79  if (quality.run != -1) {
80 
81  return true;
82 
83  } else if (!has_next) {
84 
85  rs.Close();
86 
87  return false;
88  }
89 
90  quality = JRunQuality();
91  quality.GIT = parameters.SOURCE_NAME;
92  quality.detector = getDetector(parameters.DETID);
93  quality.run = parameters.RUN;
94  }
95 
96  quality.put(parameters.PARAMETER_NAME, parameters.DATA_VALUE);
97  }
98  }
99 }
JDATABASE::JRunQuality::put
void put(const std::string &key, const std::string &value)
Put value at given key.
Definition: JRunQuality.cc:25
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
JNullStream.hh
JRootStreamer.hh
JDATABASE::JRunSummaryNumbers
Definition: JRunSummaryNumbers.hh:17
JDATABASE::JRunQuality::operator>>
friend std::istream & operator>>(std::istream &in, JRunQuality &object)
Read quality data from input stream.
Definition: JRunQuality.hh:59
JDBToolkit.hh
JEquationParameters.hh
JDATABASE::getDetector
static const JDetectorsHelper & getDetector
Function object for mapping serial number and object identifier of detectors.
Definition: JDBToolkit.hh:131
JDATABASE
Auxiliary classes and methods for database I/O.
Definition: JAHRS.hh:12
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JDB.hh
JRedirectString.hh
JDATABASE::JRunQuality::detector
int detector
Definition: JRunQuality.hh:111
JDATABASE::JRunQuality::GIT
std::string GIT
Definition: JRunQuality.hh:110
JLANG::replace
std::string replace(const std::string &input, const std::string &target, const std::string &replacement)
Replace tokens in string.
Definition: JLangToolkit.hh:124
JDATABASE::JRunQuality
Auxiliary data structure for data quality.
Definition: JRunQuality.hh:31
JRootDictionary.hh
JRunQuality.hh
std
Definition: jaanetDictionary.h:36
JDATABASE::JRunQuality::run
int run
Definition: JRunQuality.hh:112
JLangToolkit.hh