CMS 3D CMS Logo

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

#include <RunH4TablePositionDat.h>

Inheritance diagram for RunH4TablePositionDat:
IDataItem IDBObject

Public Member Functions

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

Private Attributes

int m_numEvents
 
int m_numSpills
 
int m_table_x
 
int m_table_y
 

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

Constructor & Destructor Documentation

RunH4TablePositionDat::RunH4TablePositionDat ( )

Definition at line 11 of file RunH4TablePositionDat.cc.

12 {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_table_x = 0;
19  m_table_y = 0;
20  m_numSpills = 0;
21  m_numEvents = 0;
22 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
RunH4TablePositionDat::~RunH4TablePositionDat ( )
override

Definition at line 26 of file RunH4TablePositionDat.cc.

27 {
28 }

Member Function Documentation

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

Definition at line 78 of file RunH4TablePositionDat.cc.

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

Referenced by getNumEvents().

80 {
81  this->checkConnection();
82  fillMap->clear();
83 
84  iov->setConnection(m_env, m_conn);
85  int iovID = iov->fetchID();
86  if (!iovID) {
87  // throw(std::runtime_error("RunH4TablePositionDat::writeDB: IOV not in DB"));
88  return;
89  }
90 
91  try {
92 
93  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
94  "d.table_x, d.table_y, d.number_of_spills, d.number_of_events "
95  "FROM channelview cv JOIN run_h4_table_position_dat d "
96  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
97  "WHERE d.iov_id = :iov_id");
98  m_readStmt->setInt(1, iovID);
99  ResultSet* rset = m_readStmt->executeQuery();
100 
101  std::pair< EcalLogicID, RunH4TablePositionDat > p;
103  while(rset->next()) {
104  p.first = EcalLogicID( rset->getString(1), // name
105  rset->getInt(2), // logic_id
106  rset->getInt(3), // id1
107  rset->getInt(4), // id2
108  rset->getInt(5), // id3
109  rset->getString(6)); // maps_to
110 
111  dat.setTableX( rset->getInt(7) );
112  dat.setTableY( rset->getInt(8) );
113  dat.setNumSpills( rset->getInt(9) );
114  dat.setNumEvents( rset->getInt(10) );
115 
116  p.second = dat;
117  fillMap->insert(p);
118  }
119 
120  } catch (SQLException &e) {
121  throw(std::runtime_error("RunH4TablePositionDat::fetchData(): "+e.getMessage()));
122  }
123 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false) override
Definition: RunIOV.cc:103
int RunH4TablePositionDat::getNumEvents ( ) const
inline

Definition at line 30 of file RunH4TablePositionDat.h.

References fetchData(), m_numEvents, noexcept, prepareWrite(), and writeDB().

int RunH4TablePositionDat::getNumSpills ( ) const
inline

Definition at line 27 of file RunH4TablePositionDat.h.

References m_numSpills.

std::string RunH4TablePositionDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file RunH4TablePositionDat.h.

18 { return "RUN_H4_TABLE_POSITION_DAT"; }
int RunH4TablePositionDat::getTableX ( ) const
inline

Definition at line 21 of file RunH4TablePositionDat.h.

References m_table_x.

int RunH4TablePositionDat::getTableY ( ) const
inline

Definition at line 24 of file RunH4TablePositionDat.h.

References m_table_y.

void RunH4TablePositionDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 32 of file RunH4TablePositionDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getNumEvents().

34 {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL("INSERT INTO run_h4_table_position_dat (iov_id, logic_id, "
40  "table_x, table_y, number_of_spills, number_of_events ) "
41  "VALUES (:iov_id, :logic_id, "
42  ":table_x, :table_y, :number_of_spills, :number_of_events)");
43  } catch (SQLException &e) {
44  throw(std::runtime_error("RunH4TablePositionDat::prepareWrite(): "+e.getMessage()));
45  }
46 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void RunH4TablePositionDat::setNumEvents ( int  num)
inline

Definition at line 29 of file RunH4TablePositionDat.h.

References m_numEvents, and pileupDistInMC::num.

Referenced by fetchData().

void RunH4TablePositionDat::setNumSpills ( int  num)
inline

Definition at line 26 of file RunH4TablePositionDat.h.

References m_numSpills, and pileupDistInMC::num.

Referenced by fetchData().

void RunH4TablePositionDat::setTableX ( int  num)
inline

Definition at line 20 of file RunH4TablePositionDat.h.

References m_table_x, and pileupDistInMC::num.

Referenced by fetchData().

void RunH4TablePositionDat::setTableY ( int  num)
inline

Definition at line 23 of file RunH4TablePositionDat.h.

References m_table_y, and pileupDistInMC::num.

Referenced by fetchData().

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

Definition at line 50 of file RunH4TablePositionDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getNumEvents().

52 {
53  this->checkConnection();
54  this->checkPrepare();
55 
56  int iovID = iov->fetchID();
57  if (!iovID) { throw(std::runtime_error("RunH4TablePositionDat::writeDB: IOV not in DB")); }
58 
59  int logicID = ecid->getLogicID();
60  if (!logicID) { throw(std::runtime_error("RunH4TablePositionDat::writeDB: Bad EcalLogicID")); }
61 
62  try {
63  m_writeStmt->setInt(1, iovID);
64  m_writeStmt->setInt(2, logicID);
65  m_writeStmt->setInt(3, item->getTableX());
66  m_writeStmt->setInt(4, item->getTableY());
67  m_writeStmt->setInt(5, item->getNumSpills());
68  m_writeStmt->setInt(6, item->getNumEvents());
69 
70  m_writeStmt->executeUpdate();
71  } catch (SQLException &e) {
72  throw(std::runtime_error("RunH4TablePositionDat::writeDB(): "+e.getMessage()));
73  }
74 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
int fetchID() noexcept(false) override
Definition: RunIOV.cc:103

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file RunH4TablePositionDat.h.

Member Data Documentation

int RunH4TablePositionDat::m_numEvents
private

Definition at line 46 of file RunH4TablePositionDat.h.

Referenced by getNumEvents(), and setNumEvents().

int RunH4TablePositionDat::m_numSpills
private

Definition at line 45 of file RunH4TablePositionDat.h.

Referenced by getNumSpills(), and setNumSpills().

int RunH4TablePositionDat::m_table_x
private

Definition at line 43 of file RunH4TablePositionDat.h.

Referenced by getTableX(), and setTableX().

int RunH4TablePositionDat::m_table_y
private

Definition at line 44 of file RunH4TablePositionDat.h.

Referenced by getTableY(), and setTableY().