8 using namespace oracle::occi;
17 m_pulseHeightMean = 0;
32 throw(std::runtime_error)
34 this->checkConnection();
37 m_writeStmt = m_conn->createStatement();
38 m_writeStmt->setSQL(
"INSERT INTO mon_laser_pulse_dat (iov_id, logic_id, "
39 "pulse_height_mean, pulse_height_rms, pulse_width_mean, pulse_width_rms) "
40 "VALUES (:iov_id, :logic_id, "
43 throw(std::runtime_error(
"MonLaserPulseDat::prepareWrite(): "+e.getMessage()));
50 throw(std::runtime_error)
52 this->checkConnection();
55 int iovID =
iov->fetchID();
56 if (!iovID) {
throw(std::runtime_error(
"MonLaserPulseDat::writeDB: IOV not in DB")); }
58 int logicID = ecid->getLogicID();
59 if (!logicID) {
throw(std::runtime_error(
"MonLaserPulseDat::writeDB: Bad EcalLogicID")); }
62 m_writeStmt->setInt(1, iovID);
63 m_writeStmt->setInt(2, logicID);
65 m_writeStmt->setFloat(3, item->getPulseHeightMean() );
66 m_writeStmt->setFloat(4, item->getPulseHeightRMS() );
67 m_writeStmt->setFloat(5, item->getPulseWidthMean() );
68 m_writeStmt->setFloat(6, item->getPulseWidthRMS() );
70 m_writeStmt->executeUpdate();
72 throw(std::runtime_error(
"MonLaserPulseDat::writeDB(): "+e.getMessage()));
79 throw(std::runtime_error)
81 this->checkConnection();
84 iov->setConnection(m_env, m_conn);
85 int iovID =
iov->fetchID();
93 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
94 "d.pulse_height_mean, d.pulse_height_rms, d.pulse_width_mean, d.pulse_width_rms "
95 "FROM channelview cv JOIN mon_laser_pulse_dat d "
96 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
97 "WHERE d.iov_id = :iov_id");
98 m_readStmt->setInt(1, iovID);
99 ResultSet* rset = m_readStmt->executeQuery();
101 std::pair< EcalLogicID, MonLaserPulseDat >
p;
103 while(rset->next()) {
120 throw(std::runtime_error(
"MonLaserPulseDat::fetchData(): "+e.getMessage()));
125 throw(std::runtime_error)
127 this->checkConnection();
128 this->checkPrepare();
130 int iovID =
iov->fetchID();
131 if (!iovID) {
throw(std::runtime_error(
"MonLaserPulseDat::writeArrayDB: IOV not in DB")); }
134 int nrows=
data->size();
135 int* ids=
new int[nrows];
136 int* iovid_vec=
new int[nrows];
137 float* xx=
new float[nrows];
138 float* yy=
new float[nrows];
139 float* zz=
new float[nrows];
140 float* ww=
new float[nrows];
143 ub2* ids_len=
new ub2[nrows];
144 ub2* iov_len=
new ub2[nrows];
145 ub2* x_len=
new ub2[nrows];
146 ub2* y_len=
new ub2[nrows];
147 ub2* z_len=
new ub2[nrows];
148 ub2* w_len=
new ub2[nrows];
154 typedef map< EcalLogicID, MonLaserPulseDat >::const_iterator CI;
155 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
156 channel = &(
p->first);
158 if (!logicID) {
throw(std::runtime_error(
"MonLaserPulseDat::writeArrayDB: Bad EcalLogicID")); }
160 iovid_vec[
count]=iovID;
162 dataitem = &(
p->second);
188 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
189 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
190 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
191 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
192 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
193 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT ,
sizeof(ww[0]), w_len );
196 m_writeStmt->executeArrayUpdate(nrows);
215 throw(std::runtime_error(
"MonLaserPulseDat::writeArrayDB(): "+e.getMessage()));
float getPulseHeightRMS() const
void setPulseWidthMean(float p)
void setPulseHeightRMS(float p)
oracle::occi::SQLException SQLException
float getPulseHeightMean() const
void setPulseWidthRMS(float p)
void fetchData(std::map< EcalLogicID, MonLaserPulseDat > *fillMap, MonRunIOV *iov)
void writeArrayDB(const std::map< EcalLogicID, MonLaserPulseDat > *data, MonRunIOV *iov)
void writeDB(const EcalLogicID *ecid, const MonLaserPulseDat *item, MonRunIOV *iov)
oracle::occi::ResultSet ResultSet
float getPulseWidthMean() const
char data[epos_bytes_allocation]
void setPulseHeightMean(float p)
float getPulseWidthRMS() const