CMS 3D CMS Logo

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

#include <CaliGeneralDat.h>

Inheritance diagram for CaliGeneralDat:
IDataItem IDBObject

Public Member Functions

 CaliGeneralDat ()
 
std::string getComments () const
 
int getNumEvents () const
 
std::string getTable () override
 
void setComments (std::string comments)
 
void setNumEvents (int n)
 
 ~CaliGeneralDat () 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, CaliGeneralDat > *fillVec, CaliIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB (const EcalLogicID *ecid, const CaliGeneralDat *item, CaliIOV *iov) noexcept(false)
 

Private Attributes

std::string m_comments
 
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 12 of file CaliGeneralDat.h.

Constructor & Destructor Documentation

CaliGeneralDat::CaliGeneralDat ( )

Definition at line 12 of file CaliGeneralDat.cc.

13 {
14  m_env = nullptr;
15  m_conn = nullptr;
16  m_writeStmt = nullptr;
17 
18  m_numEvents = 0;
19  m_comments = "none";
20 }
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
std::string m_comments
CaliGeneralDat::~CaliGeneralDat ( )
override

Definition at line 24 of file CaliGeneralDat.cc.

25 {
26 }

Member Function Documentation

void CaliGeneralDat::fetchData ( std::map< EcalLogicID, CaliGeneralDat > *  fillVec,
CaliIOV iov 
)
privatenoexcept

Definition at line 75 of file CaliGeneralDat.cc.

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

Referenced by getComments().

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

Definition at line 25 of file CaliGeneralDat.h.

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

25 { return m_comments; }
std::string m_comments
int CaliGeneralDat::getNumEvents ( ) const
inline

Definition at line 22 of file CaliGeneralDat.h.

References m_numEvents.

22 { return m_numEvents; }
std::string CaliGeneralDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file CaliGeneralDat.h.

19 { return "CALI_GENERAL_DAT"; }
void CaliGeneralDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 30 of file CaliGeneralDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComments().

32 {
33  this->checkConnection();
34 
35  try {
36  m_writeStmt = m_conn->createStatement();
37  m_writeStmt->setSQL("INSERT INTO cali_general_dat (iov_id, logic_id, "
38  "num_events, comments) "
39  "VALUES (:iov_id, :logic_id, "
40  ":3, :4)");
41  } catch (SQLException &e) {
42  throw(std::runtime_error(std::string("CaliGeneralDat::prepareWrite(): ")+getOraMessage(&e)));
43  }
44 }
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 CaliGeneralDat::setComments ( std::string  comments)
inline

Definition at line 24 of file CaliGeneralDat.h.

References indexGen::comments, and m_comments.

Referenced by fetchData().

24 { m_comments = comments; }
std::string m_comments
void CaliGeneralDat::setNumEvents ( int  n)
inline

Definition at line 21 of file CaliGeneralDat.h.

References m_numEvents, and gen::n.

Referenced by fetchData().

21 { m_numEvents = n; }
void CaliGeneralDat::writeDB ( const EcalLogicID ecid,
const CaliGeneralDat item,
CaliIOV iov 
)
privatenoexcept

Definition at line 48 of file CaliGeneralDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComments().

50 {
51  this->checkConnection();
52  this->checkPrepare();
53 
54  int iovID = iov->fetchID();
55  if (!iovID) { throw(std::runtime_error("CaliGeneralDat::writeDB: IOV not in DB")); }
56 
57  int logicID = ecid->getLogicID();
58  if (!logicID) { throw(std::runtime_error("CaliGeneralDat::writeDB: Bad EcalLogicID")); }
59 
60  try {
61  m_writeStmt->setInt(1, iovID);
62  m_writeStmt->setInt(2, logicID);
63 
64  m_writeStmt->setInt(3, item->getNumEvents() );
65  m_writeStmt->setString(4, item->getComments() );
66 
67  m_writeStmt->executeUpdate();
68  } catch (SQLException &e) {
69  throw(std::runtime_error(std::string("CaliGeneralDat::writeDB(): ")+getOraMessage(&e)));
70  }
71 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
std::string getComments() const
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 getNumEvents() const
int fetchID() noexcept(false) override
Definition: CaliIOV.cc:79

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file CaliGeneralDat.h.

Member Data Documentation

std::string CaliGeneralDat::m_comments
private

Definition at line 39 of file CaliGeneralDat.h.

Referenced by getComments(), and setComments().

int CaliGeneralDat::m_numEvents
private

Definition at line 38 of file CaliGeneralDat.h.

Referenced by getNumEvents(), and setNumEvents().