15 m_writeStmt =
nullptr;
26 this->checkConnection();
29 m_writeStmt = m_conn->createStatement();
31 "INSERT INTO cali_crystal_intercal_dat (iov_id, logic_id, "
32 "cali, cali_rms, num_events, task_status) "
33 "VALUES (:iov_id, :logic_id, "
35 }
catch (SQLException&
e) {
36 throw(std::runtime_error(
"CaliCrystalIntercalDat::prepareWrite(): " +
e.getMessage()));
43 this->checkConnection();
46 int iovID = iov->fetchID();
48 throw(std::runtime_error(
"CaliCrystalIntercalDat::writeDB: IOV not in DB"));
51 int logicID = ecid->getLogicID();
53 throw(std::runtime_error(
"CaliCrystalIntercalDat::writeDB: Bad EcalLogicID"));
57 m_writeStmt->setInt(1, iovID);
58 m_writeStmt->setInt(2, logicID);
60 m_writeStmt->setFloat(3,
item->getCali());
61 m_writeStmt->setFloat(4,
item->getCaliRMS());
62 m_writeStmt->setInt(5,
item->getNumEvents());
63 m_writeStmt->setInt(6,
item->getTaskStatus());
65 m_writeStmt->executeUpdate();
66 }
catch (SQLException&
e) {
67 throw(std::runtime_error(
"CaliCrystalIntercalDat::writeDB(): " +
e.getMessage()));
73 this->checkConnection();
76 iov->setConnection(m_env, m_conn);
77 int iovID = iov->fetchID();
85 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
86 "d.cali, d.cali_rms, d.num_events, d.task_status "
87 "FROM channelview cv JOIN cali_crystal_intercal_dat d "
88 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
89 "WHERE d.iov_id = :iov_id");
90 m_readStmt->setInt(1, iovID);
91 ResultSet* rset = m_readStmt->executeQuery();
93 std::pair<EcalLogicID, CaliCrystalIntercalDat>
p;
95 while (rset->next()) {
103 dat.
setCali(rset->getFloat(7));
111 }
catch (SQLException&
e) {
112 throw(std::runtime_error(
"CaliCrystalIntercalDat::fetchData(): " +
e.getMessage()));
117 CaliIOV* iov) noexcept(
false) {
118 this->checkConnection();
119 this->checkPrepare();
121 int iovID = iov->fetchID();
123 throw(std::runtime_error(
"CaliCrystalIntercalDat::writeArrayDB: IOV not in DB"));
126 int nrows =
data->size();
127 int* ids =
new int[nrows];
128 int* iovid_vec =
new int[nrows];
129 float*
xx =
new float[nrows];
130 float*
yy =
new float[nrows];
131 int*
tt =
new int[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* tt_len =
new ub2[nrows];
139 ub2* st_len =
new ub2[nrows];
144 typedef map<EcalLogicID, CaliCrystalIntercalDat>::const_iterator CI;
145 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
146 channel = &(
p->first);
149 throw(std::runtime_error(
"CaliCrystalIntercalDat::writeArrayDB: Bad EcalLogicID"));
151 ids[
count] = logicID;
152 iovid_vec[
count] = iovID;
154 dataitem = &(
p->second);
178 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
179 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
180 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIFLOAT,
sizeof(
xx[0]), x_len);
181 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIFLOAT,
sizeof(
yy[0]), y_len);
182 m_writeStmt->setDataBuffer(5, (dvoid*)
tt, OCCIINT,
sizeof(
tt[0]), tt_len);
183 m_writeStmt->setDataBuffer(6, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
185 m_writeStmt->executeArrayUpdate(nrows);
201 }
catch (SQLException&
e) {
202 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB(): " +
e.getMessage()));