CMS 3D CMS Logo

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

#include <MonPedestalsDat.h>

Inheritance diagram for MonPedestalsDat:
IDataItem IDBObject

Public Member Functions

float getPedMeanG1 () const
 
float getPedMeanG12 () const
 
float getPedMeanG6 () const
 
float getPedRMSG1 () const
 
float getPedRMSG12 () const
 
float getPedRMSG6 () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonPedestalsDat ()
 
void setPedMeanG1 (float mean)
 
void setPedMeanG12 (float mean)
 
void setPedMeanG6 (float mean)
 
void setPedRMSG1 (float rms)
 
void setPedRMSG12 (float rms)
 
void setPedRMSG6 (float rms)
 
void setTaskStatus (bool status)
 
 ~MonPedestalsDat () 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, MonPedestalsDat > *fillMap, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonPedestalsDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonPedestalsDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_pedMeanG1
 
float m_pedMeanG12
 
float m_pedMeanG6
 
float m_pedRMSG1
 
float m_pedRMSG12
 
float m_pedRMSG6
 
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 11 of file MonPedestalsDat.h.

Constructor & Destructor Documentation

◆ MonPedestalsDat()

MonPedestalsDat::MonPedestalsDat ( )

Definition at line 11 of file MonPedestalsDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_pedMeanG1 = 0;
18  m_pedMeanG6 = 0;
19  m_pedMeanG12 = 0;
20  m_pedRMSG1 = 0;
21  m_pedRMSG6 = 0;
22  m_pedRMSG12 = 0;
23  m_taskStatus = false;
24 }
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

◆ ~MonPedestalsDat()

MonPedestalsDat::~MonPedestalsDat ( )
override

Definition at line 26 of file MonPedestalsDat.cc.

26 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 76 of file MonPedestalsDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setPedMeanG1(), setPedMeanG12(), setPedMeanG6(), setPedRMSG1(), setPedRMSG12(), setPedRMSG6(), and setTaskStatus().

76  {
77  this->checkConnection();
78  fillMap->clear();
79 
80  iov->setConnection(m_env, m_conn);
81  int iovID = iov->fetchID();
82  if (!iovID) {
83  // throw(std::runtime_error("MonPedestalsDat::writeDB: IOV not in DB"));
84  return;
85  }
86 
87  try {
88  m_readStmt->setSQL(
89  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
90  "d.ped_mean_g1, d.ped_mean_g6, d.ped_mean_g12, "
91  "d.ped_rms_g1, d.ped_rms_g6, d.ped_rms_g12, d.task_status "
92  "FROM channelview cv JOIN mon_pedestals_dat d "
93  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
94  "WHERE iov_id = :iov_id");
95  m_readStmt->setInt(1, iovID);
96  ResultSet* rset = m_readStmt->executeQuery();
97 
98  std::pair<EcalLogicID, MonPedestalsDat> p;
99  MonPedestalsDat dat;
100  while (rset->next()) {
101  p.first = EcalLogicID(rset->getString(1), // name
102  rset->getInt(2), // logic_id
103  rset->getInt(3), // id1
104  rset->getInt(4), // id2
105  rset->getInt(5), // id3
106  rset->getString(6)); // maps_to
107 
108  dat.setPedMeanG1(rset->getFloat(7));
109  dat.setPedMeanG6(rset->getFloat(8));
110  dat.setPedMeanG12(rset->getFloat(9));
111  dat.setPedRMSG1(rset->getFloat(10));
112  dat.setPedRMSG6(rset->getFloat(11));
113  dat.setPedRMSG12(rset->getFloat(12));
114  dat.setTaskStatus(rset->getInt(13));
115 
116  p.second = dat;
117  fillMap->insert(p);
118  }
119  } catch (SQLException& e) {
120  throw(std::runtime_error("MonPedestalsDat::fetchData: " + e.getMessage()));
121  }
122 }
void setPedMeanG1(float mean)
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
void setPedRMSG6(float rms)
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
void setTaskStatus(bool status)
void setPedMeanG6(float mean)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setPedRMSG1(float rms)
void setPedMeanG12(float mean)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setPedRMSG12(float rms)

◆ getPedMeanG1()

float MonPedestalsDat::getPedMeanG1 ( ) const
inline

◆ getPedMeanG12()

float MonPedestalsDat::getPedMeanG12 ( ) const
inline

◆ getPedMeanG6()

float MonPedestalsDat::getPedMeanG6 ( ) const
inline

◆ getPedRMSG1()

float MonPedestalsDat::getPedRMSG1 ( ) const
inline

◆ getPedRMSG12()

float MonPedestalsDat::getPedRMSG12 ( ) const
inline

◆ getPedRMSG6()

float MonPedestalsDat::getPedRMSG6 ( ) const
inline

◆ getTable()

std::string MonPedestalsDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MonPedestalsDat.h.

18 { return "MON_PEDESTALS_DAT"; }

◆ getTaskStatus()

bool MonPedestalsDat::getTaskStatus ( ) const
inline

Definition at line 39 of file MonPedestalsDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

39 { return m_taskStatus; }

◆ prepareWrite()

void MonPedestalsDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 28 of file MonPedestalsDat.cc.

References MillePedeFileConverter_cfg::e.

28  {
29  this->checkConnection();
30 
31  try {
32  m_writeStmt = m_conn->createStatement();
33  m_writeStmt->setSQL(
34  "INSERT INTO mon_pedestals_dat (iov_id, logic_id, "
35  "ped_mean_g1, ped_mean_g6, ped_mean_g12, "
36  "ped_rms_g1, ped_rms_g6, ped_rms_g12, task_status) "
37  "VALUES (:iov_id, :logic_id, "
38  ":ped_mean_g1, :ped_mean_g6, :ped_mean_g12, "
39  ":ped_rms_g1, :ped_rms_g6, :ped_rms_g12, :task_status)");
40  } catch (SQLException& e) {
41  throw(std::runtime_error("MonPedestalsDat::prepareWrite(): " + e.getMessage()));
42  }
43 }
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

◆ setPedMeanG1()

void MonPedestalsDat::setPedMeanG1 ( float  mean)
inline

◆ setPedMeanG12()

void MonPedestalsDat::setPedMeanG12 ( float  mean)
inline

◆ setPedMeanG6()

void MonPedestalsDat::setPedMeanG6 ( float  mean)
inline

◆ setPedRMSG1()

void MonPedestalsDat::setPedRMSG1 ( float  rms)
inline

◆ setPedRMSG12()

void MonPedestalsDat::setPedRMSG12 ( float  rms)
inline

◆ setPedRMSG6()

void MonPedestalsDat::setPedRMSG6 ( float  rms)
inline

◆ setTaskStatus()

void MonPedestalsDat::setTaskStatus ( bool  status)
inline

Definition at line 38 of file MonPedestalsDat.h.

References m_taskStatus, and mps_update::status.

Referenced by fetchData(), and ecaldqm::PedestalWriter::run().

◆ writeArrayDB()

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

Definition at line 124 of file MonPedestalsDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getPedMeanG1(), getPedMeanG12(), getPedMeanG6(), getPedRMSG1(), getPedRMSG12(), getPedRMSG6(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, submitPVValidationJobs::t, groupFilesInBlocks::tt, w(), x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

124  {
125  this->checkConnection();
126  this->checkPrepare();
127 
128  int iovID = iov->fetchID();
129  if (!iovID) {
130  throw(std::runtime_error("MonPedestalsDat::writeArrayDB: IOV not in DB"));
131  }
132 
133  int nrows = data->size();
134  int* ids = new int[nrows];
135  int* iovid_vec = new int[nrows];
136  float* xx = new float[nrows];
137  float* yy = new float[nrows];
138  float* zz = new float[nrows];
139  float* ww = new float[nrows];
140  float* uu = new float[nrows];
141  float* tt = new float[nrows];
142  int* st = new int[nrows];
143 
144  ub2* ids_len = new ub2[nrows];
145  ub2* iov_len = new ub2[nrows];
146  ub2* x_len = new ub2[nrows];
147  ub2* y_len = new ub2[nrows];
148  ub2* z_len = new ub2[nrows];
149  ub2* w_len = new ub2[nrows];
150  ub2* u_len = new ub2[nrows];
151  ub2* t_len = new ub2[nrows];
152  ub2* st_len = new ub2[nrows];
153 
154  const EcalLogicID* channel;
155  const MonPedestalsDat* dataitem;
156  int count = 0;
157  typedef map<EcalLogicID, MonPedestalsDat>::const_iterator CI;
158  for (CI p = data->begin(); p != data->end(); ++p) {
159  channel = &(p->first);
160  int logicID = channel->getLogicID();
161  if (!logicID) {
162  throw(std::runtime_error("MonPedestalsDat::writeArrayDB: Bad EcalLogicID"));
163  }
164  ids[count] = logicID;
165  iovid_vec[count] = iovID;
166 
167  dataitem = &(p->second);
168  // dataIface.writeDB( channel, dataitem, iov);
169  float x = dataitem->getPedMeanG1();
170  float y = dataitem->getPedMeanG6();
171  float z = dataitem->getPedMeanG12();
172  float w = dataitem->getPedRMSG1();
173  float u = dataitem->getPedRMSG6();
174  float t = dataitem->getPedRMSG12();
175  int statu = dataitem->getTaskStatus();
176 
177  xx[count] = x;
178  yy[count] = y;
179  zz[count] = z;
180  ww[count] = w;
181  uu[count] = u;
182  tt[count] = t;
183  st[count] = statu;
184 
185  ids_len[count] = sizeof(ids[count]);
186  iov_len[count] = sizeof(iovid_vec[count]);
187 
188  x_len[count] = sizeof(xx[count]);
189  y_len[count] = sizeof(yy[count]);
190  z_len[count] = sizeof(zz[count]);
191  w_len[count] = sizeof(ww[count]);
192  u_len[count] = sizeof(uu[count]);
193  t_len[count] = sizeof(tt[count]);
194  st_len[count] = sizeof(st[count]);
195 
196  count++;
197  }
198 
199  try {
200  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
201  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
202  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
203  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
204  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT, sizeof(zz[0]), z_len);
205  m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT, sizeof(ww[0]), w_len);
206  m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIFLOAT, sizeof(uu[0]), u_len);
207  m_writeStmt->setDataBuffer(8, (dvoid*)tt, OCCIFLOAT, sizeof(tt[0]), t_len);
208  m_writeStmt->setDataBuffer(9, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
209 
210  m_writeStmt->executeArrayUpdate(nrows);
211 
212  delete[] ids;
213  delete[] iovid_vec;
214  delete[] xx;
215  delete[] yy;
216  delete[] zz;
217  delete[] ww;
218  delete[] uu;
219  delete[] tt;
220  delete[] st;
221 
222  delete[] ids_len;
223  delete[] iov_len;
224  delete[] x_len;
225  delete[] y_len;
226  delete[] z_len;
227  delete[] w_len;
228  delete[] u_len;
229  delete[] t_len;
230  delete[] st_len;
231 
232  } catch (SQLException& e) {
233  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): " + e.getMessage()));
234  }
235 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
T w() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
float getPedRMSG6() const
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
float getPedRMSG1() const
int getLogicID() const
Definition: EcalLogicID.cc:28
float getPedMeanG1() const
float getPedMeanG6() const
float getPedRMSG12() const
float getPedMeanG12() const
bool getTaskStatus() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ writeDB()

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

Definition at line 45 of file MonPedestalsDat.cc.

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

45  {
46  this->checkConnection();
47  this->checkPrepare();
48 
49  int iovID = iov->fetchID();
50  if (!iovID) {
51  throw(std::runtime_error("MonPedestalsDat::writeDB: IOV not in DB"));
52  }
53 
54  int logicID = ecid->getLogicID();
55  if (!logicID) {
56  throw(std::runtime_error("MonPedestalsDat::writeDB: Bad EcalLogicID"));
57  }
58 
59  try {
60  m_writeStmt->setInt(1, iovID);
61  m_writeStmt->setInt(2, logicID);
62  m_writeStmt->setFloat(3, item->getPedMeanG1());
63  m_writeStmt->setFloat(4, item->getPedMeanG6());
64  m_writeStmt->setFloat(5, item->getPedMeanG12());
65  m_writeStmt->setFloat(6, item->getPedRMSG1());
66  m_writeStmt->setFloat(7, item->getPedRMSG6());
67  m_writeStmt->setFloat(8, item->getPedRMSG12());
68  m_writeStmt->setInt(9, item->getTaskStatus());
69 
70  m_writeStmt->executeUpdate();
71  } catch (SQLException& e) {
72  throw(std::runtime_error("MonPedestalsDat::writeDB(): " + e.getMessage()));
73  }
74 }
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 13 of file MonPedestalsDat.h.

Member Data Documentation

◆ m_pedMeanG1

float MonPedestalsDat::m_pedMeanG1
private

Definition at line 51 of file MonPedestalsDat.h.

Referenced by getPedMeanG1(), and setPedMeanG1().

◆ m_pedMeanG12

float MonPedestalsDat::m_pedMeanG12
private

Definition at line 53 of file MonPedestalsDat.h.

Referenced by getPedMeanG12(), and setPedMeanG12().

◆ m_pedMeanG6

float MonPedestalsDat::m_pedMeanG6
private

Definition at line 52 of file MonPedestalsDat.h.

Referenced by getPedMeanG6(), and setPedMeanG6().

◆ m_pedRMSG1

float MonPedestalsDat::m_pedRMSG1
private

Definition at line 54 of file MonPedestalsDat.h.

Referenced by getPedRMSG1(), and setPedRMSG1().

◆ m_pedRMSG12

float MonPedestalsDat::m_pedRMSG12
private

Definition at line 56 of file MonPedestalsDat.h.

Referenced by getPedRMSG12(), and setPedRMSG12().

◆ m_pedRMSG6

float MonPedestalsDat::m_pedRMSG6
private

Definition at line 55 of file MonPedestalsDat.h.

Referenced by getPedRMSG6(), and setPedRMSG6().

◆ m_taskStatus

bool MonPedestalsDat::m_taskStatus
private

Definition at line 57 of file MonPedestalsDat.h.

Referenced by getTaskStatus(), and setTaskStatus().