13 m_writeStmt =
nullptr;
26 this->checkConnection();
29 m_writeStmt = m_conn->createStatement();
31 "INSERT INTO mon_laser_blue_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(
"MonLaserBlueDat::prepareWrite(): " + e.getMessage()));
41 this->checkConnection();
44 int iovID = iov->fetchID();
46 throw(std::runtime_error(
"MonLaserBlueDat::writeDB: IOV not in DB"));
49 int logicID = ecid->getLogicID();
51 throw(std::runtime_error(
"MonLaserBlueDat::writeDB: Bad EcalLogicID"));
55 m_writeStmt->setInt(1, iovID);
56 m_writeStmt->setInt(2, logicID);
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());
64 m_writeStmt->executeUpdate();
65 }
catch (SQLException&
e) {
66 throw(std::runtime_error(
"MonLaserBlueDat::writeDB(): " + e.getMessage()));
71 this->checkConnection();
75 iov->setConnection(m_env, m_conn);
76 int iovID = iov->fetchID();
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_blue_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();
92 std::pair<EcalLogicID, MonLaserBlueDat>
p;
94 while (rset->next()) {
111 }
catch (SQLException&
e) {
112 throw(std::runtime_error(
"MonLaserBlueDat::fetchData(): " + e.getMessage()));
117 this->checkConnection();
118 this->checkPrepare();
120 int iovID = iov->fetchID();
122 throw(std::runtime_error(
"MonLaserBlueDat::writeArrayDB: IOV not in DB"));
125 int nrows =
data->size();
126 int*
ids =
new int[nrows];
127 int* iovid_vec =
new int[nrows];
128 float*
xx =
new float[nrows];
129 float*
yy =
new float[nrows];
130 float*
zz =
new float[nrows];
131 float* ww =
new float[nrows];
132 int* st =
new int[nrows];
134 ub2* ids_len =
new ub2[nrows];
135 ub2* iov_len =
new ub2[nrows];
136 ub2* x_len =
new ub2[nrows];
137 ub2* y_len =
new ub2[nrows];
138 ub2* z_len =
new ub2[nrows];
139 ub2* w_len =
new ub2[nrows];
140 ub2* st_len =
new ub2[nrows];
145 typedef map<EcalLogicID, MonLaserBlueDat>::const_iterator CI;
146 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
147 channel = &(
p->first);
150 throw(std::runtime_error(
"MonLaserBlueDat::writeArrayDB: Bad EcalLogicID"));
152 ids[
count] = logicID;
153 iovid_vec[
count] = iovID;
155 dataitem = &(
p->second);
182 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
183 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
184 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT,
sizeof(xx[0]), x_len);
185 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT,
sizeof(yy[0]), y_len);
186 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT,
sizeof(zz[0]), z_len);
187 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT,
sizeof(ww[0]), w_len);
188 m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
190 m_writeStmt->executeArrayUpdate(nrows);
208 }
catch (SQLException&
e) {
209 throw(std::runtime_error(
"MonLaserBlueDat::writeArrayDB(): " + e.getMessage()));
bool getTaskStatus() const
void setAPDOverPNMean(float mean)
~MonLaserBlueDat() override
void fetchData(std::map< EcalLogicID, MonLaserBlueDat > *fillMap, MonRunIOV *iov) noexcept(false)
void prepareWrite() noexcept(false) override
void writeArrayDB(const std::map< EcalLogicID, MonLaserBlueDat > *data, MonRunIOV *iov) noexcept(false)
void setAPDRMS(float rms)
void writeDB(const EcalLogicID *ecid, const MonLaserBlueDat *item, MonRunIOV *iov) noexcept(false)
void setTaskStatus(bool status)
void setAPDOverPNRMS(float rms)
char data[epos_bytes_allocation]
float getAPDOverPNMean() const
void setAPDMean(float mean)
float getAPDOverPNRMS() const