CMS 3D CMS Logo

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

#include <MODRunIOV.h>

Inheritance diagram for MODRunIOV:
IIOV IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false) override
 
int getID ()
 
RunIOV getRunIOV ()
 
Tm getSubRunEnd () const
 
run_t getSubRunNumber () const
 
Tm getSubRunStart () const
 
 MODRunIOV ()
 
bool operator!= (const MODRunIOV &m) const
 
bool operator== (const MODRunIOV &m) const
 
void setByID (int id) noexcept(false) override
 
void setID (int id)
 
void setRunIOV (const RunIOV &iov)
 
void setSubRunEnd (const Tm &end)
 
void setSubRunNumber (subrun_t subrun)
 
void setSubRunStart (const Tm &start)
 
 ~MODRunIOV () 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 *runIOVID) noexcept(false)
 
void setByRun (RunIOV *runiov, subrun_t subrun) noexcept(false)
 
int writeDB () noexcept(false)
 

Private Attributes

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

Constructor & Destructor Documentation

◆ MODRunIOV()

MODRunIOV::MODRunIOV ( )

Definition at line 12 of file MODRunIOV.cc.

12  {
13  m_conn = nullptr;
14  m_ID = 0;
15  m_runIOV = RunIOV();
16  m_subRunNum = 0;
17  m_subRunStart = Tm();
18  m_subRunEnd = Tm();
19 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
subrun_t m_subRunNum
Definition: MODRunIOV.h:48
Tm m_subRunStart
Definition: MODRunIOV.h:49
Tm m_subRunEnd
Definition: MODRunIOV.h:50
Definition: RunIOV.h:13
Definition: Tm.h:13
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ ~MODRunIOV()

MODRunIOV::~MODRunIOV ( )
override

Definition at line 21 of file MODRunIOV.cc.

21 {}

Member Function Documentation

◆ fetchID()

int MODRunIOV::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 61 of file MODRunIOV.cc.

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

61  {
62  // Return from memory if available
63  if (m_ID) {
64  return m_ID;
65  }
66 
67  this->checkConnection();
68 
69  // fetch the parent IDs
70  int runIOVID;
71  this->fetchParentIDs(&runIOVID);
72 
73  if (!runIOVID) {
74  return 0;
75  }
76 
78 
79  if (m_subRunEnd.isNull()) {
80  m_subRunEnd = dh.getPlusInfTm();
81  }
82 
83  try {
84  Statement* stmt = m_conn->createStatement();
85  stmt->setSQL(
86  "SELECT iov_id FROM OD_run_iov "
87  "WHERE "
88  "run_iov_id = :1 AND "
89  "subrun_num = :2 AND "
90  "subrun_start = :3 AND "
91  "subrun_end = :4");
92 
93  stmt->setInt(1, runIOVID);
94  stmt->setInt(2, m_subRunNum);
95  stmt->setDate(3, dh.tmToDate(m_subRunStart));
96  stmt->setDate(4, dh.tmToDate(m_subRunEnd));
97 
98  ResultSet* rset = stmt->executeQuery();
99 
100  if (rset->next()) {
101  m_ID = rset->getInt(1);
102  } else {
103  m_ID = 0;
104  }
105  m_conn->terminateStatement(stmt);
106  } catch (SQLException& e) {
107  throw(std::runtime_error("MODRunIOV::fetchID: " + e.getMessage()));
108  }
109 
110  return m_ID;
111 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
subrun_t m_subRunNum
Definition: MODRunIOV.h:48
Tm m_subRunStart
Definition: MODRunIOV.h:49
Tm m_subRunEnd
Definition: MODRunIOV.h:50
int isNull() const
Definition: Tm.cc:46
void fetchParentIDs(int *runIOVID) noexcept(false)
Definition: MODRunIOV.cc:197
dh
Definition: cuy.py:354

◆ fetchParentIDs()

void MODRunIOV::fetchParentIDs ( int *  runIOVID)
privatenoexcept

Definition at line 197 of file MODRunIOV.cc.

197  {
198  // get the RunIOV
200  *runIOVID = m_runIOV.fetchID();
201 
202  if (!*runIOVID) {
203  throw(std::runtime_error("MODRunIOV: Given RunIOV does not exist in DB"));
204  }
205 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ getID()

int MODRunIOV::getID ( )
inline

Definition at line 21 of file MODRunIOV.h.

References IUniqueDBObject::m_ID.

21 { return m_ID; };

◆ getRunIOV()

RunIOV MODRunIOV::getRunIOV ( )

Definition at line 32 of file MODRunIOV.cc.

32 { return m_runIOV; }
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ getSubRunEnd()

Tm MODRunIOV::getSubRunEnd ( ) const

Definition at line 59 of file MODRunIOV.cc.

59 { return m_subRunEnd; }
Tm m_subRunEnd
Definition: MODRunIOV.h:50

◆ getSubRunNumber()

run_t MODRunIOV::getSubRunNumber ( ) const

Definition at line 41 of file MODRunIOV.cc.

41 { return m_subRunNum; }
subrun_t m_subRunNum
Definition: MODRunIOV.h:48

◆ getSubRunStart()

Tm MODRunIOV::getSubRunStart ( ) const

Definition at line 50 of file MODRunIOV.cc.

50 { return m_subRunStart; }
Tm m_subRunStart
Definition: MODRunIOV.h:49

◆ operator!=()

bool MODRunIOV::operator!= ( const MODRunIOV m) const
inline

◆ operator==()

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

Definition at line 38 of file MODRunIOV.h.

References visualization-live-secondInstance_cfg::m, m_runIOV, m_subRunEnd, m_subRunNum, and m_subRunStart.

38  {
39  return (m_runIOV == m.m_runIOV && m_subRunNum == m.m_subRunNum && m_subRunStart == m.m_subRunStart &&
40  m_subRunEnd == m.m_subRunEnd);
41  }
subrun_t m_subRunNum
Definition: MODRunIOV.h:48
Tm m_subRunStart
Definition: MODRunIOV.h:49
Tm m_subRunEnd
Definition: MODRunIOV.h:50
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ setByID()

void MODRunIOV::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 113 of file MODRunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, and triggerObjects_cff::id.

113  {
114  this->checkConnection();
115 
117 
118  try {
119  Statement* stmt = m_conn->createStatement();
120 
121  stmt->setSQL("SELECT run_iov_id, subrun_num, subrun_start, subrun_end FROM OD_run_iov WHERE iov_id = :1");
122  stmt->setInt(1, id);
123 
124  ResultSet* rset = stmt->executeQuery();
125  if (rset->next()) {
126  int runIOVID = rset->getInt(1);
127  m_subRunNum = rset->getInt(2);
128  Date startDate = rset->getDate(3);
129  Date endDate = rset->getDate(4);
130 
131  m_subRunStart = dh.dateToTm(startDate);
132  m_subRunEnd = dh.dateToTm(endDate);
133 
135  m_runIOV.setByID(runIOVID);
136 
137  m_ID = id;
138  } else {
139  throw(std::runtime_error("MODRunIOV::setByID: Given id is not in the database"));
140  }
141 
142  m_conn->terminateStatement(stmt);
143  } catch (SQLException& e) {
144  throw(std::runtime_error("MODRunIOV::setByID: " + e.getMessage()));
145  }
146 }
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
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
subrun_t m_subRunNum
Definition: MODRunIOV.h:48
Tm m_subRunStart
Definition: MODRunIOV.h:49
Tm m_subRunEnd
Definition: MODRunIOV.h:50
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:354
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ setByRun()

void MODRunIOV::setByRun ( RunIOV runiov,
subrun_t  subrun 
)
privatenoexcept

Definition at line 207 of file MODRunIOV.cc.

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

207  {
208  this->checkConnection();
209 
210  runiov->setConnection(m_env, m_conn);
211  int runIOVID = runiov->fetchID();
212 
213  if (!runIOVID) {
214  throw(std::runtime_error("MODRunIOV::setByRun: Given RunIOV does not exist in DB"));
215  }
216 
218 
219  try {
220  Statement* stmt = m_conn->createStatement();
221 
222  stmt->setSQL(
223  "SELECT iov_id, subrun_start, subrun_end FROM OD_run_iov "
224  "WHERE run_iov_id = :1 AND subrun_num = :2");
225  stmt->setInt(1, runIOVID);
226  stmt->setInt(2, subrun);
227 
228  ResultSet* rset = stmt->executeQuery();
229  if (rset->next()) {
230  m_runIOV = *runiov;
231  m_subRunNum = subrun;
232 
233  m_ID = rset->getInt(1);
234  Date startDate = rset->getDate(2);
235  Date endDate = rset->getDate(3);
236 
237  m_subRunStart = dh.dateToTm(startDate);
238  m_subRunEnd = dh.dateToTm(endDate);
239  } else {
240  throw(std::runtime_error("MODRunIOV::setByRun: Given subrun is not in the database"));
241  }
242 
243  m_conn->terminateStatement(stmt);
244  } catch (SQLException& e) {
245  throw(std::runtime_error("MODRunIOV::setByRun: " + e.getMessage()));
246  }
247 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
subrun_t m_subRunNum
Definition: MODRunIOV.h:48
Tm m_subRunStart
Definition: MODRunIOV.h:49
Tm m_subRunEnd
Definition: MODRunIOV.h:50
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:354
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ setID()

void MODRunIOV::setID ( int  id)

Definition at line 23 of file MODRunIOV.cc.

References triggerObjects_cff::id.

◆ setRunIOV()

void MODRunIOV::setRunIOV ( const RunIOV iov)

Definition at line 25 of file MODRunIOV.cc.

25  {
26  if (iov != m_runIOV) {
27  m_ID = 0;
28  m_runIOV = iov;
29  }
30 }
RunIOV m_runIOV
Definition: MODRunIOV.h:47

◆ setSubRunEnd()

void MODRunIOV::setSubRunEnd ( const Tm end)

Definition at line 52 of file MODRunIOV.cc.

References mps_fire::end.

52  {
53  if (end != m_subRunEnd) {
54  m_ID = 0;
55  m_subRunEnd = end;
56  }
57 }
Tm m_subRunEnd
Definition: MODRunIOV.h:50

◆ setSubRunNumber()

void MODRunIOV::setSubRunNumber ( subrun_t  subrun)

Definition at line 34 of file MODRunIOV.cc.

34  {
35  if (subrun != m_subRunNum) {
36  m_ID = 0;
37  m_subRunNum = subrun;
38  }
39 }
subrun_t m_subRunNum
Definition: MODRunIOV.h:48

◆ setSubRunStart()

void MODRunIOV::setSubRunStart ( const Tm start)

Definition at line 43 of file MODRunIOV.cc.

References command_line::start.

43  {
44  if (start != m_subRunStart) {
45  m_ID = 0;
47  }
48 }
Definition: start.py:1
Tm m_subRunStart
Definition: MODRunIOV.h:49

◆ writeDB()

int MODRunIOV::writeDB ( )
privatenoexcept

Definition at line 148 of file MODRunIOV.cc.

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

148  {
149  this->checkConnection();
150 
151  // Check if this IOV has already been written
152  if (this->fetchID()) {
153  return m_ID;
154  }
155 
156  // fetch Parent IDs
157  int runIOVID;
158  this->fetchParentIDs(&runIOVID);
159 
160  // Validate the data, use infinity-till convention
162 
163  if (m_subRunStart.isNull()) {
164  throw(std::runtime_error("MODRunIOV::writeDB: Must setSubRunStart before writing"));
165  }
166 
167  if (m_subRunEnd.isNull()) {
168  m_subRunEnd = dh.getPlusInfTm();
169  }
170 
171  try {
172  Statement* stmt = m_conn->createStatement();
173 
174  stmt->setSQL(
175  "INSERT INTO od_run_iov (iov_id, run_iov_id, subrun_num, subrun_start, subrun_end) "
176  "VALUES (OD_run_iov_sq.NextVal, :1, :2, :3, :4)");
177  stmt->setInt(1, runIOVID);
178  stmt->setInt(2, m_subRunNum);
179  stmt->setDate(3, dh.tmToDate(m_subRunStart));
180  stmt->setDate(4, dh.tmToDate(m_subRunEnd));
181 
182  stmt->executeUpdate();
183 
184  m_conn->terminateStatement(stmt);
185  } catch (SQLException& e) {
186  throw(std::runtime_error("MODRunIOV::writeDB: " + e.getMessage()));
187  }
188 
189  // Now get the ID
190  if (!this->fetchID()) {
191  throw(std::runtime_error("MODRunIOV::writeDB: Failed to write"));
192  }
193 
194  return m_ID;
195 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
subrun_t m_subRunNum
Definition: MODRunIOV.h:48
Tm m_subRunStart
Definition: MODRunIOV.h:49
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61
Tm m_subRunEnd
Definition: MODRunIOV.h:50
int isNull() const
Definition: Tm.cc:46
void fetchParentIDs(int *runIOVID) noexcept(false)
Definition: MODRunIOV.cc:197
dh
Definition: cuy.py:354

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 15 of file MODRunIOV.h.

Member Data Documentation

◆ m_runIOV

RunIOV MODRunIOV::m_runIOV
private

Definition at line 47 of file MODRunIOV.h.

Referenced by operator==().

◆ m_subRunEnd

Tm MODRunIOV::m_subRunEnd
private

Definition at line 50 of file MODRunIOV.h.

Referenced by operator==().

◆ m_subRunNum

subrun_t MODRunIOV::m_subRunNum
private

Definition at line 48 of file MODRunIOV.h.

Referenced by operator==().

◆ m_subRunStart

Tm MODRunIOV::m_subRunStart
private

Definition at line 49 of file MODRunIOV.h.

Referenced by operator==().