CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
FEConfigOddWeightDat Class Reference

#include <FEConfigOddWeightDat.h>

Inheritance diagram for FEConfigOddWeightDat:
IDataItem IDBObject

Public Member Functions

 FEConfigOddWeightDat ()
 
std::string getTable () override
 
int getWeightGroupId () const
 
void setWeightGroupId (int x)
 
 ~FEConfigOddWeightDat () 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, FEConfigOddWeightDat > *fillMap, FEConfigOddWeightInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigOddWeightDat > *data, FEConfigOddWeightInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigOddWeightDat *item, FEConfigOddWeightInfo *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 FEConfigOddWeightDat.h.

Constructor & Destructor Documentation

FEConfigOddWeightDat::FEConfigOddWeightDat ( )

Definition at line 12 of file FEConfigOddWeightDat.cc.

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

Definition at line 21 of file FEConfigOddWeightDat.cc.

21 {}

Member Function Documentation

void FEConfigOddWeightDat::fetchData ( std::map< EcalLogicID, FEConfigOddWeightDat > *  fillMap,
FEConfigOddWeightInfo iconf 
)
privatenoexcept

Definition at line 65 of file FEConfigOddWeightDat.cc.

References dat, alignCSCRings::e, Exception, AlCaHLTBitMon_ParallelJobs::p, and setWeightGroupId().

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

Implements IDataItem.

Definition at line 18 of file FEConfigOddWeightDat.h.

18 { return "FE_CONFIG_WEIGHT2_DAT"; }
int FEConfigOddWeightDat::getWeightGroupId ( ) const
inline

Definition at line 21 of file FEConfigOddWeightDat.h.

References m_group_id.

Referenced by writeArrayDB().

21 { return m_group_id; }
void FEConfigOddWeightDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file FEConfigOddWeightDat.cc.

References alignCSCRings::e, and Exception.

23  {
24  this->checkConnection();
25 
26  try {
27  m_writeStmt = m_conn->createStatement();
28  m_writeStmt->setSQL(
29  "INSERT INTO fe_config_weight2_dat (wei2_conf_id, logic_id, "
30  "group_id ) "
31  "VALUES (:wei2_conf_id, :logic_id, "
32  ":group_id )");
33  } catch (SQLException& e) {
34  throw cms::Exception("SQLException") << "FEConfigOddWeightDat::prepareWrite(): " << e.getMessage();
35  }
36 }
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 FEConfigOddWeightDat::setWeightGroupId ( int  x)
inline

Definition at line 20 of file FEConfigOddWeightDat.h.

References m_group_id, and x.

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

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

Definition at line 107 of file FEConfigOddWeightDat.cc.

References submitPVResolutionJobs::count, data, alignCSCRings::e, Exception, EcalLogicID::getLogicID(), getWeightGroupId(), AlCaHLTBitMon_ParallelJobs::p, and x.

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

Definition at line 38 of file FEConfigOddWeightDat.cc.

References alignCSCRings::e, Exception, and B2GTnPMonitor_cfi::item.

40  {
41  this->checkConnection();
42  this->checkPrepare();
43 
44  int iconfID = iconf->fetchID();
45  if (!iconfID) {
46  throw(std::runtime_error("FEConfigOddWeightDat::writeDB: ICONF not in DB"));
47  }
48 
49  int logicID = ecid->getLogicID();
50  if (!logicID) {
51  throw(std::runtime_error("FEConfigOddWeightDat::writeDB: Bad EcalLogicID"));
52  }
53 
54  try {
55  m_writeStmt->setInt(1, iconfID);
56  m_writeStmt->setInt(2, logicID);
57  m_writeStmt->setInt(3, item->getWeightGroupId());
58 
59  m_writeStmt->executeUpdate();
60  } catch (SQLException& e) {
61  throw cms::Exception("SQLException") << "FEConfigOddWeightDat::writeDB(): " << e.getMessage();
62  }
63 }
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)
int getLogicID() const
Definition: EcalLogicID.cc:28

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigOddWeightDat.h.

Member Data Documentation

int FEConfigOddWeightDat::m_group_id
private

Definition at line 34 of file FEConfigOddWeightDat.h.

Referenced by getWeightGroupId(), and setWeightGroupId().