8 using namespace oracle::occi;
13 m_writeStmt =
nullptr;
16 m_eventsOverLowThreshold = 0;
17 m_eventsOverHighThreshold = 0;
24 this->checkConnection();
27 m_writeStmt = m_conn->createStatement();
29 "INSERT INTO mon_occupancy_dat (iov_id, logic_id, "
30 "events_over_low_threshold, events_over_high_threshold, avg_energy) "
31 "VALUES (:iov_id, :logic_id, "
33 }
catch (SQLException&
e) {
34 throw(std::runtime_error(
"MonOccupancyDat::prepareWrite(): " + e.getMessage()));
39 this->checkConnection();
42 int iovID = iov->fetchID();
44 throw(std::runtime_error(
"MonOccupancyDat::writeDB: IOV not in DB"));
47 int logicID = ecid->getLogicID();
49 throw(std::runtime_error(
"MonOccupancyDat::writeDB: Bad EcalLogicID"));
53 m_writeStmt->setInt(1, iovID);
54 m_writeStmt->setInt(2, logicID);
56 m_writeStmt->setInt(3,
item->getEventsOverLowThreshold());
57 m_writeStmt->setInt(4,
item->getEventsOverHighThreshold());
58 m_writeStmt->setFloat(5,
item->getAvgEnergy());
60 m_writeStmt->executeUpdate();
61 }
catch (SQLException&
e) {
62 throw(std::runtime_error(
"MonOccupancyDat::writeDB(): " + e.getMessage()));
67 this->checkConnection();
70 iov->setConnection(m_env, m_conn);
71 int iovID = iov->fetchID();
79 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
80 "d.events_over_low_threshold, d.events_over_high_threshold, d.avg_energy "
81 "FROM channelview cv JOIN mon_occupancy_dat d "
82 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
83 "WHERE d.iov_id = :iov_id");
84 m_readStmt->setInt(1, iovID);
85 ResultSet* rset = m_readStmt->executeQuery();
87 std::pair<EcalLogicID, MonOccupancyDat>
p;
89 while (rset->next()) {
104 }
catch (SQLException&
e) {
105 throw(std::runtime_error(
"MonOccupancyDat::fetchData(): " + e.getMessage()));
110 this->checkConnection();
111 this->checkPrepare();
113 int iovID = iov->fetchID();
115 throw(std::runtime_error(
"MonOccupancyDat::writeArrayDB: IOV not in DB"));
118 int nrows =
data->size();
119 int* ids =
new int[nrows];
120 int* iovid_vec =
new int[nrows];
121 int* xx =
new int[nrows];
122 int* yy =
new int[nrows];
123 float* zz =
new float[nrows];
125 ub2* ids_len =
new ub2[nrows];
126 ub2* iov_len =
new ub2[nrows];
127 ub2* x_len =
new ub2[nrows];
128 ub2* y_len =
new ub2[nrows];
129 ub2* z_len =
new ub2[nrows];
134 typedef map<EcalLogicID, MonOccupancyDat>::const_iterator CI;
135 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
136 channel = &(
p->first);
139 throw(std::runtime_error(
"MonOccupancyDat::writeArrayDB: Bad EcalLogicID"));
141 ids[
count] = logicID;
142 iovid_vec[
count] = iovID;
144 dataitem = &(
p->second);
165 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
166 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
167 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT,
sizeof(xx[0]), x_len);
168 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT,
sizeof(yy[0]), y_len);
169 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT,
sizeof(zz[0]), z_len);
171 m_writeStmt->executeArrayUpdate(nrows);
185 }
catch (SQLException&
e) {
186 throw(std::runtime_error(
"MonOccupancyDat::writeArrayDB(): " + e.getMessage()));
void setAvgEnergy(float energy)
void writeArrayDB(const std::map< EcalLogicID, MonOccupancyDat > *data, MonRunIOV *iov) noexcept(false)
void setEventsOverLowThreshold(int events)
int getEventsOverHighThreshold() const
float getAvgEnergy() const
int getEventsOverLowThreshold() const
void fetchData(std::map< EcalLogicID, MonOccupancyDat > *fillVec, MonRunIOV *iov) noexcept(false)
~MonOccupancyDat() override
static std::vector< std::string > checklist dat
void writeDB(const EcalLogicID *ecid, const MonOccupancyDat *item, MonRunIOV *iov) noexcept(false)
void setEventsOverHighThreshold(int events)
char data[epos_bytes_allocation]
void prepareWrite() noexcept(false) override