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 const int 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::CaliGeneralDat ( )

Definition at line 12 of file CaliGeneralDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16 
17  m_numEvents = 0;
18  m_comments = "none";
19 }

◆ ~CaliGeneralDat()

CaliGeneralDat::~CaliGeneralDat ( )
override

Definition at line 21 of file CaliGeneralDat.cc.

21 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 65 of file CaliGeneralDat.cc.

65  {
66  this->checkConnection();
67  fillMap->clear();
68 
69  iov->setConnection(m_env, m_conn);
70  int iovID = iov->fetchID();
71  if (!iovID) {
72  // throw(std::runtime_error("CaliGeneralDat::writeDB: IOV not in DB"));
73  return;
74  }
75 
76  try {
77  m_readStmt->setSQL(
78  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
79  "d.num_events, d.comments "
80  "FROM channelview cv JOIN cali_general_dat d "
81  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
82  "WHERE d.iov_id = :iov_id");
83  m_readStmt->setInt(1, iovID);
84  ResultSet* rset = m_readStmt->executeQuery();
85 
86  std::pair<EcalLogicID, CaliGeneralDat> p;
87  CaliGeneralDat dat;
88  while (rset->next()) {
89  p.first = EcalLogicID(rset->getString(1), // name
90  rset->getInt(2), // logic_id
91  rset->getInt(3), // id1
92  rset->getInt(4), // id2
93  rset->getInt(5), // id3
94  rset->getString(6)); // maps_to
95 
96  dat.setNumEvents(rset->getInt(7));
97  dat.setComments(rset->getString(8));
98 
99  p.second = dat;
100  fillMap->insert(p);
101  }
102  } catch (SQLException& e) {
103  throw(std::runtime_error("CaliGeneralDat::fetchData(): " + e.getMessage()));
104  }
105 }

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

◆ getComments()

std::string CaliGeneralDat::getComments ( ) const
inline

Definition at line 25 of file CaliGeneralDat.h.

25 { return m_comments; }

References m_comments.

◆ getNumEvents()

int CaliGeneralDat::getNumEvents ( ) const
inline

Definition at line 22 of file CaliGeneralDat.h.

22 { return m_numEvents; }

References m_numEvents.

◆ getTable()

std::string CaliGeneralDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file CaliGeneralDat.h.

19 { return "CALI_GENERAL_DAT"; }

◆ prepareWrite()

void CaliGeneralDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file CaliGeneralDat.cc.

23  {
24  this->checkConnection();
25 
26  try {
27  m_writeStmt = m_conn->createStatement();
28  m_writeStmt->setSQL(
29  "INSERT INTO cali_general_dat (iov_id, logic_id, "
30  "num_events, comments) "
31  "VALUES (:iov_id, :logic_id, "
32  ":3, :4)");
33  } catch (SQLException& e) {
34  throw(std::runtime_error("CaliGeneralDat::prepareWrite(): " + e.getMessage()));
35  }
36 }

References MillePedeFileConverter_cfg::e.

◆ setComments()

void CaliGeneralDat::setComments ( std::string  comments)
inline

Definition at line 24 of file CaliGeneralDat.h.

24 { m_comments = comments; }

References m_comments.

Referenced by fetchData().

◆ setNumEvents()

void CaliGeneralDat::setNumEvents ( int  n)
inline

Definition at line 21 of file CaliGeneralDat.h.

21 { m_numEvents = n; }

References m_numEvents, and dqmiodumpmetadata::n.

Referenced by fetchData().

◆ writeDB()

void CaliGeneralDat::writeDB ( const EcalLogicID ecid,
const CaliGeneralDat item,
CaliIOV iov 
)
privatenoexcept

Definition at line 38 of file CaliGeneralDat.cc.

38  {
39  this->checkConnection();
40  this->checkPrepare();
41 
42  int iovID = iov->fetchID();
43  if (!iovID) {
44  throw(std::runtime_error("CaliGeneralDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("CaliGeneralDat::writeDB: Bad EcalLogicID"));
50  }
51 
52  try {
53  m_writeStmt->setInt(1, iovID);
54  m_writeStmt->setInt(2, logicID);
55 
56  m_writeStmt->setInt(3, item->getNumEvents());
57  m_writeStmt->setString(4, item->getComments());
58 
59  m_writeStmt->executeUpdate();
60  } catch (SQLException& e) {
61  throw(std::runtime_error("CaliGeneralDat::writeDB(): " + e.getMessage()));
62  }
63 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file CaliGeneralDat.h.

Member Data Documentation

◆ m_comments

std::string CaliGeneralDat::m_comments
private

Definition at line 36 of file CaliGeneralDat.h.

Referenced by getComments(), and setComments().

◆ m_numEvents

int CaliGeneralDat::m_numEvents
private

Definition at line 35 of file CaliGeneralDat.h.

Referenced by getNumEvents(), and setNumEvents().

dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CaliIOV::fetchID
int fetchID() noexcept(false) override
Definition: CaliIOV.cc:48
IDataItem::checkPrepare
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
IDataItem::m_readStmt
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
IDataItem::m_writeStmt
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
EcalLogicID
Definition: EcalLogicID.h:7
CaliGeneralDat::m_numEvents
int m_numEvents
Definition: CaliGeneralDat.h:35
CaliGeneralDat::setComments
void setComments(std::string comments)
Definition: CaliGeneralDat.h:24
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
CaliGeneralDat::setNumEvents
void setNumEvents(int n)
Definition: CaliGeneralDat.h:21
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
CaliGeneralDat
Definition: CaliGeneralDat.h:12
CaliGeneralDat::m_comments
std::string m_comments
Definition: CaliGeneralDat.h:36
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37