CMS 3D CMS Logo

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

#include <MonLaserGreenDat.h>

Inheritance diagram for MonLaserGreenDat:
IDataItem IDBObject

Public Member Functions

float getAPDMean () const
 
float getAPDOverPNMean () const
 
float getAPDOverPNRMS () const
 
float getAPDRMS () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonLaserGreenDat ()
 
void setAPDMean (float mean)
 
void setAPDOverPNMean (float mean)
 
void setAPDOverPNRMS (float rms)
 
void setAPDRMS (float rms)
 
void setTaskStatus (bool status)
 
 ~MonLaserGreenDat () 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, MonLaserGreenDat > *fillMap, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonLaserGreenDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonLaserGreenDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_apdMean
 
float m_apdOverPNMean
 
float m_apdOverPNRMS
 
float m_apdRMS
 
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 MonLaserGreenDat.h.

Constructor & Destructor Documentation

◆ MonLaserGreenDat()

MonLaserGreenDat::MonLaserGreenDat ( )

Definition at line 10 of file MonLaserGreenDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
16  m_apdMean = 0;
17  m_apdRMS = 0;
18  m_apdOverPNMean = 0;
19  m_apdOverPNRMS = 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

◆ ~MonLaserGreenDat()

MonLaserGreenDat::~MonLaserGreenDat ( )
override

Definition at line 23 of file MonLaserGreenDat.cc.

23 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 70 of file MonLaserGreenDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setAPDMean(), setAPDOverPNMean(), setAPDOverPNRMS(), setAPDRMS(), and setTaskStatus().

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

◆ getAPDMean()

float MonLaserGreenDat::getAPDMean ( ) const
inline

Definition at line 22 of file MonLaserGreenDat.h.

References m_apdMean.

Referenced by writeArrayDB().

22 { return m_apdMean; }

◆ getAPDOverPNMean()

float MonLaserGreenDat::getAPDOverPNMean ( ) const
inline

Definition at line 28 of file MonLaserGreenDat.h.

References m_apdOverPNMean.

Referenced by writeArrayDB().

28 { return m_apdOverPNMean; }

◆ getAPDOverPNRMS()

float MonLaserGreenDat::getAPDOverPNRMS ( ) const
inline

Definition at line 31 of file MonLaserGreenDat.h.

References m_apdOverPNRMS.

Referenced by writeArrayDB().

31 { return m_apdOverPNRMS; }

◆ getAPDRMS()

float MonLaserGreenDat::getAPDRMS ( ) const
inline

Definition at line 25 of file MonLaserGreenDat.h.

References m_apdRMS.

Referenced by writeArrayDB().

25 { return m_apdRMS; }

◆ getTable()

std::string MonLaserGreenDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonLaserGreenDat.h.

19 { return "MON_LASER_GREEN_DAT"; }

◆ getTaskStatus()

bool MonLaserGreenDat::getTaskStatus ( ) const
inline

Definition at line 34 of file MonLaserGreenDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

34 { return m_taskStatus; }

◆ prepareWrite()

void MonLaserGreenDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file MonLaserGreenDat.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_laser_green_dat (iov_id, logic_id, "
32  "apd_mean, apd_rms, apd_over_pn_mean, apd_over_pn_rms, task_status) "
33  "VALUES (:iov_id, :logic_id, "
34  ":apd_mean, :apd_rms, :apd_over_pn_mean, :apd_over_pn_rms, :task_status)");
35  } catch (SQLException& e) {
36  throw(std::runtime_error("MonLaserGreenDat::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

◆ setAPDMean()

void MonLaserGreenDat::setAPDMean ( float  mean)
inline

◆ setAPDOverPNMean()

void MonLaserGreenDat::setAPDOverPNMean ( float  mean)
inline

◆ setAPDOverPNRMS()

void MonLaserGreenDat::setAPDOverPNRMS ( float  rms)
inline

◆ setAPDRMS()

void MonLaserGreenDat::setAPDRMS ( float  rms)
inline

◆ setTaskStatus()

void MonLaserGreenDat::setTaskStatus ( bool  status)
inline

Definition at line 33 of file MonLaserGreenDat.h.

References m_taskStatus, and mps_update::status.

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

◆ writeArrayDB()

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

Definition at line 116 of file MonLaserGreenDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getAPDMean(), getAPDOverPNMean(), getAPDOverPNRMS(), getAPDRMS(), EcalLogicID::getLogicID(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, w(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::ww, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

117  {
118  this->checkConnection();
119  this->checkPrepare();
120 
121  int iovID = iov->fetchID();
122  if (!iovID) {
123  throw(std::runtime_error("MonLaserGreenDat::writeArrayDB: IOV not in DB"));
124  }
125 
126  int nrows = data->size();
127  int* ids = new int[nrows];
128  int* iovid_vec = new int[nrows];
129  float* xx = new float[nrows];
130  float* yy = new float[nrows];
131  float* zz = new float[nrows];
132  float* ww = new float[nrows];
133  int* st = new int[nrows];
134 
135  ub2* ids_len = new ub2[nrows];
136  ub2* iov_len = new ub2[nrows];
137  ub2* x_len = new ub2[nrows];
138  ub2* y_len = new ub2[nrows];
139  ub2* z_len = new ub2[nrows];
140  ub2* w_len = new ub2[nrows];
141  ub2* st_len = new ub2[nrows];
142 
143  const EcalLogicID* channel;
144  const MonLaserGreenDat* dataitem;
145  int count = 0;
146  typedef map<EcalLogicID, MonLaserGreenDat>::const_iterator CI;
147  for (CI p = data->begin(); p != data->end(); ++p) {
148  channel = &(p->first);
149  int logicID = channel->getLogicID();
150  if (!logicID) {
151  throw(std::runtime_error("MonLaserGreenDat::writeArrayDB: Bad EcalLogicID"));
152  }
153  ids[count] = logicID;
154  iovid_vec[count] = iovID;
155 
156  dataitem = &(p->second);
157  // dataIface.writeDB( channel, dataitem, iov);
158  float x = dataitem->getAPDMean();
159  float y = dataitem->getAPDRMS();
160  float z = dataitem->getAPDOverPNMean();
161  float w = dataitem->getAPDOverPNRMS();
162  int statu = dataitem->getTaskStatus();
163 
164  xx[count] = x;
165  yy[count] = y;
166  zz[count] = z;
167  ww[count] = w;
168  st[count] = statu;
169 
170  ids_len[count] = sizeof(ids[count]);
171  iov_len[count] = sizeof(iovid_vec[count]);
172 
173  x_len[count] = sizeof(xx[count]);
174  y_len[count] = sizeof(yy[count]);
175  z_len[count] = sizeof(zz[count]);
176  w_len[count] = sizeof(ww[count]);
177  st_len[count] = sizeof(st[count]);
178 
179  count++;
180  }
181 
182  try {
183  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
184  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
185  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
186  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
187  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT, sizeof(zz[0]), z_len);
188  m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT, sizeof(ww[0]), w_len);
189  m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
190 
191  m_writeStmt->executeArrayUpdate(nrows);
192 
193  delete[] ids;
194  delete[] iovid_vec;
195  delete[] xx;
196  delete[] yy;
197  delete[] zz;
198  delete[] ww;
199  delete[] st;
200 
201  delete[] ids_len;
202  delete[] iov_len;
203  delete[] x_len;
204  delete[] y_len;
205  delete[] z_len;
206  delete[] w_len;
207  delete[] st_len;
208 
209  } catch (SQLException& e) {
210  throw(std::runtime_error("MonLaserGreenDat::writeArrayDB(): " + e.getMessage()));
211  }
212 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
bool getTaskStatus() const
float getAPDOverPNMean() const
T w() const
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
float getAPDOverPNRMS() const
float getAPDRMS() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
float getAPDMean() const

◆ writeDB()

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

Definition at line 40 of file MonLaserGreenDat.cc.

References MillePedeFileConverter_cfg::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("MonLaserGreenDat::writeDB: IOV not in DB"));
47  }
48 
49  int logicID = ecid->getLogicID();
50  if (!logicID) {
51  throw(std::runtime_error("MonLaserGreenDat::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->getAPDMean());
59  m_writeStmt->setFloat(4, item->getAPDRMS());
60  m_writeStmt->setFloat(5, item->getAPDOverPNMean());
61  m_writeStmt->setFloat(6, item->getAPDOverPNRMS());
62  m_writeStmt->setInt(7, item->getTaskStatus());
63 
64  m_writeStmt->executeUpdate();
65  } catch (SQLException& e) {
66  throw(std::runtime_error("MonLaserGreenDat::writeDB(): " + e.getMessage()));
67  }
68 }
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 MonLaserGreenDat.h.

Member Data Documentation

◆ m_apdMean

float MonLaserGreenDat::m_apdMean
private

Definition at line 46 of file MonLaserGreenDat.h.

Referenced by getAPDMean(), and setAPDMean().

◆ m_apdOverPNMean

float MonLaserGreenDat::m_apdOverPNMean
private

Definition at line 48 of file MonLaserGreenDat.h.

Referenced by getAPDOverPNMean(), and setAPDOverPNMean().

◆ m_apdOverPNRMS

float MonLaserGreenDat::m_apdOverPNRMS
private

Definition at line 49 of file MonLaserGreenDat.h.

Referenced by getAPDOverPNRMS(), and setAPDOverPNRMS().

◆ m_apdRMS

float MonLaserGreenDat::m_apdRMS
private

Definition at line 47 of file MonLaserGreenDat.h.

Referenced by getAPDRMS(), and setAPDRMS().

◆ m_taskStatus

bool MonLaserGreenDat::m_taskStatus
private

Definition at line 50 of file MonLaserGreenDat.h.

Referenced by getTaskStatus(), and setTaskStatus().