13 m_writeStmt =
nullptr;
16 m_pulseHeightMean = 0;
25 this->checkConnection();
28 m_writeStmt = m_conn->createStatement();
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, " 34 }
catch (SQLException&
e) {
35 throw(std::runtime_error(
"MonLaserPulseDat::prepareWrite(): " + e.getMessage()));
40 this->checkConnection();
43 int iovID = iov->fetchID();
45 throw(std::runtime_error(
"MonLaserPulseDat::writeDB: IOV not in DB"));
48 int logicID = ecid->getLogicID();
50 throw(std::runtime_error(
"MonLaserPulseDat::writeDB: Bad EcalLogicID"));
54 m_writeStmt->setInt(1, iovID);
55 m_writeStmt->setInt(2, logicID);
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());
62 m_writeStmt->executeUpdate();
63 }
catch (SQLException&
e) {
64 throw(std::runtime_error(
"MonLaserPulseDat::writeDB(): " + e.getMessage()));
69 this->checkConnection();
72 iov->setConnection(m_env, m_conn);
73 int iovID = iov->fetchID();
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();
89 std::pair<EcalLogicID, MonLaserPulseDat>
p;
91 while (rset->next()) {
107 }
catch (SQLException&
e) {
108 throw(std::runtime_error(
"MonLaserPulseDat::fetchData(): " + e.getMessage()));
114 this->checkConnection();
115 this->checkPrepare();
117 int iovID = iov->fetchID();
119 throw(std::runtime_error(
"MonLaserPulseDat::writeArrayDB: IOV not in DB"));
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];
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];
140 typedef map<EcalLogicID, MonLaserPulseDat>::const_iterator CI;
141 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
142 channel = &(
p->first);
145 throw(std::runtime_error(
"MonLaserPulseDat::writeArrayDB: Bad EcalLogicID"));
147 ids[
count] = logicID;
148 iovid_vec[
count] = iovID;
150 dataitem = &(
p->second);
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);
181 m_writeStmt->executeArrayUpdate(nrows);
197 }
catch (SQLException&
e) {
198 throw(std::runtime_error(
"MonLaserPulseDat::writeArrayDB(): " + e.getMessage()));
float getPulseHeightRMS() const
void setPulseWidthMean(float p)
void setPulseHeightRMS(float p)
void prepareWrite() noexcept(false) override
float getPulseHeightMean() const
void writeDB(const EcalLogicID *ecid, const MonLaserPulseDat *item, MonRunIOV *iov) noexcept(false)
void setPulseWidthRMS(float p)
~MonLaserPulseDat() override
float getPulseWidthMean() const
void fetchData(std::map< EcalLogicID, MonLaserPulseDat > *fillMap, MonRunIOV *iov) noexcept(false)
char data[epos_bytes_allocation]
void setPulseHeightMean(float p)
void writeArrayDB(const std::map< EcalLogicID, MonLaserPulseDat > *data, MonRunIOV *iov) noexcept(false)
float getPulseWidthRMS() const