CMS 3D CMS Logo

FEConfigOddWeightGroupDat.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  m_group_id = 0;
18  m_w0 = 0;
19  m_w1 = 0;
20  m_w2 = 0;
21  m_w3 = 0;
22  m_w4 = 0;
23  m_w5 = 0;
24 }
25 
27 
29  this->checkConnection();
30 
31  try {
32  m_writeStmt = m_conn->createStatement();
33  m_writeStmt->setSQL(
34  "INSERT INTO fe_weight2_per_group_dat (wei2_conf_id, group_id, "
35  " w0, w1, w2, w3, w4, w5 ) "
36  "VALUES (:wei2_conf_id, :group_id, "
37  ":w0, :w1, :w2, :w3, :w4, :w5 )");
38  } catch (SQLException& e) {
39  throw(std::runtime_error("FEConfigOddWeightGroupDat::prepareWrite(): " + e.getMessage()));
40  }
41 }
42 
45  FEConfigOddWeightInfo* iconf) noexcept(false) {
46  this->checkConnection();
47  this->checkPrepare();
48 
49  int iconfID = iconf->fetchID();
50  if (!iconfID) {
51  throw(std::runtime_error("FEConfigOddWeightGroupDat::writeDB: ICONF not in DB"));
52  }
53  /* no need for the logic id in this table
54  int logicID = ecid->getLogicID();
55  if (!logicID) { throw(std::runtime_error("FEConfigOddWeightGroupDat::writeDB: Bad EcalLogicID")); }
56  */
57 
58  try {
59  m_writeStmt->setInt(1, iconfID);
60 
61  m_writeStmt->setInt(2, item->getWeightGroupId());
62  m_writeStmt->setFloat(3, item->getWeight0());
63  m_writeStmt->setFloat(4, item->getWeight1());
64  m_writeStmt->setFloat(5, item->getWeight2());
65  m_writeStmt->setFloat(6, item->getWeight3());
66  m_writeStmt->setFloat(7, item->getWeight4());
67  m_writeStmt->setFloat(8, item->getWeight5());
68 
69  m_writeStmt->executeUpdate();
70  } catch (SQLException& e) {
71  throw(std::runtime_error("FEConfigOddWeightGroupDat::writeDB(): " + e.getMessage()));
72  }
73 }
74 
75 void FEConfigOddWeightGroupDat::fetchData(map<EcalLogicID, FEConfigOddWeightGroupDat>* fillMap,
76  FEConfigOddWeightInfo* iconf) noexcept(false) {
77  this->checkConnection();
78  fillMap->clear();
79 
80  iconf->setConnection(m_env, m_conn);
81  int iconfID = iconf->fetchID();
82  if (!iconfID) {
83  throw(std::runtime_error("FEConfigOddWeightGroupDat::fetchData: ICONF not in DB"));
84  return;
85  }
86 
87  try {
88  m_readStmt->setSQL(
89  "SELECT d.group_id, d.w0, d.w1, d.w2, d.w3, d.w4, d.w5 "
90  "FROM fe_weight2_per_group_dat d "
91  "WHERE wei2_conf_id = :wei2_conf_id order by d.group_id ");
92  m_readStmt->setInt(1, iconfID);
93  ResultSet* rset = m_readStmt->executeQuery();
94 
95  std::pair<EcalLogicID, FEConfigOddWeightGroupDat> p;
97  int ig = -1;
98  while (rset->next()) {
99  ig++; // we create a dummy logic_id
100  p.first = EcalLogicID("Group_id", // name
101  ig); // logic_id
102 
103  dat.setWeightGroupId(rset->getInt(1));
104  dat.setWeight0(rset->getFloat(2));
105  dat.setWeight1(rset->getFloat(3));
106  dat.setWeight2(rset->getFloat(4));
107  dat.setWeight3(rset->getFloat(5));
108  dat.setWeight4(rset->getFloat(6));
109  dat.setWeight5(rset->getFloat(7));
110 
111  p.second = dat;
112  fillMap->insert(p);
113  }
114  } catch (SQLException& e) {
115  throw(std::runtime_error("FEConfigOddWeightGroupDat::fetchData: " + e.getMessage()));
116  }
117 }
118 
119 void FEConfigOddWeightGroupDat::writeArrayDB(const std::map<EcalLogicID, FEConfigOddWeightGroupDat>* data,
120  FEConfigOddWeightInfo* iconf) noexcept(false) {
121  this->checkConnection();
122  this->checkPrepare();
123 
124  int iconfID = iconf->fetchID();
125  if (!iconfID) {
126  throw(std::runtime_error("FEConfigOddWeightGroupDat::writeArrayDB: ICONF not in DB"));
127  }
128 
129  int nrows = data->size();
130  int* ids = new int[nrows];
131  int* iconfid_vec = new int[nrows];
132  int* xx = new int[nrows];
133  float* yy = new float[nrows];
134  float* zz = new float[nrows];
135  float* rr = new float[nrows];
136  float* ss = new float[nrows];
137  float* tt = new float[nrows];
138  float* ww = new float[nrows];
139 
140  ub2* ids_len = new ub2[nrows];
141  ub2* iconf_len = new ub2[nrows];
142  ub2* x_len = new ub2[nrows];
143  ub2* y_len = new ub2[nrows];
144  ub2* z_len = new ub2[nrows];
145  ub2* r_len = new ub2[nrows];
146  ub2* s_len = new ub2[nrows];
147  ub2* t_len = new ub2[nrows];
148  ub2* w_len = new ub2[nrows];
149 
150  // const EcalLogicID* channel;
151  const FEConfigOddWeightGroupDat* dataitem;
152  int count = 0;
153  typedef map<EcalLogicID, FEConfigOddWeightGroupDat>::const_iterator CI;
154  for (CI p = data->begin(); p != data->end(); ++p) {
155  // channel = &(p->first);
156  // int logicID = channel->getLogicID();
157  // if (!logicID) { throw(std::runtime_error("FEConfigOddWeightGroupDat::writeArrayDB: Bad EcalLogicID")); }
158  // ids[count]=logicID;
159  iconfid_vec[count] = iconfID;
160 
161  dataitem = &(p->second);
162  // dataIface.writeDB( channel, dataitem, iconf);
163  int x = dataitem->getWeightGroupId();
164  float y = dataitem->getWeight0();
165  float z = dataitem->getWeight1();
166  float r = dataitem->getWeight2();
167  float s = dataitem->getWeight3();
168  float t = dataitem->getWeight4();
169  float w = dataitem->getWeight5();
170 
171  xx[count] = x;
172  yy[count] = y;
173  zz[count] = z;
174  rr[count] = r;
175  ss[count] = s;
176  tt[count] = t;
177  ww[count] = w;
178 
179  // ids_len[count]=sizeof(ids[count]);
180  iconf_len[count] = sizeof(iconfid_vec[count]);
181 
182  x_len[count] = sizeof(xx[count]);
183  y_len[count] = sizeof(yy[count]);
184  z_len[count] = sizeof(zz[count]);
185  r_len[count] = sizeof(rr[count]);
186  s_len[count] = sizeof(ss[count]);
187  t_len[count] = sizeof(tt[count]);
188  w_len[count] = sizeof(ww[count]);
189 
190  count++;
191  }
192 
193  try {
194  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]), iconf_len);
195  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
196  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
197  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIFLOAT, sizeof(zz[0]), z_len);
198  m_writeStmt->setDataBuffer(5, (dvoid*)rr, OCCIFLOAT, sizeof(rr[0]), r_len);
199  m_writeStmt->setDataBuffer(6, (dvoid*)ss, OCCIFLOAT, sizeof(ss[0]), s_len);
200  m_writeStmt->setDataBuffer(7, (dvoid*)tt, OCCIFLOAT, sizeof(tt[0]), t_len);
201  m_writeStmt->setDataBuffer(8, (dvoid*)ww, OCCIFLOAT, sizeof(ww[0]), w_len);
202 
203  m_writeStmt->executeArrayUpdate(nrows);
204 
205  delete[] ids;
206  delete[] iconfid_vec;
207  delete[] xx;
208  delete[] yy;
209  delete[] zz;
210  delete[] rr;
211  delete[] ss;
212  delete[] tt;
213  delete[] ww;
214 
215  delete[] ids_len;
216  delete[] iconf_len;
217  delete[] x_len;
218  delete[] y_len;
219  delete[] z_len;
220  delete[] r_len;
221  delete[] s_len;
222  delete[] t_len;
223  delete[] w_len;
224 
225  } catch (SQLException& e) {
226  throw(std::runtime_error("FEConfigOddWeightGroupDat::writeArrayDB(): " + e.getMessage()));
227  }
228 }
FEConfigOddWeightInfo.h
DDAxes::y
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
FEConfigOddWeightGroupDat::getWeight1
float getWeight1() const
Definition: FEConfigOddWeightGroupDat.h:26
funct::false
false
Definition: Factorize.h:29
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FEConfigOddWeightGroupDat::getWeight5
float getWeight5() const
Definition: FEConfigOddWeightGroupDat.h:34
FEConfigOddWeightGroupDat::writeDB
void writeDB(const EcalLogicID *ecid, const FEConfigOddWeightGroupDat *item, FEConfigOddWeightInfo *iconf) noexcept(false)
Definition: FEConfigOddWeightGroupDat.cc:43
FEConfigOddWeightInfo
Definition: FEConfigOddWeightInfo.h:11
FEConfigOddWeightGroupDat::getWeight0
float getWeight0() const
Definition: FEConfigOddWeightGroupDat.h:24
FEConfigOddWeightGroupDat::setWeight1
void setWeight1(float x)
Definition: FEConfigOddWeightGroupDat.h:25
FEConfigOddWeightGroupDat::getWeightGroupId
int getWeightGroupId() const
Definition: FEConfigOddWeightGroupDat.h:21
DDAxes::x
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
oracle::occi
Definition: ConnectionManager.h:7
w
const double w
Definition: UKUtility.cc:23
DDAxes::z
EcalLogicID
Definition: EcalLogicID.h:7
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
FEConfigOddWeightGroupDat
Definition: FEConfigOddWeightGroupDat.h:11
FEConfigOddWeightGroupDat::setWeight4
void setWeight4(float x)
Definition: FEConfigOddWeightGroupDat.h:31
FEConfigOddWeightGroupDat::setWeightGroupId
void setWeightGroupId(int x)
Definition: FEConfigOddWeightGroupDat.h:20
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
FEConfigOddWeightGroupDat::writeArrayDB
void writeArrayDB(const std::map< EcalLogicID, FEConfigOddWeightGroupDat > *data, FEConfigOddWeightInfo *iconf) noexcept(false)
Definition: FEConfigOddWeightGroupDat.cc:119
FEConfigOddWeightGroupDat::setWeight2
void setWeight2(float x)
Definition: FEConfigOddWeightGroupDat.h:27
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
FEConfigOddWeightGroupDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: FEConfigOddWeightGroupDat.cc:28
FEConfigOddWeightGroupDat.h
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FEConfigOddWeightGroupDat::setWeight3
void setWeight3(float x)
Definition: FEConfigOddWeightGroupDat.h:29
std
Definition: JetResolutionObject.h:76
FEConfigOddWeightGroupDat::getWeight4
float getWeight4() const
Definition: FEConfigOddWeightGroupDat.h:32
FEConfigOddWeightGroupDat::getWeight2
float getWeight2() const
Definition: FEConfigOddWeightGroupDat.h:28
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
FEConfigOddWeightGroupDat::fetchData
void fetchData(std::map< EcalLogicID, FEConfigOddWeightGroupDat > *fillMap, FEConfigOddWeightInfo *iconf) noexcept(false)
Definition: FEConfigOddWeightGroupDat.cc:75
FEConfigOddWeightGroupDat::setWeight5
void setWeight5(float x)
Definition: FEConfigOddWeightGroupDat.h:33
Oracle.h
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
FEConfigOddWeightGroupDat::~FEConfigOddWeightGroupDat
~FEConfigOddWeightGroupDat() override
Definition: FEConfigOddWeightGroupDat.cc:26
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
FEConfigOddWeightGroupDat::setWeight0
void setWeight0(float x)
Definition: FEConfigOddWeightGroupDat.h:23
FEConfigOddWeightGroupDat::FEConfigOddWeightGroupDat
FEConfigOddWeightGroupDat()
Definition: FEConfigOddWeightGroupDat.cc:11
FEConfigOddWeightGroupDat::getWeight3
float getWeight3() const
Definition: FEConfigOddWeightGroupDat.h:30
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37