CMS 3D CMS Logo

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

#include <MonLaserPulseDat.h>

Inheritance diagram for MonLaserPulseDat:
IDataItem IDBObject

Public Member Functions

float getPulseHeightMean () const
 
float getPulseHeightRMS () const
 
float getPulseWidthMean () const
 
float getPulseWidthRMS () const
 
std::string getTable () override
 
 MonLaserPulseDat ()
 
void setPulseHeightMean (float p)
 
void setPulseHeightRMS (float p)
 
void setPulseWidthMean (float p)
 
void setPulseWidthRMS (float p)
 
 ~MonLaserPulseDat () 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, MonLaserPulseDat > *fillMap, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonLaserPulseDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonLaserPulseDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_pulseHeightMean
 
float m_pulseHeightRMS
 
float m_pulseWidthMean
 
float m_pulseWidthRMS
 

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 MonLaserPulseDat.h.

Constructor & Destructor Documentation

◆ MonLaserPulseDat()

MonLaserPulseDat::MonLaserPulseDat ( )

Definition at line 10 of file MonLaserPulseDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
17  m_pulseHeightRMS = 0;
18  m_pulseWidthMean = 0;
19  m_pulseWidthRMS = 0;
20 }
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

◆ ~MonLaserPulseDat()

MonLaserPulseDat::~MonLaserPulseDat ( )
override

Definition at line 22 of file MonLaserPulseDat.cc.

22 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 68 of file MonLaserPulseDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setPulseHeightMean(), setPulseHeightRMS(), setPulseWidthMean(), and setPulseWidthRMS().

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("MonLaserPulseDat::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.pulse_height_mean, d.pulse_height_rms, d.pulse_width_mean, d.pulse_width_rms "
83  "FROM channelview cv JOIN mon_laser_pulse_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, MonLaserPulseDat> p;
90  MonLaserPulseDat dat;
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.setPulseHeightMean(rset->getFloat(7));
100  dat.setPulseHeightRMS(rset->getFloat(8));
101  dat.setPulseWidthMean(rset->getFloat(9));
102  dat.setPulseWidthRMS(rset->getFloat(10));
103 
104  p.second = dat;
105  fillMap->insert(p);
106  }
107  } catch (SQLException& e) {
108  throw(std::runtime_error("MonLaserPulseDat::fetchData(): " + e.getMessage()));
109  }
110 }
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 setPulseWidthMean(float p)
void setPulseHeightRMS(float p)
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
void setPulseWidthRMS(float p)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setPulseHeightMean(float p)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getPulseHeightMean()

float MonLaserPulseDat::getPulseHeightMean ( ) const
inline

Definition at line 21 of file MonLaserPulseDat.h.

References m_pulseHeightMean.

Referenced by writeArrayDB().

21 { return m_pulseHeightMean; }

◆ getPulseHeightRMS()

float MonLaserPulseDat::getPulseHeightRMS ( ) const
inline

Definition at line 24 of file MonLaserPulseDat.h.

References m_pulseHeightRMS.

Referenced by writeArrayDB().

24 { return m_pulseHeightRMS; }

◆ getPulseWidthMean()

float MonLaserPulseDat::getPulseWidthMean ( ) const
inline

Definition at line 27 of file MonLaserPulseDat.h.

References m_pulseWidthMean.

Referenced by writeArrayDB().

27 { return m_pulseWidthMean; }

◆ getPulseWidthRMS()

float MonLaserPulseDat::getPulseWidthRMS ( ) const
inline

Definition at line 30 of file MonLaserPulseDat.h.

References m_pulseWidthRMS.

Referenced by writeArrayDB().

30 { return m_pulseWidthRMS; }

◆ getTable()

std::string MonLaserPulseDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MonLaserPulseDat.h.

18 { return "MON_LASER_PULSE_DAT"; }

◆ prepareWrite()

void MonLaserPulseDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 24 of file MonLaserPulseDat.cc.

References MillePedeFileConverter_cfg::e.

24  {
25  this->checkConnection();
26 
27  try {
28  m_writeStmt = m_conn->createStatement();
29  m_writeStmt->setSQL(
30  "INSERT INTO mon_laser_pulse_dat (iov_id, logic_id, "
31  "pulse_height_mean, pulse_height_rms, pulse_width_mean, pulse_width_rms) "
32  "VALUES (:iov_id, :logic_id, "
33  ":3, :4, :5, :6)");
34  } catch (SQLException& e) {
35  throw(std::runtime_error("MonLaserPulseDat::prepareWrite(): " + e.getMessage()));
36  }
37 }
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

◆ setPulseHeightMean()

void MonLaserPulseDat::setPulseHeightMean ( float  p)
inline

◆ setPulseHeightRMS()

void MonLaserPulseDat::setPulseHeightRMS ( float  p)
inline

◆ setPulseWidthMean()

void MonLaserPulseDat::setPulseWidthMean ( float  p)
inline

◆ setPulseWidthRMS()

void MonLaserPulseDat::setPulseWidthRMS ( float  p)
inline

◆ writeArrayDB()

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

Definition at line 112 of file MonLaserPulseDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getPulseHeightMean(), getPulseHeightRMS(), getPulseWidthMean(), getPulseWidthRMS(), AlCaHLTBitMon_ParallelJobs::p, w(), x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

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

◆ writeDB()

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

Definition at line 39 of file MonLaserPulseDat.cc.

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

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file MonLaserPulseDat.h.

Member Data Documentation

◆ m_pulseHeightMean

float MonLaserPulseDat::m_pulseHeightMean
private

Definition at line 42 of file MonLaserPulseDat.h.

Referenced by getPulseHeightMean(), and setPulseHeightMean().

◆ m_pulseHeightRMS

float MonLaserPulseDat::m_pulseHeightRMS
private

Definition at line 43 of file MonLaserPulseDat.h.

Referenced by getPulseHeightRMS(), and setPulseHeightRMS().

◆ m_pulseWidthMean

float MonLaserPulseDat::m_pulseWidthMean
private

Definition at line 44 of file MonLaserPulseDat.h.

Referenced by getPulseWidthMean(), and setPulseWidthMean().

◆ m_pulseWidthRMS

float MonLaserPulseDat::m_pulseWidthRMS
private

Definition at line 45 of file MonLaserPulseDat.h.

Referenced by getPulseWidthRMS(), and setPulseWidthRMS().