14 m_writeStmt =
nullptr;
36 this->checkConnection();
39 m_writeStmt = m_conn->createStatement();
40 m_writeStmt->setSQL(
"INSERT INTO mon_laser_green_dat (iov_id, logic_id, " 41 "apd_mean, apd_rms, apd_over_pn_mean, apd_over_pn_rms, task_status) " 42 "VALUES (:iov_id, :logic_id, " 43 ":apd_mean, :apd_rms, :apd_over_pn_mean, :apd_over_pn_rms, :task_status)");
44 }
catch (SQLException &
e) {
45 throw(std::runtime_error(
std::string(
"MonLaserGreenDat::prepareWrite(): ")+getOraMessage(&e)));
54 this->checkConnection();
57 int iovID = iov->fetchID();
58 if (!iovID) {
throw(std::runtime_error(
"MonLaserGreenDat::writeDB: IOV not in DB")); }
60 int logicID = ecid->getLogicID();
61 if (!logicID) {
throw(std::runtime_error(
"MonLaserGreenDat::writeDB: Bad EcalLogicID")); }
64 m_writeStmt->setInt(1, iovID);
65 m_writeStmt->setInt(2, logicID);
67 m_writeStmt->setFloat(3, item->getAPDMean() );
68 m_writeStmt->setFloat(4, item->getAPDRMS() );
69 m_writeStmt->setFloat(5, item->getAPDOverPNMean() );
70 m_writeStmt->setFloat(6, item->getAPDOverPNRMS() );
71 m_writeStmt->setInt(7, item->getTaskStatus() );
73 m_writeStmt->executeUpdate();
74 }
catch (SQLException &
e) {
75 throw(std::runtime_error(
std::string(
"MonLaserGreenDat::writeDB(): ")+getOraMessage(&e)));
84 this->checkConnection();
88 iov->setConnection(m_env, m_conn);
89 int iovID = iov->fetchID();
97 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 98 "d.apd_mean, d.apd_rms, d.apd_over_pn_mean, d.apd_over_pn_rms, d.task_status " 99 "FROM channelview cv JOIN mon_laser_green_dat d " 100 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 101 "WHERE d.iov_id = :iov_id");
102 m_readStmt->setInt(1, iovID);
103 ResultSet* rset = m_readStmt->executeQuery();
105 std::pair< EcalLogicID, MonLaserGreenDat >
p;
107 while(rset->next()) {
113 getOraString(rset,6));
125 }
catch (SQLException &
e) {
126 throw(std::runtime_error(
std::string(
"MonLaserGreenDat::fetchData(): ")+getOraMessage(&e)));
133 this->checkConnection();
134 this->checkPrepare();
136 int iovID = iov->fetchID();
137 if (!iovID) {
throw(std::runtime_error(
"MonLaserGreenDat::writeArrayDB: IOV not in DB")); }
140 int nrows=
data->size();
141 int*
ids=
new int[nrows];
142 int* iovid_vec=
new int[nrows];
143 float*
xx=
new float[nrows];
144 float*
yy=
new float[nrows];
145 float*
zz=
new float[nrows];
146 float* ww=
new float[nrows];
147 int* st=
new int[nrows];
149 ub2* ids_len=
new ub2[nrows];
150 ub2* iov_len=
new ub2[nrows];
151 ub2* x_len=
new ub2[nrows];
152 ub2* y_len=
new ub2[nrows];
153 ub2* z_len=
new ub2[nrows];
154 ub2* w_len=
new ub2[nrows];
155 ub2* st_len=
new ub2[nrows];
160 typedef map< EcalLogicID, MonLaserGreenDat >::const_iterator CI;
161 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
162 channel = &(
p->first);
164 if (!logicID) {
throw(std::runtime_error(
"MonLaserGreenDat::writeArrayDB: Bad EcalLogicID")); }
166 iovid_vec[
count]=iovID;
168 dataitem = &(
p->second);
199 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
200 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
201 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
202 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
203 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
204 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT ,
sizeof(ww[0]), w_len );
205 m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
208 m_writeStmt->executeArrayUpdate(nrows);
228 }
catch (SQLException &
e) {
229 throw(std::runtime_error(
std::string(
"MonLaserGreenDat::writeArrayDB(): ")+getOraMessage(&e)));
void prepareWrite() noexcept(false) override
float getAPDOverPNMean() const
~MonLaserGreenDat() override
void writeArrayDB(const std::map< EcalLogicID, MonLaserGreenDat > *data, MonRunIOV *iov) noexcept(false)
bool getTaskStatus() const
void setTaskStatus(bool status)
void setAPDMean(float mean)
void setAPDRMS(float rms)
void setAPDOverPNRMS(float rms)
void fetchData(std::map< EcalLogicID, MonLaserGreenDat > *fillMap, MonRunIOV *iov) noexcept(false)
void setAPDOverPNMean(float mean)
char data[epos_bytes_allocation]
void writeDB(const EcalLogicID *ecid, const MonLaserGreenDat *item, MonRunIOV *iov) noexcept(false)
float getAPDOverPNRMS() const