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

#include <MonPedestalOffsetsDat.h>

Inheritance diagram for MonPedestalOffsetsDat:
IDataItem IDBObject

Public Member Functions

int getDACG1 () const
 
int getDACG12 () const
 
int getDACG6 () const
 
std::string getTable ()
 
bool getTaskStatus () const
 
 MonPedestalOffsetsDat ()
 
void setDACG1 (int dac)
 
void setDACG12 (int dac)
 
void setDACG6 (int dac)
 
void setTaskStatus (bool status)
 
 ~MonPedestalOffsetsDat ()
 
- 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, MonPedestalOffsetsDat > *fillMap, MonRunIOV *iov, std::string mappa=" cv.maps_to ") throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, MonPedestalOffsetsDat > *data, MonRunIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const MonPedestalOffsetsDat *item, MonRunIOV *iov) throw (std::runtime_error)
 

Private Attributes

int m_dacG1
 
int m_dacG12
 
int m_dacG6
 
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 MonPedestalOffsetsDat.h.

Constructor & Destructor Documentation

MonPedestalOffsetsDat::MonPedestalOffsetsDat ( )

Definition at line 12 of file MonPedestalOffsetsDat.cc.

References NULL.

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

Definition at line 27 of file MonPedestalOffsetsDat.cc.

28 {
29 }

Member Function Documentation

void MonPedestalOffsetsDat::fetchData ( std::map< EcalLogicID, MonPedestalOffsetsDat > *  fillMap,
MonRunIOV iov,
std::string  mappa = " cv.maps_to " 
)
throw (std::runtime_error
)
private

Definition at line 78 of file MonPedestalOffsetsDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setDACG1(), setDACG12(), setDACG6(), and setTaskStatus().

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("MonPedestalOffsetsDat::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.dac_g1, d.dac_g6, d.dac_g12, d.task_status "
95  "FROM channelview cv JOIN mon_pedestal_offsets_dat d "
96  "ON cv.logic_id = d.logic_id AND cv.name = " + mappa +
97  " WHERE d.iov_id = :iov_id");
98  m_readStmt->setInt(1, iovID);
99  ResultSet* rset = m_readStmt->executeQuery();
100 
101  std::pair< EcalLogicID, MonPedestalOffsetsDat > p;
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.setDACG1( rset->getInt(7) );
112  dat.setDACG6( rset->getInt(8) );
113  dat.setDACG12( rset->getInt(9) );
114  dat.setTaskStatus( rset->getInt(10) );
115 
116  p.second = dat;
117  fillMap->insert(p);
118  }
119  } catch (SQLException &e) {
120  throw(std::runtime_error("MonPedestalOffsetsDat::fetchData(): "+e.getMessage()));
121  }
122 }
void setTaskStatus(bool status)
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
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
int MonPedestalOffsetsDat::getDACG1 ( ) const
inline

Definition at line 22 of file MonPedestalOffsetsDat.h.

References m_dacG1.

Referenced by writeArrayDB().

22 { return m_dacG1; }
int MonPedestalOffsetsDat::getDACG12 ( ) const
inline

Definition at line 28 of file MonPedestalOffsetsDat.h.

References m_dacG12.

Referenced by writeArrayDB().

int MonPedestalOffsetsDat::getDACG6 ( ) const
inline

Definition at line 25 of file MonPedestalOffsetsDat.h.

References m_dacG6.

Referenced by writeArrayDB().

25 { return m_dacG6; }
std::string MonPedestalOffsetsDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 19 of file MonPedestalOffsetsDat.h.

19 { return "MON_PEDESTAL_OFFSETS_DAT"; }
bool MonPedestalOffsetsDat::getTaskStatus ( ) const
inline

Definition at line 31 of file MonPedestalOffsetsDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

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

Implements IDataItem.

Definition at line 33 of file MonPedestalOffsetsDat.cc.

References alignCSCRings::e.

35 {
36  this->checkConnection();
37 
38  try {
39  m_writeStmt = m_conn->createStatement();
40  m_writeStmt->setSQL("INSERT INTO mon_pedestal_offsets_dat (iov_id, logic_id, "
41  "dac_g1, dac_g6, dac_g12, task_status) "
42  "VALUES (:iov_id, :logic_id, "
43  ":dac_g1, :dac_g6, :dac_g12, :task_status)");
44  } catch (SQLException &e) {
45  throw(std::runtime_error("MonPedestalOffsetsDat::prepareWrite(): "+e.getMessage()));
46  }
47 }
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 MonPedestalOffsetsDat::setDACG1 ( int  dac)
inline

Definition at line 21 of file MonPedestalOffsetsDat.h.

References m_dacG1.

Referenced by fetchData(), and EcalPedOffset::writeDb().

void MonPedestalOffsetsDat::setDACG12 ( int  dac)
inline

Definition at line 27 of file MonPedestalOffsetsDat.h.

References m_dacG12.

Referenced by fetchData(), and EcalPedOffset::writeDb().

void MonPedestalOffsetsDat::setDACG6 ( int  dac)
inline

Definition at line 24 of file MonPedestalOffsetsDat.h.

References m_dacG6.

Referenced by fetchData(), and EcalPedOffset::writeDb().

void MonPedestalOffsetsDat::setTaskStatus ( bool  status)
inline

Definition at line 30 of file MonPedestalOffsetsDat.h.

References m_taskStatus, and ntuplemaker::status.

Referenced by fetchData(), and EcalPedOffset::writeDb().

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

Definition at line 124 of file MonPedestalOffsetsDat.cc.

References prof2calltree::count, AlCaHLTBitMon_QueryRunRegistry::data, alignCSCRings::e, getDACG1(), getDACG12(), getDACG6(), EcalLogicID::getLogicID(), getTaskStatus(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, x, y, and z.

126 {
127  this->checkConnection();
128  this->checkPrepare();
129 
130  int iovID = iov->fetchID();
131  if (!iovID) { throw(std::runtime_error("MonPedestalOffsetsDat::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  int* st= new int[nrows];
141 
142  ub2* ids_len= new ub2[nrows];
143  ub2* iov_len= new ub2[nrows];
144  ub2* x_len= new ub2[nrows];
145  ub2* y_len= new ub2[nrows];
146  ub2* z_len= new ub2[nrows];
147  ub2* st_len= new ub2[nrows];
148 
149  const EcalLogicID* channel;
150  const MonPedestalOffsetsDat* dataitem;
151  int count=0;
152  typedef map< EcalLogicID, MonPedestalOffsetsDat >::const_iterator CI;
153  for (CI p = data->begin(); p != data->end(); ++p) {
154  channel = &(p->first);
155  int logicID = channel->getLogicID();
156  if (!logicID) { throw(std::runtime_error("MonPedestalOffsetsDat::writeArrayDB: Bad EcalLogicID")); }
157  ids[count]=logicID;
158  iovid_vec[count]=iovID;
159 
160  dataitem = &(p->second);
161  // dataIface.writeDB( channel, dataitem, iov);
162  float x=dataitem->getDACG1();
163  float y=dataitem->getDACG6();
164  float z=dataitem->getDACG12();
165  int statu=dataitem->getTaskStatus();
166 
167 
168 
169  xx[count]=x;
170  yy[count]=y;
171  zz[count]=z;
172  st[count]=statu;
173 
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  st_len[count]=sizeof(st[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*)st, OCCIINT , sizeof(st[0]), st_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 [] st;
204 
205  delete [] ids_len;
206  delete [] iov_len;
207  delete [] x_len;
208  delete [] y_len;
209  delete [] z_len;
210  delete [] st_len;
211 
212 
213  } catch (SQLException &e) {
214  throw(std::runtime_error("MonPedestalOffsetsDat::writeArrayDB(): "+e.getMessage()));
215  }
216 }
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
void MonPedestalOffsetsDat::writeDB ( const EcalLogicID ecid,
const MonPedestalOffsetsDat item,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 51 of file MonPedestalOffsetsDat.cc.

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

53 {
54  this->checkConnection();
55  this->checkPrepare();
56 
57  int iovID = iov->fetchID();
58  if (!iovID) { throw(std::runtime_error("MonPedestalOffsetsDat::writeDB: IOV not in DB")); }
59 
60  int logicID = ecid->getLogicID();
61  if (!logicID) { throw(std::runtime_error("MonPedestalOffsetsDat::writeDB: Bad EcalLogicID")); }
62 
63  try {
64  m_writeStmt->setInt(1, iovID);
65  m_writeStmt->setInt(2, logicID);
66  m_writeStmt->setInt(3, item->getDACG1() );
67  m_writeStmt->setInt(4, item->getDACG6() );
68  m_writeStmt->setInt(5, item->getDACG12() );
69  m_writeStmt->setInt(6, item->getTaskStatus() );
70 
71  m_writeStmt->executeUpdate();
72  } catch (SQLException &e) {
73  throw(std::runtime_error("MonPedestalOffsetsDat::writeDB(): "+e.getMessage()));
74  }
75 }
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 MonPedestalOffsetsDat.h.

Member Data Documentation

int MonPedestalOffsetsDat::m_dacG1
private

Definition at line 48 of file MonPedestalOffsetsDat.h.

Referenced by getDACG1(), and setDACG1().

int MonPedestalOffsetsDat::m_dacG12
private

Definition at line 50 of file MonPedestalOffsetsDat.h.

Referenced by getDACG12(), and setDACG12().

int MonPedestalOffsetsDat::m_dacG6
private

Definition at line 49 of file MonPedestalOffsetsDat.h.

Referenced by getDACG6(), and setDACG6().

bool MonPedestalOffsetsDat::m_taskStatus
private

Definition at line 51 of file MonPedestalOffsetsDat.h.

Referenced by getTaskStatus(), and setTaskStatus().