CMS 3D CMS Logo

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

#include <MonOccupancyDat.h>

Inheritance diagram for MonOccupancyDat:
IDataItem IDBObject

Public Member Functions

float getAvgEnergy () const
 
int getEventsOverHighThreshold () const
 
int getEventsOverLowThreshold () const
 
std::string getTable () override
 
 MonOccupancyDat ()
 
void setAvgEnergy (float energy)
 
void setEventsOverHighThreshold (int events)
 
void setEventsOverLowThreshold (int events)
 
 ~MonOccupancyDat () 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, MonOccupancyDat > *fillVec, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonOccupancyDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonOccupancyDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_avgEnergy
 
int m_eventsOverHighThreshold
 
int m_eventsOverLowThreshold
 

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

Constructor & Destructor Documentation

◆ MonOccupancyDat()

MonOccupancyDat::MonOccupancyDat ( )

Definition at line 10 of file MonOccupancyDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
18  m_avgEnergy = 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

◆ ~MonOccupancyDat()

MonOccupancyDat::~MonOccupancyDat ( )
override

Definition at line 21 of file MonOccupancyDat.cc.

21 {}

Member Function Documentation

◆ fetchData()

void MonOccupancyDat::fetchData ( std::map< EcalLogicID, MonOccupancyDat > *  fillVec,
MonRunIOV iov 
)
privatenoexcept

Definition at line 66 of file MonOccupancyDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setAvgEnergy(), setEventsOverHighThreshold(), and setEventsOverLowThreshold().

66  {
67  this->checkConnection();
68  fillMap->clear();
69 
70  iov->setConnection(m_env, m_conn);
71  int iovID = iov->fetchID();
72  if (!iovID) {
73  // throw(std::runtime_error("MonOccupancyDat::writeDB: IOV not in DB"));
74  return;
75  }
76 
77  try {
78  m_readStmt->setSQL(
79  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
80  "d.events_over_low_threshold, d.events_over_high_threshold, d.avg_energy "
81  "FROM channelview cv JOIN mon_occupancy_dat d "
82  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
83  "WHERE d.iov_id = :iov_id");
84  m_readStmt->setInt(1, iovID);
85  ResultSet* rset = m_readStmt->executeQuery();
86 
87  std::pair<EcalLogicID, MonOccupancyDat> p;
88  MonOccupancyDat dat;
89  while (rset->next()) {
90  p.first = EcalLogicID(rset->getString(1), // name
91  rset->getInt(2), // logic_id
92  rset->getInt(3), // id1
93  rset->getInt(4), // id2
94  rset->getInt(5), // id3
95  rset->getString(6)); // maps_to
96 
97  dat.setEventsOverLowThreshold(rset->getInt(7));
98  dat.setEventsOverHighThreshold(rset->getInt(8));
99  dat.setAvgEnergy(rset->getFloat(9));
100 
101  p.second = dat;
102  fillMap->insert(p);
103  }
104  } catch (SQLException& e) {
105  throw(std::runtime_error("MonOccupancyDat::fetchData(): " + e.getMessage()));
106  }
107 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setAvgEnergy(float energy)
void setEventsOverLowThreshold(int events)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setEventsOverHighThreshold(int events)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getAvgEnergy()

float MonOccupancyDat::getAvgEnergy ( ) const
inline

Definition at line 28 of file MonOccupancyDat.h.

References m_avgEnergy.

Referenced by writeArrayDB().

28 { return m_avgEnergy; }

◆ getEventsOverHighThreshold()

int MonOccupancyDat::getEventsOverHighThreshold ( ) const
inline

◆ getEventsOverLowThreshold()

int MonOccupancyDat::getEventsOverLowThreshold ( ) const
inline

Definition at line 22 of file MonOccupancyDat.h.

References m_eventsOverLowThreshold.

Referenced by writeArrayDB().

22 { return m_eventsOverLowThreshold; }

◆ getTable()

std::string MonOccupancyDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonOccupancyDat.h.

19 { return "MON_OCCUPANCY_DAT"; }

◆ prepareWrite()

void MonOccupancyDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file MonOccupancyDat.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 mon_occupancy_dat (iov_id, logic_id, "
30  "events_over_low_threshold, events_over_high_threshold, avg_energy) "
31  "VALUES (:iov_id, :logic_id, "
32  ":3, :4, :5)");
33  } catch (SQLException& e) {
34  throw(std::runtime_error("MonOccupancyDat::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

◆ setAvgEnergy()

void MonOccupancyDat::setAvgEnergy ( float  energy)
inline

◆ setEventsOverHighThreshold()

void MonOccupancyDat::setEventsOverHighThreshold ( int  events)
inline

Definition at line 24 of file MonOccupancyDat.h.

References events, and m_eventsOverHighThreshold.

Referenced by fetchData().

◆ setEventsOverLowThreshold()

void MonOccupancyDat::setEventsOverLowThreshold ( int  events)
inline

Definition at line 21 of file MonOccupancyDat.h.

References events, and m_eventsOverLowThreshold.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 109 of file MonOccupancyDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getAvgEnergy(), getEventsOverHighThreshold(), getEventsOverLowThreshold(), EcalLogicID::getLogicID(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

109  {
110  this->checkConnection();
111  this->checkPrepare();
112 
113  int iovID = iov->fetchID();
114  if (!iovID) {
115  throw(std::runtime_error("MonOccupancyDat::writeArrayDB: IOV not in DB"));
116  }
117 
118  int nrows = data->size();
119  int* ids = new int[nrows];
120  int* iovid_vec = new int[nrows];
121  int* xx = new int[nrows];
122  int* yy = new int[nrows];
123  float* zz = 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  ub2* z_len = new ub2[nrows];
130 
131  const EcalLogicID* channel;
132  const MonOccupancyDat* dataitem;
133  int count = 0;
134  typedef map<EcalLogicID, MonOccupancyDat>::const_iterator CI;
135  for (CI p = data->begin(); p != data->end(); ++p) {
136  channel = &(p->first);
137  int logicID = channel->getLogicID();
138  if (!logicID) {
139  throw(std::runtime_error("MonOccupancyDat::writeArrayDB: Bad EcalLogicID"));
140  }
141  ids[count] = logicID;
142  iovid_vec[count] = iovID;
143 
144  dataitem = &(p->second);
145  // dataIface.writeDB( channel, dataitem, iov);
146  int x = dataitem->getEventsOverLowThreshold();
147  int y = dataitem->getEventsOverHighThreshold();
148  float z = dataitem->getAvgEnergy();
149 
150  xx[count] = x;
151  yy[count] = y;
152  zz[count] = z;
153 
154  ids_len[count] = sizeof(ids[count]);
155  iov_len[count] = sizeof(iovid_vec[count]);
156 
157  x_len[count] = sizeof(xx[count]);
158  y_len[count] = sizeof(yy[count]);
159  z_len[count] = sizeof(zz[count]);
160 
161  count++;
162  }
163 
164  try {
165  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
166  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
167  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
168  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
169  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT, sizeof(zz[0]), z_len);
170 
171  m_writeStmt->executeArrayUpdate(nrows);
172 
173  delete[] ids;
174  delete[] iovid_vec;
175  delete[] xx;
176  delete[] yy;
177  delete[] zz;
178 
179  delete[] ids_len;
180  delete[] iov_len;
181  delete[] x_len;
182  delete[] y_len;
183  delete[] z_len;
184 
185  } catch (SQLException& e) {
186  throw(std::runtime_error("MonOccupancyDat::writeArrayDB(): " + e.getMessage()));
187  }
188 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
int getEventsOverHighThreshold() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
int getLogicID() const
Definition: EcalLogicID.cc:28
float getAvgEnergy() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int getEventsOverLowThreshold() const

◆ writeDB()

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

Definition at line 38 of file MonOccupancyDat.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("MonOccupancyDat::writeDB: IOV not in DB"));
45  }
46 
47  int logicID = ecid->getLogicID();
48  if (!logicID) {
49  throw(std::runtime_error("MonOccupancyDat::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->getEventsOverLowThreshold());
57  m_writeStmt->setInt(4, item->getEventsOverHighThreshold());
58  m_writeStmt->setFloat(5, item->getAvgEnergy());
59 
60  m_writeStmt->executeUpdate();
61  } catch (SQLException& e) {
62  throw(std::runtime_error("MonOccupancyDat::writeDB(): " + e.getMessage()));
63  }
64 }
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 fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
int getLogicID() const
Definition: EcalLogicID.cc:28

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonOccupancyDat.h.

Member Data Documentation

◆ m_avgEnergy

float MonOccupancyDat::m_avgEnergy
private

Definition at line 42 of file MonOccupancyDat.h.

Referenced by getAvgEnergy(), and setAvgEnergy().

◆ m_eventsOverHighThreshold

int MonOccupancyDat::m_eventsOverHighThreshold
private

Definition at line 41 of file MonOccupancyDat.h.

Referenced by getEventsOverHighThreshold(), and setEventsOverHighThreshold().

◆ m_eventsOverLowThreshold

int MonOccupancyDat::m_eventsOverLowThreshold
private

Definition at line 40 of file MonOccupancyDat.h.

Referenced by getEventsOverLowThreshold(), and setEventsOverLowThreshold().