test
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
MonLaserPulseDat Class Reference

#include <MonLaserPulseDat.h>

Inheritance diagram for MonLaserPulseDat:
IDataItem IDBObject

Public Member Functions

float getPulseHeightMean () const
 
float getPulseHeightRMS () const
 
float getPulseWidthMean () const
 
float getPulseWidthRMS () const
 
std::string getTable ()
 
 MonLaserPulseDat ()
 
void setPulseHeightMean (float p)
 
void setPulseHeightRMS (float p)
 
void setPulseWidthMean (float p)
 
void setPulseWidthRMS (float p)
 
 ~MonLaserPulseDat ()
 
- 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, MonLaserPulseDat > *fillMap, MonRunIOV *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, MonLaserPulseDat > *data, MonRunIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const MonLaserPulseDat *item, MonRunIOV *iov) throw (std::runtime_error)
 

Private Attributes

float m_pulseHeightMean
 
float m_pulseHeightRMS
 
float m_pulseWidthMean
 
float m_pulseWidthRMS
 

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

Constructor & Destructor Documentation

MonLaserPulseDat::MonLaserPulseDat ( )

Definition at line 10 of file MonLaserPulseDat.cc.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16 
18  m_pulseHeightRMS = 0;
19  m_pulseWidthMean = 0;
20  m_pulseWidthRMS = 0;
21 }
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
MonLaserPulseDat::~MonLaserPulseDat ( )

Definition at line 25 of file MonLaserPulseDat.cc.

26 {
27 }

Member Function Documentation

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

Definition at line 78 of file MonLaserPulseDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setPulseHeightMean(), setPulseHeightRMS(), setPulseWidthMean(), and setPulseWidthRMS().

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

Definition at line 21 of file MonLaserPulseDat.h.

References m_pulseHeightMean.

Referenced by writeArrayDB().

21 { return m_pulseHeightMean; }
float MonLaserPulseDat::getPulseHeightRMS ( ) const
inline

Definition at line 24 of file MonLaserPulseDat.h.

References m_pulseHeightRMS.

Referenced by writeArrayDB().

24 { return m_pulseHeightRMS; }
float MonLaserPulseDat::getPulseWidthMean ( ) const
inline

Definition at line 27 of file MonLaserPulseDat.h.

References m_pulseWidthMean.

Referenced by writeArrayDB().

27 { return m_pulseWidthMean; }
float MonLaserPulseDat::getPulseWidthRMS ( ) const
inline

Definition at line 30 of file MonLaserPulseDat.h.

References m_pulseWidthRMS.

Referenced by writeArrayDB().

30 { return m_pulseWidthRMS; }
std::string MonLaserPulseDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file MonLaserPulseDat.h.

18 { return "MON_LASER_PULSE_DAT"; }
void MonLaserPulseDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 31 of file MonLaserPulseDat.cc.

References alignCSCRings::e.

33 {
34  this->checkConnection();
35 
36  try {
37  m_writeStmt = m_conn->createStatement();
38  m_writeStmt->setSQL("INSERT INTO mon_laser_pulse_dat (iov_id, logic_id, "
39  "pulse_height_mean, pulse_height_rms, pulse_width_mean, pulse_width_rms) "
40  "VALUES (:iov_id, :logic_id, "
41  ":3, :4, :5, :6)");
42  } catch (SQLException &e) {
43  throw(std::runtime_error("MonLaserPulseDat::prepareWrite(): "+e.getMessage()));
44  }
45 }
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 MonLaserPulseDat::setPulseHeightMean ( float  p)
inline
void MonLaserPulseDat::setPulseHeightRMS ( float  p)
inline
void MonLaserPulseDat::setPulseWidthMean ( float  p)
inline
void MonLaserPulseDat::setPulseWidthRMS ( float  p)
inline
void MonLaserPulseDat::writeArrayDB ( const std::map< EcalLogicID, MonLaserPulseDat > *  data,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 124 of file MonLaserPulseDat.cc.

References KineDebug3::count(), AlCaHLTBitMon_QueryRunRegistry::data, alignCSCRings::e, EcalLogicID::getLogicID(), getPulseHeightMean(), getPulseHeightRMS(), getPulseWidthMean(), getPulseWidthRMS(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, w, x, y, and z.

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

Definition at line 49 of file MonLaserPulseDat.cc.

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

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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file MonLaserPulseDat.h.

Member Data Documentation

float MonLaserPulseDat::m_pulseHeightMean
private

Definition at line 46 of file MonLaserPulseDat.h.

Referenced by getPulseHeightMean(), and setPulseHeightMean().

float MonLaserPulseDat::m_pulseHeightRMS
private

Definition at line 47 of file MonLaserPulseDat.h.

Referenced by getPulseHeightRMS(), and setPulseHeightRMS().

float MonLaserPulseDat::m_pulseWidthMean
private

Definition at line 48 of file MonLaserPulseDat.h.

Referenced by getPulseWidthMean(), and setPulseWidthMean().

float MonLaserPulseDat::m_pulseWidthRMS
private

Definition at line 49 of file MonLaserPulseDat.h.

Referenced by getPulseWidthRMS(), and setPulseWidthRMS().