CMS 3D CMS Logo

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

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

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 () 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 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, and IDataItem::m_writeStmt.

25 {
26  m_env = nullptr;
27  m_conn = nullptr;
28  m_writeStmt = nullptr;
29  m_readStmt = nullptr;
30 
31  m_timingMean = 0;
32  m_timingRMS = 0;
33  m_taskStatus=false;
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
bool m_taskStatus
Definition: ITimingDat.h:248
float m_timingRMS
Definition: ITimingDat.h:247
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
float m_timingMean
Definition: ITimingDat.h:246
ITimingDat::~ITimingDat ( )
inlineoverride

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

Definition at line 193 of file ITimingDat.h.

References IDBObject::checkConnection(), MillePedeFileConverter_cfg::e, getTable(), IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

194 {
195  this->checkConnection();
196  fillMap->clear();
197 
198  iov->setConnection(m_env, m_conn);
199  int iovID = iov->fetchID();
200  if (!iovID) {
201  // throw(std::runtime_error("ITimingDat::writeDB: IOV not in DB"));
202  return;
203  }
204 
205  try {
206 
207  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
208  "d.timing_mean, d.timing_rms, d.task_status "
209  "FROM channelview cv JOIN "+ getTable() +" d "
210  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
211  "WHERE d.iov_id = :iov_id");
212  m_readStmt->setInt(1, iovID);
213  ResultSet* rset = m_readStmt->executeQuery();
214 
215  std::pair< EcalLogicID, DATT > p;
216  DATT dat;
217  while(rset->next()) {
218  p.first = EcalLogicID( getOraString(rset,1), // name
219  rset->getInt(2), // logic_id
220  rset->getInt(3), // id1
221  rset->getInt(4), // id2
222  rset->getInt(5), // id3
223  getOraString(rset,6)); // maps_to
224 
225  dat.setTimingMean( rset->getFloat(7) );
226  dat.setTimingRMS( rset->getFloat(8) );
227  dat.setTaskStatus( rset->getInt(9) );
228 
229 
230  p.second = dat;
231  fillMap->insert(p);
232  }
233 
234 
235  } catch (SQLException &e) {
236  throw(std::runtime_error(std::string("ITimingDat::fetchData(): ")+getOraMessage(&e)));
237  }
238 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable() override
Definition: ITimingDat.h:42
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19
oracle::occi::ResultSet ResultSet
Definition: ITimingDat.h:20
std::string ITimingDat::getTable ( )
inlineoverridevirtual
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:248
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:246
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:247
void ITimingDat::prepareWrite ( )
inlineoverrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 56 of file ITimingDat.h.

References IDBObject::checkConnection(), MillePedeFileConverter_cfg::e, getTable(), IDBObject::m_conn, IDataItem::m_writeStmt, and AlCaHLTBitMon_QueryRunRegistry::string.

57 {
58  this->checkConnection();
59 
60  try {
61  m_writeStmt = m_conn->createStatement();
62  m_writeStmt->setSQL("INSERT INTO " + getTable() + " (iov_id, logic_id, "
63  "timing_mean, timing_rms , task_status ) "
64  "VALUES (:iov_id, :logic_id, "
65  ":timing_mean, :timing_rms, :task_status )");
66  } catch (SQLException &e) {
67  throw(std::runtime_error(std::string("ITimingDat::prepareWrite(): ")+getOraMessage(&e)));
68  }
69 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable() override
Definition: ITimingDat.h:42
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19
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; }
std::string m_table_name
Definition: ITimingDat.h:249
void ITimingDat::setTaskStatus ( bool  status)
inline

Definition at line 51 of file ITimingDat.h.

References m_taskStatus, and mps_update::status.

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

51 { m_taskStatus = status; }
bool m_taskStatus
Definition: ITimingDat.h:248
void ITimingDat::setTimingMean ( float  mean)
inline
void ITimingDat::setTimingRMS ( float  rms)
inline
template<class DATT , class IOVT >
void ITimingDat::writeArrayDB ( const std::map< EcalLogicID, DATT > *  data,
IOVT *  iov 
)
inlineprivatenoexcept

Definition at line 100 of file ITimingDat.h.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), KineDebug3::count(), data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), electrons_cff::ids, IDataItem::m_writeStmt, AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, x, geometryCSVtoXML::xx, y, and geometryCSVtoXML::yy.

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

Definition at line 73 of file ITimingDat.h.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), MillePedeFileConverter_cfg::e, IDataItem::m_writeStmt, and AlCaHLTBitMon_QueryRunRegistry::string.

74 {
75  this->checkConnection();
76  this->checkPrepare();
77 
78  int iovID = iov->fetchID();
79  if (!iovID) { throw(std::runtime_error("ITimingDat::writeDB: IOV not in DB")); }
80 
81  int logicID = ecid->getLogicID();
82  if (!logicID) { throw(std::runtime_error("ITimingDat::writeDB: Bad EcalLogicID")); }
83 
84  try {
85  m_writeStmt->setInt(1, iovID);
86  m_writeStmt->setInt(2, logicID);
87 
88  m_writeStmt->setFloat(3, item->getTimingMean() );
89  m_writeStmt->setFloat(4, item->getTimingRMS() );
90  m_writeStmt->setInt(5, item->getTaskStatus() );
91 
92 
93  m_writeStmt->executeUpdate();
94  } catch (SQLException &e) {
95  throw(std::runtime_error(std::string("ITimingDat::writeDB(): ")+getOraMessage(&e)));
96  }
97 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
oracle::occi::SQLException SQLException
Definition: ITimingDat.h:19

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

Referenced by getTable(), and setTable().

bool ITimingDat::m_taskStatus
private

Definition at line 248 of file ITimingDat.h.

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

float ITimingDat::m_timingMean
private

Definition at line 246 of file ITimingDat.h.

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

float ITimingDat::m_timingRMS
private

Definition at line 247 of file ITimingDat.h.

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