CMS 3D CMS Logo

DCUCCSDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
4 
8 
9 using namespace std;
10 using namespace oracle::occi;
11 
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_m1_vdd1 = 0;
19  m_m2_vdd1 = 0;
20  m_m1_vdd2 = 0;
21  m_m2_vdd2 = 0;
22  m_m1_vinj = 0;
23  m_m2_vinj = 0;
24  m_m1_vcc = 0;
25  m_m2_vcc = 0;
26  m_m1_dcutemp = 0;
27  m_m2_dcutemp = 0;
28  m_ccstemplow = 0;
29  m_ccstemphigh = 0;
30 }
31 
33 
34 void DCUCCSDat::prepareWrite() noexcept(false) {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL(
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()));
50  }
51 }
52 
53 void DCUCCSDat::writeDB(const EcalLogicID* ecid, const DCUCCSDat* item, DCUIOV* iov) noexcept(false) {
54  this->checkConnection();
55  this->checkPrepare();
56 
57  int iovID = iov->fetchID();
58  if (!iovID) {
59  throw(std::runtime_error("DCUCCSDat::writeDB: IOV not in DB"));
60  }
61 
62  int logicID = ecid->getLogicID();
63  if (!logicID) {
64  throw(std::runtime_error("DCUCCSDat::writeDB: Bad EcalLogicID"));
65  }
66 
67  try {
68  m_writeStmt->setInt(1, iovID);
69  m_writeStmt->setInt(2, logicID);
70 
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());
83 
84  m_writeStmt->executeUpdate();
85  } catch (SQLException& e) {
86  throw(std::runtime_error("DCUCCSDat::writeDB(): " + e.getMessage()));
87  }
88 }
89 
90 void DCUCCSDat::fetchData(std::map<EcalLogicID, DCUCCSDat>* fillMap, DCUIOV* iov) noexcept(false) {
91  this->checkConnection();
92  fillMap->clear();
93 
94  iov->setConnection(m_env, m_conn);
95  int iovID = iov->fetchID();
96  if (!iovID) {
97  // throw(std::runtime_error("DCUCCSDat::writeDB: IOV not in DB"));
98  return;
99  }
100 
101  try {
102  m_readStmt->setSQL(
103  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, "
104  "cv.maps_to, "
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();
115 
116  std::pair<EcalLogicID, DCUCCSDat> p;
117  DCUCCSDat dat;
118  while (rset->next()) {
119  p.first = EcalLogicID(rset->getString(1), // name
120  rset->getInt(2), // logic_id
121  rset->getInt(3), // id1
122  rset->getInt(4), // id2
123  rset->getInt(5), // id3
124  rset->getString(6)); // maps_to
125 
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));
131  p.second = dat;
132  fillMap->insert(p);
133  }
134  } catch (SQLException& e) {
135  throw(std::runtime_error("DCUCCSDat::fetchData(): " + e.getMessage()));
136  }
137 }
138 
139 void DCUCCSDat::writeArrayDB(const std::map<EcalLogicID, DCUCCSDat>* data, DCUIOV* iov) noexcept(false) {
140  this->checkConnection();
141  this->checkPrepare();
142 
143  int iovID = iov->fetchID();
144  if (!iovID) {
145  throw(std::runtime_error("DCUCCSDat::writeArrayDB: IOV not in DB"));
146  }
147 
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];
163 
164  ub2* ids_len = new ub2[nrows];
165  ub2* iov_len = new ub2[nrows];
166  ub2* x_len = new ub2[nrows];
167 
168  const EcalLogicID* channel;
169  const DCUCCSDat* dataitem;
170  int count = 0;
171  typedef map<EcalLogicID, DCUCCSDat>::const_iterator CI;
172  for (CI p = data->begin(); p != data->end(); ++p) {
173  channel = &(p->first);
174  int logicID = channel->getLogicID();
175  if (!logicID) {
176  throw(std::runtime_error("DCUCCSDat::writeArrayDB: Bad EcalLogicID"));
177  }
178  ids[count] = logicID;
179  iovid_vec[count] = iovID;
180 
181  dataitem = &(p->second);
182 
183  x1[count] = dataitem->getM1VDD1();
184  x2[count] = dataitem->getM2VDD1();
185  x3[count] = dataitem->getM1VDD2();
186  x4[count] = dataitem->getM2VDD2();
187  x5[count] = dataitem->getM1Vinj();
188  x6[count] = dataitem->getM2Vinj();
189  x7[count] = dataitem->getM1Vcc();
190  x8[count] = dataitem->getM2Vcc();
191  x9[count] = dataitem->getM1DCUTemp();
192  xa[count] = dataitem->getM2DCUTemp();
193  xb[count] = dataitem->getCCSTempLow();
194  xc[count] = dataitem->getCCSTempHigh();
195 
196  ids_len[count] = sizeof(ids[count]);
197  iov_len[count] = sizeof(iovid_vec[count]);
198 
199  x_len[count] = sizeof(x1[count]);
200 
201  count++;
202  }
203 
204  try {
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);
219 
220  m_writeStmt->executeArrayUpdate(nrows);
221 
222  delete[] ids;
223  delete[] iovid_vec;
224  delete[] x1;
225  delete[] x2;
226  delete[] x3;
227  delete[] x4;
228  delete[] x5;
229  delete[] x6;
230  delete[] x7;
231  delete[] x8;
232  delete[] x9;
233  delete[] xa;
234  delete[] xb;
235  delete[] xc;
236 
237  delete[] ids_len;
238  delete[] iov_len;
239  delete[] x_len;
240 
241  } catch (SQLException& e) {
242  throw(std::runtime_error("DCUCCSDat::writeArrayDB(): " + e.getMessage()));
243  }
244 }
DCUCCSDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: DCUCCSDat.cc:34
funct::false
false
Definition: Factorize.h:34
DCUCCSDat::getCCSTempHigh
float getCCSTempHigh() const
Definition: DCUCCSDat.h:80
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
std::data
constexpr auto data(C &c) -> decltype(c.data())
Definition: cuda_cxx17.h:40
RunIOV.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
DCUCCSDat::setVDD
void setVDD(float m1vdd1, float m1vdd2, float m2vdd1, float m2vdd2)
Definition: DCUCCSDat.h:25
DCUIOV
Definition: DCUIOV.h:13
DCUCCSDat::setVcc
void setVcc(float v1, float v2)
Definition: DCUCCSDat.h:39
DCUCCSDat::getM1DCUTemp
float getM1DCUTemp() const
Definition: DCUCCSDat.h:77
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
DCUCCSDat::getM1Vcc
float getM1Vcc() const
Definition: DCUCCSDat.h:75
oracle::occi
Definition: ConnectionManager.h:7
DCUCCSDat::getM2Vcc
float getM2Vcc() const
Definition: DCUCCSDat.h:76
EcalLogicID
Definition: EcalLogicID.h:7
DCUCCSDat::getM2VDD2
float getM2VDD2() const
Definition: DCUCCSDat.h:72
DCUCCSDat::writeArrayDB
void writeArrayDB(const std::map< EcalLogicID, DCUCCSDat > *data, DCUIOV *iov) noexcept(false)
Definition: DCUCCSDat.cc:139
DCUCCSDat::setVinj
void setVinj(float v1, float v2)
Definition: DCUCCSDat.h:33
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
DCUCCSDat::getM1VDD2
float getM1VDD2() const
Definition: DCUCCSDat.h:70
DCUCCSDat::setCCSTemp
void setCCSTemp(float low, float high)
Definition: DCUCCSDat.h:51
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
DCUCCSDat::getM1VDD1
float getM1VDD1() const
Definition: DCUCCSDat.h:69
DCUCCSDat::getM2Vinj
float getM2Vinj() const
Definition: DCUCCSDat.h:74
DCUCCSDat::~DCUCCSDat
~DCUCCSDat() override
Definition: DCUCCSDat.cc:32
DCUCCSDat::getM2VDD1
float getM2VDD1() const
Definition: DCUCCSDat.h:71
std
Definition: JetResolutionObject.h:76
DCUCCSDat::DCUCCSDat
DCUCCSDat()
Definition: DCUCCSDat.cc:12
DCUCCSDat::getM1Vinj
float getM1Vinj() const
Definition: DCUCCSDat.h:73
DCUCCSDat::fetchData
void fetchData(std::map< EcalLogicID, DCUCCSDat > *fillVec, DCUIOV *iov) noexcept(false)
Definition: DCUCCSDat.cc:90
DCUCCSDat::getCCSTempLow
float getCCSTempLow() const
Definition: DCUCCSDat.h:79
DCUCCSDat.h
Oracle.h
DCUCCSDat::getM2DCUTemp
float getM2DCUTemp() const
Definition: DCUCCSDat.h:78
RunTag.h
DCUCCSDat::writeDB
void writeDB(const EcalLogicID *ecid, const DCUCCSDat *item, DCUIOV *iov) noexcept(false)
Definition: DCUCCSDat.cc:53
DCUCCSDat::setDCUTemp
void setDCUTemp(float t1, float t2)
Definition: DCUCCSDat.h:45
DCUCCSDat
Definition: DCUCCSDat.h:12
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37