CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
 RunDat ()
 
void setNumEvents (int num)
 
 ~RunDat ()
 
- 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) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const RunDat *item, RunIOV *iov) throw (std::runtime_error)
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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 ( )

Definition at line 11 of file RunDat.cc.

References NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_numEvents = 0;
17 }
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
#define NULL
Definition: scimark2.h:8
int m_numEvents
Definition: RunDat.h:34
RunDat::~RunDat ( )

Definition at line 21 of file RunDat.cc.

22 {
23 }

Member Function Documentation

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

Definition at line 70 of file RunDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, and setNumEvents().

72 {
73  this->checkConnection();
74  fillMap->clear();
75 
76  iov->setConnection(m_env, m_conn);
77  int iovID = iov->fetchID();
78  if (!iovID) {
79  // throw(std::runtime_error("RunDat::writeDB: IOV not in DB"));
80  return;
81  }
82 
83  try {
84  Statement* stmt = m_conn->createStatement();
85  stmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
86  "d.num_events "
87  "FROM channelview cv JOIN run_dat d "
88  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
89  "WHERE d.iov_id = :iov_id");
90  stmt->setInt(1, iovID);
91  ResultSet* rset = stmt->executeQuery();
92 
93  std::pair< EcalLogicID, RunDat > p;
94  RunDat dat;
95  while(rset->next()) {
96  p.first = EcalLogicID( rset->getString(1), // name
97  rset->getInt(2), // logic_id
98  rset->getInt(3), // id1
99  rset->getInt(4), // id2
100  rset->getInt(5), // id3
101  rset->getString(6)); // maps_to
102 
103  dat.setNumEvents( rset->getInt(7) );
104 
105  p.second = dat;
106  fillMap->insert(p);
107  }
108  m_conn->terminateStatement(stmt);
109  } catch (SQLException &e) {
110  throw(std::runtime_error("RunDat::fetchData(): "+e.getMessage()));
111  }
112 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID()
Definition: RunIOV.cc:103
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setNumEvents(int num)
Definition: RunDat.h:20
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Definition: RunDat.h:11
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
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:34
std::string RunDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file RunDat.h.

18 { return "RUN_DAT"; }
void RunDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 27 of file RunDat.cc.

References alignCSCRings::e.

29 {
30  this->checkConnection();
31 
32  try {
33  m_writeStmt = m_conn->createStatement();
34  m_writeStmt->setSQL("INSERT INTO run_dat (iov_id, logic_id, "
35  "num_events) "
36  "VALUES (:iov_id, :logic_id, "
37  ":num_events)");
38  } catch (SQLException &e) {
39  throw(std::runtime_error("RunDat::prepareWrite(): "+e.getMessage()));
40  }
41 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void RunDat::setNumEvents ( int  num)
inline

Definition at line 20 of file RunDat.h.

References m_numEvents, and pileupDistInMC::num.

Referenced by fetchData().

20 { m_numEvents = num; }
int m_numEvents
Definition: RunDat.h:34
void RunDat::writeDB ( const EcalLogicID ecid,
const RunDat item,
RunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 45 of file RunDat.cc.

References alignCSCRings::e, and o2o::iov.

47 {
48  this->checkConnection();
49  this->checkPrepare();
50 
51  int iovID = iov->fetchID();
52  if (!iovID) { throw(std::runtime_error("RunDat::writeDB: IOV not in DB")); }
53 
54  int logicID = ecid->getLogicID();
55  if (!logicID) { throw(std::runtime_error("RunDat::writeDB: Bad EcalLogicID")); }
56 
57  try {
58  m_writeStmt->setInt(1, iovID);
59  m_writeStmt->setInt(2, logicID);
60  m_writeStmt->setInt(3, item->getNumEvents());
61 
62  m_writeStmt->executeUpdate();
63  } catch (SQLException &e) {
64  throw(std::runtime_error("RunDat::writeDB(): "+e.getMessage()));
65  }
66 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int fetchID()
Definition: RunIOV.cc:103
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getNumEvents() const
Definition: RunDat.h:21
int getLogicID() const
Definition: EcalLogicID.cc:41
void checkPrepare()
Definition: IDataItem.h:31
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file RunDat.h.

Member Data Documentation

int RunDat::m_numEvents
private

Definition at line 34 of file RunDat.h.

Referenced by getNumEvents(), and setNumEvents().