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
RunCrystalErrorsDat Class Reference

#include <RunCrystalErrorsDat.h>

Inheritance diagram for RunCrystalErrorsDat:
IDataItem IDBObject

Public Member Functions

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

Constructor & Destructor Documentation

RunCrystalErrorsDat::RunCrystalErrorsDat ( )

Definition at line 11 of file RunCrystalErrorsDat.cc.

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

Definition at line 18 of file RunCrystalErrorsDat.cc.

18 {}

Member Function Documentation

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

Definition at line 62 of file RunCrystalErrorsDat.cc.

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

62  {
63  this->checkConnection();
64  fillMap->clear();
65 
66  iov->setConnection(m_env, m_conn);
67  int iovID = iov->fetchID();
68  if (!iovID) {
69  // throw(std::runtime_error("RunCrystalErrorsDat::writeDB: IOV not in DB"));
70  return;
71  }
72 
73  try {
74  Statement* stmt = m_conn->createStatement();
75  /* Using TO_CHAR because OCCI does not support 64-bit integers well */
76  stmt->setSQL(
77  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
78  "to_char(d.error_bits) "
79  "FROM channelview cv JOIN run_crystal_errors_dat d "
80  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
81  "WHERE d.iov_id = :iov_id");
82  stmt->setInt(1, iovID);
83  ResultSet* rset = stmt->executeQuery();
84 
85  std::pair<EcalLogicID, RunCrystalErrorsDat> p;
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.setErrorBits(std::stoul(rset->getString(7)));
96 
97  p.second = dat;
98  fillMap->insert(p);
99  }
100  m_conn->terminateStatement(stmt);
101 
102  } catch (SQLException& e) {
103  throw(std::runtime_error("RunCrystalErrorsDat::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
void setErrorBits(uint64_t bits)
static std::vector< std::string > checklist dat
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
uint64_t RunCrystalErrorsDat::getErrorBits ( ) const
inline

Definition at line 22 of file RunCrystalErrorsDat.h.

References m_errorBits.

22 { return m_errorBits; }
std::string RunCrystalErrorsDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file RunCrystalErrorsDat.h.

19 { return "RUN_CRYSTAL_ERRORS_DAT"; }
void RunCrystalErrorsDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 20 of file RunCrystalErrorsDat.cc.

References alignCSCRings::e.

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

Definition at line 21 of file RunCrystalErrorsDat.h.

References m_errorBits.

Referenced by fetchData().

21 { m_errorBits = bits; }
void RunCrystalErrorsDat::writeDB ( const EcalLogicID ecid,
const RunCrystalErrorsDat item,
RunIOV iov 
)
privatenoexcept

Definition at line 36 of file RunCrystalErrorsDat.cc.

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

38  {
39  this->checkConnection();
40  this->checkPrepare();
41 
42  int iovID = iov->fetchID();
43  if (!iovID) {
44  throw(std::runtime_error("RunCrystalErrorsDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("RunCrystalErrorsDat::writeDB: Bad EcalLogicID"));
50  }
51 
52  try {
53  m_writeStmt->setInt(1, iovID);
54  m_writeStmt->setInt(2, logicID);
55  m_writeStmt->setString(3, std::to_string(item->getErrorBits()));
56  m_writeStmt->executeUpdate();
57  } catch (SQLException& e) {
58  throw(std::runtime_error("RunCrystalErrorsDat::writeDB(): " + e.getMessage()));
59  }
60 }
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
uint64_t getErrorBits() const
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file RunCrystalErrorsDat.h.

Member Data Documentation

uint64_t RunCrystalErrorsDat::m_errorBits
private

Definition at line 32 of file RunCrystalErrorsDat.h.

Referenced by getErrorBits(), and setErrorBits().