15 m_writeStmt =
nullptr;
26 this->checkConnection();
29 m_writeStmt = m_conn->createStatement();
31 "INSERT INTO mon_pedestals_online_dat (iov_id, logic_id, "
32 "adc_mean_g12, adc_rms_g12, task_status) "
33 "VALUES (:iov_id, :logic_id, "
34 ":adc_mean_g12, :adc_rms_g12, :task_status)");
35 }
catch (SQLException&
e) {
36 throw(std::runtime_error(
"MonPedestalsOnlineDat::prepareWrite(): " +
e.getMessage()));
43 this->checkConnection();
46 int iovID = iov->fetchID();
48 throw(std::runtime_error(
"MonPedestalsOnlineDat::writeDB: IOV not in DB"));
51 int logicID = ecid->getLogicID();
53 throw(std::runtime_error(
"MonPedestalsOnlineDat::writeDB: Bad EcalLogicID"));
57 m_writeStmt->setInt(1, iovID);
58 m_writeStmt->setInt(2, logicID);
59 m_writeStmt->setFloat(3,
item->getADCMeanG12());
60 m_writeStmt->setFloat(4,
item->getADCRMSG12());
61 m_writeStmt->setInt(5,
item->getTaskStatus());
63 m_writeStmt->executeUpdate();
64 }
catch (SQLException&
e) {
65 throw(std::runtime_error(
"MonPedestalsOnlineDat::writeDB(): " +
e.getMessage()));
71 this->checkConnection();
74 iov->setConnection(m_env, m_conn);
75 int iovID = iov->fetchID();
83 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
84 "d.adc_mean_g12, d.adc_rms_g12, d.task_status "
85 "FROM channelview cv JOIN mon_pedestals_online_dat d "
86 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
87 "WHERE d.iov_id = :iov_id");
88 m_readStmt->setInt(1, iovID);
89 ResultSet* rset = m_readStmt->executeQuery();
91 std::pair<EcalLogicID, MonPedestalsOnlineDat>
p;
93 while (rset->next()) {
108 }
catch (SQLException&
e) {
109 throw(std::runtime_error(
"MonPedestalsOnlineDat::fetchData(): " +
e.getMessage()));
115 this->checkConnection();
116 this->checkPrepare();
118 int iovID = iov->fetchID();
120 throw(std::runtime_error(
"MonPedestalsOnlineDat::writeArrayDB: IOV not in DB"));
123 int nrows =
data->size();
124 int* ids =
new int[nrows];
125 int* iovid_vec =
new int[nrows];
126 float*
xx =
new float[nrows];
127 float*
yy =
new float[nrows];
128 int* st =
new int[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* st_len =
new ub2[nrows];
139 typedef map<EcalLogicID, MonPedestalsOnlineDat>::const_iterator CI;
140 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
141 channel = &(
p->first);
144 throw(std::runtime_error(
"MonPedestalsOnlineDat::writeArrayDB: Bad EcalLogicID"));
146 ids[
count] = logicID;
147 iovid_vec[
count] = iovID;
149 dataitem = &(
p->second);
170 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
171 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
172 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIFLOAT,
sizeof(
xx[0]), x_len);
173 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIFLOAT,
sizeof(
yy[0]), y_len);
174 m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
176 m_writeStmt->executeArrayUpdate(nrows);
190 }
catch (SQLException&
e) {
191 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB(): " +
e.getMessage()));