CMS 3D CMS Logo

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

#include <MonH4TablePositionDat.h>

Inheritance diagram for MonH4TablePositionDat:
IDataItem IDBObject

Public Member Functions

std::string getTable () override
 
float getTableX () const
 
float getTableY () const
 
 MonH4TablePositionDat ()
 
void setTableX (float x)
 
void setTableY (float y)
 
 ~MonH4TablePositionDat () 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, MonH4TablePositionDat > *fillMap, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonH4TablePositionDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonH4TablePositionDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_tableX
 
float m_tableY
 

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 11 of file MonH4TablePositionDat.h.

Constructor & Destructor Documentation

◆ MonH4TablePositionDat()

MonH4TablePositionDat::MonH4TablePositionDat ( )

Definition at line 10 of file MonH4TablePositionDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
16  m_tableX = 0;
17  m_tableY = 0;
18 }

◆ ~MonH4TablePositionDat()

MonH4TablePositionDat::~MonH4TablePositionDat ( )
override

Definition at line 20 of file MonH4TablePositionDat.cc.

20 {}

Member Function Documentation

◆ fetchData()

void MonH4TablePositionDat::fetchData ( std::map< EcalLogicID, MonH4TablePositionDat > *  fillMap,
MonRunIOV iov 
)
privatenoexcept

Definition at line 66 of file MonH4TablePositionDat.cc.

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

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setTableX(), and setTableY().

◆ getTable()

std::string MonH4TablePositionDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MonH4TablePositionDat.h.

18 { return "MON_H4_TABLE_POSITION_DAT"; }

◆ getTableX()

float MonH4TablePositionDat::getTableX ( ) const
inline

Definition at line 21 of file MonH4TablePositionDat.h.

21 { return m_tableX; }

References m_tableX.

Referenced by writeArrayDB().

◆ getTableY()

float MonH4TablePositionDat::getTableY ( ) const
inline

Definition at line 24 of file MonH4TablePositionDat.h.

24 { return m_tableY; }

References m_tableY.

Referenced by writeArrayDB().

◆ prepareWrite()

void MonH4TablePositionDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 22 of file MonH4TablePositionDat.cc.

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

References MillePedeFileConverter_cfg::e.

◆ setTableX()

void MonH4TablePositionDat::setTableX ( float  x)
inline

Definition at line 20 of file MonH4TablePositionDat.h.

20 { m_tableX = x; }

References m_tableX, and x.

Referenced by fetchData().

◆ setTableY()

void MonH4TablePositionDat::setTableY ( float  y)
inline

Definition at line 23 of file MonH4TablePositionDat.h.

23 { m_tableY = y; }

References m_tableY, and y.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 109 of file MonH4TablePositionDat.cc.

110  {
111  this->checkConnection();
112  this->checkPrepare();
113 
114  int iovID = iov->fetchID();
115  if (!iovID) {
116  throw(std::runtime_error("MonH4TablePositionDat::writeArrayDB: IOV not in DB"));
117  }
118 
119  int nrows = data->size();
120  int* ids = new int[nrows];
121  int* iovid_vec = new int[nrows];
122  float* xx = new float[nrows];
123  float* yy = new float[nrows];
124 
125  ub2* ids_len = new ub2[nrows];
126  ub2* iov_len = new ub2[nrows];
127  ub2* x_len = new ub2[nrows];
128  ub2* y_len = new ub2[nrows];
129 
130  const EcalLogicID* channel;
131  const MonH4TablePositionDat* dataitem;
132  int count = 0;
133  typedef map<EcalLogicID, MonH4TablePositionDat>::const_iterator CI;
134  for (CI p = data->begin(); p != data->end(); ++p) {
135  channel = &(p->first);
136  int logicID = channel->getLogicID();
137  if (!logicID) {
138  throw(std::runtime_error("MonH4TablePositionDat::writeArrayDB: Bad EcalLogicID"));
139  }
140  ids[count] = logicID;
141  iovid_vec[count] = iovID;
142 
143  dataitem = &(p->second);
144  // dataIface.writeDB( channel, dataitem, iov);
145  float x = dataitem->getTableX();
146  float y = dataitem->getTableY();
147 
148  xx[count] = x;
149  yy[count] = y;
150 
151  ids_len[count] = sizeof(ids[count]);
152  iov_len[count] = sizeof(iovid_vec[count]);
153 
154  x_len[count] = sizeof(xx[count]);
155  y_len[count] = sizeof(yy[count]);
156 
157  count++;
158  }
159 
160  try {
161  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
162  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
163  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
164  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
165 
166  m_writeStmt->executeArrayUpdate(nrows);
167 
168  delete[] ids;
169  delete[] iovid_vec;
170  delete[] xx;
171  delete[] yy;
172 
173  delete[] ids_len;
174  delete[] iov_len;
175  delete[] x_len;
176  delete[] y_len;
177 
178  } catch (SQLException& e) {
179  throw(std::runtime_error("MonH4TablePositionDat::writeArrayDB(): " + e.getMessage()));
180  }
181 }

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getTableX(), getTableY(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, and geometryCSVtoXML::yy.

◆ writeDB()

void MonH4TablePositionDat::writeDB ( const EcalLogicID ecid,
const MonH4TablePositionDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 37 of file MonH4TablePositionDat.cc.

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

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file MonH4TablePositionDat.h.

Member Data Documentation

◆ m_tableX

float MonH4TablePositionDat::m_tableX
private

Definition at line 36 of file MonH4TablePositionDat.h.

Referenced by getTableX(), and setTableX().

◆ m_tableY

float MonH4TablePositionDat::m_tableY
private

Definition at line 37 of file MonH4TablePositionDat.h.

Referenced by getTableY(), and setTableY().

DDAxes::y
MonRunIOV::fetchID
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
MonH4TablePositionDat::setTableX
void setTableX(float x)
Definition: MonH4TablePositionDat.h:20
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
MonH4TablePositionDat::setTableY
void setTableY(float y)
Definition: MonH4TablePositionDat.h:23
MonH4TablePositionDat::m_tableY
float m_tableY
Definition: MonH4TablePositionDat.h:37
MonH4TablePositionDat::m_tableX
float m_tableX
Definition: MonH4TablePositionDat.h:36
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
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
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
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
MonH4TablePositionDat::getTableX
float getTableX() const
Definition: MonH4TablePositionDat.h:21
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
MonH4TablePositionDat
Definition: MonH4TablePositionDat.h:11
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MonH4TablePositionDat::getTableY
float getTableY() const
Definition: MonH4TablePositionDat.h:24