CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MonRunIOV Class Reference

#include <MonRunIOV.h>

Inheritance diagram for MonRunIOV:
IIOV IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false) override
 
int getID ()
 
MonRunTag getMonRunTag () const
 
RunIOV getRunIOV ()
 
Tm getSubRunEnd () const
 
run_t getSubRunNumber () const
 
Tm getSubRunStart () const
 
 MonRunIOV ()
 
bool operator!= (const MonRunIOV &m) const
 
bool operator== (const MonRunIOV &m) const
 
void setByID (int id) noexcept(false) override
 
void setID (int id)
 
void setMonRunTag (const MonRunTag &tag)
 
void setRunIOV (const RunIOV &iov)
 
void setSubRunEnd (const Tm &end)
 
void setSubRunNumber (subrun_t subrun)
 
void setSubRunStart (const Tm &start)
 
 ~MonRunIOV () override
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void fetchParentIDs (int *monRunTagID, int *runIOVID) noexcept(false)
 
void setByRun (MonRunTag *montag, RunIOV *runiov, subrun_t subrun) noexcept(false)
 
int writeDB () noexcept(false)
 

Private Attributes

MonRunTag m_monRunTag
 
RunIOV m_runIOV
 
Tm m_subRunEnd
 
subrun_t m_subRunNum
 
Tm m_subRunStart
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 14 of file MonRunIOV.h.

Constructor & Destructor Documentation

MonRunIOV::MonRunIOV ( )

Definition at line 13 of file MonRunIOV.cc.

13  {
14  m_conn = nullptr;
15  m_ID = 0;
17  m_runIOV = RunIOV();
18  m_subRunNum = 0;
19  m_subRunStart = Tm();
20  m_subRunEnd = Tm();
21 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunIOV m_runIOV
Definition: MonRunIOV.h:51
Tm m_subRunStart
Definition: MonRunIOV.h:53
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
Tm m_subRunEnd
Definition: MonRunIOV.h:54
Definition: RunIOV.h:13
Definition: Tm.h:13
MonRunIOV::~MonRunIOV ( )
override

Definition at line 23 of file MonRunIOV.cc.

23 {}

Member Function Documentation

int MonRunIOV::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 72 of file MonRunIOV.cc.

References cuy::dh, alignCSCRings::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

72  {
73  // Return from memory if available
74  if (m_ID) {
75  return m_ID;
76  }
77 
78  this->checkConnection();
79 
80  // fetch the parent IDs
81  int monRunTagID, runIOVID;
82  this->fetchParentIDs(&monRunTagID, &runIOVID);
83 
84  if (!monRunTagID || !runIOVID) {
85  return 0;
86  }
87 
89 
90  if (m_subRunEnd.isNull()) {
91  m_subRunEnd = dh.getPlusInfTm();
92  }
93 
94  try {
95  Statement* stmt = m_conn->createStatement();
96  stmt->setSQL(
97  "SELECT iov_id FROM mon_run_iov "
98  "WHERE tag_id = :1 AND "
99  "run_iov_id = :2 AND "
100  "subrun_num = :3 AND "
101  "subrun_start = :4 AND "
102  "subrun_end = :5");
103  stmt->setInt(1, monRunTagID);
104  stmt->setInt(2, runIOVID);
105  stmt->setInt(3, m_subRunNum);
106  stmt->setDate(4, dh.tmToDate(m_subRunStart));
107  stmt->setDate(5, dh.tmToDate(m_subRunEnd));
108 
109  ResultSet* rset = stmt->executeQuery();
110 
111  if (rset->next()) {
112  m_ID = rset->getInt(1);
113  } else {
114  m_ID = 0;
115  }
116  m_conn->terminateStatement(stmt);
117  } catch (SQLException& e) {
118  throw(std::runtime_error("MonRunIOV::fetchID: " + e.getMessage()));
119  }
120 
121  return m_ID;
122 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void fetchParentIDs(int *monRunTagID, int *runIOVID) noexcept(false)
Definition: MonRunIOV.cc:217
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_subRunStart
Definition: MonRunIOV.h:53
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
int isNull() const
Definition: Tm.cc:46
Tm m_subRunEnd
Definition: MonRunIOV.h:54
tuple dh
Definition: cuy.py:354
void MonRunIOV::fetchParentIDs ( int *  monRunTagID,
int *  runIOVID 
)
privatenoexcept

Definition at line 217 of file MonRunIOV.cc.

217  {
218  // get the MonRunTag
220  *monRunTagID = m_monRunTag.fetchID();
221 
222  // get the RunIOV
224  *runIOVID = m_runIOV.fetchID();
225 
226  if (!*runIOVID) {
227  throw(std::runtime_error("MonRunIOV: Given RunIOV does not exist in DB"));
228  }
229 }
int fetchID() noexcept(false) override
Definition: MonRunTag.cc:37
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunIOV m_runIOV
Definition: MonRunIOV.h:51
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
int MonRunIOV::getID ( )
inline

Definition at line 22 of file MonRunIOV.h.

References IUniqueDBObject::m_ID.

22 { return m_ID; };
MonRunTag MonRunIOV::getMonRunTag ( ) const

Definition at line 34 of file MonRunIOV.cc.

34 { return m_monRunTag; }
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
RunIOV MonRunIOV::getRunIOV ( )

Definition at line 43 of file MonRunIOV.cc.

43 { return m_runIOV; }
RunIOV m_runIOV
Definition: MonRunIOV.h:51
Tm MonRunIOV::getSubRunEnd ( ) const

Definition at line 70 of file MonRunIOV.cc.

70 { return m_subRunEnd; }
Tm m_subRunEnd
Definition: MonRunIOV.h:54
run_t MonRunIOV::getSubRunNumber ( ) const

Definition at line 52 of file MonRunIOV.cc.

52 { return m_subRunNum; }
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
Tm MonRunIOV::getSubRunStart ( ) const

Definition at line 61 of file MonRunIOV.cc.

61 { return m_subRunStart; }
Tm m_subRunStart
Definition: MonRunIOV.h:53
bool MonRunIOV::operator!= ( const MonRunIOV m) const
inline

Definition at line 46 of file MonRunIOV.h.

References visualization-live-secondInstance_cfg::m.

bool MonRunIOV::operator== ( const MonRunIOV m) const
inline

Definition at line 41 of file MonRunIOV.h.

References m_monRunTag, m_runIOV, m_subRunEnd, m_subRunNum, and m_subRunStart.

41  {
42  return (m_monRunTag == m.m_monRunTag && m_runIOV == m.m_runIOV && m_subRunNum == m.m_subRunNum &&
44  }
RunIOV m_runIOV
Definition: MonRunIOV.h:51
Tm m_subRunStart
Definition: MonRunIOV.h:53
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
Tm m_subRunEnd
Definition: MonRunIOV.h:54
void MonRunIOV::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 124 of file MonRunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, and gpuClustering::id.

124  {
125  this->checkConnection();
126 
128 
129  try {
130  Statement* stmt = m_conn->createStatement();
131 
132  stmt->setSQL("SELECT tag_id, run_iov_id, subrun_num, subrun_start, subrun_end FROM mon_run_iov WHERE iov_id = :1");
133  stmt->setInt(1, id);
134 
135  ResultSet* rset = stmt->executeQuery();
136  if (rset->next()) {
137  int monRunTagID = rset->getInt(1);
138  int runIOVID = rset->getInt(2);
139  m_subRunNum = rset->getInt(3);
140  Date startDate = rset->getDate(4);
141  Date endDate = rset->getDate(5);
142 
143  m_subRunStart = dh.dateToTm(startDate);
144  m_subRunEnd = dh.dateToTm(endDate);
145 
147  m_monRunTag.setByID(monRunTagID);
148 
150  m_runIOV.setByID(runIOVID);
151 
152  m_ID = id;
153  } else {
154  throw(std::runtime_error("MonRunIOV::setByID: Given tag_id is not in the database"));
155  }
156 
157  m_conn->terminateStatement(stmt);
158  } catch (SQLException& e) {
159  throw(std::runtime_error("MonRunIOV::setByID: " + e.getMessage()));
160  }
161 }
void setByID(int id) noexcept(false) override
Definition: RunIOV.cc:106
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunIOV m_runIOV
Definition: MonRunIOV.h:51
uint16_t *__restrict__ id
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_subRunStart
Definition: MonRunIOV.h:53
void setByID(int id) noexcept(false) override
Definition: MonRunTag.cc:75
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Tm m_subRunEnd
Definition: MonRunIOV.h:54
tuple dh
Definition: cuy.py:354
void MonRunIOV::setByRun ( MonRunTag montag,
RunIOV runiov,
subrun_t  subrun 
)
privatenoexcept

Definition at line 231 of file MonRunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, and alignCSCRings::e.

Referenced by EcalCondDBInterface::fetchMonRunIOV().

231  {
232  this->checkConnection();
233 
234  runiov->setConnection(m_env, m_conn);
235  int runIOVID = runiov->fetchID();
236 
237  if (!runIOVID) {
238  throw(std::runtime_error("MonRunIOV::setByRun: Given RunIOV does not exist in DB"));
239  }
240 
241  montag->setConnection(m_env, m_conn);
242  int monTagID = montag->fetchID();
243 
244  if (!monTagID) {
245  throw(std::runtime_error("MonRunIOV::setByRun: Given MonRunTag does not exist in the DB"));
246  }
247 
249 
250  try {
251  Statement* stmt = m_conn->createStatement();
252 
253  stmt->setSQL(
254  "SELECT iov_id, subrun_start, subrun_end FROM mon_run_iov "
255  "WHERE tag_id = :1 AND run_iov_id = :2 AND subrun_num = :3");
256  stmt->setInt(1, monTagID);
257  stmt->setInt(2, runIOVID);
258  stmt->setInt(3, subrun);
259 
260  ResultSet* rset = stmt->executeQuery();
261  if (rset->next()) {
262  m_monRunTag = *montag;
263  m_runIOV = *runiov;
264  m_subRunNum = subrun;
265 
266  m_ID = rset->getInt(1);
267  Date startDate = rset->getDate(2);
268  Date endDate = rset->getDate(3);
269 
270  m_subRunStart = dh.dateToTm(startDate);
271  m_subRunEnd = dh.dateToTm(endDate);
272  } else {
273  throw(std::runtime_error("MonRunIOV::setByRun: Given subrun is not in the database"));
274  }
275 
276  m_conn->terminateStatement(stmt);
277  } catch (SQLException& e) {
278  throw(std::runtime_error("MonRunIOV::setByRun: " + e.getMessage()));
279  }
280 }
int fetchID() noexcept(false) override
Definition: MonRunTag.cc:37
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunIOV m_runIOV
Definition: MonRunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_subRunStart
Definition: MonRunIOV.h:53
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Tm m_subRunEnd
Definition: MonRunIOV.h:54
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
tuple dh
Definition: cuy.py:354
void MonRunIOV::setID ( int  id)

Definition at line 25 of file MonRunIOV.cc.

References gpuClustering::id.

Referenced by MonRunList::fetchLastNRuns(), and MonRunList::fetchRuns().

25 { m_ID = id; }
uint16_t *__restrict__ id
void MonRunIOV::setMonRunTag ( const MonRunTag tag)
void MonRunIOV::setRunIOV ( const RunIOV iov)

Definition at line 36 of file MonRunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().

36  {
37  if (iov != m_runIOV) {
38  m_ID = 0;
39  m_runIOV = iov;
40  }
41 }
RunIOV m_runIOV
Definition: MonRunIOV.h:51
void MonRunIOV::setSubRunEnd ( const Tm end)

Definition at line 63 of file MonRunIOV.cc.

References dataset::end.

Referenced by EcalCondDBWriter::dqmEndJob(), MonRunList::fetchLastNRuns(), and MonRunList::fetchRuns().

63  {
64  if (end != m_subRunEnd) {
65  m_ID = 0;
66  m_subRunEnd = end;
67  }
68 }
string end
Definition: dataset.py:937
Tm m_subRunEnd
Definition: MonRunIOV.h:54
void MonRunIOV::setSubRunNumber ( subrun_t  subrun)

Definition at line 45 of file MonRunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().

45  {
46  if (subrun != m_subRunNum) {
47  m_ID = 0;
48  m_subRunNum = subrun;
49  }
50 }
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
void MonRunIOV::setSubRunStart ( const Tm start)

Definition at line 54 of file MonRunIOV.cc.

References command_line::start.

Referenced by EcalCondDBWriter::dqmEndJob(), MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().

54  {
55  if (start != m_subRunStart) {
56  m_ID = 0;
58  }
59 }
Tm m_subRunStart
Definition: MonRunIOV.h:53
int MonRunIOV::writeDB ( )
privatenoexcept

Definition at line 163 of file MonRunIOV.cc.

References cuy::dh, alignCSCRings::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

163  {
164  this->checkConnection();
165 
166  // Check if this IOV has already been written
167  if (this->fetchID()) {
168  return m_ID;
169  }
170 
171  // fetch Parent IDs
172  int monRunTagID, runIOVID;
173  this->fetchParentIDs(&monRunTagID, &runIOVID);
174 
175  if (!monRunTagID) {
176  monRunTagID = m_monRunTag.writeDB();
177  }
178 
179  // Validate the data, use infinity-till convention
181 
182  if (m_subRunStart.isNull()) {
183  throw(std::runtime_error("MonRunIOV::writeDB: Must setSubRunStart before writing"));
184  }
185 
186  if (m_subRunEnd.isNull()) {
187  m_subRunEnd = dh.getPlusInfTm();
188  }
189 
190  try {
191  Statement* stmt = m_conn->createStatement();
192 
193  stmt->setSQL(
194  "INSERT INTO mon_run_iov (iov_id, tag_id, run_iov_id, subrun_num, subrun_start, subrun_end) "
195  "VALUES (mon_run_iov_sq.NextVal, :1, :2, :3, :4, :5)");
196  stmt->setInt(1, monRunTagID);
197  stmt->setInt(2, runIOVID);
198  stmt->setInt(3, m_subRunNum);
199  stmt->setDate(4, dh.tmToDate(m_subRunStart));
200  stmt->setDate(5, dh.tmToDate(m_subRunEnd));
201 
202  stmt->executeUpdate();
203 
204  m_conn->terminateStatement(stmt);
205  } catch (SQLException& e) {
206  throw(std::runtime_error("MonRunIOV::writeDB: " + e.getMessage()));
207  }
208 
209  // Now get the ID
210  if (!this->fetchID()) {
211  throw(std::runtime_error("MonRunIOV::writeDB: Failed to write"));
212  }
213 
214  return m_ID;
215 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void fetchParentIDs(int *monRunTagID, int *runIOVID) noexcept(false)
Definition: MonRunIOV.cc:217
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_subRunStart
Definition: MonRunIOV.h:53
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
MonRunTag m_monRunTag
Definition: MonRunIOV.h:50
subrun_t m_subRunNum
Definition: MonRunIOV.h:52
int isNull() const
Definition: Tm.cc:46
Tm m_subRunEnd
Definition: MonRunIOV.h:54
tuple dh
Definition: cuy.py:354
int writeDB() noexcept(false)
Definition: MonRunTag.cc:100

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 16 of file MonRunIOV.h.

Member Data Documentation

MonRunTag MonRunIOV::m_monRunTag
private

Definition at line 50 of file MonRunIOV.h.

Referenced by operator==().

RunIOV MonRunIOV::m_runIOV
private

Definition at line 51 of file MonRunIOV.h.

Referenced by operator==().

Tm MonRunIOV::m_subRunEnd
private

Definition at line 54 of file MonRunIOV.h.

Referenced by operator==().

subrun_t MonRunIOV::m_subRunNum
private

Definition at line 52 of file MonRunIOV.h.

Referenced by operator==().

Tm MonRunIOV::m_subRunStart
private

Definition at line 53 of file MonRunIOV.h.

Referenced by operator==().