CMS 3D CMS Logo

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