CMS 3D CMS Logo

ODGolBiasCurrentDat.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_gol = 0;
17  m_fed = 0;
18  m_tt = 0;
19  m_cur = 0;
20  m_pll_cur = 0;
21  m_sta = 0;
22 }
23 
25 
27  this->checkConnection();
28 
29  try {
30  m_writeStmt = m_conn->createStatement();
31  m_writeStmt->setSQL("INSERT INTO " + getTable() +
32  " (rec_id, fed_id, tt_id, gol_id, gol_current, pll_current, status ) "
33  "VALUES (:1, :2, :3, :4, :5 , :6, :7)");
34  } catch (SQLException& e) {
35  throw(std::runtime_error("ODGolBiasCurrentDat::prepareWrite(): " + e.getMessage()));
36  }
37 }
38 
40  this->checkConnection();
41 
42  try {
43  m_writeStmt->setInt(1, item->getId());
44  m_writeStmt->setInt(2, item->getFedId());
45  m_writeStmt->setInt(3, item->getTTId());
46  m_writeStmt->setInt(4, item->getGolId());
47  m_writeStmt->setInt(5, item->getCurrent());
48  m_writeStmt->setInt(6, item->getPLLCurrent());
49  m_writeStmt->setInt(7, item->getStatus());
50 
51  m_writeStmt->executeUpdate();
52  } catch (SQLException& e) {
53  throw(std::runtime_error("ODGolBiasCurrentDat::writeDB(): " + e.getMessage()));
54  }
55 }
56 
57 void ODGolBiasCurrentDat::fetchData(std::vector<ODGolBiasCurrentDat>* p, ODGolBiasCurrentInfo* iov) noexcept(false) {
58  this->checkConnection();
59 
60  iov->setConnection(m_env, m_conn);
61  int iovID = iov->fetchID();
62  if (!iovID) {
63  std::cout << "ID not in the DB" << endl;
64  return;
65  }
66 
67  try {
68  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by fed_id, tt_id, gol_id ");
69  m_readStmt->setInt(1, iovID);
70  ResultSet* rset = m_readStmt->executeQuery();
71 
72  // std::vector< ODGolBiasCurrentDat > p;
74  while (rset->next()) {
75  // dat.setId( rset->getInt(1) );
76  dat.setFedId(rset->getInt(2));
77  dat.setTTId(rset->getInt(3));
78  dat.setGolId(rset->getInt(4));
79  dat.setCurrent(rset->getInt(5));
80  dat.setPLLCurrent(rset->getInt(6));
81  dat.setStatus(rset->getInt(7));
82 
83  p->push_back(dat);
84  }
85 
86  } catch (SQLException& e) {
87  throw(std::runtime_error("ODGolBiasCurrentDat::fetchData(): " + e.getMessage()));
88  }
89 }
90 
91 // ************************************************************************ //
92 
93 void ODGolBiasCurrentDat::writeArrayDB(const std::vector<ODGolBiasCurrentDat>& data,
94  ODGolBiasCurrentInfo* iov) noexcept(false) {
95  this->checkConnection();
96 
97  int iovID = iov->fetchID();
98  if (!iovID) {
99  throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB"));
100  }
101 
102  int nrows = data.size();
103  int* ids = new int[nrows];
104  int* xx = new int[nrows];
105  int* yy = new int[nrows];
106  int* zz = new int[nrows];
107  int* ww = new int[nrows];
108  int* kk = new int[nrows];
109  int* st = new int[nrows];
110 
111  ub2* ids_len = new ub2[nrows];
112  ub2* x_len = new ub2[nrows];
113  ub2* y_len = new ub2[nrows];
114  ub2* z_len = new ub2[nrows];
115  ub2* w_len = new ub2[nrows];
116  ub2* k_len = new ub2[nrows];
117  ub2* st_len = new ub2[nrows];
118 
119  ODGolBiasCurrentDat dataitem;
120 
121  for (int count = 0; count != (int)data.size(); count++) {
122  dataitem = data[count];
123  ids[count] = iovID;
124  xx[count] = dataitem.getFedId();
125  yy[count] = dataitem.getTTId();
126  zz[count] = dataitem.getGolId();
127  ww[count] = dataitem.getCurrent();
128  kk[count] = dataitem.getPLLCurrent();
129  st[count] = dataitem.getStatus();
130 
131  ids_len[count] = sizeof(ids[count]);
132  x_len[count] = sizeof(xx[count]);
133  y_len[count] = sizeof(yy[count]);
134  z_len[count] = sizeof(zz[count]);
135  w_len[count] = sizeof(ww[count]);
136  k_len[count] = sizeof(kk[count]);
137  st_len[count] = sizeof(st[count]);
138  }
139 
140  try {
141  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
142  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
143  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
144  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT, sizeof(zz[0]), z_len);
145  m_writeStmt->setDataBuffer(5, (dvoid*)ww, OCCIINT, sizeof(ww[0]), w_len);
146  m_writeStmt->setDataBuffer(6, (dvoid*)kk, OCCIINT, sizeof(kk[0]), k_len);
147  m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
148 
149  m_writeStmt->executeArrayUpdate(nrows);
150 
151  delete[] ids;
152  delete[] xx;
153  delete[] yy;
154  delete[] zz;
155  delete[] ww;
156  delete[] kk;
157  delete[] st;
158 
159  delete[] ids_len;
160  delete[] x_len;
161  delete[] y_len;
162  delete[] z_len;
163  delete[] w_len;
164  delete[] k_len;
165  delete[] st_len;
166 
167  } catch (SQLException& e) {
168  throw(std::runtime_error("ODGolBiasCurrentDat::writeArrayDB(): " + e.getMessage()));
169  }
170 }
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
funct::false
false
Definition: Factorize.h:34
ODGolBiasCurrentDat::getPLLCurrent
int getPLLCurrent() const
Definition: ODGolBiasCurrentDat.h:36
std::data
constexpr auto data(C &c) -> decltype(c.data())
Definition: cuda_cxx17.h:40
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ODGolBiasCurrentDat::setGolId
void setGolId(int dac)
Definition: ODGolBiasCurrentDat.h:23
ODGolBiasCurrentDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: ODGolBiasCurrentDat.cc:26
ODGolBiasCurrentDat::~ODGolBiasCurrentDat
~ODGolBiasCurrentDat() override
Definition: ODGolBiasCurrentDat.cc:24
ODGolBiasCurrentDat::getTTId
int getTTId() const
Definition: ODGolBiasCurrentDat.h:30
ODGolBiasCurrentDat::getStatus
int getStatus() const
Definition: ODGolBiasCurrentDat.h:39
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
ODGolBiasCurrentDat::getGolId
int getGolId() const
Definition: ODGolBiasCurrentDat.h:24
ODGolBiasCurrentDat
Definition: ODGolBiasCurrentDat.h:11
ODGolBiasCurrentDat::getCurrent
int getCurrent() const
Definition: ODGolBiasCurrentDat.h:33
oracle::occi
Definition: ConnectionManager.h:7
ODGolBiasCurrentDat::fetchData
void fetchData(std::vector< ODGolBiasCurrentDat > *fillMap, ODGolBiasCurrentInfo *iov) noexcept(false)
Definition: ODGolBiasCurrentDat.cc:57
GetRecoTauVFromDQM_MC_cff.kk
kk
Definition: GetRecoTauVFromDQM_MC_cff.py:84
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
createfilelist.int
int
Definition: createfilelist.py:10
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
ODGolBiasCurrentDat::setCurrent
void setCurrent(int dac)
Definition: ODGolBiasCurrentDat.h:32
std
Definition: JetResolutionObject.h:76
ODGolBiasCurrentDat::writeArrayDB
void writeArrayDB(const std::vector< ODGolBiasCurrentDat > &data, ODGolBiasCurrentInfo *iov) noexcept(false)
Definition: ODGolBiasCurrentDat.cc:93
ODGolBiasCurrentDat::getFedId
int getFedId() const
Definition: ODGolBiasCurrentDat.h:27
ODGolBiasCurrentDat::setPLLCurrent
void setPLLCurrent(int x)
Definition: ODGolBiasCurrentDat.h:35
ODGolBiasCurrentInfo
Definition: ODGolBiasCurrentInfo.h:9
ODGolBiasCurrentDat.h
ODGolBiasCurrentDat::ODGolBiasCurrentDat
ODGolBiasCurrentDat()
Definition: ODGolBiasCurrentDat.cc:10
Oracle.h
ODGolBiasCurrentDat::setTTId
void setTTId(int dac)
Definition: ODGolBiasCurrentDat.h:29
ODGolBiasCurrentDat::setFedId
void setFedId(int dac)
Definition: ODGolBiasCurrentDat.h:26
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
ODGolBiasCurrentDat::writeDB
void writeDB(const ODGolBiasCurrentDat *item, ODGolBiasCurrentInfo *iov) noexcept(false)
Definition: ODGolBiasCurrentDat.cc:39
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
ODGolBiasCurrentDat::setStatus
void setStatus(int dac)
Definition: ODGolBiasCurrentDat.h:38