#include <MonRunIOV.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
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) throw (std::runtime_error) |
void | setID (int id) |
void | setMonRunTag (MonRunTag tag) |
void | setRunIOV (RunIOV iov) |
void | setSubRunEnd (Tm end) |
void | setSubRunNumber (subrun_t subrun) |
void | setSubRunStart (Tm start) |
~MonRunIOV () | |
Private Member Functions | |
void | fetchParentIDs (int *monRunTagID, int *runIOVID) throw (std::runtime_error) |
void | setByRun (MonRunTag *montag, RunIOV *runiov, subrun_t subrun) throw (std::runtime_error) |
int | writeDB () throw (std::runtime_error) |
Private Attributes | |
MonRunTag | m_monRunTag |
RunIOV | m_runIOV |
Tm | m_subRunEnd |
subrun_t | m_subRunNum |
Tm | m_subRunStart |
Friends | |
class | EcalCondDBInterface |
Definition at line 14 of file MonRunIOV.h.
MonRunIOV::MonRunIOV | ( | ) |
Definition at line 13 of file MonRunIOV.cc.
References NULL.
{ m_conn = NULL; m_ID = 0; m_monRunTag = MonRunTag(); m_runIOV = RunIOV(); m_subRunNum = 0; m_subRunStart = Tm(); m_subRunEnd = Tm(); }
MonRunIOV::~MonRunIOV | ( | ) |
Definition at line 26 of file MonRunIOV.cc.
{ }
int MonRunIOV::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 118 of file MonRunIOV.cc.
References DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); // fetch the parent IDs int monRunTagID, runIOVID; this->fetchParentIDs(&monRunTagID, &runIOVID); if (!monRunTagID || !runIOVID) { return 0; } DateHandler dh(m_env, m_conn); if (m_subRunEnd.isNull()) { m_subRunEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id FROM mon_run_iov " "WHERE tag_id = :1 AND " "run_iov_id = :2 AND " "subrun_num = :3 AND " "subrun_start = :4 AND " "subrun_end = :5"); stmt->setInt(1, monRunTagID); stmt->setInt(2, runIOVID); stmt->setInt(3, m_subRunNum); stmt->setDate(4, dh.tmToDate(m_subRunStart)); stmt->setDate(5, dh.tmToDate(m_subRunEnd)); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunIOV::fetchID: "+e.getMessage())); } return m_ID; }
void MonRunIOV::fetchParentIDs | ( | int * | monRunTagID, |
int * | runIOVID | ||
) | throw (std::runtime_error) [private] |
Definition at line 273 of file MonRunIOV.cc.
{ // get the MonRunTag m_monRunTag.setConnection(m_env, m_conn); *monRunTagID = m_monRunTag.fetchID(); // get the RunIOV m_runIOV.setConnection(m_env, m_conn); *runIOVID = m_runIOV.fetchID(); if (! *runIOVID) { throw(std::runtime_error("MonRunIOV: Given RunIOV does not exist in DB")); } }
int MonRunIOV::getID | ( | ) | [inline] |
MonRunTag MonRunIOV::getMonRunTag | ( | ) | const |
Definition at line 46 of file MonRunIOV.cc.
{ return m_monRunTag; }
RunIOV MonRunIOV::getRunIOV | ( | ) |
Definition at line 61 of file MonRunIOV.cc.
{ return m_runIOV; }
Tm MonRunIOV::getSubRunEnd | ( | ) | const |
Definition at line 111 of file MonRunIOV.cc.
{ return m_subRunEnd; }
run_t MonRunIOV::getSubRunNumber | ( | ) | const |
Definition at line 77 of file MonRunIOV.cc.
{ return m_subRunNum; }
Tm MonRunIOV::getSubRunStart | ( | ) | const |
Definition at line 94 of file MonRunIOV.cc.
{ return m_subRunStart; }
bool MonRunIOV::operator!= | ( | const MonRunIOV & | m | ) | const [inline] |
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.
{ return ( m_monRunTag == m.m_monRunTag && m_runIOV == m.m_runIOV && m_subRunNum == m.m_subRunNum && m_subRunStart == m.m_subRunStart && m_subRunEnd == m.m_subRunEnd ); }
void MonRunIOV::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 173 of file MonRunIOV.cc.
References DateHandler::dateToTm().
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id, run_iov_id, subrun_num, subrun_start, subrun_end FROM mon_run_iov WHERE iov_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { int monRunTagID = rset->getInt(1); int runIOVID = rset->getInt(2); m_subRunNum = rset->getInt(3); Date startDate = rset->getDate(4); Date endDate = rset->getDate(5); m_subRunStart = dh.dateToTm( startDate ); m_subRunEnd = dh.dateToTm( endDate ); m_monRunTag.setConnection(m_env, m_conn); m_monRunTag.setByID(monRunTagID); m_runIOV.setConnection(m_env, m_conn); m_runIOV.setByID(runIOVID); m_ID = id; } else { throw(std::runtime_error("MonRunIOV::setByID: Given tag_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunIOV::setByID: "+e.getMessage())); } }
void MonRunIOV::setByRun | ( | MonRunTag * | montag, |
RunIOV * | runiov, | ||
subrun_t | subrun | ||
) | throw (std::runtime_error) [private] |
Definition at line 292 of file MonRunIOV.cc.
References DateHandler::dateToTm().
Referenced by EcalCondDBInterface::fetchMonRunIOV().
{ this->checkConnection(); runiov->setConnection(m_env, m_conn); int runIOVID = runiov->fetchID(); if (!runIOVID) { throw(std::runtime_error("MonRunIOV::setByRun: Given RunIOV does not exist in DB")); } montag->setConnection(m_env, m_conn); int monTagID = montag->fetchID(); if (!monTagID) { throw(std::runtime_error("MonRunIOV::setByRun: Given MonRunTag does not exist in the DB")); } DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id, subrun_start, subrun_end FROM mon_run_iov " "WHERE tag_id = :1 AND run_iov_id = :2 AND subrun_num = :3"); stmt->setInt(1, monTagID); stmt->setInt(2, runIOVID); stmt->setInt(3, subrun); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_monRunTag = *montag; m_runIOV = *runiov; m_subRunNum = subrun; m_ID = rset->getInt(1); Date startDate = rset->getDate(2); Date endDate = rset->getDate(3); m_subRunStart = dh.dateToTm( startDate ); m_subRunEnd = dh.dateToTm( endDate ); } else { throw(std::runtime_error("MonRunIOV::setByRun: Given subrun is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunIOV::setByRun: "+e.getMessage())); } }
void MonRunIOV::setID | ( | int | id | ) |
Definition at line 31 of file MonRunIOV.cc.
Referenced by MonRunList::fetchLastNRuns(), and MonRunList::fetchRuns().
{ m_ID = id; }
void MonRunIOV::setMonRunTag | ( | MonRunTag | tag | ) |
Definition at line 36 of file MonRunIOV.cc.
References GlobalPosition_Frontier_DevDB_cff::tag.
Referenced by MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().
{ if (tag != m_monRunTag) { m_ID = 0; m_monRunTag = tag; } }
void MonRunIOV::setRunIOV | ( | RunIOV | iov | ) |
Definition at line 53 of file MonRunIOV.cc.
References o2o::iov.
Referenced by MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().
void MonRunIOV::setSubRunEnd | ( | Tm | end | ) |
Definition at line 101 of file MonRunIOV.cc.
References end.
Referenced by MonRunList::fetchLastNRuns(), and MonRunList::fetchRuns().
{ if (end != m_subRunEnd) { m_ID = 0; m_subRunEnd = end; } }
void MonRunIOV::setSubRunNumber | ( | subrun_t | subrun | ) |
Definition at line 67 of file MonRunIOV.cc.
Referenced by MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().
{ if (subrun != m_subRunNum) { m_ID = 0; m_subRunNum = subrun; } }
void MonRunIOV::setSubRunStart | ( | Tm | start | ) |
Definition at line 84 of file MonRunIOV.cc.
Referenced by MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), and EcalPedOffset::writeDb().
{ if (start != m_subRunStart) { m_ID = 0; m_subRunStart = start; } }
int MonRunIOV::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 216 of file MonRunIOV.cc.
References DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ this->checkConnection(); // Check if this IOV has already been written if (this->fetchID()) { return m_ID; } // fetch Parent IDs int monRunTagID, runIOVID; this->fetchParentIDs(&monRunTagID, &runIOVID); if (!monRunTagID) { monRunTagID = m_monRunTag.writeDB(); } // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); if (m_subRunStart.isNull()) { throw(std::runtime_error("MonRunIOV::writeDB: Must setSubRunStart before writing")); } if (m_subRunEnd.isNull()) { m_subRunEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("INSERT INTO mon_run_iov (iov_id, tag_id, run_iov_id, subrun_num, subrun_start, subrun_end) " "VALUES (mon_run_iov_sq.NextVal, :1, :2, :3, :4, :5)"); stmt->setInt(1, monRunTagID); stmt->setInt(2, runIOVID); stmt->setInt(3, m_subRunNum); stmt->setDate(4, dh.tmToDate(m_subRunStart)); stmt->setDate(5, dh.tmToDate(m_subRunEnd)); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunIOV::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("MonRunIOV::writeDB: Failed to write")); } return m_ID; }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 16 of file MonRunIOV.h.
MonRunTag MonRunIOV::m_monRunTag [private] |
Definition at line 54 of file MonRunIOV.h.
Referenced by operator==().
RunIOV MonRunIOV::m_runIOV [private] |
Definition at line 55 of file MonRunIOV.h.
Referenced by operator==().
Tm MonRunIOV::m_subRunEnd [private] |
Definition at line 58 of file MonRunIOV.h.
Referenced by operator==().
subrun_t MonRunIOV::m_subRunNum [private] |
Definition at line 56 of file MonRunIOV.h.
Referenced by operator==().
Tm MonRunIOV::m_subRunStart [private] |
Definition at line 57 of file MonRunIOV.h.
Referenced by operator==().