CMS 3D CMS Logo

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

#include <DCUIDarkDat.h>

Inheritance diagram for DCUIDarkDat:
IDataItem IDBObject

Public Member Functions

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

Private Attributes

float m_apdIDark
 

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

Constructor & Destructor Documentation

◆ DCUIDarkDat()

DCUIDarkDat::DCUIDarkDat ( )

Definition at line 12 of file DCUIDarkDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_apdIDark = 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
float m_apdIDark
Definition: DCUIDarkDat.h:34

◆ ~DCUIDarkDat()

DCUIDarkDat::~DCUIDarkDat ( )
override

Definition at line 21 of file DCUIDarkDat.cc.

21 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 64 of file DCUIDarkDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, and setAPDIDark().

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("DCUIDarkDat::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.apd_idark "
79  "FROM channelview cv JOIN dcu_idark_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, DCUIDarkDat> p;
86  DCUIDarkDat dat;
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.setAPDIDark(rset->getFloat(7));
96 
97  p.second = dat;
98  fillMap->insert(p);
99  }
100  } catch (SQLException& e) {
101  throw(std::runtime_error("DCUIDarkDat::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
void setAPDIDark(float i)
Definition: DCUIDarkDat.h:21
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
int fetchID() noexcept(false) override
Definition: DCUIOV.cc:48
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getAPDIDark()

float DCUIDarkDat::getAPDIDark ( ) const
inline

Definition at line 22 of file DCUIDarkDat.h.

References m_apdIDark.

Referenced by writeArrayDB().

22 { return m_apdIDark; }
float m_apdIDark
Definition: DCUIDarkDat.h:34

◆ getTable()

std::string DCUIDarkDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file DCUIDarkDat.h.

19 { return "DCU_IDARK_DAT"; }

◆ prepareWrite()

void DCUIDarkDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file DCUIDarkDat.cc.

References MillePedeFileConverter_cfg::e.

23  {
24  this->checkConnection();
25 
26  try {
27  m_writeStmt = m_conn->createStatement();
28  m_writeStmt->setSQL(
29  "INSERT INTO dcu_idark_dat (iov_id, logic_id, "
30  "apd_idark) "
31  "VALUES (:iov_id, :logic_id, "
32  ":apd_idark)");
33  } catch (SQLException& e) {
34  throw(std::runtime_error("DCUIDarkDat::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

◆ setAPDIDark()

void DCUIDarkDat::setAPDIDark ( float  i)
inline

Definition at line 21 of file DCUIDarkDat.h.

References mps_fire::i, and m_apdIDark.

Referenced by fetchData().

21 { m_apdIDark = i; }
float m_apdIDark
Definition: DCUIDarkDat.h:34

◆ writeArrayDB()

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

Definition at line 104 of file DCUIDarkDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getAPDIDark(), EcalLogicID::getLogicID(), AlCaHLTBitMon_ParallelJobs::p, x, and geometryCSVtoXML::xx.

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

◆ writeDB()

void DCUIDarkDat::writeDB ( const EcalLogicID ecid,
const DCUIDarkDat item,
DCUIOV iov 
)
privatenoexcept

Definition at line 38 of file DCUIDarkDat.cc.

References MillePedeFileConverter_cfg::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("DCUIDarkDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("DCUIDarkDat::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->getAPDIDark());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("DCUIDarkDat::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
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: DCUIOV.cc:48

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file DCUIDarkDat.h.

Member Data Documentation

◆ m_apdIDark

float DCUIDarkDat::m_apdIDark
private

Definition at line 34 of file DCUIDarkDat.h.

Referenced by getAPDIDark(), and setAPDIDark().