35 this->checkConnection();
38 m_writeStmt = m_conn->createStatement();
39 m_writeStmt->setSQL(
"INSERT INTO cali_crystal_intercal_dat (iov_id, logic_id, " 40 "cali, cali_rms, num_events, task_status) " 41 "VALUES (:iov_id, :logic_id, " 43 }
catch (SQLException &
e) {
44 throw(std::runtime_error(
"CaliCrystalIntercalDat::prepareWrite(): "+e.getMessage()));
53 this->checkConnection();
56 int iovID = iov->fetchID();
57 if (!iovID) {
throw(std::runtime_error(
"CaliCrystalIntercalDat::writeDB: IOV not in DB")); }
59 int logicID = ecid->getLogicID();
60 if (!logicID) {
throw(std::runtime_error(
"CaliCrystalIntercalDat::writeDB: Bad EcalLogicID")); }
63 m_writeStmt->setInt(1, iovID);
64 m_writeStmt->setInt(2, logicID);
66 m_writeStmt->setFloat(3, item->getCali() );
67 m_writeStmt->setFloat(4, item->getCaliRMS() );
68 m_writeStmt->setInt(5, item->getNumEvents() );
69 m_writeStmt->setInt(6, item->getTaskStatus() );
71 m_writeStmt->executeUpdate();
72 }
catch (SQLException &
e) {
73 throw(std::runtime_error(
"CaliCrystalIntercalDat::writeDB(): "+e.getMessage()));
82 this->checkConnection();
85 iov->setConnection(m_env, m_conn);
86 int iovID = iov->fetchID();
94 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 95 "d.cali, d.cali_rms, d.num_events, d.task_status " 96 "FROM channelview cv JOIN cali_crystal_intercal_dat d " 97 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 98 "WHERE d.iov_id = :iov_id");
99 m_readStmt->setInt(1, iovID);
100 ResultSet* rset = m_readStmt->executeQuery();
102 std::pair< EcalLogicID, CaliCrystalIntercalDat >
p;
104 while(rset->next()) {
112 dat.
setCali( rset->getFloat(7) );
120 }
catch (SQLException &
e) {
121 throw(std::runtime_error(
"CaliCrystalIntercalDat::fetchData(): "+e.getMessage()));
128 this->checkConnection();
129 this->checkPrepare();
131 int iovID = iov->fetchID();
132 if (!iovID) {
throw(std::runtime_error(
"CaliCrystalIntercalDat::writeArrayDB: IOV not in DB")); }
135 int nrows=
data->size();
136 int*
ids=
new int[nrows];
137 int* iovid_vec=
new int[nrows];
138 float*
xx=
new float[nrows];
139 float*
yy=
new float[nrows];
140 int*
tt=
new int[nrows];
141 int* st=
new int[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* tt_len=
new ub2[nrows];
148 ub2* st_len=
new ub2[nrows];
153 typedef map< EcalLogicID, CaliCrystalIntercalDat >::const_iterator CI;
154 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
155 channel = &(
p->first);
157 if (!logicID) {
throw(std::runtime_error(
"CaliCrystalIntercalDat::writeArrayDB: Bad EcalLogicID")); }
159 iovid_vec[
count]=iovID;
161 dataitem = &(
p->second);
189 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
190 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
191 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
192 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
193 m_writeStmt->setDataBuffer(5, (dvoid*)tt, OCCIINT ,
sizeof(tt[0]), tt_len );
194 m_writeStmt->setDataBuffer(6, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
197 m_writeStmt->executeArrayUpdate(nrows);
215 }
catch (SQLException &
e) {
216 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB(): "+e.getMessage()));
~CaliCrystalIntercalDat()
bool getTaskStatus() const
void fetchData(std::map< EcalLogicID, CaliCrystalIntercalDat > *fillVec, CaliIOV *iov) noexcept(false)
void writeArrayDB(const std::map< EcalLogicID, CaliCrystalIntercalDat > *data, CaliIOV *iov) noexcept(false)
void prepareWrite() noexcept(false)
void writeDB(const EcalLogicID *ecid, const CaliCrystalIntercalDat *item, CaliIOV *iov) noexcept(false)
char data[epos_bytes_allocation]
void setTaskStatus(bool s)