CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
RunIOV Class Reference

#include <RunIOV.h>

Inheritance diagram for RunIOV:
IIOV IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false)
 
int fetchIDByRunAndTag () noexcept(false)
 
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) noexcept(false)
 
void setDBInsertionTime (const Tm &dbtime)
 
void setID (int id)
 
void setRunEnd (const Tm &end)
 
void setRunNumber (run_t run)
 
void setRunStart (const Tm &start)
 
void setRunTag (const RunTag &tag)
 
 ~RunIOV ()
 
- 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 setByRecentData (std::string dataTable, RunTag *tag, run_t run=(unsigned int)-1) noexcept(false)
 
void setByRecentData (std::string dataTable, std::string location, run_t run) noexcept(false)
 
void setByRun (RunTag *tag, run_t run) noexcept(false)
 
void setByRun (std::string location, run_t run) noexcept(false)
 
void setByTime (std::string location, const Tm &t) noexcept(false)
 
int updateEndTimeDB () noexcept(false)
 
int updateStartTimeDB () noexcept(false)
 
int writeDB () noexcept(false)
 

Private Attributes

Tm m_dbtime
 
Tm m_runEnd
 
run_t m_runNum
 
Tm m_runStart
 
RunTag m_runTag
 

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 13 of file RunIOV.h.

Constructor & Destructor Documentation

RunIOV::RunIOV ( )

Definition at line 12 of file RunIOV.cc.

References NULL.

13 {
14  m_conn = NULL;
15  m_ID = 0;
16  m_runNum = 0;
17  m_runStart = Tm();
18  m_runEnd = Tm();
19 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
#define NULL
Definition: scimark2.h:8
Tm m_runEnd
Definition: RunIOV.h:57
run_t m_runNum
Definition: RunIOV.h:55
Definition: Tm.h:13
RunIOV::~RunIOV ( )

Definition at line 23 of file RunIOV.cc.

24 {
25 }

Member Function Documentation

int RunIOV::fetchID ( )
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 103 of file RunIOV.cc.

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

Referenced by getID().

105 {
106  // Return from memory if available
107  if (m_ID) {
108  return m_ID;
109  }
110 
111  this->checkConnection();
112 
114  int tagID = m_runTag.fetchID();
115  if (!tagID) {
116  return 0;
117  }
118 
120 
121  if (m_runEnd.isNull()) {
122  m_runEnd = dh.getPlusInfTm();
123  }
124 
125  try {
126  Statement* stmt = m_conn->createStatement();
127  stmt->setSQL("SELECT iov_id FROM run_iov "
128  "WHERE tag_id = :tag_id AND "
129  "run_num = :run_num AND "
130  "run_start = :run_start " );
131  stmt->setInt(1, tagID);
132  stmt->setInt(2, m_runNum);
133  stmt->setDate(3, dh.tmToDate(m_runStart));
134 
135  ResultSet* rset = stmt->executeQuery();
136 
137  if (rset->next()) {
138  m_ID = rset->getInt(1);
139  } else {
140  m_ID = 0;
141  }
142  m_conn->terminateStatement(stmt);
143  } catch (SQLException &e) {
144  throw(std::runtime_error("RunIOV::fetchID: "+e.getMessage()));
145  }
146 
147  return m_ID;
148 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int fetchID() noexcept(false)
Definition: RunTag.cc:80
run_t m_runNum
Definition: RunIOV.h:55
int isNull() const
Definition: Tm.cc:63
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353
int RunIOV::fetchIDByRunAndTag ( )
noexcept

Definition at line 284 of file RunIOV.cc.

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

Referenced by getID().

286 {
287  // Return from memory if available
288  if (m_ID) {
289  return m_ID;
290  }
291 
292  this->checkConnection();
293 
295  int tagID = m_runTag.fetchID();
296  if (!tagID) {
297  return 0;
298  }
299 
301 
302  if (m_runEnd.isNull()) {
303  m_runEnd = dh.getPlusInfTm();
304  }
305 
306  try {
307  Statement* stmt = m_conn->createStatement();
308  stmt->setSQL("SELECT iov_id FROM run_iov "
309  "WHERE tag_id = :tag_id AND "
310  "run_num = :run_num " );
311  stmt->setInt(1, tagID);
312  stmt->setInt(2, m_runNum);
313 
314  ResultSet* rset = stmt->executeQuery();
315 
316  if (rset->next()) {
317  m_ID = rset->getInt(1);
318  } else {
319  m_ID = 0;
320  }
321  m_conn->terminateStatement(stmt);
322  } catch (SQLException &e) {
323  throw(std::runtime_error("RunIOV::fetchID: "+e.getMessage()));
324  }
325 
326  return m_ID;
327 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int fetchID() noexcept(false)
Definition: RunTag.cc:80
run_t m_runNum
Definition: RunIOV.h:55
int isNull() const
Definition: Tm.cc:63
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353
Tm RunIOV::getDBInsertionTime ( )
inline

Definition at line 32 of file RunIOV.h.

References m_dbtime.

32 {return m_dbtime;}
Tm m_dbtime
Definition: RunIOV.h:59
int RunIOV::getID ( )
inline
Tm RunIOV::getRunEnd ( ) const

Definition at line 79 of file RunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), and EcalTPGDBApp::printIOV().

80 {
81  return m_runEnd;
82 }
Tm m_runEnd
Definition: RunIOV.h:57
run_t RunIOV::getRunNumber ( ) const
Tm RunIOV::getRunStart ( ) const

Definition at line 62 of file RunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), and EcalTPGDBApp::printIOV().

63 {
64  return m_runStart;
65 }
Tm m_runStart
Definition: RunIOV.h:56
RunTag RunIOV::getRunTag ( ) const

Definition at line 96 of file RunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), EcalCondDBReader::EcalCondDBReader(), EcalTPGDBApp::printIOV(), and EcalPedOffset::writeDb().

97 {
98  return m_runTag;
99 }
RunTag m_runTag
Definition: RunIOV.h:58
bool RunIOV::operator!= ( const RunIOV r) const
inline

Definition at line 51 of file RunIOV.h.

References alignCSCRings::r.

51 { return !(*this == r); }
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.

44  {
45  return (m_runNum == r.m_runNum &&
46  m_runStart == r.m_runStart &&
47  m_runEnd == r.m_runEnd &&
48  m_runTag == r.m_runTag);
49  }
Tm m_runStart
Definition: RunIOV.h:56
Tm m_runEnd
Definition: RunIOV.h:57
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void RunIOV::setByID ( int  id)
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 152 of file RunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, and hcalTTPDigis_cfi::id.

Referenced by LMFCorrCoefDat::fetchLastInsertedRun(), LMFSeqDat::fetchParentIDs(), getID(), and LMFSeqDat::getParameters().

154 {
155  this->checkConnection();
156 
158 
159  try {
160  Statement* stmt = m_conn->createStatement();
161 
162  stmt->setSQL("SELECT tag_id, run_num, run_start, run_end FROM run_iov WHERE iov_id = :1");
163  stmt->setInt(1, id);
164 
165  ResultSet* rset = stmt->executeQuery();
166  if (rset->next()) {
167  int tagID = rset->getInt(1);
168  m_runNum = rset->getInt(2);
169  Date startDate = rset->getDate(3);
170  Date endDate = rset->getDate(4);
171 
172  m_runStart = dh.dateToTm( startDate );
173  m_runEnd = dh.dateToTm( endDate );
174 
176  m_runTag.setByID(tagID);
177  m_ID = id;
178  } else {
179  throw(std::runtime_error("RunIOV::setByID: Given tag_id is not in the database"));
180  }
181 
182  m_conn->terminateStatement(stmt);
183  } catch (SQLException &e) {
184  throw(std::runtime_error("RunIOV::setByID: "+e.getMessage()));
185  }
186 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
run_t m_runNum
Definition: RunIOV.h:55
void setByID(int id) noexcept(false)
Definition: RunTag.cc:127
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353
void RunIOV::setByRecentData ( std::string  dataTable,
RunTag tag,
run_t  run = (unsigned int)-1 
)
privatenoexcept

Definition at line 496 of file RunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, findQualityFiles::run, and GlobalPosition_Frontier_DevDB_cff::tag.

498 {
499  this->checkConnection();
500 
501  tag->setConnection(m_env, m_conn);
502  int tagID = tag->fetchID();
503  if (!tagID) {
504  throw(std::runtime_error("RunIOV::setByRecentData: Given tag is not in the database"));
505  }
506 
508 
509  try {
510  Statement* stmt = m_conn->createStatement();
511 
512  stmt->setSQL("SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end "
513  "FROM run_iov riov "
514  "JOIN "+dataTable+" dat on dat.iov_id = riov.iov_id "
515  "WHERE tag_id = :1 AND riov.run_num <= :run ORDER BY riov.run_num DESC) WHERE rownum = 1");
516 
517  stmt->setInt(1, tagID);
518  stmt->setInt(2, run);
519 
520  ResultSet* rset = stmt->executeQuery();
521  if (rset->next()) {
522  m_runTag = *tag;
523 
524  m_ID = rset->getInt(1);
525  m_runNum = rset->getInt(2);
526  Date startDate = rset->getDate(3);
527  Date endDate = rset->getDate(4);
528 
529  m_runStart = dh.dateToTm( startDate );
530  m_runEnd = dh.dateToTm( endDate );
531  } else {
532  throw(std::runtime_error("RunIOV::setByRecentData: No data exists for given tag and run"));
533  }
534 
535  m_conn->terminateStatement(stmt);
536  } catch (SQLException &e) {
537  throw(std::runtime_error("RunIOV::setByRecentData: "+e.getMessage()));
538  }
539 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int fetchID() noexcept(false)
Definition: RunTag.cc:80
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353
void RunIOV::setByRecentData ( std::string  dataTable,
std::string  location,
run_t  run 
)
privatenoexcept

Definition at line 546 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, and findQualityFiles::run.

548 {
549  this->checkConnection();
550 
552 
553  try {
554  Statement* stmt = m_conn->createStatement();
555 
556  stmt->setSQL("SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end "
557  "FROM run_iov riov "
558  "JOIN "+dataTable+" dat on dat.iov_id = riov.iov_id "
559  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
560  "JOIN location_def loc ON rtag.location_id = loc.def_id "
561  "WHERE loc.location = :1 AND riov.run_num <= :2 ORDER BY riov.run_num DESC ) WHERE rownum = 1");
562 
563  stmt->setString(1, location);
564  stmt->setInt(2, run);
565 
566  ResultSet* rset = stmt->executeQuery();
567 
568 
569  if (rset->next()) {
570  int id = rset->getInt(1);
571  this->setByID(id);
572  } else {
573  throw(std::runtime_error("RunIOV::setByRecentData(datatable, loc, run): Given run is not in the database"));
574  }
575 
576 
577  m_conn->terminateStatement(stmt);
578  } catch (SQLException &e) {
579  throw(std::runtime_error("RunIOV::setByRecentData: "+e.getMessage()));
580  }
581 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setByID(int id) noexcept(false)
Definition: RunIOV.cc:152
dh
Definition: cuy.py:353
void RunIOV::setByRun ( RunTag tag,
run_t  run 
)
privatenoexcept

Definition at line 376 of file RunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, findQualityFiles::run, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by EcalCondDBInterface::fetchRunIOV().

378 {
379  this->checkConnection();
380 
381  tag->setConnection(m_env, m_conn);
382  int tagID = tag->fetchID();
383  if (!tagID) {
384  throw(std::runtime_error("RunIOV::setByRun: Given tag is not in the database"));
385  }
386 
388 
389  try {
390  Statement* stmt = m_conn->createStatement();
391 
392  stmt->setSQL("SELECT iov_id, run_start, run_end FROM run_iov WHERE tag_id = :1 AND run_num = :2");
393  stmt->setInt(1, tagID);
394  stmt->setInt(2, run);
395 
396  ResultSet* rset = stmt->executeQuery();
397  if (rset->next()) {
398  m_runTag = *tag;
399  m_runNum = run;
400 
401  m_ID = rset->getInt(1);
402  Date startDate = rset->getDate(2);
403  Date endDate = rset->getDate(3);
404 
405  m_runStart = dh.dateToTm( startDate );
406  m_runEnd = dh.dateToTm( endDate );
407  } else {
408  throw(std::runtime_error("RunIOV::setByRun: Given run is not in the database"));
409  }
410 
411  m_conn->terminateStatement(stmt);
412  } catch (SQLException &e) {
413  throw(std::runtime_error("RunIOV::setByRun: "+e.getMessage()));
414  }
415 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int fetchID() noexcept(false)
Definition: RunTag.cc:80
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353
void RunIOV::setByRun ( std::string  location,
run_t  run 
)
privatenoexcept

Definition at line 458 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, and findQualityFiles::run.

460 {
461  this->checkConnection();
462 
464 
465  try {
466  Statement* stmt = m_conn->createStatement();
467 
468  stmt->setSQL("SELECT iov_id FROM run_iov riov "
469  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
470  "JOIN location_def loc ON rtag.location_id = loc.def_id "
471  "WHERE loc.location = :1 AND riov.run_num = :2 "
472  "AND rtag.gen_tag != 'INVALID'");
473  stmt->setString(1, location);
474  stmt->setInt(2, run);
475 
476  ResultSet* rset = stmt->executeQuery();
477  if (rset->next()) {
478  int id = rset->getInt(1);
479  this->setByID(id);
480  } else {
481  throw(std::runtime_error("RunIOV::setByRun(loc, run): Given run is not in the database"));
482  }
483 
484  // Check for uniqueness of run
485  if (rset->next()) {
486  throw(std::runtime_error("RunIOV::setByRun(loc, run): Run is nonunique for given location."));
487  }
488 
489  m_conn->terminateStatement(stmt);
490  } catch (SQLException &e) {
491  throw(std::runtime_error("RunIOV::setByRun(loc, run): "+e.getMessage()));
492  }
493 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setByID(int id) noexcept(false)
Definition: RunIOV.cc:152
dh
Definition: cuy.py:353
void RunIOV::setByTime ( std::string  location,
const Tm t 
)
privatenoexcept

Definition at line 417 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, and lumiQTWidget::t.

Referenced by EcalCondDBInterface::fetchRunIOV().

419 {
420  this->checkConnection();
421 
423 
424  try {
425  Statement* stmt = m_conn->createStatement();
426 
427  stmt->setSQL("SELECT iov_id FROM (SELECT iov_id FROM run_iov riov "
428  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
429  "JOIN location_def loc ON rtag.location_id = loc.def_id "
430  "WHERE loc.location = :1 AND "
431  "run_start <= to_date(:2, 'YYYY-MM-DD HH24:MI:SS') AND "
432  "run_end >= to_date(:3, 'YYYY-MM-DD HH24:MI:SS') "
433  "AND rtag.gen_tag != 'INVALID' ORDER BY iov_id DESC) "
434  "where ROWNUM <=1");
435  stmt->setString(1, location);
436  stmt->setString(2, t.str());
437  stmt->setString(3, t.str());
438 
439  ResultSet* rset = stmt->executeQuery();
440  if (rset->next()) {
441  int id = rset->getInt(1);
442  this->setByID(id);
443  } else {
444  throw(std::runtime_error("RunIOV::setByTime(loc, run): Given run is not in the database"));
445  }
446 
447  // Check for uniqueness of run
448  if (rset->next()) {
449  throw(std::runtime_error("RunIOV::setByTime(loc, run): Run is nonunique for given location."));
450  }
451 
452  m_conn->terminateStatement(stmt);
453  } catch (SQLException &e) {
454  throw(std::runtime_error("RunIOV::setByTime(loc, run): " + e.getMessage()));
455  }
456 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string str() const
Definition: Tm.cc:89
void setByID(int id) noexcept(false)
Definition: RunIOV.cc:152
dh
Definition: cuy.py:353
void RunIOV::setDBInsertionTime ( const Tm dbtime)
inline
void RunIOV::setID ( int  id)
void RunIOV::setRunEnd ( const 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().

70 {
71  if (end != m_runEnd) {
72  m_ID = 0;
73  m_runEnd = end;
74  }
75 }
#define end
Definition: vmac.h:37
Tm m_runEnd
Definition: RunIOV.h:57
void RunIOV::setRunNumber ( run_t  run)
void RunIOV::setRunStart ( const Tm start)
void RunIOV::setRunTag ( const RunTag tag)
int RunIOV::updateEndTimeDB ( )
privatenoexcept

Definition at line 240 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DateHandler::getPlusInfTm(), DateHandler::tmToDate(), and GlobalTrackerMuonAlignment_cfi::writeDB.

242 {
243  this->checkConnection();
244 
245  // Check if this IOV has already been written
246  if(!this->fetchID()){
247  this->writeDB();
248  }
249 
250 
252  // int tagID = m_runTag.writeDB();
253 
254  // Validate the data, use infinity-till convention
256 
257  // we only update the run end here
258  if (m_runEnd.isNull()) {
259  m_runEnd = dh.getPlusInfTm();
260  }
261 
262  try {
263  Statement* stmt = m_conn->createStatement();
264 
265  stmt->setSQL("UPDATE run_iov set run_end=:1 where iov_id=:2 " );
266  stmt->setDate(1, dh.tmToDate(m_runEnd));
267  stmt->setInt(2, m_ID);
268 
269  stmt->executeUpdate();
270 
271  m_conn->terminateStatement(stmt);
272  } catch (SQLException &e) {
273  throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage()));
274  }
275 
276  // Now get the ID
277  if (!this->fetchID()) {
278  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
279  }
280 
281  return m_ID;
282 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int writeDB() noexcept(false)
Definition: RunIOV.cc:190
int fetchID() noexcept(false)
Definition: RunIOV.cc:103
int isNull() const
Definition: Tm.cc:63
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353
int RunIOV::updateStartTimeDB ( )
privatenoexcept

Definition at line 330 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DateHandler::getPlusInfTm(), DateHandler::tmToDate(), and GlobalTrackerMuonAlignment_cfi::writeDB.

332 {
333  this->checkConnection();
334 
335  // Check if this IOV has already been written
336  if(!this->fetchIDByRunAndTag()){
337  this->writeDB();
338  }
339 
340 
341  // m_runTag.setConnection(m_env, m_conn);
342  // int tagID = m_runTag.writeDB();
343 
344  // Validate the data, use infinity-till convention
346 
347  // we only update the run start here
348  if (m_runEnd.isNull()) {
349  m_runEnd = dh.getPlusInfTm();
350  }
351 
352  try {
353  Statement* stmt = m_conn->createStatement();
354 
355  stmt->setSQL("UPDATE run_iov set run_start=:1 where iov_id=:2 " );
356  stmt->setDate(1, dh.tmToDate(m_runStart));
357  stmt->setInt(2, m_ID);
358 
359  stmt->executeUpdate();
360 
361  m_conn->terminateStatement(stmt);
362  } catch (SQLException &e) {
363  throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage()));
364  }
365 
366  // Now get the ID
367  if (!this->fetchID()) {
368  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
369  }
370 
371  return m_ID;
372 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchIDByRunAndTag() noexcept(false)
Definition: RunIOV.cc:284
Tm m_runStart
Definition: RunIOV.h:56
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int writeDB() noexcept(false)
Definition: RunIOV.cc:190
int fetchID() noexcept(false)
Definition: RunIOV.cc:103
int isNull() const
Definition: Tm.cc:63
dh
Definition: cuy.py:353
int RunIOV::writeDB ( )
privatenoexcept

Definition at line 190 of file RunIOV.cc.

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

192 {
193  this->checkConnection();
194 
195  // Check if this IOV has already been written
196  if (this->fetchID()) {
197  return m_ID;
198  }
199 
201  int tagID = m_runTag.writeDB();
202 
203  // Validate the data, use infinity-till convention
205 
206  if (m_runStart.isNull()) {
207  throw(std::runtime_error("RunIOV::writeDB: Must setRunStart before writing"));
208  }
209 
210  if (m_runEnd.isNull()) {
211  m_runEnd = dh.getPlusInfTm();
212  }
213 
214  try {
215  Statement* stmt = m_conn->createStatement();
216 
217  stmt->setSQL("INSERT INTO run_iov (iov_id, tag_id, run_num, run_start, run_end) "
218  "VALUES (run_iov_sq.NextVal, :1, :2, :3, :4)");
219  stmt->setInt(1, tagID);
220  stmt->setInt(2, m_runNum);
221  stmt->setDate(3, dh.tmToDate(m_runStart));
222  stmt->setDate(4, dh.tmToDate(m_runEnd));
223 
224  stmt->executeUpdate();
225 
226  m_conn->terminateStatement(stmt);
227  } catch (SQLException &e) {
228  throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage()));
229  }
230 
231  // Now get the ID
232  if (!this->fetchID()) {
233  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
234  }
235 
236  return m_ID;
237 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int writeDB() noexcept(false)
Definition: RunTag.cc:162
Tm m_runStart
Definition: RunIOV.h:56
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
Tm m_runEnd
Definition: RunIOV.h:57
int fetchID() noexcept(false)
Definition: RunIOV.cc:103
run_t m_runNum
Definition: RunIOV.h:55
int isNull() const
Definition: Tm.cc:63
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:353

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 15 of file RunIOV.h.

Member Data Documentation

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==().