15 m_writeStmt =
nullptr;
35 this->checkConnection();
38 m_writeStmt = m_conn->createStatement();
40 "INSERT INTO dcu_ccs_dat (iov_id, logic_id, " 41 "m1_vdd1, m2_vdd1, m1_vdd2, m2_vdd2, m1_vinj, " 42 "m2_vinj, m1_vcc, m2_vcc, m1_dcutemp, m2_dcutemp, " 43 "ccstemplow, ccstemphigh) " 44 "VALUES (:iov_id, :logic_id, " 45 ":m1_vdd1, :m2_vdd1, :m1_vdd2, :m2_vdd2, :m1_vinj, " 46 ":m2_vinj, :m1_vcc, :m2_vcc, :m1_dcutemp, " 47 ":m2_dcutemp, :ccstemplow, :ccstemphigh)");
48 }
catch (SQLException&
e) {
49 throw(std::runtime_error(
"DCUCCSDat::prepareWrite(): " +
e.getMessage()));
54 this->checkConnection();
57 int iovID = iov->fetchID();
59 throw(std::runtime_error(
"DCUCCSDat::writeDB: IOV not in DB"));
62 int logicID = ecid->getLogicID();
64 throw(std::runtime_error(
"DCUCCSDat::writeDB: Bad EcalLogicID"));
68 m_writeStmt->setInt(1, iovID);
69 m_writeStmt->setInt(2, logicID);
71 m_writeStmt->setFloat(3,
item->getM1VDD1());
72 m_writeStmt->setFloat(4,
item->getM2VDD1());
73 m_writeStmt->setFloat(5,
item->getM1VDD2());
74 m_writeStmt->setFloat(6,
item->getM2VDD2());
75 m_writeStmt->setFloat(7,
item->getM1Vinj());
76 m_writeStmt->setFloat(8,
item->getM2Vinj());
77 m_writeStmt->setFloat(9,
item->getM1Vcc());
78 m_writeStmt->setFloat(10,
item->getM2Vcc());
79 m_writeStmt->setFloat(11,
item->getM1DCUTemp());
80 m_writeStmt->setFloat(12,
item->getM2DCUTemp());
81 m_writeStmt->setFloat(13,
item->getCCSTempLow());
82 m_writeStmt->setFloat(14,
item->getCCSTempHigh());
84 m_writeStmt->executeUpdate();
85 }
catch (SQLException&
e) {
86 throw(std::runtime_error(
"DCUCCSDat::writeDB(): " +
e.getMessage()));
91 this->checkConnection();
94 iov->setConnection(m_env, m_conn);
95 int iovID = iov->fetchID();
103 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, " 105 "d.m1_vdd1, d.m2_vdd1, d.m1_vdd2, d.m2_vdd2, " 106 "d.m1_vinj, d.m2_vinj, " 107 "d.m1_vcc, d.m2_vcc, " 108 "d.m1_dcutemp, d.m2_dcutemp, " 109 "d.ccstemplow, d.ccstemphigh " 110 "FROM channelview cv JOIN dcu_ccs_dat d " 111 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 112 "WHERE d.iov_id = :iov_id");
113 m_readStmt->setInt(1, iovID);
114 ResultSet* rset = m_readStmt->executeQuery();
116 std::pair<EcalLogicID, DCUCCSDat>
p;
118 while (rset->next()) {
126 dat.
setVDD(rset->getFloat(7), rset->getFloat(9), rset->getFloat(8), rset->getFloat(10));
127 dat.
setVinj(rset->getFloat(11), rset->getFloat(12));
128 dat.
setVcc(rset->getFloat(13), rset->getFloat(14));
129 dat.
setDCUTemp(rset->getFloat(15), rset->getFloat(16));
130 dat.
setCCSTemp(rset->getFloat(17), rset->getFloat(18));
134 }
catch (SQLException&
e) {
135 throw(std::runtime_error(
"DCUCCSDat::fetchData(): " +
e.getMessage()));
140 this->checkConnection();
141 this->checkPrepare();
143 int iovID = iov->fetchID();
145 throw(std::runtime_error(
"DCUCCSDat::writeArrayDB: IOV not in DB"));
148 int nrows =
data->size();
149 int* ids =
new int[nrows];
150 int* iovid_vec =
new int[nrows];
151 float*
x1 =
new float[nrows];
152 float*
x2 =
new float[nrows];
153 float* x3 =
new float[nrows];
154 float* x4 =
new float[nrows];
155 float* x5 =
new float[nrows];
156 float* x6 =
new float[nrows];
157 float* x7 =
new float[nrows];
158 float* x8 =
new float[nrows];
159 float* x9 =
new float[nrows];
160 float* xa =
new float[nrows];
161 float* xb =
new float[nrows];
162 float* xc =
new float[nrows];
164 ub2* ids_len =
new ub2[nrows];
165 ub2* iov_len =
new ub2[nrows];
166 ub2* x_len =
new ub2[nrows];
171 typedef map<EcalLogicID, DCUCCSDat>::const_iterator CI;
172 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
173 channel = &(
p->first);
176 throw(std::runtime_error(
"DCUCCSDat::writeArrayDB: Bad EcalLogicID"));
178 ids[
count] = logicID;
179 iovid_vec[
count] = iovID;
181 dataitem = &(
p->second);
205 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
206 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
207 m_writeStmt->setDataBuffer(3, (dvoid*)
x1, OCCIFLOAT,
sizeof(
x1[0]), x_len);
208 m_writeStmt->setDataBuffer(3, (dvoid*)
x2, OCCIFLOAT,
sizeof(
x1[0]), x_len);
209 m_writeStmt->setDataBuffer(3, (dvoid*)x3, OCCIFLOAT,
sizeof(
x1[0]), x_len);
210 m_writeStmt->setDataBuffer(3, (dvoid*)x4, OCCIFLOAT,
sizeof(
x1[0]), x_len);
211 m_writeStmt->setDataBuffer(3, (dvoid*)x5, OCCIFLOAT,
sizeof(
x1[0]), x_len);
212 m_writeStmt->setDataBuffer(3, (dvoid*)x6, OCCIFLOAT,
sizeof(
x1[0]), x_len);
213 m_writeStmt->setDataBuffer(3, (dvoid*)x7, OCCIFLOAT,
sizeof(
x1[0]), x_len);
214 m_writeStmt->setDataBuffer(3, (dvoid*)x8, OCCIFLOAT,
sizeof(
x1[0]), x_len);
215 m_writeStmt->setDataBuffer(3, (dvoid*)x9, OCCIFLOAT,
sizeof(
x1[0]), x_len);
216 m_writeStmt->setDataBuffer(3, (dvoid*)xa, OCCIFLOAT,
sizeof(
x1[0]), x_len);
217 m_writeStmt->setDataBuffer(3, (dvoid*)xb, OCCIFLOAT,
sizeof(
x1[0]), x_len);
218 m_writeStmt->setDataBuffer(3, (dvoid*)xc, OCCIFLOAT,
sizeof(
x1[0]), x_len);
220 m_writeStmt->executeArrayUpdate(nrows);
241 }
catch (SQLException&
e) {
242 throw(std::runtime_error(
"DCUCCSDat::writeArrayDB(): " +
e.getMessage()));
void setVinj(float v1, float v2)
void setVDD(float m1vdd1, float m1vdd2, float m2vdd1, float m2vdd2)
float getM2DCUTemp() const
void writeDB(const EcalLogicID *ecid, const DCUCCSDat *item, DCUIOV *iov) noexcept(false)
void writeArrayDB(const std::map< EcalLogicID, DCUCCSDat > *data, DCUIOV *iov) noexcept(false)
void setCCSTemp(float low, float high)
void setVcc(float v1, float v2)
void setDCUTemp(float t1, float t2)
char data[epos_bytes_allocation]
float getCCSTempHigh() const
void prepareWrite() noexcept(false) override
float getCCSTempLow() const
void fetchData(std::map< EcalLogicID, DCUCCSDat > *fillVec, DCUIOV *iov) noexcept(false)
float getM1DCUTemp() const