10 using namespace oracle::occi;
35 throw(std::runtime_error)
37 this->checkConnection();
40 m_writeStmt = m_conn->createStatement();
41 m_writeStmt->setSQL(
"INSERT INTO mon_pn_ped_dat (iov_id, logic_id, "
42 "ped_mean_g1, ped_rms_g1, ped_mean_g16, ped_rms_g16, task_status) "
43 "VALUES (:iov_id, :logic_id, "
44 ":3, :4, :5, :6, :7)");
46 throw(std::runtime_error(
"MonPNPedDat::prepareWrite(): "+e.getMessage()));
53 throw(std::runtime_error)
55 this->checkConnection();
58 int iovID =
iov->fetchID();
59 if (!iovID) {
throw(std::runtime_error(
"MonPNPedDat::writeDB: IOV not in DB")); }
61 int logicID = ecid->getLogicID();
62 if (!logicID) {
throw(std::runtime_error(
"MonPNPedDat::writeDB: Bad EcalLogicID")); }
65 m_writeStmt->setInt(1, iovID);
66 m_writeStmt->setInt(2, logicID);
68 m_writeStmt->setFloat(3, item->getPedMeanG1() );
69 m_writeStmt->setFloat(4, item->getPedRMSG1() );
70 m_writeStmt->setFloat(5, item->getPedMeanG16() );
71 m_writeStmt->setFloat(6, item->getPedRMSG16() );
72 m_writeStmt->setInt(7, item->getTaskStatus() );
74 m_writeStmt->executeUpdate();
76 throw(std::runtime_error(
"MonPNPedDat::writeDB(): "+e.getMessage()));
83 throw(std::runtime_error)
85 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.ped_mean_g1,d.ped_rms_g1, d.ped_mean_g16, d.ped_rms_g16, d.task_status "
99 "FROM channelview cv JOIN mon_pn_ped_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, MonPNPedDat >
p;
107 while(rset->next()) {
124 throw(std::runtime_error(
"MonPNPedDat::fetchData(): "+e.getMessage()));
129 throw(std::runtime_error)
131 this->checkConnection();
132 this->checkPrepare();
134 int iovID =
iov->fetchID();
135 if (!iovID) {
throw(std::runtime_error(
"MonPNPedDat::writeArrayDB: IOV not in DB")); }
138 int nrows=
data->size();
139 int* ids=
new int[nrows];
140 int* iovid_vec=
new int[nrows];
141 float* xx=
new float[nrows];
142 float* yy=
new float[nrows];
143 float* zz=
new float[nrows];
144 float* ww=
new float[nrows];
145 int* st=
new int[nrows];
147 ub2* ids_len=
new ub2[nrows];
148 ub2* iov_len=
new ub2[nrows];
149 ub2* x_len=
new ub2[nrows];
150 ub2* y_len=
new ub2[nrows];
151 ub2* z_len=
new ub2[nrows];
152 ub2* w_len=
new ub2[nrows];
154 ub2* st_len=
new ub2[nrows];
159 typedef map< EcalLogicID, MonPNPedDat >::const_iterator CI;
160 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
161 channel = &(
p->first);
163 if (!logicID) {
throw(std::runtime_error(
"MonPNPedDat::writeArrayDB: Bad EcalLogicID")); }
165 iovid_vec[
count]=iovID;
167 dataitem = &(
p->second);
200 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
201 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
202 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
203 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
204 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
205 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT ,
sizeof(ww[0]), w_len );
206 m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
209 m_writeStmt->executeArrayUpdate(nrows);
232 throw(std::runtime_error(
"MonPNPedDat::writeArrayDB(): "+e.getMessage()));
float getPedRMSG1() const
void setPedRMSG16(float mean)
void writeDB(const EcalLogicID *ecid, const MonPNPedDat *item, MonRunIOV *iov)
void setPedRMSG1(float mean)
void setPedMeanG1(float mean)
oracle::occi::SQLException SQLException
void setPedMeanG16(float mean)
float getPedRMSG16() const
oracle::occi::ResultSet ResultSet
float getPedMeanG16() const
bool getTaskStatus() const
float getPedMeanG1() const
void writeArrayDB(const std::map< EcalLogicID, MonPNPedDat > *data, MonRunIOV *iov)
void setTaskStatus(bool status)
void fetchData(std::map< EcalLogicID, MonPNPedDat > *fillVec, MonRunIOV *iov)