17 m_eventsOverLowThreshold = 0;
18 m_eventsOverHighThreshold = 0;
33 this->checkConnection();
36 m_writeStmt = m_conn->createStatement();
37 m_writeStmt->setSQL(
"INSERT INTO mon_occupancy_dat (iov_id, logic_id, " 38 "events_over_low_threshold, events_over_high_threshold, avg_energy) " 39 "VALUES (:iov_id, :logic_id, " 42 throw(std::runtime_error(
"MonOccupancyDat::prepareWrite(): "+e.getMessage()));
51 this->checkConnection();
54 int iovID = iov->fetchID();
55 if (!iovID) {
throw(std::runtime_error(
"MonOccupancyDat::writeDB: IOV not in DB")); }
57 int logicID = ecid->getLogicID();
58 if (!logicID) {
throw(std::runtime_error(
"MonOccupancyDat::writeDB: Bad EcalLogicID")); }
61 m_writeStmt->setInt(1, iovID);
62 m_writeStmt->setInt(2, logicID);
64 m_writeStmt->setInt(3, item->getEventsOverLowThreshold() );
65 m_writeStmt->setInt(4, item->getEventsOverHighThreshold() );
66 m_writeStmt->setFloat(5, item->getAvgEnergy() );
68 m_writeStmt->executeUpdate();
70 throw(std::runtime_error(
"MonOccupancyDat::writeDB(): "+e.getMessage()));
79 this->checkConnection();
82 iov->setConnection(m_env, m_conn);
83 int iovID = iov->fetchID();
91 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 92 "d.events_over_low_threshold, d.events_over_high_threshold, d.avg_energy " 93 "FROM channelview cv JOIN mon_occupancy_dat d " 94 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 95 "WHERE d.iov_id = :iov_id");
96 m_readStmt->setInt(1, iovID);
97 ResultSet* rset = m_readStmt->executeQuery();
99 std::pair< EcalLogicID, MonOccupancyDat >
p;
101 while(rset->next()) {
117 throw(std::runtime_error(
"MonOccupancyDat::fetchData(): "+e.getMessage()));
124 this->checkConnection();
125 this->checkPrepare();
127 int iovID = iov->fetchID();
128 if (!iovID) {
throw(std::runtime_error(
"MonOccupancyDat::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 float*
zz=
new float[nrows];
138 ub2* ids_len=
new ub2[nrows];
139 ub2* iov_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, MonOccupancyDat >::const_iterator CI;
149 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
150 channel = &(
p->first);
152 if (!logicID) {
throw(std::runtime_error(
"MonOccupancyDat::writeArrayDB: Bad EcalLogicID")); }
154 iovid_vec[
count]=iovID;
156 dataitem = &(
p->second);
180 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
181 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
182 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT ,
sizeof(xx[0]), x_len );
183 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT ,
sizeof(yy[0]), y_len );
184 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
186 m_writeStmt->executeArrayUpdate(nrows);
202 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
oracle::occi::SQLException SQLException
float getAvgEnergy() const
int getEventsOverLowThreshold() const
void fetchData(std::map< EcalLogicID, MonOccupancyDat > *fillVec, MonRunIOV *iov) noexcept(false)
void prepareWrite() noexcept(false)
void writeDB(const EcalLogicID *ecid, const MonOccupancyDat *item, MonRunIOV *iov) noexcept(false)
oracle::occi::ResultSet ResultSet
void setEventsOverHighThreshold(int events)
char data[epos_bytes_allocation]