CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
 MonOccupancyDat ()
 
void setAvgEnergy (float energy)
 
void setEventsOverHighThreshold (int events)
 
void setEventsOverLowThreshold (int events)
 
 ~MonOccupancyDat ()
 
- 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) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, MonOccupancyDat > *data, MonRunIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const MonOccupancyDat *item, MonRunIOV *iov) throw (std::runtime_error)
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
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
#define NULL
Definition: scimark2.h:8
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
MonOccupancyDat::~MonOccupancyDat ( )

Definition at line 24 of file MonOccupancyDat.cc.

25 {
26 }

Member Function Documentation

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

Definition at line 76 of file MonOccupancyDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setAvgEnergy(), setEventsOverHighThreshold(), and setEventsOverLowThreshold().

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( rset->getString(1), // name
103  rset->getInt(2), // logic_id
104  rset->getInt(3), // id1
105  rset->getInt(4), // id2
106  rset->getInt(5), // id3
107  rset->getString(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("MonOccupancyDat::fetchData(): "+e.getMessage()));
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()
Definition: MonRunIOV.cc:118
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setEventsOverHighThreshold(int events)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
float MonOccupancyDat::getAvgEnergy ( ) const
inline

Definition at line 28 of file MonOccupancyDat.h.

References m_avgEnergy.

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

Implements IDataItem.

Definition at line 19 of file MonOccupancyDat.h.

19 { return "MON_OCCUPANCY_DAT"; }
void MonOccupancyDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 30 of file MonOccupancyDat.cc.

References alignCSCRings::e.

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("MonOccupancyDat::prepareWrite(): "+e.getMessage()));
43  }
44 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void MonOccupancyDat::setAvgEnergy ( float  energy)
inline
void MonOccupancyDat::setEventsOverHighThreshold ( int  events)
inline

Definition at line 24 of file MonOccupancyDat.h.

References patZpeak::events, and m_eventsOverHighThreshold.

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

void MonOccupancyDat::setEventsOverLowThreshold ( int  events)
inline

Definition at line 21 of file MonOccupancyDat.h.

References patZpeak::events, and m_eventsOverLowThreshold.

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

tuple events
Definition: patZpeak.py:19
void MonOccupancyDat::writeArrayDB ( const std::map< EcalLogicID, MonOccupancyDat > *  data,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 121 of file MonOccupancyDat.cc.

References prof2calltree::count, data, alignCSCRings::e, getAvgEnergy(), getEventsOverHighThreshold(), getEventsOverLowThreshold(), EcalLogicID::getLogicID(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, x, y, and z.

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("MonOccupancyDat::writeArrayDB(): "+e.getMessage()));
203  }
204 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int getEventsOverHighThreshold() const
int fetchID()
Definition: MonRunIOV.cc:118
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
float getAvgEnergy() const
int getEventsOverLowThreshold() const
int getLogicID() const
Definition: EcalLogicID.cc:41
void checkPrepare()
Definition: IDataItem.h:31
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void checkConnection() const
Definition: IDBObject.h:41
void MonOccupancyDat::writeDB ( const EcalLogicID ecid,
const MonOccupancyDat item,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 48 of file MonOccupancyDat.cc.

References alignCSCRings::e, and o2o::iov.

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("MonOccupancyDat::writeDB(): "+e.getMessage()));
71  }
72 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int getEventsOverHighThreshold() const
int fetchID()
Definition: MonRunIOV.cc:118
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
float getAvgEnergy() const
int getEventsOverLowThreshold() const
int getLogicID() const
Definition: EcalLogicID.cc:41
void checkPrepare()
Definition: IDataItem.h:31
void checkConnection() const
Definition: IDBObject.h: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().