15 m_writeStmt =
nullptr;
32 this->checkConnection();
35 m_writeStmt = m_conn->createStatement();
37 "INSERT INTO mon_pn_blue_dat (iov_id, logic_id, "
38 "adc_mean_g1, adc_rms_g1, adc_mean_g16, adc_rms_g16, ped_mean_g1, ped_rms_g1, ped_mean_g16, ped_rms_g16, "
40 "VALUES (:iov_id, :logic_id, "
41 ":3, :4, :5, :6, :7, :8, :9, :10, :11)");
42 }
catch (SQLException&
e) {
43 throw(std::runtime_error(
"MonPNBlueDat::prepareWrite(): " +
e.getMessage()));
48 this->checkConnection();
51 int iovID = iov->fetchID();
53 throw(std::runtime_error(
"MonPNBlueDat::writeDB: IOV not in DB"));
56 int logicID = ecid->getLogicID();
58 throw(std::runtime_error(
"MonPNBlueDat::writeDB: Bad EcalLogicID"));
62 m_writeStmt->setInt(1, iovID);
63 m_writeStmt->setInt(2, logicID);
65 m_writeStmt->setFloat(3,
item->getADCMeanG1());
66 m_writeStmt->setFloat(4,
item->getADCRMSG1());
67 m_writeStmt->setFloat(5,
item->getADCMeanG16());
68 m_writeStmt->setFloat(6,
item->getADCRMSG16());
69 m_writeStmt->setFloat(7,
item->getPedMeanG1());
70 m_writeStmt->setFloat(8,
item->getPedRMSG1());
71 m_writeStmt->setFloat(9,
item->getPedMeanG16());
72 m_writeStmt->setFloat(10,
item->getPedRMSG16());
73 m_writeStmt->setInt(11,
item->getTaskStatus());
75 m_writeStmt->executeUpdate();
76 }
catch (SQLException&
e) {
77 throw(std::runtime_error(
"MonPNBlueDat::writeDB(): " +
e.getMessage()));
82 this->checkConnection();
85 iov->setConnection(m_env, m_conn);
86 int iovID = iov->fetchID();
94 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
95 "d.adc_mean_g1, d.adc_rms_g1, d.adc_mean_g16, d.adc_rms_g16, d.ped_mean_g1,d.ped_rms_g1, d.ped_mean_g16, "
96 "d.ped_rms_g16, d.task_status "
97 "FROM channelview cv JOIN mon_pn_blue_dat d "
98 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
99 "WHERE d.iov_id = :iov_id");
100 m_readStmt->setInt(1, iovID);
101 ResultSet* rset = m_readStmt->executeQuery();
103 std::pair<EcalLogicID, MonPNBlueDat>
p;
105 while (rset->next()) {
125 }
catch (SQLException&
e) {
126 throw(std::runtime_error(
"MonPNBlueDat::fetchData(): " +
e.getMessage()));
131 this->checkConnection();
132 this->checkPrepare();
134 int iovID = iov->fetchID();
136 throw(std::runtime_error(
"MonPNBlueDat::writeArrayDB: IOV not in DB"));
139 int nrows =
data->size();
140 int* ids =
new int[nrows];
141 int* iovid_vec =
new int[nrows];
142 float*
xx =
new float[nrows];
143 float*
yy =
new float[nrows];
144 float*
zz =
new float[nrows];
145 float* ww =
new float[nrows];
146 float* uu =
new float[nrows];
147 float*
tt =
new float[nrows];
148 float*
rr =
new float[nrows];
149 float*
pp =
new float[nrows];
150 int* st =
new int[nrows];
152 ub2* ids_len =
new ub2[nrows];
153 ub2* iov_len =
new ub2[nrows];
154 ub2* x_len =
new ub2[nrows];
155 ub2* y_len =
new ub2[nrows];
156 ub2* z_len =
new ub2[nrows];
157 ub2* w_len =
new ub2[nrows];
158 ub2* u_len =
new ub2[nrows];
159 ub2* t_len =
new ub2[nrows];
160 ub2* r_len =
new ub2[nrows];
161 ub2* p_len =
new ub2[nrows];
162 ub2* st_len =
new ub2[nrows];
167 typedef map<EcalLogicID, MonPNBlueDat>::const_iterator CI;
168 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
169 channel = &(
p->first);
172 throw(std::runtime_error(
"MonPNBlueDat::writeArrayDB: Bad EcalLogicID"));
174 ids[
count] = logicID;
175 iovid_vec[
count] = iovID;
177 dataitem = &(
p->second);
216 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
217 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
218 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIFLOAT,
sizeof(
xx[0]), x_len);
219 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIFLOAT,
sizeof(
yy[0]), y_len);
220 m_writeStmt->setDataBuffer(5, (dvoid*)
zz, OCCIFLOAT,
sizeof(
zz[0]), z_len);
221 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT,
sizeof(ww[0]), w_len);
222 m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIFLOAT,
sizeof(uu[0]), u_len);
223 m_writeStmt->setDataBuffer(8, (dvoid*)
tt, OCCIFLOAT,
sizeof(
tt[0]), t_len);
224 m_writeStmt->setDataBuffer(9, (dvoid*)
rr, OCCIFLOAT,
sizeof(
rr[0]), r_len);
225 m_writeStmt->setDataBuffer(10, (dvoid*)
pp, OCCIFLOAT,
sizeof(
pp[0]), p_len);
226 m_writeStmt->setDataBuffer(11, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
228 m_writeStmt->executeArrayUpdate(nrows);
254 }
catch (SQLException&
e) {
255 throw(std::runtime_error(
"MonPNBlueDat::writeArrayDB(): " +
e.getMessage()));