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
MonPedestalsOnlineDat Class Reference

#include <MonPedestalsOnlineDat.h>

Inheritance diagram for MonPedestalsOnlineDat:
IDataItem IDBObject

Public Member Functions

float getADCMeanG12 () const
 
float getADCRMSG12 () const
 
std::string getTable ()
 
bool getTaskStatus () const
 
 MonPedestalsOnlineDat ()
 
void setADCMeanG12 (float mean)
 
void setADCRMSG12 (float rms)
 
void setTaskStatus (bool status)
 
 ~MonPedestalsOnlineDat ()
 
- 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, MonPedestalsOnlineDat > *fillMap, MonRunIOV *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, MonPedestalsOnlineDat > *data, MonRunIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const MonPedestalsOnlineDat *item, MonRunIOV *iov) throw (std::runtime_error)
 

Private Attributes

float m_adcMeanG12
 
float m_adcRMSG12
 
bool m_taskStatus
 

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

Constructor & Destructor Documentation

MonPedestalsOnlineDat::MonPedestalsOnlineDat ( )

Definition at line 12 of file MonPedestalsOnlineDat.cc.

References NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
18 
19  m_adcMeanG12 = 0;
20  m_adcRMSG12 = 0;
21  m_taskStatus = 0;
22 }
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
MonPedestalsOnlineDat::~MonPedestalsOnlineDat ( )

Definition at line 26 of file MonPedestalsOnlineDat.cc.

27 {
28 }

Member Function Documentation

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

Definition at line 77 of file MonPedestalsOnlineDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setADCMeanG12(), setADCRMSG12(), and setTaskStatus().

79 {
80  this->checkConnection();
81  fillMap->clear();
82 
83  iov->setConnection(m_env, m_conn);
84  int iovID = iov->fetchID();
85  if (!iovID) {
86  // throw(std::runtime_error("MonPedestalsOnlineDat::writeDB: IOV not in DB"));
87  return;
88  }
89 
90  try {
91 
92  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
93  "d.adc_mean_g12, d.adc_rms_g12, d.task_status "
94  "FROM channelview cv JOIN mon_pedestals_online_dat d "
95  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
96  "WHERE d.iov_id = :iov_id");
97  m_readStmt->setInt(1, iovID);
98  ResultSet* rset = m_readStmt->executeQuery();
99 
100  std::pair< EcalLogicID, MonPedestalsOnlineDat > p;
102  while(rset->next()) {
103  p.first = EcalLogicID( rset->getString(1), // name
104  rset->getInt(2), // logic_id
105  rset->getInt(3), // id1
106  rset->getInt(4), // id2
107  rset->getInt(5), // id3
108  rset->getString(6)); // maps_to
109 
110  dat.setADCMeanG12( rset->getFloat(7) );
111  dat.setADCRMSG12( rset->getFloat(8) );
112  dat.setTaskStatus( rset->getInt(9) );
113 
114  p.second = dat;
115  fillMap->insert(p);
116  }
117  } catch (SQLException &e) {
118  throw(std::runtime_error("MonPedestalsOnlineDat::fetchData(): "+e.getMessage()));
119  }
120 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID()
Definition: MonRunIOV.cc:118
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setTaskStatus(bool status)
void setADCMeanG12(float mean)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
float MonPedestalsOnlineDat::getADCMeanG12 ( ) const
inline
float MonPedestalsOnlineDat::getADCRMSG12 ( ) const
inline
std::string MonPedestalsOnlineDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 19 of file MonPedestalsOnlineDat.h.

19 { return "MON_PEDESTALS_ONLINE_DAT"; }
bool MonPedestalsOnlineDat::getTaskStatus ( ) const
inline

Definition at line 28 of file MonPedestalsOnlineDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

void MonPedestalsOnlineDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 32 of file MonPedestalsOnlineDat.cc.

References alignCSCRings::e.

34 {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL("INSERT INTO mon_pedestals_online_dat (iov_id, logic_id, "
40  "adc_mean_g12, adc_rms_g12, task_status) "
41  "VALUES (:iov_id, :logic_id, "
42  ":adc_mean_g12, :adc_rms_g12, :task_status)");
43  } catch (SQLException &e) {
44  throw(std::runtime_error("MonPedestalsOnlineDat::prepareWrite(): "+e.getMessage()));
45  }
46 }
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 MonPedestalsOnlineDat::setADCMeanG12 ( float  mean)
inline

Definition at line 21 of file MonPedestalsOnlineDat.h.

References m_adcMeanG12, and timingPdfMaker::mean.

Referenced by fetchData().

void MonPedestalsOnlineDat::setADCRMSG12 ( float  rms)
inline

Definition at line 24 of file MonPedestalsOnlineDat.h.

References m_adcRMSG12, and plotscripts::rms().

Referenced by fetchData().

void MonPedestalsOnlineDat::setTaskStatus ( bool  status)
inline

Definition at line 27 of file MonPedestalsOnlineDat.h.

References m_taskStatus, and mps_update::status.

Referenced by fetchData().

void MonPedestalsOnlineDat::writeArrayDB ( const std::map< EcalLogicID, MonPedestalsOnlineDat > *  data,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 122 of file MonPedestalsOnlineDat.cc.

References KineDebug3::count(), data, alignCSCRings::e, getADCMeanG12(), getADCRMSG12(), EcalLogicID::getLogicID(), getTaskStatus(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, x, and y.

124 {
125  this->checkConnection();
126  this->checkPrepare();
127 
128  int iovID = iov->fetchID();
129  if (!iovID) { throw(std::runtime_error("MonPedestalsOnlineDat::writeArrayDB: IOV not in DB")); }
130 
131 
132  int nrows=data->size();
133  int* ids= new int[nrows];
134  int* iovid_vec= new int[nrows];
135  float* xx= new float[nrows];
136  float* yy= new float[nrows];
137  int* st= new int[nrows];
138 
139  ub2* ids_len= new ub2[nrows];
140  ub2* iov_len= new ub2[nrows];
141  ub2* x_len= new ub2[nrows];
142  ub2* y_len= new ub2[nrows];
143  ub2* st_len= new ub2[nrows];
144 
145  const EcalLogicID* channel;
146  const MonPedestalsOnlineDat* dataitem;
147  int count=0;
148  typedef map< EcalLogicID, MonPedestalsOnlineDat >::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("MonPedestalsOnlineDat::writeArrayDB: Bad EcalLogicID")); }
153  ids[count]=logicID;
154  iovid_vec[count]=iovID;
155 
156  dataitem = &(p->second);
157  // dataIface.writeDB( channel, dataitem, iov);
158  float x=dataitem->getADCMeanG12();
159  float y=dataitem->getADCRMSG12();
160  int statu=dataitem->getTaskStatus();
161 
162 
163 
164  xx[count]=x;
165  yy[count]=y;
166  st[count]=statu;
167 
168 
169  ids_len[count]=sizeof(ids[count]);
170  iov_len[count]=sizeof(iovid_vec[count]);
171 
172  x_len[count]=sizeof(xx[count]);
173  y_len[count]=sizeof(yy[count]);
174  st_len[count]=sizeof(st[count]);
175 
176  count++;
177  }
178 
179 
180  try {
181  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
182  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
183  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
184  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
185  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
186 
187 
188  m_writeStmt->executeArrayUpdate(nrows);
189 
190  delete [] ids;
191  delete [] iovid_vec;
192  delete [] xx;
193  delete [] yy;
194  delete [] st;
195 
196  delete [] ids_len;
197  delete [] iov_len;
198  delete [] x_len;
199  delete [] y_len;
200  delete [] st_len;
201 
202 
203 
204  } catch (SQLException &e) {
205  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): "+e.getMessage()));
206  }
207 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int fetchID()
Definition: MonRunIOV.cc:118
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
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 MonPedestalsOnlineDat::writeDB ( const EcalLogicID ecid,
const MonPedestalsOnlineDat item,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 50 of file MonPedestalsOnlineDat.cc.

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

52 {
53  this->checkConnection();
54  this->checkPrepare();
55 
56  int iovID = iov->fetchID();
57  if (!iovID) { throw(std::runtime_error("MonPedestalsOnlineDat::writeDB: IOV not in DB")); }
58 
59  int logicID = ecid->getLogicID();
60  if (!logicID) { throw(std::runtime_error("MonPedestalsOnlineDat::writeDB: Bad EcalLogicID")); }
61 
62  try {
63  m_writeStmt->setInt(1, iovID);
64  m_writeStmt->setInt(2, logicID);
65  m_writeStmt->setFloat(3, item->getADCMeanG12() );
66  m_writeStmt->setFloat(4, item->getADCRMSG12() );
67  m_writeStmt->setInt(5, item->getTaskStatus() );
68 
69  m_writeStmt->executeUpdate();
70  } catch (SQLException &e) {
71  throw(std::runtime_error("MonPedestalsOnlineDat::writeDB(): "+e.getMessage()));
72  }
73 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int fetchID()
Definition: MonRunIOV.cc:118
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
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 MonPedestalsOnlineDat.h.

Member Data Documentation

float MonPedestalsOnlineDat::m_adcMeanG12
private

Definition at line 46 of file MonPedestalsOnlineDat.h.

Referenced by getADCMeanG12(), and setADCMeanG12().

float MonPedestalsOnlineDat::m_adcRMSG12
private

Definition at line 47 of file MonPedestalsOnlineDat.h.

Referenced by getADCRMSG12(), and setADCRMSG12().

bool MonPedestalsOnlineDat::m_taskStatus
private

Definition at line 48 of file MonPedestalsOnlineDat.h.

Referenced by getTaskStatus(), and setTaskStatus().