14 m_writeStmt =
nullptr;
29 this->checkConnection();
32 m_writeStmt = m_conn->createStatement();
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()));
46 this->checkConnection();
49 int iovID = iov->fetchID();
51 throw(std::runtime_error(
"MonPedestalsDat::writeDB: IOV not in DB"));
54 int logicID = ecid->getLogicID();
56 throw(std::runtime_error(
"MonPedestalsDat::writeDB: Bad EcalLogicID"));
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());
70 m_writeStmt->executeUpdate();
71 }
catch (SQLException&
e) {
72 throw(std::runtime_error(
"MonPedestalsDat::writeDB(): " + e.getMessage()));
77 this->checkConnection();
80 iov->setConnection(m_env, m_conn);
81 int iovID = iov->fetchID();
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();
98 std::pair<EcalLogicID, MonPedestalsDat>
p;
100 while (rset->next()) {
119 }
catch (SQLException&
e) {
120 throw(std::runtime_error(
"MonPedestalsDat::fetchData: " + e.getMessage()));
125 this->checkConnection();
126 this->checkPrepare();
128 int iovID = iov->fetchID();
130 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB: IOV not in DB"));
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];
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];
157 typedef map<EcalLogicID, MonPedestalsDat>::const_iterator CI;
158 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
159 channel = &(
p->first);
162 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB: Bad EcalLogicID"));
164 ids[
count] = logicID;
165 iovid_vec[
count] = iovID;
167 dataitem = &(
p->second);
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);
210 m_writeStmt->executeArrayUpdate(nrows);
232 }
catch (SQLException&
e) {
233 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB(): " + e.getMessage()));
void setPedMeanG1(float mean)
float getPedRMSG1() const
void setPedRMSG6(float rms)
void setTaskStatus(bool status)
float getPedMeanG12() const
float getPedRMSG12() const
void prepareWrite() noexcept(false) override
void setPedMeanG6(float mean)
bool getTaskStatus() const
void setPedRMSG1(float rms)
void fetchData(std::map< EcalLogicID, MonPedestalsDat > *fillMap, MonRunIOV *iov) noexcept(false)
float getPedMeanG1() const
char data[epos_bytes_allocation]
float getPedMeanG6() const
void setPedMeanG12(float mean)
void writeDB(const EcalLogicID *ecid, const MonPedestalsDat *item, MonRunIOV *iov) noexcept(false)
void writeArrayDB(const std::map< EcalLogicID, MonPedestalsDat > *data, MonRunIOV *iov) noexcept(false)
float getPedRMSG6() const
~MonPedestalsDat() override
void setPedRMSG12(float rms)