CMS 3D CMS Logo

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

#include <DCUIDarkPedDat.h>

Inheritance diagram for DCUIDarkPedDat:
IDataItem IDBObject

Public Member Functions

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

Private Attributes

float m_ped
 

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

Constructor & Destructor Documentation

◆ DCUIDarkPedDat()

DCUIDarkPedDat::DCUIDarkPedDat ( )

Definition at line 12 of file DCUIDarkPedDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_ped = 0;
19 }

◆ ~DCUIDarkPedDat()

DCUIDarkPedDat::~DCUIDarkPedDat ( )
override

Definition at line 21 of file DCUIDarkPedDat.cc.

21 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 64 of file DCUIDarkPedDat.cc.

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("DCUIDarkPedDat::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.ped "
79  "FROM channelview cv JOIN dcu_idark_ped_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, DCUIDarkPedDat> p;
86  DCUIDarkPedDat 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.setPed(rset->getFloat(7));
96 
97  p.second = dat;
98  fillMap->insert(p);
99  }
100  } catch (SQLException& e) {
101  throw(std::runtime_error("DCUIDarkPedDat::fetchData(): " + e.getMessage()));
102  }
103 }

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

◆ getPed()

float DCUIDarkPedDat::getPed ( ) const
inline

Definition at line 22 of file DCUIDarkPedDat.h.

22 { return m_ped; }

References m_ped.

Referenced by writeArrayDB().

◆ getTable()

std::string DCUIDarkPedDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file DCUIDarkPedDat.h.

19 { return "DCU_IDARK_PED_DAT"; }

◆ prepareWrite()

void DCUIDarkPedDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file DCUIDarkPedDat.cc.

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

References MillePedeFileConverter_cfg::e.

◆ setPed()

void DCUIDarkPedDat::setPed ( float  temp)
inline

Definition at line 21 of file DCUIDarkPedDat.h.

21 { m_ped = temp; }

References m_ped, and groupFilesInBlocks::temp.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 104 of file DCUIDarkPedDat.cc.

104  {
105  this->checkConnection();
106  this->checkPrepare();
107 
108  int iovID = iov->fetchID();
109  if (!iovID) {
110  throw(std::runtime_error("DCUIDarkPedDat::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 DCUIDarkPedDat* dataitem;
124  int count = 0;
125  typedef map<EcalLogicID, DCUIDarkPedDat>::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("DCUIDarkPedDat::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->getPed();
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("DCUIDarkPedDat::writeArrayDB(): " + e.getMessage()));
166  }
167 }

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

◆ writeDB()

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

Definition at line 38 of file DCUIDarkPedDat.cc.

38  {
39  this->checkConnection();
40  this->checkPrepare();
41 
42  int iovID = iov->fetchID();
43  if (!iovID) {
44  throw(std::runtime_error("DCUIDarkPedDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("DCUIDarkPedDat::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->getPed());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("DCUIDarkPedDat::writeDB(): " + e.getMessage()));
61  }
62 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file DCUIDarkPedDat.h.

Member Data Documentation

◆ m_ped

float DCUIDarkPedDat::m_ped
private

Definition at line 34 of file DCUIDarkPedDat.h.

Referenced by getPed(), and setPed().

DCUIDarkPedDat::setPed
void setPed(float temp)
Definition: DCUIDarkPedDat.h:21
IDataItem::checkPrepare
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
DDAxes::x
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
IDataItem::m_readStmt
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
DCUIDarkPedDat
Definition: DCUIDarkPedDat.h:12
DCUIOV::fetchID
int fetchID() noexcept(false) override
Definition: DCUIOV.cc:48
DCUIDarkPedDat::getPed
float getPed() const
Definition: DCUIDarkPedDat.h:22
IDataItem::m_writeStmt
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
DCUIDarkPedDat::m_ped
float m_ped
Definition: DCUIDarkPedDat.h:34
EcalLogicID
Definition: EcalLogicID.h:7
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
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
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37