CMS 3D CMS Logo

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

#include <RunDat.h>

Inheritance diagram for RunDat:
IDataItem IDBObject

Public Member Functions

int getNumEvents () const
 
std::string getTable () override
 
 RunDat ()
 
void setNumEvents (int num)
 
 ~RunDat () 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, RunDat > *fillMap, RunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB (const EcalLogicID *ecid, const RunDat *item, RunIOV *iov) noexcept(false)
 

Private Attributes

int m_numEvents
 

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

Constructor & Destructor Documentation

◆ RunDat()

RunDat::RunDat ( )

Definition at line 11 of file RunDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_numEvents = 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
int m_numEvents
Definition: RunDat.h:31

◆ ~RunDat()

RunDat::~RunDat ( )
override

Definition at line 18 of file RunDat.cc.

18 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 60 of file RunDat.cc.

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

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

◆ getNumEvents()

int RunDat::getNumEvents ( ) const
inline

Definition at line 21 of file RunDat.h.

References m_numEvents.

21 { return m_numEvents; }
int m_numEvents
Definition: RunDat.h:31

◆ getTable()

std::string RunDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file RunDat.h.

18 { return "RUN_DAT"; }

◆ prepareWrite()

void RunDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 20 of file RunDat.cc.

References MillePedeFileConverter_cfg::e.

20  {
21  this->checkConnection();
22 
23  try {
24  m_writeStmt = m_conn->createStatement();
25  m_writeStmt->setSQL(
26  "INSERT INTO run_dat (iov_id, logic_id, "
27  "num_events) "
28  "VALUES (:iov_id, :logic_id, "
29  ":num_events)");
30  } catch (SQLException& e) {
31  throw(std::runtime_error("RunDat::prepareWrite(): " + e.getMessage()));
32  }
33 }
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

◆ setNumEvents()

void RunDat::setNumEvents ( int  num)
inline

Definition at line 20 of file RunDat.h.

References m_numEvents, and EgammaValidation_cff::num.

Referenced by fetchData().

◆ writeDB()

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

Definition at line 35 of file RunDat.cc.

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

35  {
36  this->checkConnection();
37  this->checkPrepare();
38 
39  int iovID = iov->fetchID();
40  if (!iovID) {
41  throw(std::runtime_error("RunDat::writeDB: IOV not in DB"));
42  }
43 
44  int logicID = ecid->getLogicID();
45  if (!logicID) {
46  throw(std::runtime_error("RunDat::writeDB: Bad EcalLogicID"));
47  }
48 
49  try {
50  m_writeStmt->setInt(1, iovID);
51  m_writeStmt->setInt(2, logicID);
52  m_writeStmt->setInt(3, item->getNumEvents());
53 
54  m_writeStmt->executeUpdate();
55  } catch (SQLException& e) {
56  throw(std::runtime_error("RunDat::writeDB(): " + e.getMessage()));
57  }
58 }
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 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 13 of file RunDat.h.

Member Data Documentation

◆ m_numEvents

int RunDat::m_numEvents
private

Definition at line 31 of file RunDat.h.

Referenced by getNumEvents(), and setNumEvents().