10 using namespace oracle::occi;
37 throw(std::runtime_error)
39 this->checkConnection();
42 m_writeStmt = m_conn->createStatement();
43 m_writeStmt->setSQL(
"INSERT INTO mon_test_pulse_dat (iov_id, logic_id, "
44 "adc_mean_g1, adc_rms_g1, adc_mean_g6, adc_rms_g6, adc_mean_g12, adc_rms_g12, task_status) "
45 "VALUES (:iov_id, :logic_id, "
46 ":adc_mean_g1, :adc_rms_g1, :adc_rms_g6, :adc_rms_g6, :adc_mean_g12, :adc_rms_g12, :task_status)");
48 throw(std::runtime_error(
"MonTestPulseDat::prepareWrite(): "+e.getMessage()));
55 throw(std::runtime_error)
57 this->checkConnection();
60 int iovID =
iov->fetchID();
61 if (!iovID) {
throw(std::runtime_error(
"MonTestPulseDat::writeDB: IOV not in DB")); }
63 int logicID = ecid->getLogicID();
64 if (!logicID) {
throw(std::runtime_error(
"MonTestPulseDat::writeDB: Bad EcalLogicID")); }
67 m_writeStmt->setInt(1, iovID);
68 m_writeStmt->setInt(2, logicID);
69 m_writeStmt->setFloat(3, item->getADCMeanG1() );
70 m_writeStmt->setFloat(4, item->getADCRMSG1() );
71 m_writeStmt->setFloat(5, item->getADCMeanG6() );
72 m_writeStmt->setFloat(6, item->getADCRMSG6() );
73 m_writeStmt->setFloat(7, item->getADCMeanG12() );
74 m_writeStmt->setFloat(8, item->getADCRMSG12() );
75 m_writeStmt->setInt(9, item->getTaskStatus() );
77 m_writeStmt->executeUpdate();
79 throw(std::runtime_error(
"MonTestPulseDat::writeDB(): "+e.getMessage()));
86 throw(std::runtime_error)
88 this->checkConnection();
91 iov->setConnection(m_env, m_conn);
92 int iovID =
iov->fetchID();
100 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
101 "d.adc_mean_g1, d.adc_rms_g1, d.adc_mean_g6, d.adc_rms_g6, d.adc_mean_g12, d.adc_rms_g12, d.task_status "
102 "FROM channelview cv JOIN mon_test_pulse_dat d "
103 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
104 "WHERE d.iov_id = :iov_id");
105 m_readStmt->setInt(1, iovID);
106 ResultSet* rset = m_readStmt->executeQuery();
108 std::pair< EcalLogicID, MonTestPulseDat >
p;
110 while(rset->next()) {
130 throw(std::runtime_error(
"MonTestPulseDat::fetchData(): "+e.getMessage()));
135 throw(std::runtime_error)
137 this->checkConnection();
138 this->checkPrepare();
140 int iovID =
iov->fetchID();
141 if (!iovID) {
throw(std::runtime_error(
"MonTestPulseDat::writeArrayDB: IOV not in DB")); }
144 int nrows=
data->size();
145 int* ids=
new int[nrows];
146 int* iovid_vec=
new int[nrows];
147 float* xx=
new float[nrows];
148 float* yy=
new float[nrows];
149 float* zz=
new float[nrows];
150 float* ww=
new float[nrows];
151 float* uu=
new float[nrows];
152 float*
tt=
new float[nrows];
153 int* st=
new int[nrows];
155 ub2* ids_len=
new ub2[nrows];
156 ub2* iov_len=
new ub2[nrows];
157 ub2* x_len=
new ub2[nrows];
158 ub2* y_len=
new ub2[nrows];
159 ub2* z_len=
new ub2[nrows];
160 ub2* w_len=
new ub2[nrows];
161 ub2* u_len=
new ub2[nrows];
162 ub2* t_len=
new ub2[nrows];
163 ub2* st_len=
new ub2[nrows];
168 typedef map< EcalLogicID, MonTestPulseDat >::const_iterator CI;
169 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
170 channel = &(
p->first);
172 if (!logicID) {
throw(std::runtime_error(
"MonTestPulseDat::writeArrayDB: Bad EcalLogicID")); }
174 iovid_vec[
count]=iovID;
176 dataitem = &(
p->second);
213 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
214 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
215 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
216 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
217 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT ,
sizeof(zz[0]), z_len );
218 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT ,
sizeof(ww[0]), w_len );
219 m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIFLOAT ,
sizeof(uu[0]), u_len );
220 m_writeStmt->setDataBuffer(8, (dvoid*)tt, OCCIFLOAT ,
sizeof(tt[0]), t_len );
221 m_writeStmt->setDataBuffer(9, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
224 m_writeStmt->executeArrayUpdate(nrows);
249 throw(std::runtime_error(
"MonTestPulseDat::writeArrayDB(): "+e.getMessage()));
void setADCRMSG1(float rms)
float getADCMeanG6() const
void setADCMeanG1(float mean)
float getADCRMSG12() const
void setADCMeanG6(float mean)
oracle::occi::SQLException SQLException
void writeArrayDB(const std::map< EcalLogicID, MonTestPulseDat > *data, MonRunIOV *iov)
void setADCMeanG12(float mean)
void fetchData(std::map< EcalLogicID, MonTestPulseDat > *fillMap, MonRunIOV *iov)
void setTaskStatus(bool status)
float getADCRMSG1() const
void setADCRMSG12(float rms)
float getADCMeanG12() const
bool getTaskStatus() const
void setADCRMSG6(float rms)
oracle::occi::ResultSet ResultSet
void writeDB(const EcalLogicID *ecid, const MonTestPulseDat *item, MonRunIOV *iov)
float getADCRMSG6() const
float getADCMeanG1() const