CMS 3D CMS Logo

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

#include <MonPedestalsOnlineDat.h>

Inheritance diagram for MonPedestalsOnlineDat:
IDataItem IDBObject

Public Member Functions

float getADCMeanG12 () const
 
float getADCRMSG12 () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonPedestalsOnlineDat ()
 
void setADCMeanG12 (float mean)
 
void setADCRMSG12 (float rms)
 
void setTaskStatus (bool status)
 
 ~MonPedestalsOnlineDat () 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, MonPedestalsOnlineDat > *fillMap, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonPedestalsOnlineDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonPedestalsOnlineDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_adcMeanG12
 
float m_adcRMSG12
 
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 MonPedestalsOnlineDat.h.

Constructor & Destructor Documentation

◆ MonPedestalsOnlineDat()

MonPedestalsOnlineDat::MonPedestalsOnlineDat ( )

Definition at line 12 of file MonPedestalsOnlineDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_adcMeanG12 = 0;
19  m_adcRMSG12 = 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

◆ ~MonPedestalsOnlineDat()

MonPedestalsOnlineDat::~MonPedestalsOnlineDat ( )
override

Definition at line 23 of file MonPedestalsOnlineDat.cc.

23 {}

Member Function Documentation

◆ fetchData()

void MonPedestalsOnlineDat::fetchData ( std::map< EcalLogicID, MonPedestalsOnlineDat > *  fillMap,
MonRunIOV iov 
)
privatenoexcept

Definition at line 69 of file MonPedestalsOnlineDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setADCMeanG12(), setADCRMSG12(), and setTaskStatus().

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

◆ getADCMeanG12()

float MonPedestalsOnlineDat::getADCMeanG12 ( ) const
inline

◆ getADCRMSG12()

float MonPedestalsOnlineDat::getADCRMSG12 ( ) const
inline

◆ getTable()

std::string MonPedestalsOnlineDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonPedestalsOnlineDat.h.

19 { return "MON_PEDESTALS_ONLINE_DAT"; }

◆ getTaskStatus()

bool MonPedestalsOnlineDat::getTaskStatus ( ) const
inline

Definition at line 28 of file MonPedestalsOnlineDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

◆ prepareWrite()

void MonPedestalsOnlineDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file MonPedestalsOnlineDat.cc.

References MillePedeFileConverter_cfg::e.

25  {
26  this->checkConnection();
27 
28  try {
29  m_writeStmt = m_conn->createStatement();
30  m_writeStmt->setSQL(
31  "INSERT INTO mon_pedestals_online_dat (iov_id, logic_id, "
32  "adc_mean_g12, adc_rms_g12, task_status) "
33  "VALUES (:iov_id, :logic_id, "
34  ":adc_mean_g12, :adc_rms_g12, :task_status)");
35  } catch (SQLException& e) {
36  throw(std::runtime_error("MonPedestalsOnlineDat::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

◆ setADCMeanG12()

void MonPedestalsOnlineDat::setADCMeanG12 ( float  mean)
inline

◆ setADCRMSG12()

void MonPedestalsOnlineDat::setADCRMSG12 ( float  rms)
inline

◆ setTaskStatus()

void MonPedestalsOnlineDat::setTaskStatus ( bool  status)
inline

Definition at line 27 of file MonPedestalsOnlineDat.h.

References m_taskStatus, and mps_update::status.

Referenced by fetchData().

◆ writeArrayDB()

void MonPedestalsOnlineDat::writeArrayDB ( const std::map< EcalLogicID, MonPedestalsOnlineDat > *  data,
MonRunIOV iov 
)
privatenoexcept

Definition at line 113 of file MonPedestalsOnlineDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getADCMeanG12(), getADCRMSG12(), EcalLogicID::getLogicID(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, and geometryCSVtoXML::yy.

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

◆ writeDB()

void MonPedestalsOnlineDat::writeDB ( const EcalLogicID ecid,
const MonPedestalsOnlineDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 40 of file MonPedestalsOnlineDat.cc.

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

42  {
43  this->checkConnection();
44  this->checkPrepare();
45 
46  int iovID = iov->fetchID();
47  if (!iovID) {
48  throw(std::runtime_error("MonPedestalsOnlineDat::writeDB: IOV not in DB"));
49  }
50 
51  int logicID = ecid->getLogicID();
52  if (!logicID) {
53  throw(std::runtime_error("MonPedestalsOnlineDat::writeDB: Bad EcalLogicID"));
54  }
55 
56  try {
57  m_writeStmt->setInt(1, iovID);
58  m_writeStmt->setInt(2, logicID);
59  m_writeStmt->setFloat(3, item->getADCMeanG12());
60  m_writeStmt->setFloat(4, item->getADCRMSG12());
61  m_writeStmt->setInt(5, item->getTaskStatus());
62 
63  m_writeStmt->executeUpdate();
64  } catch (SQLException& e) {
65  throw(std::runtime_error("MonPedestalsOnlineDat::writeDB(): " + e.getMessage()));
66  }
67 }
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
int getLogicID() const
Definition: EcalLogicID.cc:28

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonPedestalsOnlineDat.h.

Member Data Documentation

◆ m_adcMeanG12

float MonPedestalsOnlineDat::m_adcMeanG12
private

Definition at line 40 of file MonPedestalsOnlineDat.h.

Referenced by getADCMeanG12(), and setADCMeanG12().

◆ m_adcRMSG12

float MonPedestalsOnlineDat::m_adcRMSG12
private

Definition at line 41 of file MonPedestalsOnlineDat.h.

Referenced by getADCRMSG12(), and setADCRMSG12().

◆ m_taskStatus

bool MonPedestalsOnlineDat::m_taskStatus
private

Definition at line 42 of file MonPedestalsOnlineDat.h.

Referenced by getTaskStatus(), and setTaskStatus().