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

#include <MonH4TablePositionDat.h>

Inheritance diagram for MonH4TablePositionDat:
IDataItem IDBObject

Public Member Functions

std::string getTable ()
 
float getTableX () const
 
float getTableY () const
 
 MonH4TablePositionDat ()
 
void setTableX (float x)
 
void setTableY (float y)
 
 ~MonH4TablePositionDat ()
 
- 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, MonH4TablePositionDat > *fillMap, MonRunIOV *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, MonH4TablePositionDat > *data, MonRunIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const MonH4TablePositionDat *item, MonRunIOV *iov) throw (std::runtime_error)
 

Private Attributes

float m_tableX
 
float m_tableY
 

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 MonH4TablePositionDat.h.

Constructor & Destructor Documentation

MonH4TablePositionDat::MonH4TablePositionDat ( )

Definition at line 10 of file MonH4TablePositionDat.cc.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16 
17  m_tableX = 0;
18  m_tableY = 0;
19 }
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
MonH4TablePositionDat::~MonH4TablePositionDat ( )

Definition at line 23 of file MonH4TablePositionDat.cc.

24 {
25 }

Member Function Documentation

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

Definition at line 74 of file MonH4TablePositionDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setTableX(), and setTableY().

76 {
77  this->checkConnection();
78  fillMap->clear();
79 
80  iov->setConnection(m_env, m_conn);
81  int iovID = iov->fetchID();
82  if (!iovID) {
83  // throw(std::runtime_error("MonH4TablePositionDat::writeDB: IOV not in DB"));
84  return;
85  }
86 
87  try {
88 
89  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
90  "d.table_x, d.table_y "
91  "FROM channelview cv JOIN mon_h4_table_position_dat d "
92  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
93  "WHERE d.iov_id = :iov_id");
94  m_readStmt->setInt(1, iovID);
95  ResultSet* rset = m_readStmt->executeQuery();
96 
97  std::pair< EcalLogicID, MonH4TablePositionDat > p;
99  while(rset->next()) {
100  p.first = EcalLogicID( rset->getString(1), // name
101  rset->getInt(2), // logic_id
102  rset->getInt(3), // id1
103  rset->getInt(4), // id2
104  rset->getInt(5), // id3
105  rset->getString(6)); // maps_to
106 
107  dat.setTableX( rset->getFloat(7) );
108  dat.setTableY( rset->getFloat(8) );
109 
110  p.second = dat;
111  fillMap->insert(p);
112  }
113  } catch (SQLException &e) {
114  throw(std::runtime_error("MonH4TablePositionDat::fetchData(): "+e.getMessage()));
115  }
116 }
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
std::string MonH4TablePositionDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file MonH4TablePositionDat.h.

18 { return "MON_H4_TABLE_POSITION_DAT"; }
float MonH4TablePositionDat::getTableX ( ) const
inline

Definition at line 21 of file MonH4TablePositionDat.h.

References m_tableX.

Referenced by writeArrayDB().

21 { return m_tableX; }
float MonH4TablePositionDat::getTableY ( ) const
inline

Definition at line 24 of file MonH4TablePositionDat.h.

References m_tableY.

Referenced by writeArrayDB().

24 { return m_tableY; }
void MonH4TablePositionDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 29 of file MonH4TablePositionDat.cc.

References alignCSCRings::e.

31 {
32  this->checkConnection();
33 
34  try {
35  m_writeStmt = m_conn->createStatement();
36  m_writeStmt->setSQL("INSERT INTO mon_h4_table_position_dat (iov_id, logic_id, "
37  "table_x, table_y) "
38  "VALUES (:iov_id, :logic_id, "
39  ":3, :4)");
40  } catch (SQLException &e) {
41  throw(std::runtime_error("MonH4TablePositionDat::prepareWrite(): "+e.getMessage()));
42  }
43 }
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 MonH4TablePositionDat::setTableX ( float  x)
inline

Definition at line 20 of file MonH4TablePositionDat.h.

References m_tableX, and x.

Referenced by fetchData().

void MonH4TablePositionDat::setTableY ( float  y)
inline

Definition at line 23 of file MonH4TablePositionDat.h.

References m_tableY, and y.

Referenced by fetchData().

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

Definition at line 118 of file MonH4TablePositionDat.cc.

References prof2calltree::count, data, alignCSCRings::e, EcalLogicID::getLogicID(), getTableX(), getTableY(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, x, and y.

120 {
121  this->checkConnection();
122  this->checkPrepare();
123 
124  int iovID = iov->fetchID();
125  if (!iovID) { throw(std::runtime_error("MonH4TablePositionDat::writeArrayDB: IOV not in DB")); }
126 
127 
128  int nrows=data->size();
129  int* ids= new int[nrows];
130  int* iovid_vec= new int[nrows];
131  float* xx= new float[nrows];
132  float* yy= new float[nrows];
133 
134 
135  ub2* ids_len= new ub2[nrows];
136  ub2* iov_len= new ub2[nrows];
137  ub2* x_len= new ub2[nrows];
138  ub2* y_len= new ub2[nrows];
139 
140  const EcalLogicID* channel;
141  const MonH4TablePositionDat* dataitem;
142  int count=0;
143  typedef map< EcalLogicID, MonH4TablePositionDat >::const_iterator CI;
144  for (CI p = data->begin(); p != data->end(); ++p) {
145  channel = &(p->first);
146  int logicID = channel->getLogicID();
147  if (!logicID) { throw(std::runtime_error("MonH4TablePositionDat::writeArrayDB: Bad EcalLogicID")); }
148  ids[count]=logicID;
149  iovid_vec[count]=iovID;
150 
151  dataitem = &(p->second);
152  // dataIface.writeDB( channel, dataitem, iov);
153  float x=dataitem->getTableX();
154  float y=dataitem->getTableY();
155 
156  xx[count]=x;
157  yy[count]=y;
158 
159  ids_len[count]=sizeof(ids[count]);
160  iov_len[count]=sizeof(iovid_vec[count]);
161 
162  x_len[count]=sizeof(xx[count]);
163  y_len[count]=sizeof(yy[count]);
164 
165  count++;
166  }
167 
168 
169  try {
170  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
171  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
172  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
173  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
174 
175  m_writeStmt->executeArrayUpdate(nrows);
176 
177  delete [] ids;
178  delete [] iovid_vec;
179  delete [] xx;
180  delete [] yy;
181 
182  delete [] ids_len;
183  delete [] iov_len;
184  delete [] x_len;
185  delete [] y_len;
186 
187  } catch (SQLException &e) {
188  throw(std::runtime_error("MonH4TablePositionDat::writeArrayDB(): "+e.getMessage()));
189  }
190 }
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
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void checkConnection() const
Definition: IDBObject.h:41
void MonH4TablePositionDat::writeDB ( const EcalLogicID ecid,
const MonH4TablePositionDat item,
MonRunIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 47 of file MonH4TablePositionDat.cc.

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

49 {
50  this->checkConnection();
51  this->checkPrepare();
52 
53  int iovID = iov->fetchID();
54  if (!iovID) { throw(std::runtime_error("MonH4TablePositionDat::writeDB: IOV not in DB")); }
55 
56  int logicID = ecid->getLogicID();
57  if (!logicID) { throw(std::runtime_error("MonH4TablePositionDat::writeDB: Bad EcalLogicID")); }
58 
59  try {
60  m_writeStmt->setInt(1, iovID);
61  m_writeStmt->setInt(2, logicID);
62 
63  m_writeStmt->setFloat(3, item->getTableX() );
64  m_writeStmt->setFloat(4, item->getTableY() );
65 
66  m_writeStmt->executeUpdate();
67  } catch (SQLException &e) {
68  throw(std::runtime_error("MonH4TablePositionDat::writeDB(): "+e.getMessage()));
69  }
70 }
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 13 of file MonH4TablePositionDat.h.

Member Data Documentation

float MonH4TablePositionDat::m_tableX
private

Definition at line 40 of file MonH4TablePositionDat.h.

Referenced by getTableX(), and setTableX().

float MonH4TablePositionDat::m_tableY
private

Definition at line 41 of file MonH4TablePositionDat.h.

Referenced by getTableY(), and setTableY().