CMS 3D CMS Logo

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