14 m_writeStmt =
nullptr;
25 this->checkConnection();
28 m_writeStmt = m_conn->createStatement();
30 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
31 " (ped_conf_id, logic_id, "
32 "mean_12, mean_6, mean_1 ) "
33 "VALUES (:ped_conf_id, :logic_id, "
34 ":ped_mean_g12, :ped_mean_g6, :ped_mean_g1 )");
35 }
catch (SQLException&
e) {
36 throw(std::runtime_error(
"FEConfigPedDat::prepareWrite(): " +
e.getMessage()));
43 this->checkConnection();
45 int iconfID = iconf->fetchID();
47 throw(std::runtime_error(
"FEConfigPedDat::writeDB: ICONF not in DB"));
50 int logicID = ecid->getLogicID();
52 throw(std::runtime_error(
"FEConfigPedDat::writeDB: Bad EcalLogicID"));
56 m_writeStmt->setInt(1, iconfID);
57 m_writeStmt->setInt(2, logicID);
58 m_writeStmt->setFloat(3,
item->getPedMeanG12());
59 m_writeStmt->setFloat(4,
item->getPedMeanG6());
60 m_writeStmt->setFloat(5,
item->getPedMeanG1());
62 m_writeStmt->executeUpdate();
63 }
catch (SQLException&
e) {
64 throw(std::runtime_error(
"FEConfigPedDat::writeDB(): " +
e.getMessage()));
69 this->checkConnection();
72 iconf->setConnection(m_env, m_conn);
73 int iconfID = iconf->fetchID();
81 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
82 "d.mean_12, d.mean_6, d.mean_1 "
83 "FROM channelview cv JOIN fe_config_ped_dat d "
84 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
85 "WHERE ped_conf_id = :ped_conf_id");
86 m_readStmt->setInt(1, iconfID);
87 ResultSet* rset = m_readStmt->executeQuery();
89 std::pair<EcalLogicID, FEConfigPedDat>
p;
91 while (rset->next()) {
106 }
catch (SQLException&
e) {
107 throw(std::runtime_error(
"FEConfigPedDat::fetchData: " +
e.getMessage()));
113 this->checkConnection();
114 this->checkPrepare();
116 int iconfID = iconf->fetchID();
118 throw(std::runtime_error(
"FEConfigPedDat::writeArrayDB: ICONF not in DB"));
121 int nrows =
data->size();
122 int* ids =
new int[nrows];
123 int* iconfid_vec =
new int[nrows];
124 float*
xx =
new float[nrows];
125 float*
yy =
new float[nrows];
126 float*
zz =
new float[nrows];
128 ub2* ids_len =
new ub2[nrows];
129 ub2* iconf_len =
new ub2[nrows];
130 ub2* x_len =
new ub2[nrows];
131 ub2* y_len =
new ub2[nrows];
132 ub2* z_len =
new ub2[nrows];
137 typedef map<EcalLogicID, FEConfigPedDat>::const_iterator CI;
138 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
139 channel = &(
p->first);
142 throw(std::runtime_error(
"FEConfigPedDat::writeArrayDB: Bad EcalLogicID"));
144 ids[
count] = logicID;
145 iconfid_vec[
count] = iconfID;
147 dataitem = &(
p->second);
158 iconf_len[
count] =
sizeof(iconfid_vec[
count]);
168 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]), iconf_len);
169 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
170 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIFLOAT,
sizeof(
xx[0]), x_len);
171 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIFLOAT,
sizeof(
yy[0]), y_len);
172 m_writeStmt->setDataBuffer(5, (dvoid*)
zz, OCCIFLOAT,
sizeof(
zz[0]), z_len);
174 m_writeStmt->executeArrayUpdate(nrows);
177 delete[] iconfid_vec;
188 }
catch (SQLException&
e) {
189 throw(std::runtime_error(
"FEConfigPedDat::writeArrayDB(): " +
e.getMessage()));