CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
FEConfigLUTGroupDat Class Reference

#include <FEConfigLUTGroupDat.h>

Inheritance diagram for FEConfigLUTGroupDat:
IDataItem IDBObject

Public Member Functions

 FEConfigLUTGroupDat ()
 
int getLUTGroupId () const
 
int getLUTValue (int i) const
 
std::string getTable () override
 
void setLUTGroupId (int x)
 
void setLUTValue (int i, int x)
 
 ~FEConfigLUTGroupDat () override
 
- Public Member Functions inherited from IDataItem
 IDataItem ()
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void fetchData (std::map< EcalLogicID, FEConfigLUTGroupDat > *fillMap, FEConfigLUTInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigLUTGroupDat > *data, FEConfigLUTInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigLUTGroupDat *item, FEConfigLUTInfo *iconf) noexcept(false)
 

Private Attributes

int m_group_id
 
int m_lut [1024]
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IDataItem
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IDataItem
oracle::occi::Statement * m_readStmt
 
oracle::occi::Statement * m_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 11 of file FEConfigLUTGroupDat.h.

Constructor & Destructor Documentation

◆ FEConfigLUTGroupDat()

FEConfigLUTGroupDat::FEConfigLUTGroupDat ( )

Definition at line 11 of file FEConfigLUTGroupDat.cc.

References mps_fire::i.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_group_id = 0;
18  for (int i = 0; i < 1024; i++) {
19  m_lut[i] = 0;
20  }
21 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24

◆ ~FEConfigLUTGroupDat()

FEConfigLUTGroupDat::~FEConfigLUTGroupDat ( )
override

Definition at line 23 of file FEConfigLUTGroupDat.cc.

23 {}

Member Function Documentation

◆ fetchData()

void FEConfigLUTGroupDat::fetchData ( std::map< EcalLogicID, FEConfigLUTGroupDat > *  fillMap,
FEConfigLUTInfo iconf 
)
privatenoexcept

Definition at line 105 of file FEConfigLUTGroupDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setLUTGroupId(), setLUTValue(), and AlCaHLTBitMon_QueryRunRegistry::string.

106  {
107  this->checkConnection();
108  fillMap->clear();
109 
110  iconf->setConnection(m_env, m_conn);
111  int iconfID = iconf->fetchID();
112  if (!iconfID) {
113  throw(std::runtime_error("FEConfigLUTGroupDat::fetchData: ICONF not in DB"));
114  return;
115  }
116 
117  try {
118  m_readStmt->setSQL(
119  "SELECT d.group_id, d.lut_id, d.lut_value "
120  "FROM fe_lut_per_group_dat d "
121  "WHERE lut_conf_id = :lut_conf_id order by d.group_id, d.lut_id ");
122  m_readStmt->setInt(1, iconfID);
123  ResultSet* rset = m_readStmt->executeQuery();
124 
126  std::pair<EcalLogicID, FEConfigLUTGroupDat> p;
127 
128  int nrows = 1024;
129 
130  int ig = -1;
131 
132  while (rset->next()) {
133  ig = rset->getInt(1);
134  int il = rset->getInt(2);
135  int ival = rset->getInt(3);
136  if (il == 0) {
137  p.first = EcalLogicID("Group_id", ig); // a dummy logic_id
138  dat = FEConfigLUTGroupDat();
139  dat.setLUTGroupId(ig);
140  dat.setLUTValue(il, ival);
141  } else {
142  dat.setLUTValue(il, ival);
143  }
144 
145  if (il == (nrows - 1)) {
146  p.second = dat;
147  fillMap->insert(p);
148  }
149  }
150  } catch (SQLException& e) {
151  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::fetchData: ") + e.getMessage()));
152  }
153 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setLUTValue(int i, int x)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
int fetchID() noexcept(false)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getLUTGroupId()

int FEConfigLUTGroupDat::getLUTGroupId ( ) const
inline

Definition at line 21 of file FEConfigLUTGroupDat.h.

References m_group_id.

Referenced by popcon::EcalTPGLutIdMapHandler::getNewObjects(), and writeArrayDB().

21 { return m_group_id; }

◆ getLUTValue()

int FEConfigLUTGroupDat::getLUTValue ( int  i) const
inline

Definition at line 24 of file FEConfigLUTGroupDat.h.

References mps_fire::i, and m_lut.

Referenced by popcon::EcalTPGLutIdMapHandler::getNewObjects(), and writeArrayDB().

24 { return m_lut[i]; }

◆ getTable()

std::string FEConfigLUTGroupDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigLUTGroupDat.h.

18 { return "FE_CONFIG_LUT_PER_GROUP_DAT"; }

◆ prepareWrite()

void FEConfigLUTGroupDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file FEConfigLUTGroupDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

25  {
26  this->checkConnection();
27 
28  try {
29  m_writeStmt = m_conn->createStatement();
30  m_writeStmt->setSQL(
31  "INSERT INTO fe_lut_per_group_dat (lut_conf_id, group_id, "
32  " lut_id, lut_value ) "
33  "VALUES (:lut_conf_id, :group_id, "
34  ":lut_id, :lut_value )");
35  } catch (SQLException& e) {
36  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::prepareWrite(): ") + e.getMessage()));
37  }
38 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36

◆ setLUTGroupId()

void FEConfigLUTGroupDat::setLUTGroupId ( int  x)
inline

Definition at line 20 of file FEConfigLUTGroupDat.h.

References m_group_id, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

◆ setLUTValue()

void FEConfigLUTGroupDat::setLUTValue ( int  i,
int  x 
)
inline

Definition at line 23 of file FEConfigLUTGroupDat.h.

References mps_fire::i, m_lut, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

◆ writeArrayDB()

void FEConfigLUTGroupDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigLUTGroupDat > *  data,
FEConfigLUTInfo iconf 
)
privatenoexcept

Definition at line 155 of file FEConfigLUTGroupDat.cc.

References submitPVResolutionJobs::count, gather_cfg::cout, data, MillePedeFileConverter_cfg::e, getLUTGroupId(), getLUTValue(), mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

156  {
157  this->checkConnection();
158  this->checkPrepare();
159 
160  int iconfID = iconf->fetchID();
161  if (!iconfID) {
162  throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB: ICONF not in DB"));
163  }
164 
165  int nrows = data->size() * 1024;
166 
167  int* iconfid_vec = new int[nrows];
168  int* xx = new int[nrows];
169  int* yy = new int[nrows];
170  int* zz = new int[nrows];
171 
172  ub2* iconf_len = new ub2[nrows];
173  ub2* x_len = new ub2[nrows];
174  ub2* y_len = new ub2[nrows];
175  ub2* z_len = new ub2[nrows];
176 
177  const FEConfigLUTGroupDat* dataitem;
178  int count = 0;
179  typedef map<EcalLogicID, FEConfigLUTGroupDat>::const_iterator CI;
180  for (CI p = data->begin(); p != data->end(); ++p) {
181  dataitem = &(p->second);
182  int x = dataitem->getLUTGroupId();
183 
184  for (int i = 0; i < 1024; i++) {
185  iconfid_vec[count] = iconfID;
186  int y = i;
187  int z = dataitem->getLUTValue(i);
188 
189  xx[count] = x;
190  yy[count] = y;
191  zz[count] = z;
192 
193  iconf_len[count] = sizeof(iconfid_vec[count]);
194 
195  x_len[count] = sizeof(xx[count]);
196  y_len[count] = sizeof(yy[count]);
197  z_len[count] = sizeof(zz[count]);
198 
199  count++;
200  }
201  }
202 
203  try {
204  // for (int i=0; i<nrows; i++){
205 
206  int i = 0;
207  cout << "about to insert " << iconfid_vec[i] << " " << xx[i] << " " << yy[i] << " " << zz[i] << endl;
208  i = nrows - 1;
209  cout << "about to insert " << iconfid_vec[i] << " " << xx[i] << " " << yy[i] << " " << zz[i] << endl;
210  // }
211  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]), iconf_len);
212  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
213  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
214  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT, sizeof(zz[0]), z_len);
215 
216  m_writeStmt->executeArrayUpdate(nrows);
217 
218  delete[] iconfid_vec;
219  delete[] xx;
220  delete[] yy;
221  delete[] zz;
222 
223  delete[] iconf_len;
224  delete[] x_len;
225  delete[] y_len;
226  delete[] z_len;
227 
228  } catch (SQLException& e) {
229  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::writeArrayDB(): ") + e.getMessage()));
230  }
231 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
int getLUTValue(int i) const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ writeDB()

void FEConfigLUTGroupDat::writeDB ( const EcalLogicID ecid,
const FEConfigLUTGroupDat item,
FEConfigLUTInfo iconf 
)
privatenoexcept

Definition at line 40 of file FEConfigLUTGroupDat.cc.

References submitPVResolutionJobs::count, gather_cfg::cout, MillePedeFileConverter_cfg::e, B2GTnPMonitor_cfi::item, AlCaHLTBitMon_QueryRunRegistry::string, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

42  {
43  this->checkConnection();
44  this->checkPrepare();
45 
46  int iconfID = iconf->fetchID();
47 
48  cout << "iconf=" << iconfID << endl;
49 
50  if (!iconfID) {
51  throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB: ICONF not in DB"));
52  }
53 
54  int nrows = 1024;
55  int* iconfid_vec = new int[nrows];
56  int* xx = new int[nrows];
57  int* yy = new int[nrows];
58  int* zz = new int[nrows];
59 
60  ub2* iconf_len = new ub2[nrows];
61  ub2* x_len = new ub2[nrows];
62  ub2* y_len = new ub2[nrows];
63  ub2* z_len = new ub2[nrows];
64 
65  for (int count = 0; count < nrows; count++) {
66  iconfid_vec[count] = iconfID;
67  int x = item->getLUTGroupId();
68  int y = count;
69  int z = m_lut[count];
70 
71  xx[count] = x;
72  yy[count] = y;
73  zz[count] = z;
74 
75  iconf_len[count] = sizeof(iconfid_vec[count]);
76 
77  x_len[count] = sizeof(xx[count]);
78  y_len[count] = sizeof(yy[count]);
79  z_len[count] = sizeof(zz[count]);
80  }
81 
82  try {
83  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]), iconf_len);
84  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
85  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
86  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT, sizeof(zz[0]), z_len);
87 
88  m_writeStmt->executeArrayUpdate(nrows);
89 
90  delete[] iconfid_vec;
91  delete[] xx;
92  delete[] yy;
93  delete[] zz;
94 
95  delete[] iconf_len;
96  delete[] x_len;
97  delete[] y_len;
98  delete[] z_len;
99 
100  } catch (SQLException& e) {
101  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::writeArrayDB(): ") + e.getMessage()));
102  }
103 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false)

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigLUTGroupDat.h.

Member Data Documentation

◆ m_group_id

int FEConfigLUTGroupDat::m_group_id
private

Definition at line 36 of file FEConfigLUTGroupDat.h.

Referenced by getLUTGroupId(), and setLUTGroupId().

◆ m_lut

int FEConfigLUTGroupDat::m_lut[1024]
private

Definition at line 37 of file FEConfigLUTGroupDat.h.

Referenced by getLUTValue(), and setLUTValue().