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 ( )

Definition at line 10 of file MonOccupancyDat.cc.

11 {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
19  m_avgEnergy = 0;
20 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
MonOccupancyDat::~MonOccupancyDat ( )
override

Definition at line 24 of file MonOccupancyDat.cc.

25 {
26 }

Member Function Documentation

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

Definition at line 76 of file MonOccupancyDat.cc.

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

Referenced by getAvgEnergy().

78 {
79  this->checkConnection();
80  fillMap->clear();
81 
82  iov->setConnection(m_env, m_conn);
83  int iovID = iov->fetchID();
84  if (!iovID) {
85  // throw(std::runtime_error("MonOccupancyDat::writeDB: IOV not in DB"));
86  return;
87  }
88 
89  try {
90 
91  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
92  "d.events_over_low_threshold, d.events_over_high_threshold, d.avg_energy "
93  "FROM channelview cv JOIN mon_occupancy_dat d "
94  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
95  "WHERE d.iov_id = :iov_id");
96  m_readStmt->setInt(1, iovID);
97  ResultSet* rset = m_readStmt->executeQuery();
98 
99  std::pair< EcalLogicID, MonOccupancyDat > p;
100  MonOccupancyDat dat;
101  while(rset->next()) {
102  p.first = EcalLogicID( getOraString(rset,1), // name
103  rset->getInt(2), // logic_id
104  rset->getInt(3), // id1
105  rset->getInt(4), // id2
106  rset->getInt(5), // id3
107  getOraString(rset,6)); // maps_to
108 
109  dat.setEventsOverLowThreshold( rset->getInt(7) );
110  dat.setEventsOverHighThreshold( rset->getInt(8) );
111  dat.setAvgEnergy( rset->getFloat(9) );
112 
113  p.second = dat;
114  fillMap->insert(p);
115  }
116  } catch (SQLException &e) {
117  throw(std::runtime_error(std::string("MonOccupancyDat::fetchData(): ")+getOraMessage(&e)));
118  }
119 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setAvgEnergy(float energy)
void setEventsOverLowThreshold(int events)
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setEventsOverHighThreshold(int events)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
float MonOccupancyDat::getAvgEnergy ( ) const
inline

Definition at line 28 of file MonOccupancyDat.h.

References data, fetchData(), m_avgEnergy, noexcept, prepareWrite(), writeArrayDB(), and writeDB().

Referenced by writeArrayDB().

28 { return m_avgEnergy; }
int MonOccupancyDat::getEventsOverHighThreshold ( ) const
inline
int MonOccupancyDat::getEventsOverLowThreshold ( ) const
inline

Definition at line 22 of file MonOccupancyDat.h.

References m_eventsOverLowThreshold.

Referenced by writeArrayDB().

22 { return m_eventsOverLowThreshold; }
std::string MonOccupancyDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonOccupancyDat.h.

19 { return "MON_OCCUPANCY_DAT"; }
void MonOccupancyDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 30 of file MonOccupancyDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getAvgEnergy().

32 {
33  this->checkConnection();
34 
35  try {
36  m_writeStmt = m_conn->createStatement();
37  m_writeStmt->setSQL("INSERT INTO mon_occupancy_dat (iov_id, logic_id, "
38  "events_over_low_threshold, events_over_high_threshold, avg_energy) "
39  "VALUES (:iov_id, :logic_id, "
40  ":3, :4, :5)");
41  } catch (SQLException &e) {
42  throw(std::runtime_error(std::string("MonOccupancyDat::prepareWrite(): ")+getOraMessage(&e)));
43  }
44 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void MonOccupancyDat::setAvgEnergy ( float  energy)
inline

Definition at line 27 of file MonOccupancyDat.h.

References m_avgEnergy.

Referenced by fetchData(), and ecaldqm::OccupancyWriter::run().

27 { m_avgEnergy = energy; }
void MonOccupancyDat::setEventsOverHighThreshold ( int  events)
inline
void MonOccupancyDat::setEventsOverLowThreshold ( int  events)
inline
void MonOccupancyDat::writeArrayDB ( const std::map< EcalLogicID, MonOccupancyDat > *  data,
MonRunIOV iov 
)
privatenoexcept

Definition at line 121 of file MonOccupancyDat.cc.

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

Referenced by getAvgEnergy().

123 {
124  this->checkConnection();
125  this->checkPrepare();
126 
127  int iovID = iov->fetchID();
128  if (!iovID) { throw(std::runtime_error("MonOccupancyDat::writeArrayDB: IOV not in DB")); }
129 
130 
131  int nrows=data->size();
132  int* ids= new int[nrows];
133  int* iovid_vec= new int[nrows];
134  int* xx= new int[nrows];
135  int* yy= new int[nrows];
136  float* zz= new float[nrows];
137 
138  ub2* ids_len= new ub2[nrows];
139  ub2* iov_len= new ub2[nrows];
140  ub2* x_len= new ub2[nrows];
141  ub2* y_len= new ub2[nrows];
142  ub2* z_len= new ub2[nrows];
143 
144 
145  const EcalLogicID* channel;
146  const MonOccupancyDat* dataitem;
147  int count=0;
148  typedef map< EcalLogicID, MonOccupancyDat >::const_iterator CI;
149  for (CI p = data->begin(); p != data->end(); ++p) {
150  channel = &(p->first);
151  int logicID = channel->getLogicID();
152  if (!logicID) { throw(std::runtime_error("MonOccupancyDat::writeArrayDB: Bad EcalLogicID")); }
153  ids[count]=logicID;
154  iovid_vec[count]=iovID;
155 
156  dataitem = &(p->second);
157  // dataIface.writeDB( channel, dataitem, iov);
158  int x=dataitem->getEventsOverLowThreshold();
159  int y=dataitem->getEventsOverHighThreshold();
160  float z=dataitem->getAvgEnergy();
161 
162 
163 
164  xx[count]=x;
165  yy[count]=y;
166  zz[count]=z;
167 
168  ids_len[count]=sizeof(ids[count]);
169  iov_len[count]=sizeof(iovid_vec[count]);
170 
171  x_len[count]=sizeof(xx[count]);
172  y_len[count]=sizeof(yy[count]);
173  z_len[count]=sizeof(zz[count]);
174 
175  count++;
176  }
177 
178 
179  try {
180  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
181  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
182  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
183  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
184  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len );
185 
186  m_writeStmt->executeArrayUpdate(nrows);
187 
188  delete [] ids;
189  delete [] iovid_vec;
190  delete [] xx;
191  delete [] yy;
192  delete [] zz;
193 
194  delete [] ids_len;
195  delete [] iov_len;
196  delete [] x_len;
197  delete [] y_len;
198  delete [] z_len;
199 
200 
201  } catch (SQLException &e) {
202  throw(std::runtime_error(std::string("MonOccupancyDat::writeArrayDB(): ")+getOraMessage(&e)));
203  }
204 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int getEventsOverHighThreshold() const
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
float getAvgEnergy() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getEventsOverLowThreshold() const
int getLogicID() const
Definition: EcalLogicID.cc:41
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void MonOccupancyDat::writeDB ( const EcalLogicID ecid,
const MonOccupancyDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 48 of file MonOccupancyDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getAvgEnergy().

50 {
51  this->checkConnection();
52  this->checkPrepare();
53 
54  int iovID = iov->fetchID();
55  if (!iovID) { throw(std::runtime_error("MonOccupancyDat::writeDB: IOV not in DB")); }
56 
57  int logicID = ecid->getLogicID();
58  if (!logicID) { throw(std::runtime_error("MonOccupancyDat::writeDB: Bad EcalLogicID")); }
59 
60  try {
61  m_writeStmt->setInt(1, iovID);
62  m_writeStmt->setInt(2, logicID);
63 
64  m_writeStmt->setInt(3, item->getEventsOverLowThreshold() );
65  m_writeStmt->setInt(4, item->getEventsOverHighThreshold() );
66  m_writeStmt->setFloat(5, item->getAvgEnergy() );
67 
68  m_writeStmt->executeUpdate();
69  } catch (SQLException &e) {
70  throw(std::runtime_error(std::string("MonOccupancyDat::writeDB(): ")+getOraMessage(&e)));
71  }
72 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int getEventsOverHighThreshold() const
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
float getAvgEnergy() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getEventsOverLowThreshold() const
int getLogicID() const
Definition: EcalLogicID.cc:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonOccupancyDat.h.

Member Data Documentation

float MonOccupancyDat::m_avgEnergy
private

Definition at line 47 of file MonOccupancyDat.h.

Referenced by getAvgEnergy(), and setAvgEnergy().

int MonOccupancyDat::m_eventsOverHighThreshold
private

Definition at line 46 of file MonOccupancyDat.h.

Referenced by getEventsOverHighThreshold(), and setEventsOverHighThreshold().

int MonOccupancyDat::m_eventsOverLowThreshold
private

Definition at line 45 of file MonOccupancyDat.h.

Referenced by getEventsOverLowThreshold(), and setEventsOverLowThreshold().