CMS 3D CMS Logo

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

#include <RunMemChErrorsDat.h>

Inheritance diagram for RunMemChErrorsDat:
IDataItem IDBObject

Public Member Functions

uint64_t getErrorBits () const
 
std::string getTable () override
 
 RunMemChErrorsDat ()
 
void setErrorBits (uint64_t bits)
 
 ~RunMemChErrorsDat () 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, RunMemChErrorsDat > *fillMap, RunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB (const EcalLogicID *ecid, const RunMemChErrorsDat *item, RunIOV *iov) noexcept(false)
 

Private Attributes

uint64_t m_errorBits
 

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 12 of file RunMemChErrorsDat.h.

Constructor & Destructor Documentation

◆ RunMemChErrorsDat()

RunMemChErrorsDat::RunMemChErrorsDat ( )

Definition at line 11 of file RunMemChErrorsDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16  m_errorBits = 0;
17 }
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

◆ ~RunMemChErrorsDat()

RunMemChErrorsDat::~RunMemChErrorsDat ( )
override

Definition at line 19 of file RunMemChErrorsDat.cc.

19 {}

Member Function Documentation

◆ fetchData()

void RunMemChErrorsDat::fetchData ( std::map< EcalLogicID, RunMemChErrorsDat > *  fillMap,
RunIOV iov 
)
privatenoexcept

Definition at line 61 of file RunMemChErrorsDat.cc.

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

61  {
62  this->checkConnection();
63  fillMap->clear();
64 
65  iov->setConnection(m_env, m_conn);
66  int iovID = iov->fetchID();
67  if (!iovID) {
68  // throw(std::runtime_error("RunMemChErrorsDat::writeDB: IOV not in DB"));
69  return;
70  }
71 
72  try {
73  /* Using TO_CHAR because OCCI does not support 64-bit integers well */
74  m_readStmt->setSQL(
75  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
76  "to_char(d.error_bits) "
77  "FROM channelview cv JOIN run_mem_ch_errors_dat d "
78  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
79  "WHERE d.iov_id = :iov_id");
80  m_readStmt->setInt(1, iovID);
81  ResultSet* rset = m_readStmt->executeQuery();
82 
83  std::pair<EcalLogicID, RunMemChErrorsDat> p;
85  while (rset->next()) {
86  p.first = EcalLogicID(rset->getString(1), // name
87  rset->getInt(2), // logic_id
88  rset->getInt(3), // id1
89  rset->getInt(4), // id2
90  rset->getInt(5), // id3
91  rset->getString(6)); // maps_to
92 
93  dat.setErrorBits(std::stoul(rset->getString(7)));
94 
95  p.second = dat;
96  fillMap->insert(p);
97  }
98 
99  } catch (SQLException& e) {
100  throw(std::runtime_error("RunMemChErrorsDat::fetchData(): " + e.getMessage()));
101  }
102 }
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 setErrorBits(uint64_t bits)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60

◆ getErrorBits()

uint64_t RunMemChErrorsDat::getErrorBits ( ) const
inline

Definition at line 22 of file RunMemChErrorsDat.h.

References m_errorBits.

22 { return m_errorBits; }

◆ getTable()

std::string RunMemChErrorsDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file RunMemChErrorsDat.h.

19 { return "RUN_MEM_CH_ERRORS_DAT"; }

◆ prepareWrite()

void RunMemChErrorsDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 21 of file RunMemChErrorsDat.cc.

References MillePedeFileConverter_cfg::e.

21  {
22  this->checkConnection();
23 
24  try {
25  m_writeStmt = m_conn->createStatement();
26  /* Using TO_NUMBER because OCCI does not support 64-bit integers well */
27  m_writeStmt->setSQL(
28  "INSERT INTO run_mem_ch_errors_dat (iov_id, logic_id, "
29  "error_bits) "
30  "VALUES (:iov_id, :logic_id, "
31  "to_number(:error_bits))");
32  } catch (SQLException& e) {
33  throw(std::runtime_error("RunMemChErrorsDat::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

◆ setErrorBits()

void RunMemChErrorsDat::setErrorBits ( uint64_t  bits)
inline

Definition at line 21 of file RunMemChErrorsDat.h.

References gpuClustering::pixelStatus::bits, and m_errorBits.

Referenced by fetchData().

21 { m_errorBits = bits; }
constexpr uint32_t bits
Definition: gpuClustering.h:23

◆ writeDB()

void RunMemChErrorsDat::writeDB ( const EcalLogicID ecid,
const RunMemChErrorsDat item,
RunIOV iov 
)
privatenoexcept

Definition at line 37 of file RunMemChErrorsDat.cc.

References MillePedeFileConverter_cfg::e, B2GTnPMonitor_cfi::item, and cond::impl::to_string().

37  {
38  this->checkConnection();
39  this->checkPrepare();
40 
41  int iovID = iov->fetchID();
42  if (!iovID) {
43  throw(std::runtime_error("RunMemChErrorsDat::writeDB: IOV not in DB"));
44  }
45 
46  int logicID = ecid->getLogicID();
47  if (!logicID) {
48  throw(std::runtime_error("RunMemChErrorsDat::writeDB: Bad EcalLogicID"));
49  }
50 
51  try {
52  m_writeStmt->setInt(1, iovID);
53  m_writeStmt->setInt(2, logicID);
54  m_writeStmt->setString(3, std::to_string(item->getErrorBits()));
55  m_writeStmt->executeUpdate();
56  } catch (SQLException& e) {
57  throw(std::runtime_error("RunMemChErrorsDat::writeDB(): " + e.getMessage()));
58  }
59 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file RunMemChErrorsDat.h.

Member Data Documentation

◆ m_errorBits

uint64_t RunMemChErrorsDat::m_errorBits
private

Definition at line 32 of file RunMemChErrorsDat.h.

Referenced by getErrorBits(), and setErrorBits().