CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
ITimingDat Class Reference

#include <ITimingDat.h>

Inheritance diagram for ITimingDat:
IDataItem IDBObject MonTimingCrystalDat MonTimingLaserBlueCrystalDat MonTimingLaserBlueTTDat MonTimingLaserGreenCrystalDat MonTimingLaserGreenTTDat MonTimingLaserIRedCrystalDat MonTimingLaserIRedTTDat MonTimingLaserRedCrystalDat MonTimingLaserRedTTDat MonTimingLed1CrystalDat MonTimingLed1TTDat MonTimingLed2CrystalDat MonTimingLed2TTDat MonTimingTTDat

Public Types

typedef oracle::occi::ResultSet ResultSet
 
typedef oracle::occi::SQLException SQLException
 

Public Member Functions

std::string getTable ()
 
bool getTaskStatus () const
 
float getTimingMean () const
 
float getTimingRMS () const
 
 ITimingDat ()
 
void setTable (std::string x)
 
void setTaskStatus (bool status)
 
void setTimingMean (float mean)
 
void setTimingRMS (float rms)
 
 ~ITimingDat ()
 
- 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

template<class DATT , class IOVT >
void fetchData (std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
template<class DATT , class IOVT >
void writeArrayDB (const std::map< EcalLogicID, DATT > *data, IOVT *iov) throw (std::runtime_error)
 
template<class DATT , class IOVT >
void writeDB (const EcalLogicID *ecid, const DATT *item, IOVT *iov) throw (std::runtime_error)
 

Private Attributes

std::string m_table_name
 
bool m_taskStatus
 
float m_timingMean
 
float m_timingRMS
 

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 17 of file ITimingDat.h.

Member Typedef Documentation

typedef oracle::occi::ResultSet ITimingDat::ResultSet

Definition at line 20 of file ITimingDat.h.

typedef oracle::occi::SQLException ITimingDat::SQLException

Definition at line 19 of file ITimingDat.h.

Constructor & Destructor Documentation

ITimingDat::ITimingDat ( )
inline

Definition at line 24 of file ITimingDat.h.

References IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, m_taskStatus, m_timingMean, m_timingRMS, IDataItem::m_writeStmt, and NULL.

25 {
26  m_env = NULL;
27  m_conn = NULL;
28  m_writeStmt = NULL;
29  m_readStmt = NULL;
30 
31  m_timingMean = 0;
32  m_timingRMS = 0;
33  m_taskStatus=0;
34 };
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
bool m_taskStatus
Definition: ITimingDat.h:253
float m_timingRMS
Definition: ITimingDat.h:252
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
float m_timingMean
Definition: ITimingDat.h:251
ITimingDat::~ITimingDat ( )
inline

Definition at line 38 of file ITimingDat.h.

38 {};

Member Function Documentation

template<class DATT , class IOVT >
void ITimingDat::fetchData ( std::map< EcalLogicID, DATT > *  fillMap,
IOVT *  iov 
)
throw (std::runtime_error
)
inlineprivate

Definition at line 197 of file ITimingDat.h.

References IDBObject::checkConnection(), alignCSCRings::e, getTable(), o2o::iov, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, and AlCaHLTBitMon_ParallelJobs::p.

199 {
200  this->checkConnection();
201  fillMap->clear();
202 
203  iov->setConnection(m_env, m_conn);
204  int iovID = iov->fetchID();
205  if (!iovID) {
206  // throw(std::runtime_error("ITimingDat::writeDB: IOV not in DB"));
207  return;
208  }
209 
210  try {
211 
212  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
213  "d.timing_mean, d.timing_rms, d.task_status "
214  "FROM channelview cv JOIN "+ getTable() +" d "
215  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
216  "WHERE d.iov_id = :iov_id");
217  m_readStmt->setInt(1, iovID);
218  ResultSet* rset = m_readStmt->executeQuery();
219 
220  std::pair< EcalLogicID, DATT > p;
221  DATT dat;
222  while(rset->next()) {
223  p.first = EcalLogicID( rset->getString(1), // name
224  rset->getInt(2), // logic_id
225  rset->getInt(3), // id1
226  rset->getInt(4), // id2
227  rset->getInt(5), // id3
228  rset->getString(6)); // maps_to
229 
230  dat.setTimingMean( rset->getFloat(7) );
231  dat.setTimingRMS( rset->getFloat(8) );
232  dat.setTaskStatus( rset->getInt(9) );
233 
234 
235  p.second = dat;
236  fillMap->insert(p);
237  }
238 
239 
240  } catch (SQLException &e) {
241  throw(std::runtime_error("ITimingDat::fetchData(): "+e.getMessage()));
242  }
243 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
Definition: ITimingDat.h:42
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple iov
Definition: o2o.py:307
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
Definition: IDBObject.h:41
std::string ITimingDat::getTable ( )
inlinevirtual
bool ITimingDat::getTaskStatus ( ) const
inline

Definition at line 52 of file ITimingDat.h.

References m_taskStatus.

52 { return m_taskStatus; }
bool m_taskStatus
Definition: ITimingDat.h:253
float ITimingDat::getTimingMean ( ) const
inline

Definition at line 46 of file ITimingDat.h.

References m_timingMean.

46 { return m_timingMean; }
float m_timingMean
Definition: ITimingDat.h:251
float ITimingDat::getTimingRMS ( ) const
inline

Definition at line 49 of file ITimingDat.h.

References m_timingRMS.

49 { return m_timingRMS; }
float m_timingRMS
Definition: ITimingDat.h:252
void ITimingDat::prepareWrite ( )
throw (std::runtime_error
)
inlineprivatevirtual

Implements IDataItem.

Definition at line 56 of file ITimingDat.h.

References IDBObject::checkConnection(), alignCSCRings::e, getTable(), IDBObject::m_conn, and IDataItem::m_writeStmt.

58 {
59  this->checkConnection();
60 
61  try {
62  m_writeStmt = m_conn->createStatement();
63  m_writeStmt->setSQL("INSERT INTO " + getTable() + " (iov_id, logic_id, "
64  "timing_mean, timing_rms , task_status ) "
65  "VALUES (:iov_id, :logic_id, "
66  ":timing_mean, :timing_rms, :task_status )");
67  } catch (SQLException &e) {
68  throw(std::runtime_error("ITimingDat::prepareWrite(): "+e.getMessage()));
69  }
70 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
Definition: ITimingDat.h:42
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void ITimingDat::setTable ( std::string  x)
inline

Definition at line 43 of file ITimingDat.h.

References m_table_name, and x.

43 { m_table_name=x; }
Definition: DDAxes.h:10
std::string m_table_name
Definition: ITimingDat.h:254
void ITimingDat::setTaskStatus ( bool  status)
inline

Definition at line 51 of file ITimingDat.h.

References m_taskStatus, and ntuplemaker::status.

Referenced by ecaldqm::LaserWriter::run(), and ecaldqm::LedWriter::run().

51 { m_taskStatus = status; }
bool m_taskStatus
Definition: ITimingDat.h:253
tuple status
Definition: ntuplemaker.py:245
void ITimingDat::setTimingMean ( float  mean)
inline

Definition at line 45 of file ITimingDat.h.

References m_timingMean, and timingPdfMaker::mean.

Referenced by ecaldqm::LaserWriter::run(), and ecaldqm::LedWriter::run().

45 { m_timingMean = mean; }
float m_timingMean
Definition: ITimingDat.h:251
void ITimingDat::setTimingRMS ( float  rms)
inline

Definition at line 48 of file ITimingDat.h.

References m_timingRMS, and plotscripts::rms().

Referenced by ecaldqm::LaserWriter::run(), and ecaldqm::LedWriter::run().

48 { m_timingRMS = rms; }
float m_timingRMS
Definition: ITimingDat.h:252
template<class DATT , class IOVT >
void ITimingDat::writeArrayDB ( const std::map< EcalLogicID, DATT > *  data,
IOVT *  iov 
)
throw (std::runtime_error
)
inlineprivate

Definition at line 102 of file ITimingDat.h.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), prof2calltree::count, data, alignCSCRings::e, EcalLogicID::getLogicID(), o2o::iov, IDataItem::m_writeStmt, AlCaHLTBitMon_ParallelJobs::p, x, and detailsBasic3DVector::y.

105 {
106  using oracle::occi::OCCIINT;
107  using oracle::occi::OCCIFLOAT;
108 
109  this->checkConnection();
110  this->checkPrepare();
111 
112  int iovID = iov->fetchID();
113  if (!iovID) { throw(std::runtime_error("ITimingDat::writeArrayDB: IOV not in DB")); }
114 
115 
116  int nrows=data->size();
117  int* ids= new int[nrows];
118  int* iovid_vec= new int[nrows];
119  float* xx= new float[nrows];
120  float* yy= new float[nrows];
121  int* st= new int[nrows];
122 
123 
124  ub2* ids_len= new ub2[nrows];
125  ub2* iov_len= new ub2[nrows];
126  ub2* x_len= new ub2[nrows];
127  ub2* y_len= new ub2[nrows];
128  ub2* st_len= new ub2[nrows];
129 
130 
131  const EcalLogicID* channel;
132  const DATT* dataitem;
133  int count=0;
134  // typedef std::map< EcalLogicID, DATT >::const_iterator CI;
135  typedef typename std::map< EcalLogicID, DATT >::const_iterator CI;
136  for (CI p = data->begin(); p != data->end(); ++p) {
137  channel = &(p->first);
138  int logicID = channel->getLogicID();
139  if (!logicID) { throw(std::runtime_error("ITimingDat::writeArrayDB: Bad EcalLogicID")); }
140  ids[count]=logicID;
141  iovid_vec[count]=iovID;
142 
143  dataitem = &(p->second);
144 
145  float x=dataitem->getTimingMean();
146  float y=dataitem->getTimingRMS();
147  int statu=dataitem->getTaskStatus();
148 
149  xx[count]=x;
150  yy[count]=y;
151  st[count]=statu;
152 
153 
154 
155  ids_len[count]=sizeof(ids[count]);
156  iov_len[count]=sizeof(iovid_vec[count]);
157 
158  x_len[count]=sizeof(xx[count]);
159  y_len[count]=sizeof(yy[count]);
160  st_len[count]=sizeof(st[count]);
161 
162  count++;
163  }
164 
165 
166  try {
167  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
168  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
169  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
170  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
171  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
172 
173  m_writeStmt->executeArrayUpdate(nrows);
174 
175  delete [] ids;
176  delete [] iovid_vec;
177  delete [] xx;
178  delete [] yy;
179  delete [] st;
180 
181  delete [] ids_len;
182  delete [] iov_len;
183  delete [] x_len;
184  delete [] y_len;
185  delete [] st_len;
186 
187  } catch (SQLException &e) {
188  throw(std::runtime_error("ITimingDat::writeArrayDB(): "+e.getMessage()));
189  }
190 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple iov
Definition: o2o.py:307
int getLogicID() const
Definition: EcalLogicID.cc:41
void checkPrepare()
Definition: IDataItem.h:31
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Definition: DDAxes.h:10
void checkConnection() const
Definition: IDBObject.h:41
template<class DATT , class IOVT >
void ITimingDat::writeDB ( const EcalLogicID ecid,
const DATT *  item,
IOVT *  iov 
)
throw (std::runtime_error
)
inlineprivate

Definition at line 74 of file ITimingDat.h.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), alignCSCRings::e, o2o::iov, and IDataItem::m_writeStmt.

76 {
77  this->checkConnection();
78  this->checkPrepare();
79 
80  int iovID = iov->fetchID();
81  if (!iovID) { throw(std::runtime_error("ITimingDat::writeDB: IOV not in DB")); }
82 
83  int logicID = ecid->getLogicID();
84  if (!logicID) { throw(std::runtime_error("ITimingDat::writeDB: Bad EcalLogicID")); }
85 
86  try {
87  m_writeStmt->setInt(1, iovID);
88  m_writeStmt->setInt(2, logicID);
89 
90  m_writeStmt->setFloat(3, item->getTimingMean() );
91  m_writeStmt->setFloat(4, item->getTimingRMS() );
92  m_writeStmt->setInt(5, item->getTaskStatus() );
93 
94 
95  m_writeStmt->executeUpdate();
96  } catch (SQLException &e) {
97  throw(std::runtime_error("ITimingDat::writeDB(): "+e.getMessage()));
98  }
99 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple iov
Definition: o2o.py:307
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 21 of file ITimingDat.h.

Member Data Documentation

std::string ITimingDat::m_table_name
private

Definition at line 254 of file ITimingDat.h.

Referenced by getTable(), and setTable().

bool ITimingDat::m_taskStatus
private

Definition at line 253 of file ITimingDat.h.

Referenced by getTaskStatus(), ITimingDat(), and setTaskStatus().

float ITimingDat::m_timingMean
private

Definition at line 251 of file ITimingDat.h.

Referenced by getTimingMean(), ITimingDat(), and setTimingMean().

float ITimingDat::m_timingRMS
private

Definition at line 252 of file ITimingDat.h.

Referenced by getTimingRMS(), ITimingDat(), and setTimingRMS().