CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
DCUCapsuleTempDat Class Reference

#include <DCUCapsuleTempDat.h>

Inheritance diagram for DCUCapsuleTempDat:
IDataItem IDBObject

Public Member Functions

 DCUCapsuleTempDat ()
 
float getCapsuleTemp () const
 
std::string getTable () override
 
void setCapsuleTemp (float temp)
 
 ~DCUCapsuleTempDat () 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, DCUCapsuleTempDat > *fillVec, DCUIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, DCUCapsuleTempDat > *data, DCUIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const DCUCapsuleTempDat *item, DCUIOV *iov) noexcept(false)
 

Private Attributes

float m_capsuleTemp
 

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

Constructor & Destructor Documentation

DCUCapsuleTempDat::DCUCapsuleTempDat ( )

Definition at line 12 of file DCUCapsuleTempDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_capsuleTemp = 0;
19 }
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
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
DCUCapsuleTempDat::~DCUCapsuleTempDat ( )
override

Definition at line 21 of file DCUCapsuleTempDat.cc.

21 {}

Member Function Documentation

void DCUCapsuleTempDat::fetchData ( std::map< EcalLogicID, DCUCapsuleTempDat > *  fillVec,
DCUIOV iov 
)
privatenoexcept

Definition at line 64 of file DCUCapsuleTempDat.cc.

References dat, alignCSCRings::e, AlCaHLTBitMon_ParallelJobs::p, and setCapsuleTemp().

64  {
65  this->checkConnection();
66  fillMap->clear();
67 
68  iov->setConnection(m_env, m_conn);
69  int iovID = iov->fetchID();
70  if (!iovID) {
71  // throw(std::runtime_error("DCUCapsuleTempDat::writeDB: IOV not in DB"));
72  return;
73  }
74 
75  try {
76  m_readStmt->setSQL(
77  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
78  "d.capsule_temp "
79  "FROM channelview cv JOIN dcu_capsule_temp_dat d "
80  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
81  "WHERE d.iov_id = :iov_id");
82  m_readStmt->setInt(1, iovID);
83  ResultSet* rset = m_readStmt->executeQuery();
84 
85  std::pair<EcalLogicID, DCUCapsuleTempDat> p;
87  while (rset->next()) {
88  p.first = EcalLogicID(rset->getString(1), // name
89  rset->getInt(2), // logic_id
90  rset->getInt(3), // id1
91  rset->getInt(4), // id2
92  rset->getInt(5), // id3
93  rset->getString(6)); // maps_to
94 
95  dat.setCapsuleTemp(rset->getFloat(7));
96 
97  p.second = dat;
98  fillMap->insert(p);
99  }
100  } catch (SQLException& e) {
101  throw(std::runtime_error("DCUCapsuleTempDat::fetchData(): " + e.getMessage()));
102  }
103 }
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
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
static std::vector< std::string > checklist dat
int fetchID() noexcept(false) override
Definition: DCUIOV.cc:48
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setCapsuleTemp(float temp)
float DCUCapsuleTempDat::getCapsuleTemp ( ) const
inline

Definition at line 22 of file DCUCapsuleTempDat.h.

References m_capsuleTemp.

Referenced by writeArrayDB().

22 { return m_capsuleTemp; }
std::string DCUCapsuleTempDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file DCUCapsuleTempDat.h.

19 { return "DCU_CAPSULE_TEMP_DAT"; }
void DCUCapsuleTempDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file DCUCapsuleTempDat.cc.

References alignCSCRings::e.

23  {
24  this->checkConnection();
25 
26  try {
27  m_writeStmt = m_conn->createStatement();
28  m_writeStmt->setSQL(
29  "INSERT INTO dcu_capsule_temp_dat (iov_id, logic_id, "
30  "capsule_temp) "
31  "VALUES (:iov_id, :logic_id, "
32  ":capsule_temp)");
33  } catch (SQLException& e) {
34  throw(std::runtime_error("DCUCapsuleTempDat::prepareWrite(): " + e.getMessage()));
35  }
36 }
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
void DCUCapsuleTempDat::setCapsuleTemp ( float  temp)
inline

Definition at line 21 of file DCUCapsuleTempDat.h.

References m_capsuleTemp, and groupFilesInBlocks::temp.

Referenced by fetchData().

void DCUCapsuleTempDat::writeArrayDB ( const std::map< EcalLogicID, DCUCapsuleTempDat > *  data,
DCUIOV iov 
)
privatenoexcept

Definition at line 104 of file DCUCapsuleTempDat.cc.

References submitPVResolutionJobs::count, data, alignCSCRings::e, getCapsuleTemp(), EcalLogicID::getLogicID(), AlCaHLTBitMon_ParallelJobs::p, and x.

105  {
106  this->checkConnection();
107  this->checkPrepare();
108 
109  int iovID = iov->fetchID();
110  if (!iovID) {
111  throw(std::runtime_error("DCUCapsuleTempDat::writeArrayDB: IOV not in DB"));
112  }
113 
114  int nrows = data->size();
115  int* ids = new int[nrows];
116  int* iovid_vec = new int[nrows];
117  float* xx = new float[nrows];
118 
119  ub2* ids_len = new ub2[nrows];
120  ub2* iov_len = new ub2[nrows];
121  ub2* x_len = new ub2[nrows];
122 
123  const EcalLogicID* channel;
124  const DCUCapsuleTempDat* dataitem;
125  int count = 0;
126  typedef map<EcalLogicID, DCUCapsuleTempDat>::const_iterator CI;
127  for (CI p = data->begin(); p != data->end(); ++p) {
128  channel = &(p->first);
129  int logicID = channel->getLogicID();
130  if (!logicID) {
131  throw(std::runtime_error("DCUCapsuleTempDat::writeArrayDB: Bad EcalLogicID"));
132  }
133  ids[count] = logicID;
134  iovid_vec[count] = iovID;
135 
136  dataitem = &(p->second);
137  // dataIface.writeDB( channel, dataitem, iov);
138  float x = dataitem->getCapsuleTemp();
139 
140  xx[count] = x;
141 
142  ids_len[count] = sizeof(ids[count]);
143  iov_len[count] = sizeof(iovid_vec[count]);
144 
145  x_len[count] = sizeof(xx[count]);
146 
147  count++;
148  }
149 
150  try {
151  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
152  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
153  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
154 
155  m_writeStmt->executeArrayUpdate(nrows);
156 
157  delete[] ids;
158  delete[] iovid_vec;
159  delete[] xx;
160 
161  delete[] ids_len;
162  delete[] iov_len;
163  delete[] x_len;
164 
165  } catch (SQLException& e) {
166  throw(std::runtime_error("DCUCapsuleTempDat::writeArrayDB(): " + e.getMessage()));
167  }
168 }
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
float getCapsuleTemp() const
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: DCUIOV.cc:48
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void DCUCapsuleTempDat::writeDB ( const EcalLogicID ecid,
const DCUCapsuleTempDat item,
DCUIOV iov 
)
privatenoexcept

Definition at line 38 of file DCUCapsuleTempDat.cc.

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

38  {
39  this->checkConnection();
40  this->checkPrepare();
41 
42  int iovID = iov->fetchID();
43  if (!iovID) {
44  throw(std::runtime_error("DCUCapsuleTempDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("DCUCapsuleTempDat::writeDB: Bad EcalLogicID"));
50  }
51 
52  try {
53  m_writeStmt->setInt(1, iovID);
54  m_writeStmt->setInt(2, logicID);
55 
56  m_writeStmt->setFloat(3, item->getCapsuleTemp());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("DCUCapsuleTempDat::writeDB(): " + e.getMessage()));
61  }
62 }
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
float getCapsuleTemp() const
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: DCUIOV.cc:48

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file DCUCapsuleTempDat.h.

Member Data Documentation

float DCUCapsuleTempDat::m_capsuleTemp
private

Definition at line 34 of file DCUCapsuleTempDat.h.

Referenced by getCapsuleTemp(), and setCapsuleTemp().