CMS 3D CMS Logo

FEConfigCokeDat.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  clear();
19 }
20 
22 
24  this->checkConnection();
25 
26  try {
27  m_writeStmt = m_conn->createStatement();
28  m_writeStmt->setSQL(
29  "INSERT INTO " + getTable() +
30  " (coke_conf_id, logic_id, "
31  " THRESHOLD, SUCC_EVENT_LIMIT, CUMUL_EVENT_LIMIT, SUCC_DETECT_ENABLE, CUMUL_DETECT_ENABLE, THD1_THRESHOLD, "
32  "SUCC1_EV_LIMIT, CUMUL1_EV_LIMIT, COMBI_MODE, OCC_MODE, COMB_SUCC_DETECT, COMB_CUMUL_DETECT, OCC_DETECT, "
33  "CUMUL1_DETECT, THD2_THRESHOLD , OCC_LIMIT , THD3_THRESHOLD , CUMUL2_LIMIT , STOP_BUFW ) "
34  "VALUES (:coke_conf_id, :logic_id, "
35  ":m1, :m2, :m3, :m4, :m5, :m6, :m7, :m8, :m9, :m10, :m11, :m12, :m13, :m14, :m15, :m16, :m17, :m18, :m19 )");
36  } catch (SQLException& e) {
37  throw cms::Exception("SQLException") << "FEConfigCokeDat::prepareWrite(): " << e.getMessage();
38  }
39 }
40 
42  const FEConfigCokeDat* item,
43  FEConfigCokeInfo* iconf) noexcept(false) {
44  this->checkConnection();
45  this->checkPrepare();
46 
47  int iconfID = iconf->fetchID();
48  if (!iconfID) {
49  throw(std::runtime_error("FEConfigCokeDat::writeDB: ICONF not in DB"));
50  }
51 
52  int logicID = ecid->getLogicID();
53  if (!logicID) {
54  throw(std::runtime_error("FEConfigCokeDat::writeDB: Bad EcalLogicID"));
55  }
56 
57  try {
58  m_writeStmt->setInt(1, iconfID);
59  m_writeStmt->setInt(2, logicID);
60  m_writeStmt->setInt(3, item->getPar1());
61  m_writeStmt->setInt(4, item->getPar2());
62  m_writeStmt->setInt(5, item->getPar3());
63  m_writeStmt->setInt(6, item->getPar4());
64  m_writeStmt->setInt(7, item->getPar5());
65  m_writeStmt->setInt(8, item->getPar6());
66  m_writeStmt->setInt(9, item->getPar7());
67  m_writeStmt->setInt(10, item->getPar8());
68  m_writeStmt->setInt(11, item->getPar9());
69  m_writeStmt->setInt(12, item->getPar10());
70  m_writeStmt->setInt(13, item->getPar11());
71  m_writeStmt->setInt(14, item->getPar12());
72  m_writeStmt->setInt(15, item->getPar13());
73  m_writeStmt->setInt(16, item->getPar14());
74  m_writeStmt->setInt(17, item->getPar15());
75  m_writeStmt->setInt(18, item->getPar16());
76  m_writeStmt->setInt(19, item->getPar17());
77  m_writeStmt->setInt(20, item->getPar18());
78  m_writeStmt->setInt(21, item->getPar19());
79 
80  m_writeStmt->executeUpdate();
81  } catch (SQLException& e) {
82  throw cms::Exception("SQLException") << "FEConfigCokeDat::writeDB(): " << e.getMessage();
83  }
84 }
85 
86 void FEConfigCokeDat::fetchData(map<EcalLogicID, FEConfigCokeDat>* fillMap, FEConfigCokeInfo* iconf) noexcept(false) {
87  this->checkConnection();
88  fillMap->clear();
89 
90  iconf->setConnection(m_env, m_conn);
91  int iconfID = iconf->fetchID();
92  if (!iconfID) {
93  // throw(std::runtime_error("FEConfigCokeDat::writeDB: ICONF not in DB"));
94  return;
95  }
96 
97  try {
98  m_readStmt->setSQL(
99  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
100  " d.THRESHOLD, d.SUCC_EVENT_LIMIT, d.CUMUL_EVENT_LIMIT, d.SUCC_DETECT_ENABLE, d.CUMUL_DETECT_ENABLE, "
101  "d.THD1_THRESHOLD, d.SUCC1_EV_LIMIT, d.CUMUL1_EV_LIMIT, d.COMBI_MODE, d.OCC_MODE, d.COMB_SUCC_DETECT, "
102  "d.COMB_CUMUL_DETECT, d.OCC_DETECT, d.CUMUL1_DETECT, d.THD2_THRESHOLD , d.OCC_LIMIT , d.THD3_THRESHOLD , "
103  "d.CUMUL2_LIMIT , d.STOP_BUFW "
104  "FROM channelview cv JOIN " +
105  getTable() +
106  " d "
107  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
108  "WHERE coke_conf_id = :coke_conf_id");
109  m_readStmt->setInt(1, iconfID);
110  ResultSet* rset = m_readStmt->executeQuery();
111 
112  std::pair<EcalLogicID, FEConfigCokeDat> p;
113  FEConfigCokeDat dat;
114  while (rset->next()) {
115  p.first = EcalLogicID(rset->getString(1), // name
116  rset->getInt(2), // logic_id
117  rset->getInt(3), // id1
118  rset->getInt(4), // id2
119  rset->getInt(5), // id3
120  rset->getString(6)); // maps_to
121 
122  dat.setPar1(rset->getInt(7));
123  dat.setPar2(rset->getInt(8));
124  dat.setPar3(rset->getInt(9));
125  dat.setPar4(rset->getInt(10));
126  dat.setPar5(rset->getInt(11));
127  dat.setPar6(rset->getInt(12));
128  dat.setPar7(rset->getInt(13));
129  dat.setPar8(rset->getInt(14));
130  dat.setPar9(rset->getInt(15));
131  dat.setPar10(rset->getInt(16));
132  dat.setPar11(rset->getInt(17));
133  dat.setPar12(rset->getInt(18));
134  dat.setPar13(rset->getInt(19));
135  dat.setPar14(rset->getInt(20));
136  dat.setPar15(rset->getInt(21));
137  dat.setPar16(rset->getInt(22));
138  dat.setPar17(rset->getInt(23));
139  dat.setPar18(rset->getInt(24));
140  dat.setPar19(rset->getInt(25));
141 
142  p.second = dat;
143  fillMap->insert(p);
144  }
145  } catch (SQLException& e) {
146  throw cms::Exception("SQLException") << "FEConfigCokeDat::fetchData: " << e.getMessage();
147  }
148 }
149 
150 void FEConfigCokeDat::writeArrayDB(const std::map<EcalLogicID, FEConfigCokeDat>* data,
151  FEConfigCokeInfo* iconf) noexcept(false) {
152  this->checkConnection();
153  this->checkPrepare();
154 
155  int iconfID = iconf->fetchID();
156  if (!iconfID) {
157  throw(std::runtime_error("FEConfigCokeDat::writeArrayDB: ICONF not in DB"));
158  }
159 
160  int nrows = data->size();
161  int* ids = new int[nrows];
162  int* iconfid_vec = new int[nrows];
163  int* xx1 = new int[nrows];
164  int* xx2 = new int[nrows];
165  int* xx3 = new int[nrows];
166  int* xx4 = new int[nrows];
167  int* xx5 = new int[nrows];
168  int* xx6 = new int[nrows];
169  int* xx7 = new int[nrows];
170  int* xx8 = new int[nrows];
171  int* xx9 = new int[nrows];
172  int* xx10 = new int[nrows];
173  int* xx11 = new int[nrows];
174  int* xx12 = new int[nrows];
175  int* xx13 = new int[nrows];
176  int* xx14 = new int[nrows];
177  int* xx15 = new int[nrows];
178  int* xx16 = new int[nrows];
179  int* xx17 = new int[nrows];
180  int* xx18 = new int[nrows];
181  int* xx19 = new int[nrows];
182 
183  ub2* ids_len = new ub2[nrows];
184  ub2* iconf_len = new ub2[nrows];
185  ub2* x1_len = new ub2[nrows];
186  ub2* x2_len = new ub2[nrows];
187  ub2* x3_len = new ub2[nrows];
188  ub2* x4_len = new ub2[nrows];
189  ub2* x5_len = new ub2[nrows];
190  ub2* x6_len = new ub2[nrows];
191  ub2* x7_len = new ub2[nrows];
192  ub2* x8_len = new ub2[nrows];
193  ub2* x9_len = new ub2[nrows];
194  ub2* x10_len = new ub2[nrows];
195  ub2* x11_len = new ub2[nrows];
196  ub2* x12_len = new ub2[nrows];
197  ub2* x13_len = new ub2[nrows];
198  ub2* x14_len = new ub2[nrows];
199  ub2* x15_len = new ub2[nrows];
200  ub2* x16_len = new ub2[nrows];
201  ub2* x17_len = new ub2[nrows];
202  ub2* x18_len = new ub2[nrows];
203  ub2* x19_len = new ub2[nrows];
204 
205  const EcalLogicID* channel;
206  const FEConfigCokeDat* dataitem;
207  int count = 0;
208  typedef map<EcalLogicID, FEConfigCokeDat>::const_iterator CI;
209  for (CI p = data->begin(); p != data->end(); ++p) {
210  channel = &(p->first);
211  int logicID = channel->getLogicID();
212  if (!logicID) {
213  throw(std::runtime_error("FEConfigCokeDat::writeArrayDB: Bad EcalLogicID"));
214  }
215  ids[count] = logicID;
216  iconfid_vec[count] = iconfID;
217 
218  dataitem = &(p->second);
219 
220  xx1[count] = dataitem->getPar1();
221  xx2[count] = dataitem->getPar2();
222  xx3[count] = dataitem->getPar3();
223  xx4[count] = dataitem->getPar4();
224  xx5[count] = dataitem->getPar5();
225  xx6[count] = dataitem->getPar6();
226  xx7[count] = dataitem->getPar7();
227  xx8[count] = dataitem->getPar8();
228  xx9[count] = dataitem->getPar9();
229  xx10[count] = dataitem->getPar10();
230  xx11[count] = dataitem->getPar11();
231  xx12[count] = dataitem->getPar12();
232  xx13[count] = dataitem->getPar13();
233  xx14[count] = dataitem->getPar14();
234  xx15[count] = dataitem->getPar15();
235  xx16[count] = dataitem->getPar16();
236  xx17[count] = dataitem->getPar17();
237  xx18[count] = dataitem->getPar18();
238  xx19[count] = dataitem->getPar19();
239 
240  ids_len[count] = sizeof(ids[count]);
241  iconf_len[count] = sizeof(iconfid_vec[count]);
242 
243  x1_len[count] = sizeof(xx1[count]);
244  x2_len[count] = sizeof(xx2[count]);
245  x3_len[count] = sizeof(xx3[count]);
246  x4_len[count] = sizeof(xx4[count]);
247  x5_len[count] = sizeof(xx5[count]);
248  x6_len[count] = sizeof(xx6[count]);
249  x7_len[count] = sizeof(xx7[count]);
250  x8_len[count] = sizeof(xx8[count]);
251  x9_len[count] = sizeof(xx9[count]);
252  x10_len[count] = sizeof(xx10[count]);
253  x11_len[count] = sizeof(xx11[count]);
254  x12_len[count] = sizeof(xx12[count]);
255  x13_len[count] = sizeof(xx13[count]);
256  x14_len[count] = sizeof(xx14[count]);
257  x15_len[count] = sizeof(xx15[count]);
258  x16_len[count] = sizeof(xx16[count]);
259  x17_len[count] = sizeof(xx17[count]);
260  x18_len[count] = sizeof(xx18[count]);
261  x19_len[count] = sizeof(xx19[count]);
262 
263  count++;
264  }
265 
266  try {
267  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]), iconf_len);
268  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
269  m_writeStmt->setDataBuffer(3, (dvoid*)xx1, OCCIINT, sizeof(xx1[0]), x1_len);
270  m_writeStmt->setDataBuffer(4, (dvoid*)xx2, OCCIINT, sizeof(xx2[0]), x2_len);
271  m_writeStmt->setDataBuffer(5, (dvoid*)xx3, OCCIINT, sizeof(xx3[0]), x3_len);
272  m_writeStmt->setDataBuffer(6, (dvoid*)xx4, OCCIINT, sizeof(xx4[0]), x4_len);
273  m_writeStmt->setDataBuffer(7, (dvoid*)xx5, OCCIINT, sizeof(xx5[0]), x5_len);
274  m_writeStmt->setDataBuffer(8, (dvoid*)xx6, OCCIINT, sizeof(xx6[0]), x6_len);
275  m_writeStmt->setDataBuffer(9, (dvoid*)xx7, OCCIINT, sizeof(xx7[0]), x7_len);
276  m_writeStmt->setDataBuffer(10, (dvoid*)xx8, OCCIINT, sizeof(xx8[0]), x8_len);
277  m_writeStmt->setDataBuffer(11, (dvoid*)xx9, OCCIINT, sizeof(xx9[0]), x9_len);
278  m_writeStmt->setDataBuffer(12, (dvoid*)xx10, OCCIINT, sizeof(xx10[0]), x10_len);
279  m_writeStmt->setDataBuffer(13, (dvoid*)xx11, OCCIINT, sizeof(xx11[0]), x11_len);
280  m_writeStmt->setDataBuffer(14, (dvoid*)xx12, OCCIINT, sizeof(xx12[0]), x12_len);
281  m_writeStmt->setDataBuffer(15, (dvoid*)xx13, OCCIINT, sizeof(xx13[0]), x13_len);
282  m_writeStmt->setDataBuffer(16, (dvoid*)xx14, OCCIINT, sizeof(xx14[0]), x14_len);
283  m_writeStmt->setDataBuffer(17, (dvoid*)xx15, OCCIINT, sizeof(xx15[0]), x15_len);
284  m_writeStmt->setDataBuffer(18, (dvoid*)xx16, OCCIINT, sizeof(xx16[0]), x16_len);
285  m_writeStmt->setDataBuffer(19, (dvoid*)xx17, OCCIINT, sizeof(xx17[0]), x17_len);
286  m_writeStmt->setDataBuffer(20, (dvoid*)xx18, OCCIINT, sizeof(xx18[0]), x18_len);
287  m_writeStmt->setDataBuffer(21, (dvoid*)xx19, OCCIINT, sizeof(xx19[0]), x19_len);
288 
289  m_writeStmt->executeArrayUpdate(nrows);
290 
291  delete[] ids;
292  delete[] iconfid_vec;
293  delete[] xx1;
294  delete[] xx2;
295  delete[] xx3;
296  delete[] xx4;
297  delete[] xx5;
298  delete[] xx6;
299  delete[] xx7;
300  delete[] xx8;
301  delete[] xx9;
302  delete[] xx10;
303  delete[] xx11;
304  delete[] xx12;
305  delete[] xx13;
306  delete[] xx14;
307  delete[] xx15;
308  delete[] xx16;
309  delete[] xx17;
310  delete[] xx18;
311  delete[] xx19;
312 
313  delete[] ids_len;
314  delete[] iconf_len;
315  delete[] x1_len;
316  delete[] x2_len;
317  delete[] x3_len;
318  delete[] x4_len;
319  delete[] x5_len;
320  delete[] x6_len;
321  delete[] x7_len;
322  delete[] x8_len;
323  delete[] x9_len;
324  delete[] x10_len;
325  delete[] x11_len;
326  delete[] x12_len;
327  delete[] x13_len;
328  delete[] x14_len;
329  delete[] x15_len;
330  delete[] x16_len;
331  delete[] x17_len;
332  delete[] x18_len;
333  delete[] x19_len;
334 
335  } catch (SQLException& e) {
336  throw cms::Exception("SQLException") << "FEConfigCokeDat::writeArrayDB(): " << e.getMessage();
337  }
338 }
void setPar7(int x)
int getPar6() const
int getPar3() const
int getPar12() const
int getPar13() const
int getPar9() const
void setPar17(int x)
int getPar19() const
void setPar15(int x)
void writeArrayDB(const std::map< EcalLogicID, FEConfigCokeDat > *data, FEConfigCokeInfo *iconf) noexcept(false)
int getPar15() const
~FEConfigCokeDat() override
void setPar12(int x)
void setPar19(int x)
void setPar14(int x)
void setPar4(int x)
int getLogicID() const
Definition: EcalLogicID.cc:28
void setPar18(int x)
int getPar5() const
int getPar2() const
void setPar9(int x)
void setPar11(int x)
int getPar8() const
void setPar16(int x)
void setPar8(int x)
int getPar18() const
void setPar5(int x)
int getPar7() const
int getPar4() const
void prepareWrite() noexcept(false) override
int getPar14() const
void setPar10(int x)
int getPar17() const
void writeDB(const EcalLogicID *ecid, const FEConfigCokeDat *item, FEConfigCokeInfo *iconf) noexcept(false)
void setPar13(int x)
void setPar6(int x)
void setPar1(int x)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
int getPar16() const
void setPar3(int x)
void fetchData(std::map< EcalLogicID, FEConfigCokeDat > *fillMap, FEConfigCokeInfo *iconf) noexcept(false)
int getPar11() const
int getPar10() const
void clear(EGIsoObj &c)
Definition: egamma.h:82
int getPar1() const
void setPar2(int x)