#include <RunList.h>
Public Member Functions | |
void | fetchGlobalRunsByLocation (int min_run, int max_run, const LocationDef locDef) throw (std::runtime_error) |
void | fetchLastNRuns (int max_run, int n_runs) throw (std::runtime_error) |
void | fetchNonEmptyGlobalRuns (int min_run, int max_run) throw (std::runtime_error) |
void | fetchNonEmptyGlobalRuns () throw (std::runtime_error) |
void | fetchNonEmptyRuns (int min_run, int max_run) throw (std::runtime_error) |
void | fetchNonEmptyRuns () throw (std::runtime_error) |
void | fetchRuns (int min_run, int max_run) throw (std::runtime_error) |
void | fetchRuns (int min_run, int max_run, bool withTriggers, bool withGlobalTriggers) throw (std::runtime_error) |
void | fetchRuns () throw (std::runtime_error) |
void | fetchRunsByLocation (int min_run, int max_run, const LocationDef locDef) throw (std::runtime_error) |
std::vector< RunIOV > | getRuns () |
RunTag | getRunTag () const |
RunList () | |
void | setRunTag (RunTag tag) |
~RunList () | |
Private Attributes | |
RunTag | m_runTag |
std::vector< RunIOV > | m_vec_runiov |
Friends | |
class | EcalCondDBInterface |
RunList::RunList | ( | ) |
RunList::~RunList | ( | ) |
Definition at line 18 of file RunList.cc.
{ }
void RunList::fetchGlobalRunsByLocation | ( | int | min_run, |
int | max_run, | ||
const LocationDef | locDef | ||
) | throw (std::runtime_error) |
Definition at line 354 of file RunList.cc.
References getBeamSpotDB::atag, gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, RunIOV::setDBInsertionTime(), RunTag::setGeneralTag(), RunIOV::setID(), RunTag::setLocationDef(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), RunTypeDef::setRunType(), and RunTag::setRunTypeDef().
Referenced by EcalCondDBInterface::fetchGlobalRunListByLocation().
{ this->checkConnection(); int nruns=0; int my_min_run=min_run-1; int my_max_run=max_run+1; try { Statement* stmt0 = m_conn->createStatement(); stmt0->setSQL("SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l " " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 " " and t.gen_tag='GLOBAL' " " and r.run_num> :2 and r.run_num< :3 "); stmt0->setString(1,locDef.getLocation() ); stmt0->setInt(2, my_min_run); stmt0->setInt(3, my_max_run); ResultSet* rset0 = stmt0->executeQuery(); if (rset0->next()) { nruns = rset0->getInt(1); } m_conn->terminateStatement(stmt0); cout <<"number of runs="<< nruns << endl; m_vec_runiov.reserve(nruns); Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , " " t.gen_tag, rt.RUN_TYPE " " FROM run_iov r , run_tag t, location_def l, run_type_def rt " " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID " " AND l.LOCATION= :1 " " and t.gen_tag='GLOBAL' " " and r.run_num> :2 and r.run_num< :3 " " order by run_num " ); stmt->setString(1,locDef.getLocation() ); stmt->setInt(2, my_min_run); stmt->setInt(3, my_max_run); DateHandler dh(m_env, m_conn); Tm runStart; Tm runEnd; Tm dbtime; ResultSet* rset = stmt->executeQuery(); int i=0; while (i<nruns) { rset->next(); int iovID = rset->getInt(1); // int tagID = rset->getInt(2); int runNum = rset->getInt(3); Date startDate = rset->getDate(4); Date endDate = rset->getDate(5); Date dbDate = rset->getDate(6); runStart = dh.dateToTm( startDate ); runEnd = dh.dateToTm( endDate ); dbtime = dh.dateToTm( dbDate ); RunTag atag; atag.setLocationDef(locDef); atag.setGeneralTag(rset->getString(7)); RunTypeDef rundef; rundef.setRunType(rset->getString(8)); atag.setRunTypeDef(rundef); RunIOV r ; r.setRunNumber(runNum); r.setRunStart(runStart); r.setRunEnd(runEnd); r.setDBInsertionTime(dbtime); r.setRunTag(atag); r.setID(iovID); m_vec_runiov.push_back(r); i++; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunList::fetchRunsByLocation: "+e.getMessage())); } }
void RunList::fetchLastNRuns | ( | int | max_run, |
int | n_runs | ||
) | throw (std::runtime_error) |
Definition at line 191 of file RunList.cc.
References gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, RunIOV::setDBInsertionTime(), RunIOV::setID(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), and RunIOV::setRunTag().
Referenced by EcalCondDBInterface::fetchRunListLastNRuns().
{ // fetch the last n_runs that come just before max_run (including max_run) this->checkConnection(); m_runTag.setConnection(m_env, m_conn); int tagID = m_runTag.fetchID(); cout <<"tag id="<< tagID << endl; if (!tagID) { return ; } int my_max_run=max_run+1; try { int nruns=n_runs+1; m_vec_runiov.reserve(nruns); Statement* stmt = m_conn->createStatement(); stmt->setSQL("select iov_id, tag_id, run_num, run_start, run_end, DB_TIMESTAMP from " " (SELECT * from RUN_IOV " " WHERE tag_id = :tag_id " " and run_num< :max_run " " order by run_num DESC ) where rownum< :n_runs ORDER BY run_num ASC " ); stmt->setInt(1, tagID); stmt->setInt(2, my_max_run); stmt->setInt(3, nruns); DateHandler dh(m_env, m_conn); Tm runStart; Tm runEnd; Tm dbtime; ResultSet* rset = stmt->executeQuery(); int i=0; while (i<n_runs) { rset->next(); int iovID = rset->getInt(1); // int tagID = rset->getInt(2); int runNum = rset->getInt(3); Date startDate = rset->getDate(4); Date endDate = rset->getDate(5); Date dbDate = rset->getDate(6); runStart = dh.dateToTm( startDate ); runEnd = dh.dateToTm( endDate ); dbtime = dh.dateToTm( dbDate ); RunIOV r ; r.setRunNumber(runNum); r.setRunStart(runStart); r.setRunEnd(runEnd); r.setDBInsertionTime(dbtime); r.setRunTag(m_runTag); r.setID(iovID); m_vec_runiov.push_back(r); i++; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunList::fetchLastNRuns: "+e.getMessage())); } }
void RunList::fetchNonEmptyGlobalRuns | ( | ) | throw (std::runtime_error) |
Definition at line 46 of file RunList.cc.
Referenced by EcalCondDBInterface::fetchNonEmptyGlobalRunList().
{ fetchRuns(-1, -1, false, true); }
void RunList::fetchNonEmptyGlobalRuns | ( | int | min_run, |
int | max_run | ||
) | throw (std::runtime_error) |
Definition at line 58 of file RunList.cc.
{ fetchRuns(min_run, max_run, false, true); }
void RunList::fetchNonEmptyRuns | ( | ) | throw (std::runtime_error) |
Definition at line 40 of file RunList.cc.
Referenced by EcalCondDBInterface::fetchNonEmptyRunList().
{ fetchRuns(-1, -1, true, false); }
void RunList::fetchNonEmptyRuns | ( | int | min_run, |
int | max_run | ||
) | throw (std::runtime_error) |
Definition at line 52 of file RunList.cc.
{ fetchRuns(min_run, max_run, true, false); }
void RunList::fetchRuns | ( | ) | throw (std::runtime_error) |
Definition at line 64 of file RunList.cc.
Referenced by EcalCondDBInterface::fetchRunList().
{ fetchRuns(-1, -1); }
void RunList::fetchRuns | ( | int | min_run, |
int | max_run | ||
) | throw (std::runtime_error) |
Definition at line 70 of file RunList.cc.
{ fetchRuns(min_run, max_run, false, false); }
void RunList::fetchRuns | ( | int | min_run, |
int | max_run, | ||
bool | withTriggers, | ||
bool | withGlobalTriggers | ||
) | throw (std::runtime_error) |
Definition at line 76 of file RunList.cc.
References gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, RunIOV::setDBInsertionTime(), RunIOV::setID(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), and RunIOV::setRunTag().
{ /* withTriggers and withGlobalTriggers selects those non empty runs. Possible combinations are withTriggers withGlobalTriggers select ------------ ------------------ ------------------------------ false false all false true only runs with global triggers true false only runs with any trigger true true only runs with global triggers */ this->checkConnection(); int nruns=0; m_runTag.setConnection(m_env, m_conn); int tagID = m_runTag.fetchID(); cout <<"tag id="<< tagID << endl; if (!tagID) { return ; } int my_min_run=min_run-1; int my_max_run=max_run+1; try { Statement* stmt0 = m_conn->createStatement(); string sql = "SELECT count(iov_id) FROM run_iov " "WHERE tag_id = :tag_id "; if (min_run > 0) { // don't need to specify empty/non empty here. This is needed // just to allocate the memory for the vector sql += " and run_iov.run_num> :min_run and run_iov.run_num< :max_run "; } stmt0->setSQL(sql); stmt0->setInt(1, tagID); if (min_run > 0) { stmt0->setInt(2, my_min_run); stmt0->setInt(3, my_max_run); } ResultSet* rset0 = stmt0->executeQuery(); if (rset0->next()) { nruns = rset0->getInt(1); } m_conn->terminateStatement(stmt0); cout <<"number of runs="<< nruns << endl; m_vec_runiov.reserve(nruns); Statement* stmt = m_conn->createStatement(); sql = "SELECT DISTINCT i.iov_id, tag_id, run_num, run_start, run_end, " "db_timestamp FROM run_iov i "; if ((withTriggers) || (withGlobalTriggers)) { sql += "join cms_ecal_cond.run_dat d on d.iov_id = i.iov_id " "left join CMS_RUNINFO.RUNSESSION_PARAMETER G on " "(i.run_num = G.RUNNUMBER and G.NAME = 'CMS.TRG:NumTriggers') "; } sql += "WHERE tag_id = :tag_id "; if (min_run > 0) { sql += "and i.run_num> :min_run and i.run_num< :max_run "; } if (withGlobalTriggers) { sql += "and G.STRING_VALUE != '0' "; } else if (withTriggers) { sql += "and (G.STRING_VALUE != '0' or num_events > 0) "; } sql += " order by run_num "; stmt->setSQL(sql); stmt->setInt(1, tagID); if (min_run > 0) { stmt->setInt(2, my_min_run); stmt->setInt(3, my_max_run); } DateHandler dh(m_env, m_conn); Tm runStart; Tm runEnd; Tm dbtime; ResultSet* rset = stmt->executeQuery(); int i=0; while ((i<nruns) && (rset->next())) { int iovID = rset->getInt(1); // int tagID = rset->getInt(2); int runNum = rset->getInt(3); Date startDate = rset->getDate(4); Date endDate = rset->getDate(5); Date dbDate = rset->getDate(6); runStart = dh.dateToTm( startDate ); runEnd = dh.dateToTm( endDate ); dbtime = dh.dateToTm( dbDate ); RunIOV r ; r.setRunNumber(runNum); r.setRunStart(runStart); r.setRunEnd(runEnd); r.setDBInsertionTime(dbtime); r.setRunTag(m_runTag); r.setID(iovID); m_vec_runiov.push_back(r); i++; } m_vec_runiov.resize(i); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunList::fetchRuns: "+e.getMessage())); } }
void RunList::fetchRunsByLocation | ( | int | min_run, |
int | max_run, | ||
const LocationDef | locDef | ||
) | throw (std::runtime_error) |
Definition at line 265 of file RunList.cc.
References getBeamSpotDB::atag, gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, RunIOV::setDBInsertionTime(), RunTag::setGeneralTag(), RunIOV::setID(), RunTag::setLocationDef(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), RunTypeDef::setRunType(), and RunTag::setRunTypeDef().
Referenced by EcalCondDBInterface::fetchRunListByLocation().
{ this->checkConnection(); int nruns=0; int my_min_run=min_run-1; int my_max_run=max_run+1; try { Statement* stmt0 = m_conn->createStatement(); stmt0->setSQL("SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l " " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 " " and r.run_num> :2 and r.run_num< :3 "); stmt0->setString(1,locDef.getLocation() ); stmt0->setInt(2, my_min_run); stmt0->setInt(3, my_max_run); ResultSet* rset0 = stmt0->executeQuery(); if (rset0->next()) { nruns = rset0->getInt(1); } m_conn->terminateStatement(stmt0); cout <<"number of runs="<< nruns << endl; m_vec_runiov.reserve(nruns); Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , " " t.gen_tag, rt.RUN_TYPE " " FROM run_iov r , run_tag t, location_def l, run_type_def rt " " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID " " AND l.LOCATION= :1 " " and r.run_num> :2 and r.run_num< :3 " " order by run_num " ); stmt->setString(1,locDef.getLocation() ); stmt->setInt(2, my_min_run); stmt->setInt(3, my_max_run); DateHandler dh(m_env, m_conn); Tm runStart; Tm runEnd; Tm dbtime; ResultSet* rset = stmt->executeQuery(); int i=0; while (i<nruns) { rset->next(); int iovID = rset->getInt(1); // int tagID = rset->getInt(2); int runNum = rset->getInt(3); Date startDate = rset->getDate(4); Date endDate = rset->getDate(5); Date dbDate = rset->getDate(6); runStart = dh.dateToTm( startDate ); runEnd = dh.dateToTm( endDate ); dbtime = dh.dateToTm( dbDate ); RunTag atag; atag.setLocationDef(locDef); atag.setGeneralTag(rset->getString(7)); RunTypeDef rundef; rundef.setRunType(rset->getString(8)); atag.setRunTypeDef(rundef); RunIOV r ; r.setRunNumber(runNum); r.setRunStart(runStart); r.setRunEnd(runEnd); r.setDBInsertionTime(dbtime); r.setRunTag(atag); r.setID(iovID); m_vec_runiov.push_back(r); i++; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunList::fetchRunsByLocation: "+e.getMessage())); } }
std::vector< RunIOV > RunList::getRuns | ( | ) |
Definition at line 35 of file RunList.cc.
Referenced by popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGSpikeThresholdHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalSRPHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGBadStripHandler::getNewObjects(), popcon::EcalTPGLutGroupHandler::getNewObjects(), and popcon::EcalTPGFineGrainStripEEHandler::getNewObjects().
{ return m_vec_runiov; }
RunTag RunList::getRunTag | ( | ) | const |
Definition at line 30 of file RunList.cc.
{ return m_runTag; }
void RunList::setRunTag | ( | RunTag | tag | ) |
Definition at line 22 of file RunList.cc.
References GlobalPosition_Frontier_DevDB_cff::tag.
Referenced by EcalCondDBInterface::fetchGlobalRunListByLocation(), EcalCondDBInterface::fetchNonEmptyGlobalRunList(), EcalCondDBInterface::fetchNonEmptyRunList(), EcalCondDBInterface::fetchRunList(), EcalCondDBInterface::fetchRunListByLocation(), and EcalCondDBInterface::fetchRunListLastNRuns().
friend class EcalCondDBInterface [friend] |
RunTag RunList::m_runTag [private] |
std::vector<RunIOV> RunList::m_vec_runiov [private] |