#include <RunIOV.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
int | fetchIDByRunAndTag () throw (std::runtime_error) |
Tm | getDBInsertionTime () |
int | getID () |
Tm | getRunEnd () const |
run_t | getRunNumber () const |
Tm | getRunStart () const |
RunTag | getRunTag () const |
bool | operator!= (const RunIOV &r) const |
bool | operator== (const RunIOV &r) const |
RunIOV () | |
void | setByID (int id) throw (std::runtime_error) |
void | setDBInsertionTime (Tm dbtime) |
void | setID (int id) |
void | setRunEnd (Tm end) |
void | setRunNumber (run_t run) |
void | setRunStart (Tm start) |
void | setRunTag (RunTag tag) |
~RunIOV () | |
Private Member Functions | |
void | setByRecentData (std::string dataTable, RunTag *tag, run_t run=(unsigned int)-1) throw (std::runtime_error) |
void | setByRecentData (std::string dataTable, std::string location, run_t run) throw (std::runtime_error) |
void | setByRun (std::string location, run_t run) throw (std::runtime_error) |
void | setByRun (RunTag *tag, run_t run) throw (std::runtime_error) |
int | updateEndTimeDB () throw (std::runtime_error) |
int | updateStartTimeDB () throw (std::runtime_error) |
int | writeDB () throw (std::runtime_error) |
Private Attributes | |
Tm | m_dbtime |
Tm | m_runEnd |
run_t | m_runNum |
Tm | m_runStart |
RunTag | m_runTag |
Friends | |
class | EcalCondDBInterface |
RunIOV::RunIOV | ( | ) |
int RunIOV::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 103 of file RunIOV.cc.
References DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); m_runTag.setConnection(m_env, m_conn); int tagID = m_runTag.fetchID(); if (!tagID) { return 0; } DateHandler dh(m_env, m_conn); if (m_runEnd.isNull()) { m_runEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id FROM run_iov " "WHERE tag_id = :tag_id AND " "run_num = :run_num AND " "run_start = :run_start " ); stmt->setInt(1, tagID); stmt->setInt(2, m_runNum); stmt->setDate(3, dh.tmToDate(m_runStart)); 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("RunIOV::fetchID: "+e.getMessage())); } return m_ID; }
int RunIOV::fetchIDByRunAndTag | ( | ) | throw (std::runtime_error) |
Definition at line 284 of file RunIOV.cc.
References DateHandler::getPlusInfTm().
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); m_runTag.setConnection(m_env, m_conn); int tagID = m_runTag.fetchID(); if (!tagID) { return 0; } DateHandler dh(m_env, m_conn); if (m_runEnd.isNull()) { m_runEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id FROM run_iov " "WHERE tag_id = :tag_id AND " "run_num = :run_num " ); stmt->setInt(1, tagID); stmt->setInt(2, m_runNum); 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("RunIOV::fetchID: "+e.getMessage())); } return m_ID; }
Tm RunIOV::getDBInsertionTime | ( | ) | [inline] |
int RunIOV::getID | ( | ) | [inline] |
Definition at line 36 of file RunIOV.h.
References IUniqueDBObject::m_ID.
Referenced by LMFSeqDat::fetchByRunIOV(), LMFSeqDat::fetchIdSql(), LMFSeqDat::fetchParentIDs(), and LMFSeqDat::writeDBSql().
{ return m_ID;} ;
Tm RunIOV::getRunEnd | ( | ) | const |
Definition at line 79 of file RunIOV.cc.
Referenced by EcalTPGDBApp::printIOV().
{ return m_runEnd; }
run_t RunIOV::getRunNumber | ( | ) | const |
Definition at line 45 of file RunIOV.cc.
Referenced by popcon::EcalDCSHandler::getNewObjects(), popcon::EcalIntercalibHandler::getNewObjects(), EcalTPGDBApp::printIOV(), and EcalErrorMask::readDB().
{ return m_runNum; }
Tm RunIOV::getRunStart | ( | ) | const |
Definition at line 62 of file RunIOV.cc.
Referenced by EcalTPGDBApp::printIOV().
{ return m_runStart; }
RunTag RunIOV::getRunTag | ( | ) | const |
Definition at line 96 of file RunIOV.cc.
Referenced by EcalTPGDBApp::printIOV(), and EcalPedOffset::writeDb().
{ return m_runTag; }
bool RunIOV::operator!= | ( | const RunIOV & | r | ) | const [inline] |
bool RunIOV::operator== | ( | const RunIOV & | r | ) | const [inline] |
Definition at line 43 of file RunIOV.h.
References m_runEnd, m_runNum, m_runStart, and m_runTag.
{ return (m_runNum == r.m_runNum && m_runStart == r.m_runStart && m_runEnd == r.m_runEnd && m_runTag == r.m_runTag); }
void RunIOV::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 152 of file RunIOV.cc.
References DateHandler::dateToTm().
Referenced by LMFCorrCoefDat::fetchLastInsertedRun(), LMFSeqDat::fetchParentIDs(), and LMFSeqDat::getParameters().
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id, run_num, run_start, run_end FROM run_iov WHERE iov_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { int tagID = rset->getInt(1); m_runNum = rset->getInt(2); Date startDate = rset->getDate(3); Date endDate = rset->getDate(4); m_runStart = dh.dateToTm( startDate ); m_runEnd = dh.dateToTm( endDate ); m_runTag.setConnection(m_env, m_conn); m_runTag.setByID(tagID); m_ID = id; } else { throw(std::runtime_error("RunIOV::setByID: Given tag_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::setByID: "+e.getMessage())); } }
void RunIOV::setByRecentData | ( | std::string | dataTable, |
RunTag * | tag, | ||
run_t | run = (unsigned int)-1 |
||
) | throw (std::runtime_error) [private] |
Definition at line 457 of file RunIOV.cc.
References DateHandler::dateToTm(), DTTTrigCorrFirst::run, and GlobalPosition_Frontier_DevDB_cff::tag.
{ this->checkConnection(); tag->setConnection(m_env, m_conn); int tagID = tag->fetchID(); if (!tagID) { throw(std::runtime_error("RunIOV::setByRecentData: Given tag is not in the database")); } DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end " "FROM run_iov riov " "JOIN "+dataTable+" dat on dat.iov_id = riov.iov_id " "WHERE tag_id = :1 AND riov.run_num <= :run ORDER BY riov.run_num DESC) WHERE rownum = 1"); stmt->setInt(1, tagID); stmt->setInt(2, run); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_runTag = *tag; m_ID = rset->getInt(1); m_runNum = rset->getInt(2); Date startDate = rset->getDate(3); Date endDate = rset->getDate(4); m_runStart = dh.dateToTm( startDate ); m_runEnd = dh.dateToTm( endDate ); } else { throw(std::runtime_error("RunIOV::setByRecentData: No data exists for given tag and run")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::setByRecentData: "+e.getMessage())); } }
void RunIOV::setByRecentData | ( | std::string | dataTable, |
std::string | location, | ||
run_t | run | ||
) | throw (std::runtime_error) [private] |
Definition at line 507 of file RunIOV.cc.
References DTTTrigCorrFirst::run.
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end " "FROM run_iov riov " "JOIN "+dataTable+" dat on dat.iov_id = riov.iov_id " "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id " "JOIN location_def loc ON rtag.location_id = loc.def_id " "WHERE loc.location = :1 AND riov.run_num <= :2 ORDER BY riov.run_num DESC ) WHERE rownum = 1"); stmt->setString(1, location); stmt->setInt(2, run); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { int id = rset->getInt(1); this->setByID(id); } else { throw(std::runtime_error("RunIOV::setByRecentData(datatable, loc, run): Given run is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::setByRecentData: "+e.getMessage())); } }
Definition at line 376 of file RunIOV.cc.
References DateHandler::dateToTm(), DTTTrigCorrFirst::run, and GlobalPosition_Frontier_DevDB_cff::tag.
Referenced by EcalCondDBInterface::fetchRunIOV().
{ this->checkConnection(); tag->setConnection(m_env, m_conn); int tagID = tag->fetchID(); if (!tagID) { throw(std::runtime_error("RunIOV::setByRun: Given tag is not in the database")); } DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id, run_start, run_end FROM run_iov WHERE tag_id = :1 AND run_num = :2"); stmt->setInt(1, tagID); stmt->setInt(2, run); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_runTag = *tag; m_runNum = run; m_ID = rset->getInt(1); Date startDate = rset->getDate(2); Date endDate = rset->getDate(3); m_runStart = dh.dateToTm( startDate ); m_runEnd = dh.dateToTm( endDate ); } else { throw(std::runtime_error("RunIOV::setByRun: Given run is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::setByRun: "+e.getMessage())); } }
void RunIOV::setByRun | ( | std::string | location, |
run_t | run | ||
) | throw (std::runtime_error) [private] |
Definition at line 419 of file RunIOV.cc.
References DTTTrigCorrFirst::run.
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id FROM run_iov riov " "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id " "JOIN location_def loc ON rtag.location_id = loc.def_id " "WHERE loc.location = :1 AND riov.run_num = :2 " "AND rtag.gen_tag != 'INVALID'"); stmt->setString(1, location); stmt->setInt(2, run); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { int id = rset->getInt(1); this->setByID(id); } else { throw(std::runtime_error("RunIOV::setByRun(loc, run): Given run is not in the database")); } // Check for uniqueness of run if (rset->next()) { throw(std::runtime_error("RunIOV::setByRun(loc, run): Run is nonunique for given location.")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::setByRun(loc, run): "+e.getMessage())); } }
void RunIOV::setDBInsertionTime | ( | Tm | dbtime | ) | [inline] |
Definition at line 31 of file RunIOV.h.
References m_dbtime.
Referenced by RunList::fetchGlobalRunsByLocation(), RunList::fetchLastNRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().
{m_dbtime=dbtime;}
void RunIOV::setID | ( | int | id | ) |
Definition at line 37 of file RunIOV.cc.
Referenced by RunList::fetchGlobalRunsByLocation(), RunList::fetchLastNRuns(), MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().
{ m_ID = id; }
void RunIOV::setRunEnd | ( | Tm | end | ) |
Definition at line 69 of file RunIOV.cc.
References end.
Referenced by RunList::fetchGlobalRunsByLocation(), MonRunList::fetchLastNRuns(), RunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().
void RunIOV::setRunNumber | ( | run_t | run | ) |
Definition at line 29 of file RunIOV.cc.
References DTTTrigCorrFirst::run.
Referenced by RunList::fetchGlobalRunsByLocation(), MonRunList::fetchLastNRuns(), RunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().
void RunIOV::setRunStart | ( | Tm | start | ) |
Definition at line 52 of file RunIOV.cc.
Referenced by RunList::fetchGlobalRunsByLocation(), RunList::fetchLastNRuns(), MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().
{ if (start != m_runStart) { m_ID = 0; m_runStart = start; } }
void RunIOV::setRunTag | ( | RunTag | tag | ) |
Definition at line 86 of file RunIOV.cc.
References GlobalPosition_Frontier_DevDB_cff::tag.
Referenced by RunList::fetchGlobalRunsByLocation(), RunList::fetchLastNRuns(), MonRunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().
int RunIOV::updateEndTimeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 240 of file RunIOV.cc.
References DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ this->checkConnection(); // Check if this IOV has already been written if(!this->fetchID()){ this->writeDB(); } m_runTag.setConnection(m_env, m_conn); // int tagID = m_runTag.writeDB(); // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); // we only update the run end here if (m_runEnd.isNull()) { m_runEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("UPDATE run_iov set run_end=:1 where iov_id=:2 " ); stmt->setDate(1, dh.tmToDate(m_runEnd)); stmt->setInt(2, m_ID); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("RunIOV::writeDB: Failed to write")); } return m_ID; }
int RunIOV::updateStartTimeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 330 of file RunIOV.cc.
References DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ this->checkConnection(); // Check if this IOV has already been written if(!this->fetchIDByRunAndTag()){ this->writeDB(); } // m_runTag.setConnection(m_env, m_conn); // int tagID = m_runTag.writeDB(); // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); // we only update the run start here if (m_runEnd.isNull()) { m_runEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("UPDATE run_iov set run_start=:1 where iov_id=:2 " ); stmt->setDate(1, dh.tmToDate(m_runStart)); stmt->setInt(2, m_ID); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("RunIOV::writeDB: Failed to write")); } return m_ID; }
int RunIOV::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 190 of file RunIOV.cc.
References DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ this->checkConnection(); // Check if this IOV has already been written if (this->fetchID()) { return m_ID; } m_runTag.setConnection(m_env, m_conn); int tagID = m_runTag.writeDB(); // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); if (m_runStart.isNull()) { throw(std::runtime_error("RunIOV::writeDB: Must setRunStart before writing")); } if (m_runEnd.isNull()) { m_runEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("INSERT INTO run_iov (iov_id, tag_id, run_num, run_start, run_end) " "VALUES (run_iov_sq.NextVal, :1, :2, :3, :4)"); stmt->setInt(1, tagID); stmt->setInt(2, m_runNum); stmt->setDate(3, dh.tmToDate(m_runStart)); stmt->setDate(4, dh.tmToDate(m_runEnd)); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("RunIOV::writeDB: Failed to write")); } return m_ID; }
friend class EcalCondDBInterface [friend] |
Tm RunIOV::m_dbtime [private] |
Definition at line 59 of file RunIOV.h.
Referenced by getDBInsertionTime(), and setDBInsertionTime().
Tm RunIOV::m_runEnd [private] |
Definition at line 57 of file RunIOV.h.
Referenced by operator==().
run_t RunIOV::m_runNum [private] |
Definition at line 55 of file RunIOV.h.
Referenced by operator==().
Tm RunIOV::m_runStart [private] |
Definition at line 56 of file RunIOV.h.
Referenced by operator==().
RunTag RunIOV::m_runTag [private] |
Definition at line 58 of file RunIOV.h.
Referenced by operator==().