CMS 3D CMS Logo

MonMemChConsistencyDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
4 
6 
7 using namespace std;
8 using namespace oracle::occi;
9 
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
16  m_processedEvents = 0;
17  m_problematicEvents = 0;
18  m_problemsID = 0;
19  m_problemsGainZero = 0;
20  m_problemsGainSwitch = 0;
21  m_taskStatus = false;
22 }
23 
25 
27  this->checkConnection();
28 
29  try {
30  m_writeStmt = m_conn->createStatement();
31  m_writeStmt->setSQL(
32  "INSERT INTO mon_mem_ch_consistency_dat (iov_id, logic_id, "
33  "processed_events, problematic_events, problems_id, problems_gain_zero, problems_gain_switch, task_status) "
34  "VALUES (:iov_id, :logic_id, "
35  ":3, :4, :5, :6, :7, :8)");
36  } catch (SQLException& e) {
37  throw(std::runtime_error("MonMemChConsistencyDat::prepareWrite(): " + e.getMessage()));
38  }
39 }
40 
43  MonRunIOV* iov) noexcept(false) {
44  this->checkConnection();
45  this->checkPrepare();
46 
47  int iovID = iov->fetchID();
48  if (!iovID) {
49  throw(std::runtime_error("MonMemChConsistencyDat::writeDB: IOV not in DB"));
50  }
51 
52  int logicID = ecid->getLogicID();
53  if (!logicID) {
54  throw(std::runtime_error("MonMemChConsistencyDat::writeDB: Bad EcalLogicID"));
55  }
56 
57  try {
58  m_writeStmt->setInt(1, iovID);
59  m_writeStmt->setInt(2, logicID);
60 
61  m_writeStmt->setInt(3, item->getProcessedEvents());
62  m_writeStmt->setInt(4, item->getProblematicEvents());
63  m_writeStmt->setInt(5, item->getProblemsID());
64  m_writeStmt->setInt(6, item->getProblemsGainZero());
65  m_writeStmt->setInt(7, item->getProblemsGainSwitch());
66  m_writeStmt->setInt(8, item->getTaskStatus());
67  m_writeStmt->executeUpdate();
68  } catch (SQLException& e) {
69  throw(std::runtime_error("MonMemChConsistencyDat::writeDB(): " + e.getMessage()));
70  }
71 }
72 
73 void MonMemChConsistencyDat::fetchData(std::map<EcalLogicID, MonMemChConsistencyDat>* fillMap,
74  MonRunIOV* iov) noexcept(false) {
75  this->checkConnection();
76  fillMap->clear();
77 
78  iov->setConnection(m_env, m_conn);
79  int iovID = iov->fetchID();
80  if (!iovID) {
81  // throw(std::runtime_error("MonMemChConsistencyDat::writeDB: IOV not in DB"));
82  return;
83  }
84 
85  try {
86  m_readStmt->setSQL(
87  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
88  "d.processed_events, d.problematic_events, d.problems_id, d.problems_gain_zero, d.problems_gain_switch, "
89  "d.task_status "
90  "FROM channelview cv JOIN mon_mem_ch_consistency_dat d "
91  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
92  "WHERE d.iov_id = :iov_id");
93  m_readStmt->setInt(1, iovID);
94  ResultSet* rset = m_readStmt->executeQuery();
95 
96  std::pair<EcalLogicID, MonMemChConsistencyDat> p;
98  while (rset->next()) {
99  p.first = EcalLogicID(rset->getString(1), // name
100  rset->getInt(2), // logic_id
101  rset->getInt(3), // id1
102  rset->getInt(4), // id2
103  rset->getInt(5), // id3
104  rset->getString(6)); // maps_to
105 
106  dat.setProcessedEvents(rset->getInt(7));
107  dat.setProblematicEvents(rset->getInt(8));
108  dat.setProblemsID(rset->getInt(9));
109  dat.setProblemsGainZero(rset->getInt(10));
110  dat.setProblemsGainSwitch(rset->getInt(11));
111  dat.setTaskStatus(rset->getInt(12));
112 
113  p.second = dat;
114  fillMap->insert(p);
115  }
116  } catch (SQLException& e) {
117  throw(std::runtime_error("MonMemChConsistencyDat::fetchData(): " + e.getMessage()));
118  }
119 }
120 
121 void MonMemChConsistencyDat::writeArrayDB(const std::map<EcalLogicID, MonMemChConsistencyDat>* data,
122  MonRunIOV* iov) noexcept(false) {
123  this->checkConnection();
124  this->checkPrepare();
125 
126  int iovID = iov->fetchID();
127  if (!iovID) {
128  throw(std::runtime_error("MonMemChConsistencyDat::writeArrayDB: IOV not in DB"));
129  }
130 
131  int nrows = data->size();
132  int* ids = new int[nrows];
133  int* iovid_vec = new int[nrows];
134  int* xx = new int[nrows];
135  int* yy = new int[nrows];
136  int* zz = new int[nrows];
137  int* ww = new int[nrows];
138  int* uu = new int[nrows];
139  int* st = new int[nrows];
140 
141  ub2* ids_len = new ub2[nrows];
142  ub2* iov_len = new ub2[nrows];
143  ub2* x_len = new ub2[nrows];
144  ub2* y_len = new ub2[nrows];
145  ub2* z_len = new ub2[nrows];
146  ub2* w_len = new ub2[nrows];
147  ub2* u_len = new ub2[nrows];
148  ub2* st_len = new ub2[nrows];
149 
150  const EcalLogicID* channel;
151  const MonMemChConsistencyDat* dataitem;
152  int count = 0;
153  typedef map<EcalLogicID, MonMemChConsistencyDat>::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) {
158  throw(std::runtime_error("MonMemChConsistencyDat::writeArrayDB: Bad EcalLogicID"));
159  }
160  ids[count] = logicID;
161  iovid_vec[count] = iovID;
162 
163  dataitem = &(p->second);
164  // dataIface.writeDB( channel, dataitem, iov);
165  int x = dataitem->getProcessedEvents();
166  int y = dataitem->getProblematicEvents();
167  int z = dataitem->getProblemsID();
168  int w = dataitem->getProblemsGainZero();
169  int u = dataitem->getProblemsGainSwitch();
170  int statu = dataitem->getTaskStatus();
171 
172  xx[count] = x;
173  yy[count] = y;
174  zz[count] = z;
175  ww[count] = w;
176  uu[count] = u;
177  st[count] = statu;
178 
179  ids_len[count] = sizeof(ids[count]);
180  iov_len[count] = sizeof(iovid_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  w_len[count] = sizeof(ww[count]);
186  u_len[count] = sizeof(uu[count]);
187  st_len[count] = sizeof(st[count]);
188 
189  count++;
190  }
191 
192  try {
193  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
194  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
195  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
196  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
197  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIINT, sizeof(zz[0]), z_len);
198  m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIINT, sizeof(ww[0]), w_len);
199  m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIINT, sizeof(uu[0]), u_len);
200  m_writeStmt->setDataBuffer(8, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
201 
202  m_writeStmt->executeArrayUpdate(nrows);
203 
204  delete[] ids;
205  delete[] iovid_vec;
206  delete[] xx;
207  delete[] yy;
208  delete[] zz;
209  delete[] ww;
210  delete[] uu;
211  delete[] st;
212 
213  delete[] ids_len;
214  delete[] iov_len;
215  delete[] x_len;
216  delete[] y_len;
217  delete[] z_len;
218  delete[] w_len;
219  delete[] u_len;
220  delete[] st_len;
221 
222  } catch (SQLException& e) {
223  throw(std::runtime_error("MonMemChConsistencyDat::writeArrayDB(): " + e.getMessage()));
224  }
225 }
MonMemChConsistencyDat::writeArrayDB
void writeArrayDB(const std::map< EcalLogicID, MonMemChConsistencyDat > *data, MonRunIOV *iov) noexcept(false)
Definition: MonMemChConsistencyDat.cc:121
DDAxes::y
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
MonMemChConsistencyDat::getProblemsGainZero
int getProblemsGainZero() const
Definition: MonMemChConsistencyDat.h:31
funct::false
false
Definition: Factorize.h:29
MonMemChConsistencyDat.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MonMemChConsistencyDat::setTaskStatus
void setTaskStatus(bool status)
Definition: MonMemChConsistencyDat.h:36
DDAxes::x
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
MonMemChConsistencyDat::setProblemsGainZero
void setProblemsGainZero(int prob)
Definition: MonMemChConsistencyDat.h:30
MonMemChConsistencyDat::setProblemsGainSwitch
void setProblemsGainSwitch(int prob)
Definition: MonMemChConsistencyDat.h:33
oracle::occi
Definition: ConnectionManager.h:7
w
const double w
Definition: UKUtility.cc:23
DDAxes::z
MonMemChConsistencyDat::getProblemsGainSwitch
int getProblemsGainSwitch() const
Definition: MonMemChConsistencyDat.h:34
EcalLogicID
Definition: EcalLogicID.h:7
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
MonMemChConsistencyDat::fetchData
void fetchData(std::map< EcalLogicID, MonMemChConsistencyDat > *fillVec, MonRunIOV *iov) noexcept(false)
Definition: MonMemChConsistencyDat.cc:73
MonMemChConsistencyDat
Definition: MonMemChConsistencyDat.h:12
MonMemChConsistencyDat::getProblemsID
int getProblemsID() const
Definition: MonMemChConsistencyDat.h:28
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
MonMemChConsistencyDat::setProcessedEvents
void setProcessedEvents(int proc)
Definition: MonMemChConsistencyDat.h:21
MonMemChConsistencyDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: MonMemChConsistencyDat.cc:26
MonRunIOV
Definition: MonRunIOV.h:14
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
std
Definition: JetResolutionObject.h:76
MonMemChConsistencyDat::getProcessedEvents
int getProcessedEvents() const
Definition: MonMemChConsistencyDat.h:22
MonMemChConsistencyDat::getTaskStatus
bool getTaskStatus() const
Definition: MonMemChConsistencyDat.h:37
MonMemChConsistencyDat::~MonMemChConsistencyDat
~MonMemChConsistencyDat() override
Definition: MonMemChConsistencyDat.cc:24
MonMemChConsistencyDat::getProblematicEvents
int getProblematicEvents() const
Definition: MonMemChConsistencyDat.h:25
MonMemChConsistencyDat::writeDB
void writeDB(const EcalLogicID *ecid, const MonMemChConsistencyDat *item, MonRunIOV *iov) noexcept(false)
Definition: MonMemChConsistencyDat.cc:41
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
Oracle.h
MonMemChConsistencyDat::MonMemChConsistencyDat
MonMemChConsistencyDat()
Definition: MonMemChConsistencyDat.cc:10
MonMemChConsistencyDat::setProblematicEvents
void setProblematicEvents(int prob)
Definition: MonMemChConsistencyDat.h:24
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MonMemChConsistencyDat::setProblemsID
void setProblemsID(int id)
Definition: MonMemChConsistencyDat.h:27