CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MonPedestalsDat Class Reference

#include <MonPedestalsDat.h>

Inheritance diagram for MonPedestalsDat:
IDataItem IDBObject

Public Member Functions

float getPedMeanG1 () const
 
float getPedMeanG12 () const
 
float getPedMeanG6 () const
 
float getPedRMSG1 () const
 
float getPedRMSG12 () const
 
float getPedRMSG6 () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonPedestalsDat ()
 
void setPedMeanG1 (float mean)
 
void setPedMeanG12 (float mean)
 
void setPedMeanG6 (float mean)
 
void setPedRMSG1 (float rms)
 
void setPedRMSG12 (float rms)
 
void setPedRMSG6 (float rms)
 
void setTaskStatus (bool status)
 
 ~MonPedestalsDat () 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

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

Private Attributes

float m_pedMeanG1
 
float m_pedMeanG12
 
float m_pedMeanG6
 
float m_pedRMSG1
 
float m_pedRMSG12
 
float m_pedRMSG6
 
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 () 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 11 of file MonPedestalsDat.h.

Constructor & Destructor Documentation

MonPedestalsDat::MonPedestalsDat ( )

Definition at line 11 of file MonPedestalsDat.cc.

12 {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_pedMeanG1 = 0;
19  m_pedMeanG6 = 0;
20  m_pedMeanG12 = 0;
21  m_pedRMSG1 = 0;
22  m_pedRMSG6 = 0;
23  m_pedRMSG12 = 0;
24  m_taskStatus = false;
25 }
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
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
MonPedestalsDat::~MonPedestalsDat ( )
override

Definition at line 29 of file MonPedestalsDat.cc.

30 {
31 }

Member Function Documentation

void MonPedestalsDat::fetchData ( std::map< EcalLogicID, MonPedestalsDat > *  fillMap,
MonRunIOV iov 
)
privatenoexcept

Definition at line 86 of file MonPedestalsDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setPedMeanG1(), setPedMeanG12(), setPedMeanG6(), setPedRMSG1(), setPedRMSG12(), setPedRMSG6(), and setTaskStatus().

Referenced by getTaskStatus().

88 {
89  this->checkConnection();
90  fillMap->clear();
91 
92  iov->setConnection(m_env, m_conn);
93  int iovID = iov->fetchID();
94  if (!iovID) {
95  // throw(std::runtime_error("MonPedestalsDat::writeDB: IOV not in DB"));
96  return;
97  }
98 
99  try {
100 
101  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
102  "d.ped_mean_g1, d.ped_mean_g6, d.ped_mean_g12, "
103  "d.ped_rms_g1, d.ped_rms_g6, d.ped_rms_g12, d.task_status "
104  "FROM channelview cv JOIN mon_pedestals_dat d "
105  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
106  "WHERE iov_id = :iov_id");
107  m_readStmt->setInt(1, iovID);
108  ResultSet* rset = m_readStmt->executeQuery();
109 
110  std::pair< EcalLogicID, MonPedestalsDat > p;
111  MonPedestalsDat dat;
112  while(rset->next()) {
113  p.first = EcalLogicID( rset->getString(1), // name
114  rset->getInt(2), // logic_id
115  rset->getInt(3), // id1
116  rset->getInt(4), // id2
117  rset->getInt(5), // id3
118  rset->getString(6)); // maps_to
119 
120  dat.setPedMeanG1( rset->getFloat(7) );
121  dat.setPedMeanG6( rset->getFloat(8) );
122  dat.setPedMeanG12( rset->getFloat(9) );
123  dat.setPedRMSG1( rset->getFloat(10) );
124  dat.setPedRMSG6( rset->getFloat(11) );
125  dat.setPedRMSG12( rset->getFloat(12) );
126  dat.setTaskStatus( rset->getInt(13) );
127 
128  p.second = dat;
129  fillMap->insert(p);
130  }
131  } catch (SQLException &e) {
132  throw(std::runtime_error("MonPedestalsDat::fetchData: "+e.getMessage()));
133  }
134 }
void setPedMeanG1(float mean)
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setPedRMSG6(float rms)
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
void setTaskStatus(bool status)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setPedMeanG6(float mean)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setPedRMSG1(float rms)
void setPedMeanG12(float mean)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setPedRMSG12(float rms)
float MonPedestalsDat::getPedMeanG1 ( ) const
inline
float MonPedestalsDat::getPedMeanG12 ( ) const
inline
float MonPedestalsDat::getPedMeanG6 ( ) const
inline
float MonPedestalsDat::getPedRMSG1 ( ) const
inline
float MonPedestalsDat::getPedRMSG12 ( ) const
inline
float MonPedestalsDat::getPedRMSG6 ( ) const
inline
std::string MonPedestalsDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MonPedestalsDat.h.

18 { return "MON_PEDESTALS_DAT"; }
bool MonPedestalsDat::getTaskStatus ( ) const
inline

Definition at line 39 of file MonPedestalsDat.h.

References data, fetchData(), m_taskStatus, noexcept, prepareWrite(), writeArrayDB(), and writeDB().

Referenced by writeArrayDB().

39 { return m_taskStatus; }
void MonPedestalsDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 35 of file MonPedestalsDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getTaskStatus().

37 {
38  this->checkConnection();
39 
40  try {
41  m_writeStmt = m_conn->createStatement();
42  m_writeStmt->setSQL("INSERT INTO mon_pedestals_dat (iov_id, logic_id, "
43  "ped_mean_g1, ped_mean_g6, ped_mean_g12, "
44  "ped_rms_g1, ped_rms_g6, ped_rms_g12, task_status) "
45  "VALUES (:iov_id, :logic_id, "
46  ":ped_mean_g1, :ped_mean_g6, :ped_mean_g12, "
47  ":ped_rms_g1, :ped_rms_g6, :ped_rms_g12, :task_status)");
48  } catch (SQLException &e) {
49  throw(std::runtime_error("MonPedestalsDat::prepareWrite(): "+e.getMessage()));
50  }
51 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void MonPedestalsDat::setPedMeanG1 ( float  mean)
inline
void MonPedestalsDat::setPedMeanG12 ( float  mean)
inline
void MonPedestalsDat::setPedMeanG6 ( float  mean)
inline
void MonPedestalsDat::setPedRMSG1 ( float  rms)
inline
void MonPedestalsDat::setPedRMSG12 ( float  rms)
inline
void MonPedestalsDat::setPedRMSG6 ( float  rms)
inline
void MonPedestalsDat::setTaskStatus ( bool  status)
inline

Definition at line 38 of file MonPedestalsDat.h.

References m_taskStatus, and mps_update::status.

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

void MonPedestalsDat::writeArrayDB ( const std::map< EcalLogicID, MonPedestalsDat > *  data,
MonRunIOV iov 
)
privatenoexcept

Definition at line 136 of file MonPedestalsDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getPedMeanG1(), getPedMeanG12(), getPedMeanG6(), getPedRMSG1(), getPedRMSG12(), getPedRMSG6(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, protons_cff::t, groupFilesInBlocks::tt, w, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

Referenced by getTaskStatus().

138 {
139  this->checkConnection();
140  this->checkPrepare();
141 
142  int iovID = iov->fetchID();
143  if (!iovID) { throw(std::runtime_error("MonPedestalsDat::writeArrayDB: IOV not in DB")); }
144 
145 
146  int nrows=data->size();
147  int* ids= new int[nrows];
148  int* iovid_vec= new int[nrows];
149  float* xx= new float[nrows];
150  float* yy= new float[nrows];
151  float* zz= new float[nrows];
152  float* ww= new float[nrows];
153  float* uu= new float[nrows];
154  float* tt= new float[nrows];
155  int* st= new int[nrows];
156 
157  ub2* ids_len= new ub2[nrows];
158  ub2* iov_len= new ub2[nrows];
159  ub2* x_len= new ub2[nrows];
160  ub2* y_len= new ub2[nrows];
161  ub2* z_len= new ub2[nrows];
162  ub2* w_len= new ub2[nrows];
163  ub2* u_len= new ub2[nrows];
164  ub2* t_len= new ub2[nrows];
165  ub2* st_len= new ub2[nrows];
166 
167  const EcalLogicID* channel;
168  const MonPedestalsDat* dataitem;
169  int count=0;
170  typedef map< EcalLogicID, MonPedestalsDat >::const_iterator CI;
171  for (CI p = data->begin(); p != data->end(); ++p) {
172  channel = &(p->first);
173  int logicID = channel->getLogicID();
174  if (!logicID) { throw(std::runtime_error("MonPedestalsDat::writeArrayDB: Bad EcalLogicID")); }
175  ids[count]=logicID;
176  iovid_vec[count]=iovID;
177 
178  dataitem = &(p->second);
179  // dataIface.writeDB( channel, dataitem, iov);
180  float x=dataitem->getPedMeanG1();
181  float y=dataitem->getPedMeanG6();
182  float z=dataitem->getPedMeanG12();
183  float w=dataitem->getPedRMSG1();
184  float u=dataitem->getPedRMSG6();
185  float t=dataitem->getPedRMSG12();
186  int statu=dataitem->getTaskStatus();
187 
188 
189 
190  xx[count]=x;
191  yy[count]=y;
192  zz[count]=z;
193  ww[count]=w;
194  uu[count]=u;
195  tt[count]=t;
196  st[count]=statu;
197 
198 
199  ids_len[count]=sizeof(ids[count]);
200  iov_len[count]=sizeof(iovid_vec[count]);
201 
202  x_len[count]=sizeof(xx[count]);
203  y_len[count]=sizeof(yy[count]);
204  z_len[count]=sizeof(zz[count]);
205  w_len[count]=sizeof(ww[count]);
206  u_len[count]=sizeof(uu[count]);
207  t_len[count]=sizeof(tt[count]);
208  st_len[count]=sizeof(st[count]);
209 
210  count++;
211  }
212 
213 
214  try {
215  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
216  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
217  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
218  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
219  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len );
220  m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT , sizeof(ww[0]), w_len );
221  m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIFLOAT , sizeof(uu[0]), u_len );
222  m_writeStmt->setDataBuffer(8, (dvoid*)tt, OCCIFLOAT , sizeof(tt[0]), t_len );
223  m_writeStmt->setDataBuffer(9, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
224 
225 
226  m_writeStmt->executeArrayUpdate(nrows);
227 
228  delete [] ids;
229  delete [] iovid_vec;
230  delete [] xx;
231  delete [] yy;
232  delete [] zz;
233  delete [] ww;
234  delete [] uu;
235  delete [] tt;
236  delete [] st;
237 
238  delete [] ids_len;
239  delete [] iov_len;
240  delete [] x_len;
241  delete [] y_len;
242  delete [] z_len;
243  delete [] w_len;
244  delete [] u_len;
245  delete [] t_len;
246  delete [] st_len;
247 
248 
249 
250  } catch (SQLException &e) {
251  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): "+e.getMessage()));
252  }
253 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
const double w
Definition: UKUtility.cc:23
float getPedRMSG1() const
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
float getPedMeanG12() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
float getPedRMSG12() const
int getLogicID() const
Definition: EcalLogicID.cc:41
bool getTaskStatus() const
float getPedMeanG1() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
float getPedMeanG6() const
float getPedRMSG6() const
void MonPedestalsDat::writeDB ( const EcalLogicID ecid,
const MonPedestalsDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 55 of file MonPedestalsDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getTaskStatus().

57 {
58  this->checkConnection();
59  this->checkPrepare();
60 
61  int iovID = iov->fetchID();
62  if (!iovID) { throw(std::runtime_error("MonPedestalsDat::writeDB: IOV not in DB")); }
63 
64  int logicID = ecid->getLogicID();
65  if (!logicID) { throw(std::runtime_error("MonPedestalsDat::writeDB: Bad EcalLogicID")); }
66 
67  try {
68  m_writeStmt->setInt(1, iovID);
69  m_writeStmt->setInt(2, logicID);
70  m_writeStmt->setFloat(3, item->getPedMeanG1());
71  m_writeStmt->setFloat(4, item->getPedMeanG6());
72  m_writeStmt->setFloat(5, item->getPedMeanG12());
73  m_writeStmt->setFloat(6, item->getPedRMSG1());
74  m_writeStmt->setFloat(7, item->getPedRMSG6());
75  m_writeStmt->setFloat(8, item->getPedRMSG12());
76  m_writeStmt->setInt(9, item->getTaskStatus());
77 
78  m_writeStmt->executeUpdate();
79  } catch (SQLException &e) {
80  throw(std::runtime_error("MonPedestalsDat::writeDB(): "+e.getMessage()));
81  }
82 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
float getPedRMSG1() const
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
float getPedMeanG12() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
float getPedRMSG12() const
int getLogicID() const
Definition: EcalLogicID.cc:41
bool getTaskStatus() const
float getPedMeanG1() const
float getPedMeanG6() const
float getPedRMSG6() const

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file MonPedestalsDat.h.

Member Data Documentation

float MonPedestalsDat::m_pedMeanG1
private

Definition at line 57 of file MonPedestalsDat.h.

Referenced by getPedMeanG1(), and setPedMeanG1().

float MonPedestalsDat::m_pedMeanG12
private

Definition at line 59 of file MonPedestalsDat.h.

Referenced by getPedMeanG12(), and setPedMeanG12().

float MonPedestalsDat::m_pedMeanG6
private

Definition at line 58 of file MonPedestalsDat.h.

Referenced by getPedMeanG6(), and setPedMeanG6().

float MonPedestalsDat::m_pedRMSG1
private

Definition at line 60 of file MonPedestalsDat.h.

Referenced by getPedRMSG1(), and setPedRMSG1().

float MonPedestalsDat::m_pedRMSG12
private

Definition at line 62 of file MonPedestalsDat.h.

Referenced by getPedRMSG12(), and setPedRMSG12().

float MonPedestalsDat::m_pedRMSG6
private

Definition at line 61 of file MonPedestalsDat.h.

Referenced by getPedRMSG6(), and setPedRMSG6().

bool MonPedestalsDat::m_taskStatus
private

Definition at line 63 of file MonPedestalsDat.h.

Referenced by getTaskStatus(), and setTaskStatus().