15 m_writeStmt =
nullptr;
34 this->checkConnection();
37 m_writeStmt = m_conn->createStatement();
39 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" (ped_conf_id, logic_id, " 40 "mean_12, mean_6, mean_1 ) " 41 "VALUES (:ped_conf_id, :logic_id, " 42 ":ped_mean_g12, :ped_mean_g6, :ped_mean_g1 )" );
43 }
catch (SQLException &
e) {
44 throw(std::runtime_error(
"FEConfigPedDat::prepareWrite(): "+e.getMessage()));
53 this->checkConnection();
55 int iconfID = iconf->fetchID();
56 if (!iconfID) {
throw(std::runtime_error(
"FEConfigPedDat::writeDB: ICONF not in DB")); }
58 int logicID = ecid->getLogicID();
59 if (!logicID) {
throw(std::runtime_error(
"FEConfigPedDat::writeDB: Bad EcalLogicID")); }
62 m_writeStmt->setInt(1, iconfID);
63 m_writeStmt->setInt(2, logicID);
64 m_writeStmt->setFloat(3, item->getPedMeanG12());
65 m_writeStmt->setFloat(4, item->getPedMeanG6());
66 m_writeStmt->setFloat(5, item->getPedMeanG1());
68 m_writeStmt->executeUpdate();
69 }
catch (SQLException &
e) {
70 throw(std::runtime_error(
"FEConfigPedDat::writeDB(): "+e.getMessage()));
78 this->checkConnection();
81 iconf->setConnection(m_env, m_conn);
82 int iconfID = iconf->fetchID();
90 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 91 "d.mean_12, d.mean_6, d.mean_1 " 92 "FROM channelview cv JOIN fe_config_ped_dat d " 93 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 94 "WHERE ped_conf_id = :ped_conf_id");
95 m_readStmt->setInt(1, iconfID);
96 ResultSet* rset = m_readStmt->executeQuery();
98 std::pair< EcalLogicID, FEConfigPedDat >
p;
100 while(rset->next()) {
115 }
catch (SQLException &
e) {
116 throw(std::runtime_error(
"FEConfigPedDat::fetchData: "+e.getMessage()));
123 this->checkConnection();
124 this->checkPrepare();
126 int iconfID = iconf->fetchID();
127 if (!iconfID) {
throw(std::runtime_error(
"FEConfigPedDat::writeArrayDB: ICONF not in DB")); }
130 int nrows=
data->size();
131 int* ids=
new int[nrows];
132 int* iconfid_vec=
new int[nrows];
133 float*
xx=
new float[nrows];
134 float*
yy=
new float[nrows];
135 float*
zz=
new float[nrows];
138 ub2* ids_len=
new ub2[nrows];
139 ub2* iconf_len=
new ub2[nrows];
140 ub2* x_len=
new ub2[nrows];
141 ub2* y_len=
new ub2[nrows];
142 ub2* z_len=
new ub2[nrows];
148 typedef map< EcalLogicID, FEConfigPedDat >::const_iterator CI;
149 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
150 channel = &(
p->first);
152 if (!logicID) {
throw(std::runtime_error(
"FEConfigPedDat::writeArrayDB: Bad EcalLogicID")); }
154 iconfid_vec[
count]=iconfID;
156 dataitem = &(
p->second);
178 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]),iconf_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*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
184 m_writeStmt->executeArrayUpdate(nrows);
187 delete [] iconfid_vec;
198 }
catch (SQLException &
e) {
199 throw(std::runtime_error(
"FEConfigPedDat::writeArrayDB(): "+e.getMessage()));
float getPedMeanG1() const
void fetchData(std::map< EcalLogicID, FEConfigPedDat > *fillMap, FEConfigPedInfo *iconf) noexcept(false)
void setPedMeanG6(float mean)
void writeDB(const EcalLogicID *ecid, const FEConfigPedDat *item, FEConfigPedInfo *iconf) noexcept(false)
~FEConfigPedDat() override
void setPedMeanG1(float mean)
void writeArrayDB(const std::map< EcalLogicID, FEConfigPedDat > *data, FEConfigPedInfo *iconf) noexcept(false)
float getPedMeanG12() const
void setPedMeanG12(float mean)
float getPedMeanG6() const
char data[epos_bytes_allocation]
void prepareWrite() noexcept(false) override