14 m_writeStmt =
nullptr;
24 this->checkConnection();
27 m_writeStmt = m_conn->createStatement();
28 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
29 " (fgr_conf_id, logic_id, " 30 "threshold, lut_fg ) " 31 "VALUES (:fgr_conf_id, :logic_id, " 32 ":threshold, :lut_fg )");
33 }
catch (SQLException&
e) {
34 throw(std::runtime_error(
"FEConfigFgrEEStripDat::prepareWrite(): " +
e.getMessage()));
41 this->checkConnection();
44 int iconfID = iconf->fetchID();
46 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeDB: ICONF not in DB"));
49 int logicID = ecid->getLogicID();
51 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeDB: Bad EcalLogicID"));
55 m_writeStmt->setInt(1, iconfID);
56 m_writeStmt->setInt(2, logicID);
57 m_writeStmt->setUInt(3,
item->getThreshold());
58 m_writeStmt->setUInt(4,
item->getLutFg());
60 m_writeStmt->executeUpdate();
61 }
catch (SQLException&
e) {
62 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeDB(): " +
e.getMessage()));
68 this->checkConnection();
71 iconf->setConnection(m_env, m_conn);
72 int iconfID = iconf->fetchID();
80 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 81 "d.threshold, d.lut_fg " 82 "FROM channelview cv JOIN " +
85 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 86 "WHERE fgr_conf_id = :fgr_conf_id");
87 m_readStmt->setInt(1, iconfID);
88 ResultSet* rset = m_readStmt->executeQuery();
90 std::pair<EcalLogicID, FEConfigFgrEEStripDat>
p;
92 while (rset->next()) {
106 }
catch (SQLException&
e) {
107 throw(std::runtime_error(
"FEConfigFgrEEStripDat::fetchData: " +
e.getMessage()));
113 this->checkConnection();
114 this->checkPrepare();
116 int iconfID = iconf->fetchID();
118 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeArrayDB: ICONF not in DB"));
121 int nrows =
data->size();
122 int* ids =
new int[nrows];
123 int* iconfid_vec =
new int[nrows];
124 unsigned int*
xx =
new unsigned int[nrows];
125 unsigned int*
yy =
new unsigned int[nrows];
127 ub2* ids_len =
new ub2[nrows];
128 ub2* iconf_len =
new ub2[nrows];
129 ub2* x_len =
new ub2[nrows];
130 ub2* y_len =
new ub2[nrows];
135 typedef map<EcalLogicID, FEConfigFgrEEStripDat>::const_iterator CI;
136 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
137 channel = &(
p->first);
140 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeArrayDB: Bad EcalLogicID"));
142 ids[
count] = logicID;
143 iconfid_vec[
count] = iconfID;
145 dataitem = &(
p->second);
154 iconf_len[
count] =
sizeof(iconfid_vec[
count]);
163 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]), iconf_len);
164 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
165 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIUNSIGNED_INT,
sizeof(
xx[0]), x_len);
166 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIUNSIGNED_INT,
sizeof(
yy[0]), y_len);
168 m_writeStmt->executeArrayUpdate(nrows);
171 delete[] iconfid_vec;
180 }
catch (SQLException&
e) {
181 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeArrayDB(): " +
e.getMessage()));
unsigned int getThreshold() const
void setThreshold(unsigned int mean)
void prepareWrite() noexcept(false) override
void setLutFg(unsigned int mean)
~FEConfigFgrEEStripDat() override
char data[epos_bytes_allocation]
unsigned int getLutFg() const
void writeDB(const EcalLogicID *ecid, const FEConfigFgrEEStripDat *item, FEConfigFgrInfo *iconf) noexcept(false)
void fetchData(std::map< EcalLogicID, FEConfigFgrEEStripDat > *fillMap, FEConfigFgrInfo *iconf) noexcept(false)
void writeArrayDB(const std::map< EcalLogicID, FEConfigFgrEEStripDat > *data, FEConfigFgrInfo *iconf) noexcept(false)