10 using namespace oracle::occi;
32 throw(std::runtime_error)
34 this->checkConnection();
37 m_writeStmt = m_conn->createStatement();
38 m_writeStmt->setSQL(
"INSERT INTO dcu_capsule_temp_raw_dat (iov_id, logic_id, "
39 "capsule_temp_adc, capsule_temp_rms) "
40 "VALUES (:iov_id, :logic_id, "
43 throw(std::runtime_error(
"DCUCapsuleTempRawDat::prepareWrite(): "+e.getMessage()));
50 throw(std::runtime_error)
52 this->checkConnection();
55 int iovID =
iov->fetchID();
56 if (!iovID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeDB: IOV not in DB")); }
58 int logicID = ecid->getLogicID();
59 if (!logicID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeDB: Bad EcalLogicID")); }
62 m_writeStmt->setInt(1, iovID);
63 m_writeStmt->setInt(2, logicID);
65 m_writeStmt->setFloat(3, item->getCapsuleTempADC() );
66 m_writeStmt->setFloat(4, item->getCapsuleTempRMS() );
68 m_writeStmt->executeUpdate();
70 throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeDB(): "+e.getMessage()));
77 throw(std::runtime_error)
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.capsule_temp_adc, d.capsule_temp_rms "
93 "FROM channelview cv JOIN dcu_capsule_temp_raw_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, DCUCapsuleTempRawDat >
p;
101 while(rset->next()) {
116 throw(std::runtime_error(
"DCUCapsuleTempRawDat::fetchData(): "+e.getMessage()));
121 throw(std::runtime_error)
123 this->checkConnection();
124 this->checkPrepare();
126 int iovID =
iov->fetchID();
127 if (!iovID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeArrayDB: IOV not in DB")); }
130 int nrows=
data->size();
131 int* ids=
new int[nrows];
132 int* iovid_vec=
new int[nrows];
133 float* xx=
new float[nrows];
134 float* yy=
new float[nrows];
136 ub2* ids_len=
new ub2[nrows];
137 ub2* iov_len=
new ub2[nrows];
138 ub2* x_len=
new ub2[nrows];
139 ub2* y_len=
new ub2[nrows];
145 typedef map< EcalLogicID, DCUCapsuleTempRawDat >::const_iterator CI;
146 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
147 channel = &(
p->first);
149 if (!logicID) {
throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeArrayDB: Bad EcalLogicID")); }
151 iovid_vec[
count]=iovID;
153 dataitem = &(
p->second);
173 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
174 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
175 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
176 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
179 m_writeStmt->executeArrayUpdate(nrows);
192 throw(std::runtime_error(
"DCUCapsuleTempRawDat::writeArrayDB(): "+e.getMessage()));
float getCapsuleTempADC() const
void writeDB(const EcalLogicID *ecid, const DCUCapsuleTempRawDat *item, DCUIOV *iov)
float getCapsuleTempRMS() const
oracle::occi::SQLException SQLException
void fetchData(std::map< EcalLogicID, DCUCapsuleTempRawDat > *fillVec, DCUIOV *iov)
void writeArrayDB(const std::map< EcalLogicID, DCUCapsuleTempRawDat > *data, DCUIOV *iov)
oracle::occi::ResultSet ResultSet
void setCapsuleTempADC(float adc)
void setCapsuleTempRMS(float rms)