CMS 3D CMS Logo

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

#include <FEConfigFgrDat.h>

Inheritance diagram for FEConfigFgrDat:
IDataItem IDBObject

Public Member Functions

 FEConfigFgrDat ()
 
int getFgrGroupId () const
 
std::string getTable () override
 
void setFgrGroupId (int x)
 
 ~FEConfigFgrDat () 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, FEConfigFgrDat > *fillMap, FEConfigFgrInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigFgrDat > *data, FEConfigFgrInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigFgrDat *item, FEConfigFgrInfo *iconf) noexcept(false)
 

Private Attributes

int m_group_id
 

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 FEConfigFgrDat.h.

Constructor & Destructor Documentation

FEConfigFgrDat::FEConfigFgrDat ( )

Definition at line 11 of file FEConfigFgrDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_group_id = 0;
18 }
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
FEConfigFgrDat::~FEConfigFgrDat ( )
override

Definition at line 20 of file FEConfigFgrDat.cc.

20 {}

Member Function Documentation

void FEConfigFgrDat::fetchData ( std::map< EcalLogicID, FEConfigFgrDat > *  fillMap,
FEConfigFgrInfo iconf 
)
privatenoexcept

Definition at line 64 of file FEConfigFgrDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, and setFgrGroupId().

Referenced by getFgrGroupId().

64  {
65  this->checkConnection();
66  fillMap->clear();
67 
68  iconf->setConnection(m_env, m_conn);
69  int iconfID = iconf->fetchID();
70  if (!iconfID) {
71  // throw(std::runtime_error("FEConfigFgrDat::writeDB: ICONF not in DB"));
72  return;
73  }
74 
75  try {
76  m_readStmt->setSQL(
77  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
78  "d.group_id "
79  "FROM channelview cv JOIN fe_config_fgr_dat d "
80  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
81  "WHERE fgr_conf_id = :fgr_conf_id");
82  m_readStmt->setInt(1, iconfID);
83  ResultSet* rset = m_readStmt->executeQuery();
84 
85  std::pair<EcalLogicID, FEConfigFgrDat> p;
86  FEConfigFgrDat dat;
87  while (rset->next()) {
88  p.first = EcalLogicID(rset->getString(1), // name
89  rset->getInt(2), // logic_id
90  rset->getInt(3), // id1
91  rset->getInt(4), // id2
92  rset->getInt(5), // id3
93  rset->getString(6)); // maps_to
94 
95  dat.setFgrGroupId(rset->getInt(7));
96 
97  p.second = dat;
98  fillMap->insert(p);
99  }
100  } catch (SQLException& e) {
101  throw(std::runtime_error("FEConfigFgrDat::fetchData: " + e.getMessage()));
102  }
103 }
int fetchID() noexcept(false)
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 setFgrGroupId(int x)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int FEConfigFgrDat::getFgrGroupId ( ) const
inline
std::string FEConfigFgrDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigFgrDat.h.

18 { return "FE_CONFIG_FGR_DAT"; }
void FEConfigFgrDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 22 of file FEConfigFgrDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getFgrGroupId().

22  {
23  this->checkConnection();
24 
25  try {
26  m_writeStmt = m_conn->createStatement();
27  m_writeStmt->setSQL(
28  "INSERT INTO fe_config_fgr_dat (fgr_conf_id, logic_id, "
29  "group_id ) "
30  "VALUES (:fgr_conf_id, :logic_id, "
31  ":group_id )");
32  } catch (SQLException& e) {
33  throw(std::runtime_error("FEConfigFgrDat::prepareWrite(): " + e.getMessage()));
34  }
35 }
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
void FEConfigFgrDat::setFgrGroupId ( int  x)
inline

Definition at line 20 of file FEConfigFgrDat.h.

References m_group_id, and x.

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

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

Definition at line 105 of file FEConfigFgrDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getFgrGroupId(), EcalLogicID::getLogicID(), photons_cff::ids, AlCaHLTBitMon_ParallelJobs::p, x, and geometryCSVtoXML::xx.

Referenced by getFgrGroupId().

106  {
107  this->checkConnection();
108  this->checkPrepare();
109 
110  int iconfID = iconf->fetchID();
111  if (!iconfID) {
112  throw(std::runtime_error("FEConfigFgrDat::writeArrayDB: ICONF not in DB"));
113  }
114 
115  int nrows = data->size();
116  int* ids = new int[nrows];
117  int* iconfid_vec = new int[nrows];
118  int* xx = new int[nrows];
119 
120  ub2* ids_len = new ub2[nrows];
121  ub2* iconf_len = new ub2[nrows];
122  ub2* x_len = new ub2[nrows];
123 
124  const EcalLogicID* channel;
125  const FEConfigFgrDat* dataitem;
126  int count = 0;
127  typedef map<EcalLogicID, FEConfigFgrDat>::const_iterator CI;
128  for (CI p = data->begin(); p != data->end(); ++p) {
129  channel = &(p->first);
130  int logicID = channel->getLogicID();
131  if (!logicID) {
132  throw(std::runtime_error("FEConfigFgrDat::writeArrayDB: Bad EcalLogicID"));
133  }
134  ids[count] = logicID;
135  iconfid_vec[count] = iconfID;
136 
137  dataitem = &(p->second);
138  // dataIface.writeDB( channel, dataitem, iconf);
139  int x = dataitem->getFgrGroupId();
140 
141  xx[count] = x;
142 
143  ids_len[count] = sizeof(ids[count]);
144  iconf_len[count] = sizeof(iconfid_vec[count]);
145 
146  x_len[count] = sizeof(xx[count]);
147 
148  count++;
149  }
150 
151  try {
152  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]), iconf_len);
153  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
154  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
155 
156  m_writeStmt->executeArrayUpdate(nrows);
157 
158  delete[] ids;
159  delete[] iconfid_vec;
160  delete[] xx;
161 
162  delete[] ids_len;
163  delete[] iconf_len;
164  delete[] x_len;
165 
166  } catch (SQLException& e) {
167  throw(std::runtime_error("FEConfigFgrDat::writeArrayDB(): " + e.getMessage()));
168  }
169 }
int fetchID() noexcept(false)
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getLogicID() const
Definition: EcalLogicID.cc:28
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int getFgrGroupId() const
void FEConfigFgrDat::writeDB ( const EcalLogicID ecid,
const FEConfigFgrDat item,
FEConfigFgrInfo iconf 
)
privatenoexcept

Definition at line 37 of file FEConfigFgrDat.cc.

References MillePedeFileConverter_cfg::e, and B2GTnPMonitor_cfi::item.

Referenced by getFgrGroupId().

39  {
40  this->checkConnection();
41  this->checkPrepare();
42 
43  int iconfID = iconf->fetchID();
44  if (!iconfID) {
45  throw(std::runtime_error("FEConfigFgrDat::writeDB: ICONF not in DB"));
46  }
47 
48  int logicID = ecid->getLogicID();
49  if (!logicID) {
50  throw(std::runtime_error("FEConfigFgrDat::writeDB: Bad EcalLogicID"));
51  }
52 
53  try {
54  m_writeStmt->setInt(1, iconfID);
55  m_writeStmt->setInt(2, logicID);
56  m_writeStmt->setInt(3, item->getFgrGroupId());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("FEConfigFgrDat::writeDB(): " + e.getMessage()));
61  }
62 }
int fetchID() noexcept(false)
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getLogicID() const
Definition: EcalLogicID.cc:28
int getFgrGroupId() const

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigFgrDat.h.

Member Data Documentation

int FEConfigFgrDat::m_group_id
private

Definition at line 33 of file FEConfigFgrDat.h.

Referenced by getFgrGroupId(), and setFgrGroupId().