8 using namespace oracle::occi;
13 m_writeStmt =
nullptr;
16 m_processedEvents = 0;
17 m_problematicEvents = 0;
19 m_problemsGainZero = 0;
20 m_problemsGainSwitch = 0;
27 this->checkConnection();
30 m_writeStmt = m_conn->createStatement();
32 "INSERT INTO mon_mem_ch_consistency_dat (iov_id, logic_id, "
33 "processed_events, problematic_events, problems_id, problems_gain_zero, problems_gain_switch, task_status) "
34 "VALUES (:iov_id, :logic_id, "
35 ":3, :4, :5, :6, :7, :8)");
36 }
catch (SQLException&
e) {
37 throw(std::runtime_error(
"MonMemChConsistencyDat::prepareWrite(): " + e.getMessage()));
44 this->checkConnection();
47 int iovID = iov->fetchID();
49 throw(std::runtime_error(
"MonMemChConsistencyDat::writeDB: IOV not in DB"));
52 int logicID = ecid->getLogicID();
54 throw(std::runtime_error(
"MonMemChConsistencyDat::writeDB: Bad EcalLogicID"));
58 m_writeStmt->setInt(1, iovID);
59 m_writeStmt->setInt(2, logicID);
61 m_writeStmt->setInt(3,
item->getProcessedEvents());
62 m_writeStmt->setInt(4,
item->getProblematicEvents());
63 m_writeStmt->setInt(5,
item->getProblemsID());
64 m_writeStmt->setInt(6,
item->getProblemsGainZero());
65 m_writeStmt->setInt(7,
item->getProblemsGainSwitch());
66 m_writeStmt->setInt(8,
item->getTaskStatus());
67 m_writeStmt->executeUpdate();
68 }
catch (SQLException&
e) {
69 throw(std::runtime_error(
"MonMemChConsistencyDat::writeDB(): " + e.getMessage()));
75 this->checkConnection();
78 iov->setConnection(m_env, m_conn);
79 int iovID = iov->fetchID();
87 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
88 "d.processed_events, d.problematic_events, d.problems_id, d.problems_gain_zero, d.problems_gain_switch, "
90 "FROM channelview cv JOIN mon_mem_ch_consistency_dat d "
91 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
92 "WHERE d.iov_id = :iov_id");
93 m_readStmt->setInt(1, iovID);
94 ResultSet* rset = m_readStmt->executeQuery();
96 std::pair<EcalLogicID, MonMemChConsistencyDat>
p;
98 while (rset->next()) {
116 }
catch (SQLException&
e) {
117 throw(std::runtime_error(
"MonMemChConsistencyDat::fetchData(): " + e.getMessage()));
123 this->checkConnection();
124 this->checkPrepare();
126 int iovID = iov->fetchID();
128 throw(std::runtime_error(
"MonMemChConsistencyDat::writeArrayDB: IOV not in DB"));
131 int nrows =
data->size();
132 int* ids =
new int[nrows];
133 int* iovid_vec =
new int[nrows];
134 int* xx =
new int[nrows];
135 int* yy =
new int[nrows];
136 int* zz =
new int[nrows];
137 int* ww =
new int[nrows];
138 int* uu =
new int[nrows];
139 int* st =
new int[nrows];
141 ub2* ids_len =
new ub2[nrows];
142 ub2* iov_len =
new ub2[nrows];
143 ub2* x_len =
new ub2[nrows];
144 ub2* y_len =
new ub2[nrows];
145 ub2* z_len =
new ub2[nrows];
146 ub2* w_len =
new ub2[nrows];
147 ub2* u_len =
new ub2[nrows];
148 ub2* st_len =
new ub2[nrows];
153 typedef map<EcalLogicID, MonMemChConsistencyDat>::const_iterator CI;
154 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
155 channel = &(
p->first);
158 throw(std::runtime_error(
"MonMemChConsistencyDat::writeArrayDB: Bad EcalLogicID"));
160 ids[
count] = logicID;
161 iovid_vec[
count] = iovID;
163 dataitem = &(
p->second);
193 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
194 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
195 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT,
sizeof(xx[0]), x_len);
196 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT,
sizeof(yy[0]), y_len);
197 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIINT,
sizeof(zz[0]), z_len);
198 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIINT,
sizeof(ww[0]), w_len);
199 m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIINT,
sizeof(uu[0]), u_len);
200 m_writeStmt->setDataBuffer(8, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
202 m_writeStmt->executeArrayUpdate(nrows);
222 }
catch (SQLException&
e) {
223 throw(std::runtime_error(
"MonMemChConsistencyDat::writeArrayDB(): " + e.getMessage()));
int getProblemsID() const
void prepareWrite() noexcept(false) override
int getProblemsGainSwitch() const
void setProcessedEvents(int proc)
int getProblemsGainZero() const
int getProblematicEvents() const
~MonMemChConsistencyDat() override
void writeDB(const EcalLogicID *ecid, const MonMemChConsistencyDat *item, MonRunIOV *iov) noexcept(false)
void setProblematicEvents(int prob)
bool getTaskStatus() const
void setProblemsID(int id)
void writeArrayDB(const std::map< EcalLogicID, MonMemChConsistencyDat > *data, MonRunIOV *iov) noexcept(false)
void setTaskStatus(bool status)
static std::vector< std::string > checklist dat
char data[epos_bytes_allocation]
void setProblemsGainZero(int prob)
void setProblemsGainSwitch(int prob)
void fetchData(std::map< EcalLogicID, MonMemChConsistencyDat > *fillVec, MonRunIOV *iov) noexcept(false)
int getProcessedEvents() const