CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MonDelaysTTDat Class Reference

#include <MonDelaysTTDat.h>

Inheritance diagram for MonDelaysTTDat:
IDataItem IDBObject

Public Member Functions

float getDelayMean () const
 
float getDelayRMS () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonDelaysTTDat ()
 
void setDelayMean (float mean)
 
void setDelayRMS (float rms)
 
void setTaskStatus (bool status)
 
 ~MonDelaysTTDat () override
 
- Public Member Functions inherited from IDataItem
 IDataItem ()
 
- 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 fetchData (std::map< EcalLogicID, MonDelaysTTDat > *fillVec, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonDelaysTTDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonDelaysTTDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_delayMean
 
float m_delayRMS
 
bool m_taskStatus
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IDataItem
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IDataItem
oracle::occi::Statement * m_readStmt
 
oracle::occi::Statement * m_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 12 of file MonDelaysTTDat.h.

Constructor & Destructor Documentation

MonDelaysTTDat::MonDelaysTTDat ( )

Definition at line 12 of file MonDelaysTTDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_delayMean = 0;
19  m_delayRMS = 0;
20  m_taskStatus = false;
21 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
MonDelaysTTDat::~MonDelaysTTDat ( )
override

Definition at line 23 of file MonDelaysTTDat.cc.

23 {}

Member Function Documentation

void MonDelaysTTDat::fetchData ( std::map< EcalLogicID, MonDelaysTTDat > *  fillVec,
MonRunIOV iov 
)
privatenoexcept

Definition at line 68 of file MonDelaysTTDat.cc.

References dat, alignCSCRings::e, AlCaHLTBitMon_ParallelJobs::p, setDelayMean(), setDelayRMS(), and setTaskStatus().

68  {
69  this->checkConnection();
70  fillMap->clear();
71 
72  iov->setConnection(m_env, m_conn);
73  int iovID = iov->fetchID();
74  if (!iovID) {
75  // throw(std::runtime_error("MonDelaysTTDat::writeDB: IOV not in DB"));
76  return;
77  }
78 
79  try {
80  m_readStmt->setSQL(
81  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
82  "d.delay_mean, d.delay_rms, d.task_status "
83  "FROM channelview cv JOIN mon_delays_tt_dat d "
84  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
85  "WHERE d.iov_id = :iov_id");
86  m_readStmt->setInt(1, iovID);
87  ResultSet* rset = m_readStmt->executeQuery();
88 
89  std::pair<EcalLogicID, MonDelaysTTDat> p;
91  while (rset->next()) {
92  p.first = EcalLogicID(rset->getString(1), // name
93  rset->getInt(2), // logic_id
94  rset->getInt(3), // id1
95  rset->getInt(4), // id2
96  rset->getInt(5), // id3
97  rset->getString(6)); // maps_to
98 
99  dat.setDelayMean(rset->getFloat(7));
100  dat.setDelayRMS(rset->getFloat(8));
101  dat.setTaskStatus(rset->getInt(9));
102 
103  p.second = dat;
104  fillMap->insert(p);
105  }
106  } catch (SQLException& e) {
107  throw(std::runtime_error("MonDelaysTTDat::fetchData(): " + e.getMessage()));
108  }
109 }
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
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
void setDelayRMS(float rms)
void setTaskStatus(bool status)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
static std::vector< std::string > checklist dat
void setDelayMean(float mean)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
float MonDelaysTTDat::getDelayMean ( ) const
inline

Definition at line 22 of file MonDelaysTTDat.h.

References m_delayMean.

Referenced by writeArrayDB().

22 { return m_delayMean; }
float MonDelaysTTDat::getDelayRMS ( ) const
inline

Definition at line 25 of file MonDelaysTTDat.h.

References m_delayRMS.

Referenced by writeArrayDB().

25 { return m_delayRMS; }
std::string MonDelaysTTDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonDelaysTTDat.h.

19 { return "MON_DELAYS_TT_DAT"; }
bool MonDelaysTTDat::getTaskStatus ( ) const
inline

Definition at line 28 of file MonDelaysTTDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

28 { return m_taskStatus; }
void MonDelaysTTDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file MonDelaysTTDat.cc.

References alignCSCRings::e.

25  {
26  this->checkConnection();
27 
28  try {
29  m_writeStmt = m_conn->createStatement();
30  m_writeStmt->setSQL(
31  "INSERT INTO mon_delays_tt_dat (iov_id, logic_id, "
32  "delay_mean, delay_rms, task_status) "
33  "VALUES (:iov_id, :logic_id, "
34  ":delay_mean, :delay_rms, :task_status)");
35  } catch (SQLException& e) {
36  throw(std::runtime_error("MonDelaysTTDat::prepareWrite(): " + e.getMessage()));
37  }
38 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void MonDelaysTTDat::setDelayMean ( float  mean)
inline

Definition at line 21 of file MonDelaysTTDat.h.

References m_delayMean, and SiStripPI::mean.

Referenced by fetchData().

void MonDelaysTTDat::setDelayRMS ( float  rms)
inline

Definition at line 24 of file MonDelaysTTDat.h.

References m_delayRMS, and SiStripPI::rms.

Referenced by fetchData().

void MonDelaysTTDat::setTaskStatus ( bool  status)
inline

Definition at line 27 of file MonDelaysTTDat.h.

References m_taskStatus, and mps_update::status.

Referenced by fetchData().

27 { m_taskStatus = status; }
list status
Definition: mps_update.py:107
void MonDelaysTTDat::writeArrayDB ( const std::map< EcalLogicID, MonDelaysTTDat > *  data,
MonRunIOV iov 
)
privatenoexcept

Definition at line 111 of file MonDelaysTTDat.cc.

References submitPVResolutionJobs::count, data, alignCSCRings::e, getDelayMean(), getDelayRMS(), EcalLogicID::getLogicID(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, x, and y.

111  {
112  this->checkConnection();
113  this->checkPrepare();
114 
115  int iovID = iov->fetchID();
116  if (!iovID) {
117  throw(std::runtime_error("MonDelaysTTDat::writeArrayDB: IOV not in DB"));
118  }
119 
120  int nrows = data->size();
121  int* ids = new int[nrows];
122  int* iovid_vec = new int[nrows];
123  float* xx = new float[nrows];
124  float* yy = new float[nrows];
125  int* st = new int[nrows];
126 
127  ub2* ids_len = new ub2[nrows];
128  ub2* iov_len = new ub2[nrows];
129  ub2* x_len = new ub2[nrows];
130  ub2* y_len = new ub2[nrows];
131  ub2* st_len = new ub2[nrows];
132 
133  const EcalLogicID* channel;
134  const MonDelaysTTDat* dataitem;
135  int count = 0;
136  typedef map<EcalLogicID, MonDelaysTTDat>::const_iterator CI;
137  for (CI p = data->begin(); p != data->end(); ++p) {
138  channel = &(p->first);
139  int logicID = channel->getLogicID();
140  if (!logicID) {
141  throw(std::runtime_error("MonDelaysTTDat::writeArrayDB: Bad EcalLogicID"));
142  }
143  ids[count] = logicID;
144  iovid_vec[count] = iovID;
145 
146  dataitem = &(p->second);
147  // dataIface.writeDB( channel, dataitem, iov);
148  float x = dataitem->getDelayMean();
149  float y = dataitem->getDelayRMS();
150  int statu = dataitem->getTaskStatus();
151 
152  xx[count] = x;
153  yy[count] = y;
154  st[count] = statu;
155 
156  ids_len[count] = sizeof(ids[count]);
157  iov_len[count] = sizeof(iovid_vec[count]);
158 
159  x_len[count] = sizeof(xx[count]);
160  y_len[count] = sizeof(yy[count]);
161  st_len[count] = sizeof(st[count]);
162 
163  count++;
164  }
165 
166  try {
167  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
168  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
169  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
170  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
171  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
172 
173  m_writeStmt->executeArrayUpdate(nrows);
174 
175  delete[] ids;
176  delete[] iovid_vec;
177  delete[] xx;
178  delete[] yy;
179  delete[] st;
180 
181  delete[] ids_len;
182  delete[] iov_len;
183  delete[] x_len;
184  delete[] y_len;
185  delete[] st_len;
186 
187  } catch (SQLException& e) {
188  throw(std::runtime_error("MonDelaysTTDat::writeArrayDB(): " + e.getMessage()));
189  }
190 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
float getDelayRMS() const
int getLogicID() const
Definition: EcalLogicID.cc:28
bool getTaskStatus() const
float getDelayMean() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void MonDelaysTTDat::writeDB ( const EcalLogicID ecid,
const MonDelaysTTDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 40 of file MonDelaysTTDat.cc.

References alignCSCRings::e, and B2GTnPMonitor_cfi::item.

40  {
41  this->checkConnection();
42  this->checkPrepare();
43 
44  int iovID = iov->fetchID();
45  if (!iovID) {
46  throw(std::runtime_error("MonDelaysTTDat::writeDB: IOV not in DB"));
47  }
48 
49  int logicID = ecid->getLogicID();
50  if (!logicID) {
51  throw(std::runtime_error("MonDelaysTTDat::writeDB: Bad EcalLogicID"));
52  }
53 
54  try {
55  m_writeStmt->setInt(1, iovID);
56  m_writeStmt->setInt(2, logicID);
57 
58  m_writeStmt->setFloat(3, item->getDelayMean());
59  m_writeStmt->setFloat(4, item->getDelayRMS());
60  m_writeStmt->setInt(5, item->getTaskStatus());
61 
62  m_writeStmt->executeUpdate();
63  } catch (SQLException& e) {
64  throw(std::runtime_error("MonDelaysTTDat::writeDB(): " + e.getMessage()));
65  }
66 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
float getDelayRMS() const
int getLogicID() const
Definition: EcalLogicID.cc:28
bool getTaskStatus() const
float getDelayMean() const

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonDelaysTTDat.h.

Member Data Documentation

float MonDelaysTTDat::m_delayMean
private

Definition at line 40 of file MonDelaysTTDat.h.

Referenced by getDelayMean(), and setDelayMean().

float MonDelaysTTDat::m_delayRMS
private

Definition at line 41 of file MonDelaysTTDat.h.

Referenced by getDelayRMS(), and setDelayRMS().

bool MonDelaysTTDat::m_taskStatus
private

Definition at line 42 of file MonDelaysTTDat.h.

Referenced by getTaskStatus(), and setTaskStatus().