CMS 3D CMS Logo

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

#include <ITimingDat.h>

Inheritance diagram for ITimingDat:
IDataItem IDBObject MonTimingCrystalDat MonTimingLaserBlueCrystalDat MonTimingLaserBlueTTDat MonTimingLaserGreenCrystalDat MonTimingLaserGreenTTDat MonTimingLaserIRedCrystalDat MonTimingLaserIRedTTDat MonTimingLaserRedCrystalDat MonTimingLaserRedTTDat MonTimingLed1CrystalDat MonTimingLed1TTDat MonTimingLed2CrystalDat MonTimingLed2TTDat MonTimingTTDat

Public Types

typedef oracle::occi::ResultSet ResultSet
 
typedef oracle::occi::SQLException SQLException
 

Public Member Functions

std::string getTable () override
 
bool getTaskStatus () const
 
float getTimingMean () const
 
float getTimingRMS () const
 
 ITimingDat ()
 
void setTable (std::string x)
 
void setTaskStatus (bool status)
 
void setTimingMean (float mean)
 
void setTimingRMS (float rms)
 
 ~ITimingDat () 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

template<class DATT , class IOVT >
void fetchData (std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
template<class DATT , class IOVT >
void writeArrayDB (const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
 
template<class DATT , class IOVT >
void writeDB (const EcalLogicID *ecid, const DATT *item, IOVT *iov) noexcept(false)
 

Private Attributes

std::string m_table_name
 
bool m_taskStatus
 
float m_timingMean
 
float m_timingRMS
 

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 17 of file ITimingDat.h.

Member Typedef Documentation

typedef oracle::occi::ResultSet ITimingDat::ResultSet

Definition at line 20 of file ITimingDat.h.

typedef oracle::occi::SQLException ITimingDat::SQLException

Definition at line 19 of file ITimingDat.h.

Constructor & Destructor Documentation

ITimingDat::ITimingDat ( )
inline

Definition at line 23 of file ITimingDat.h.

References IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, m_taskStatus, m_timingMean, m_timingRMS, and IDataItem::m_writeStmt.

23  {
24  m_env = nullptr;
25  m_conn = nullptr;
26  m_writeStmt = nullptr;
27  m_readStmt = nullptr;
28 
29  m_timingMean = 0;
30  m_timingRMS = 0;
31  m_taskStatus = false;
32  };
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
bool m_taskStatus
Definition: ITimingDat.h:230
float m_timingRMS
Definition: ITimingDat.h:229
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
float m_timingMean
Definition: ITimingDat.h:228
ITimingDat::~ITimingDat ( )
inlineoverride

Definition at line 34 of file ITimingDat.h.

34 {};

Member Function Documentation

template<class DATT , class IOVT >
void ITimingDat::fetchData ( std::map< EcalLogicID, DATT > *  fillMap,
IOVT *  iov 
)
inlineprivatenoexcept

Definition at line 181 of file ITimingDat.h.

References IDBObject::checkConnection(), dat, alignCSCRings::e, getTable(), IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, and AlCaHLTBitMon_ParallelJobs::p.

181  {
182  this->checkConnection();
183  fillMap->clear();
184 
185  iov->setConnection(m_env, m_conn);
186  int iovID = iov->fetchID();
187  if (!iovID) {
188  // throw(std::runtime_error("ITimingDat::writeDB: IOV not in DB"));
189  return;
190  }
191 
192  try {
193  m_readStmt->setSQL(
194  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
195  "d.timing_mean, d.timing_rms, d.task_status "
196  "FROM channelview cv JOIN " +
197  getTable() +
198  " d "
199  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
200  "WHERE d.iov_id = :iov_id");
201  m_readStmt->setInt(1, iovID);
202  ResultSet* rset = m_readStmt->executeQuery();
203 
204  std::pair<EcalLogicID, DATT> p;
205  DATT dat;
206  while (rset->next()) {
207  p.first = EcalLogicID(rset->getString(1), // name
208  rset->getInt(2), // logic_id
209  rset->getInt(3), // id1
210  rset->getInt(4), // id2
211  rset->getInt(5), // id3
212  rset->getString(6)); // maps_to
213 
214  dat.setTimingMean(rset->getFloat(7));
215  dat.setTimingRMS(rset->getFloat(8));
216  dat.setTaskStatus(rset->getInt(9));
217 
218  p.second = dat;
219  fillMap->insert(p);
220  }
221 
222  } catch (SQLException& e) {
223  throw(std::runtime_error("ITimingDat::fetchData(): " + e.getMessage()));
224  }
225  }
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
std::string getTable() override
Definition: ITimingDat.h:37
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19
static std::vector< std::string > checklist dat
oracle::occi::ResultSet ResultSet
Definition: ITimingDat.h:20
std::string ITimingDat::getTable ( )
inlineoverridevirtual
bool ITimingDat::getTaskStatus ( ) const
inline

Definition at line 47 of file ITimingDat.h.

References m_taskStatus.

47 { return m_taskStatus; }
bool m_taskStatus
Definition: ITimingDat.h:230
float ITimingDat::getTimingMean ( ) const
inline

Definition at line 41 of file ITimingDat.h.

References m_timingMean.

41 { return m_timingMean; }
float m_timingMean
Definition: ITimingDat.h:228
float ITimingDat::getTimingRMS ( ) const
inline

Definition at line 44 of file ITimingDat.h.

References m_timingRMS.

44 { return m_timingRMS; }
float m_timingRMS
Definition: ITimingDat.h:229
void ITimingDat::prepareWrite ( )
inlineoverrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 50 of file ITimingDat.h.

References IDBObject::checkConnection(), alignCSCRings::e, getTable(), IDBObject::m_conn, and IDataItem::m_writeStmt.

50  {
51  this->checkConnection();
52 
53  try {
54  m_writeStmt = m_conn->createStatement();
55  m_writeStmt->setSQL("INSERT INTO " + getTable() +
56  " (iov_id, logic_id, "
57  "timing_mean, timing_rms , task_status ) "
58  "VALUES (:iov_id, :logic_id, "
59  ":timing_mean, :timing_rms, :task_status )");
60  } catch (SQLException& e) {
61  throw(std::runtime_error("ITimingDat::prepareWrite(): " + e.getMessage()));
62  }
63  }
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
std::string getTable() override
Definition: ITimingDat.h:37
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19
void ITimingDat::setTable ( std::string  x)
inline

Definition at line 38 of file ITimingDat.h.

References m_table_name, and x.

38 { m_table_name = x; }
std::string m_table_name
Definition: ITimingDat.h:231
void ITimingDat::setTaskStatus ( bool  status)
inline

Definition at line 46 of file ITimingDat.h.

References m_taskStatus, and mps_update::status.

Referenced by ecaldqm::LaserWriter::run(), and ecaldqm::LedWriter::run().

46 { m_taskStatus = status; }
list status
Definition: mps_update.py:107
bool m_taskStatus
Definition: ITimingDat.h:230
void ITimingDat::setTimingMean ( float  mean)
inline
void ITimingDat::setTimingRMS ( float  rms)
inline
template<class DATT , class IOVT >
void ITimingDat::writeArrayDB ( const std::map< EcalLogicID, DATT > *  data,
IOVT *  iov 
)
inlineprivatenoexcept

Definition at line 95 of file ITimingDat.h.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), submitPVResolutionJobs::count, data, alignCSCRings::e, EcalLogicID::getLogicID(), IDataItem::m_writeStmt, AlCaHLTBitMon_ParallelJobs::p, x, and y.

95  {
96  using oracle::occi::OCCIFLOAT;
97  using oracle::occi::OCCIINT;
98 
99  this->checkConnection();
100  this->checkPrepare();
101 
102  int iovID = iov->fetchID();
103  if (!iovID) {
104  throw(std::runtime_error("ITimingDat::writeArrayDB: IOV not in DB"));
105  }
106 
107  int nrows = data->size();
108  int* ids = new int[nrows];
109  int* iovid_vec = new int[nrows];
110  float* xx = new float[nrows];
111  float* yy = new float[nrows];
112  int* st = new int[nrows];
113 
114  ub2* ids_len = new ub2[nrows];
115  ub2* iov_len = new ub2[nrows];
116  ub2* x_len = new ub2[nrows];
117  ub2* y_len = new ub2[nrows];
118  ub2* st_len = new ub2[nrows];
119 
120  const EcalLogicID* channel;
121  const DATT* dataitem;
122  int count = 0;
123  // typedef std::map< EcalLogicID, DATT >::const_iterator CI;
124  typedef typename std::map<EcalLogicID, DATT>::const_iterator CI;
125  for (CI p = data->begin(); p != data->end(); ++p) {
126  channel = &(p->first);
127  int logicID = channel->getLogicID();
128  if (!logicID) {
129  throw(std::runtime_error("ITimingDat::writeArrayDB: Bad EcalLogicID"));
130  }
131  ids[count] = logicID;
132  iovid_vec[count] = iovID;
133 
134  dataitem = &(p->second);
135 
136  float x = dataitem->getTimingMean();
137  float y = dataitem->getTimingRMS();
138  int statu = dataitem->getTaskStatus();
139 
140  xx[count] = x;
141  yy[count] = y;
142  st[count] = statu;
143 
144  ids_len[count] = sizeof(ids[count]);
145  iov_len[count] = sizeof(iovid_vec[count]);
146 
147  x_len[count] = sizeof(xx[count]);
148  y_len[count] = sizeof(yy[count]);
149  st_len[count] = sizeof(st[count]);
150 
151  count++;
152  }
153 
154  try {
155  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
156  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
157  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
158  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
159  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
160 
161  m_writeStmt->executeArrayUpdate(nrows);
162 
163  delete[] ids;
164  delete[] iovid_vec;
165  delete[] xx;
166  delete[] yy;
167  delete[] st;
168 
169  delete[] ids_len;
170  delete[] iov_len;
171  delete[] x_len;
172  delete[] y_len;
173  delete[] st_len;
174 
175  } catch (SQLException& e) {
176  throw(std::runtime_error("ITimingDat::writeArrayDB(): " + e.getMessage()));
177  }
178  }
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 getLogicID() const
Definition: EcalLogicID.cc:28
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
template<class DATT , class IOVT >
void ITimingDat::writeDB ( const EcalLogicID ecid,
const DATT *  item,
IOVT *  iov 
)
inlineprivatenoexcept

Definition at line 66 of file ITimingDat.h.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), alignCSCRings::e, B2GTnPMonitor_cfi::item, and IDataItem::m_writeStmt.

66  {
67  this->checkConnection();
68  this->checkPrepare();
69 
70  int iovID = iov->fetchID();
71  if (!iovID) {
72  throw(std::runtime_error("ITimingDat::writeDB: IOV not in DB"));
73  }
74 
75  int logicID = ecid->getLogicID();
76  if (!logicID) {
77  throw(std::runtime_error("ITimingDat::writeDB: Bad EcalLogicID"));
78  }
79 
80  try {
81  m_writeStmt->setInt(1, iovID);
82  m_writeStmt->setInt(2, logicID);
83 
84  m_writeStmt->setFloat(3, item->getTimingMean());
85  m_writeStmt->setFloat(4, item->getTimingRMS());
86  m_writeStmt->setInt(5, item->getTaskStatus());
87 
88  m_writeStmt->executeUpdate();
89  } catch (SQLException& e) {
90  throw(std::runtime_error("ITimingDat::writeDB(): " + e.getMessage()));
91  }
92  }
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 getLogicID() const
Definition: EcalLogicID.cc:28
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 21 of file ITimingDat.h.

Member Data Documentation

std::string ITimingDat::m_table_name
private

Definition at line 231 of file ITimingDat.h.

Referenced by getTable(), and setTable().

bool ITimingDat::m_taskStatus
private

Definition at line 230 of file ITimingDat.h.

Referenced by getTaskStatus(), ITimingDat(), and setTaskStatus().

float ITimingDat::m_timingMean
private

Definition at line 228 of file ITimingDat.h.

Referenced by getTimingMean(), ITimingDat(), and setTimingMean().

float ITimingDat::m_timingRMS
private

Definition at line 229 of file ITimingDat.h.

Referenced by getTimingRMS(), ITimingDat(), and setTimingRMS().