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

#include <ODDelaysDat.h>

Inheritance diagram for ODDelaysDat:
IODConfig IDBObject

Public Member Functions

int getFedId () const
 
int getId () const
 
int getSMId () const
 
std::string getTable ()
 
int getTimeOffset () const
 
int getTTId () const
 
 ODDelaysDat ()
 
void setFedId (int dac)
 
void setId (int dac)
 
void setSMId (int dac)
 
void setTimeOffset (int dac)
 
void setTTId (int dac)
 
 ~ODDelaysDat ()
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- 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::vector< ODDelaysDat > *fillMap, ODFEDelaysInfo *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::vector< ODDelaysDat > data, ODFEDelaysInfo *iov) throw (std::runtime_error)
 
void writeDB (const ODDelaysDat *item, ODFEDelaysInfo *iov) throw (std::runtime_error)
 

Private Attributes

int m_fed
 
int m_ID
 
int m_sm
 
int m_t1
 
int m_tt
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) 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 IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 10 of file ODDelaysDat.h.

Constructor & Destructor Documentation

ODDelaysDat::ODDelaysDat ( )

Definition at line 10 of file ODDelaysDat.cc.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16 
17  m_sm = 0;
18  m_fed = 0;
19  m_tt = 0;
20  m_t1 = 0;
21 
22 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
#define NULL
Definition: scimark2.h:8
Statement * m_readStmt
Definition: IODConfig.h:37
ODDelaysDat::~ODDelaysDat ( )

Definition at line 26 of file ODDelaysDat.cc.

27 {
28 }

Member Function Documentation

void ODDelaysDat::fetchData ( std::vector< ODDelaysDat > *  fillMap,
ODFEDelaysInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 68 of file ODDelaysDat.cc.

References o2o::iov, L1TEmulatorMonitor_cff::p, setFedId(), setSMId(), setTimeOffset(), and setTTId().

70 {
71  this->checkConnection();
72 
73  iov->setConnection(m_env, m_conn);
74  int iovID = iov->fetchID();
75  if (!iovID) {
76  // throw(std::runtime_error("ODDelaysDat::writeDB: IOV not in DB"));
77  return;
78  }
79 
80  try {
81  m_readStmt->setSQL("SELECT * FROM " + getTable() + "WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id ");
82  m_readStmt->setInt(1, iovID);
83  ResultSet* rset = m_readStmt->executeQuery();
84 
85  // std::vector< ODDelaysDat > p;
86  ODDelaysDat dat;
87  while(rset->next()) {
88  // dat.setId( rset->getInt(1) );
89  dat.setSMId( rset->getInt(2) );
90  dat.setFedId( rset->getInt(3) );
91  dat.setTTId( rset->getInt(4) );
92  dat.setTimeOffset( rset->getInt(5) );
93 
94  p->push_back( dat);
95 
96  }
97  } catch (SQLException &e) {
98  throw(std::runtime_error("ODDelaysDat::fetchData(): "+e.getMessage()));
99  }
100 }
std::string getTable()
Definition: ODDelaysDat.h:17
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setTimeOffset(int dac)
Definition: ODDelaysDat.h:32
void setTTId(int dac)
Definition: ODDelaysDat.h:28
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setSMId(int dac)
Definition: ODDelaysDat.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
void setFedId(int dac)
Definition: ODDelaysDat.h:25
int ODDelaysDat::getFedId ( ) const
inline

Definition at line 26 of file ODDelaysDat.h.

References m_fed.

Referenced by writeArrayDB().

26 { return m_fed; }
int ODDelaysDat::getId ( ) const
inline

Definition at line 20 of file ODDelaysDat.h.

References m_ID.

20 { return m_ID; }
int ODDelaysDat::getSMId ( ) const
inline

Definition at line 23 of file ODDelaysDat.h.

References m_sm.

Referenced by writeArrayDB().

23 { return m_sm; }
std::string ODDelaysDat::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 17 of file ODDelaysDat.h.

17 { return "DELAYS_DAT"; }
int ODDelaysDat::getTimeOffset ( ) const
inline

Definition at line 33 of file ODDelaysDat.h.

References m_t1.

Referenced by writeArrayDB().

33 { return m_t1; }
int ODDelaysDat::getTTId ( ) const
inline

Definition at line 29 of file ODDelaysDat.h.

References m_tt.

Referenced by writeArrayDB().

29 { return m_tt; }
void ODDelaysDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 32 of file ODDelaysDat.cc.

34 {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, sm_id, fed_id, tt_id, time_offset ) "
40  "VALUES (:1, :2, :3, :4, :5 )");
41  } catch (SQLException &e) {
42  throw(std::runtime_error("ODDelaysDat::prepareWrite(): "+e.getMessage()));
43  }
44 }
std::string getTable()
Definition: ODDelaysDat.h:17
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
void ODDelaysDat::setFedId ( int  dac)
inline

Definition at line 25 of file ODDelaysDat.h.

References m_fed.

Referenced by fetchData().

25 { m_fed = dac; }
void ODDelaysDat::setId ( int  dac)
inline

Definition at line 19 of file ODDelaysDat.h.

References m_ID.

19 { m_ID = dac; }
void ODDelaysDat::setSMId ( int  dac)
inline

Definition at line 22 of file ODDelaysDat.h.

References m_sm.

Referenced by fetchData().

22 { m_sm = dac; }
void ODDelaysDat::setTimeOffset ( int  dac)
inline

Definition at line 32 of file ODDelaysDat.h.

References m_t1.

Referenced by fetchData().

32 { m_t1 = dac; }
void ODDelaysDat::setTTId ( int  dac)
inline

Definition at line 28 of file ODDelaysDat.h.

References m_tt.

Referenced by fetchData().

28 { m_tt = dac; }
void ODDelaysDat::writeArrayDB ( const std::vector< ODDelaysDat data,
ODFEDelaysInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 104 of file ODDelaysDat.cc.

References prof2calltree::count, runTheMatrix::data, getFedId(), getSMId(), getTimeOffset(), getTTId(), and o2o::iov.

106 {
107  this->checkConnection();
108 
109  int iovID = iov->fetchID();
110  if (!iovID) { throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB")); }
111 
112 
113  int nrows=data.size();
114  int* ids= new int[nrows];
115  int* xx= new int[nrows];
116  int* yy= new int[nrows];
117  int* zz= new int[nrows];
118  int* st= new int[nrows];
119 
120 
121 
122  ub2* ids_len= new ub2[nrows];
123  ub2* x_len= new ub2[nrows];
124  ub2* y_len= new ub2[nrows];
125  ub2* z_len= new ub2[nrows];
126  ub2* st_len= new ub2[nrows];
127 
128 
129  ODDelaysDat dataitem;
130 
131  int n_data= (int) data.size();
132 
133  for (int count = 0; count < n_data ; count++) {
134  dataitem=data[count];
135  ids[count]=iovID;
136  xx[count]=dataitem.getSMId();
137  yy[count]=dataitem.getFedId();
138  zz[count]=dataitem.getTTId();
139  st[count]=dataitem.getTimeOffset();
140 
141 
142  ids_len[count]=sizeof(ids[count]);
143  x_len[count]=sizeof(xx[count]);
144  y_len[count]=sizeof(yy[count]);
145  z_len[count]=sizeof(zz[count]);
146  st_len[count]=sizeof(st[count]);
147 
148  }
149 
150 
151  try {
152  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]),ids_len);
153  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
154  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
155  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
156  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
157 
158  m_writeStmt->executeArrayUpdate(nrows);
159 
160  delete [] ids;
161  delete [] xx;
162  delete [] yy;
163  delete [] zz;
164  delete [] st;
165 
166  delete [] ids_len;
167  delete [] x_len;
168  delete [] y_len;
169  delete [] z_len;
170  delete [] st_len;
171 
172  } catch (SQLException &e) {
173  throw(std::runtime_error("ODDelaysDat::writeArrayDB(): "+e.getMessage()));
174  }
175 }
Statement * m_writeStmt
Definition: IODConfig.h:36
int getSMId() const
Definition: ODDelaysDat.h:23
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getFedId() const
Definition: ODDelaysDat.h:26
int getTTId() const
Definition: ODDelaysDat.h:29
int getTimeOffset() const
Definition: ODDelaysDat.h:33
void checkConnection() const
Definition: IDBObject.h:41
void ODDelaysDat::writeDB ( const ODDelaysDat item,
ODFEDelaysInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 48 of file ODDelaysDat.cc.

50 {
51  this->checkConnection();
52 
53  try {
54  m_writeStmt->setInt(1, item->getId());
55  m_writeStmt->setInt(2, item->getSMId());
56  m_writeStmt->setInt(3, item->getFedId() );
57  m_writeStmt->setInt(4, item->getTTId() );
58  m_writeStmt->setInt(5, item->getTimeOffset() );
59 
60  m_writeStmt->executeUpdate();
61  } catch (SQLException &e) {
62  throw(std::runtime_error("ODDelaysDat::writeDB(): "+e.getMessage()));
63  }
64 }
Statement * m_writeStmt
Definition: IODConfig.h:36
int getId() const
Definition: ODDelaysDat.h:20
int getSMId() const
Definition: ODDelaysDat.h:23
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getFedId() const
Definition: ODDelaysDat.h:26
int getTTId() const
Definition: ODDelaysDat.h:29
int getTimeOffset() const
Definition: ODDelaysDat.h:33
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 12 of file ODDelaysDat.h.

Member Data Documentation

int ODDelaysDat::m_fed
private

Definition at line 51 of file ODDelaysDat.h.

Referenced by getFedId(), and setFedId().

int ODDelaysDat::m_ID
private

Definition at line 54 of file ODDelaysDat.h.

Referenced by getId(), and setId().

int ODDelaysDat::m_sm
private

Definition at line 50 of file ODDelaysDat.h.

Referenced by getSMId(), and setSMId().

int ODDelaysDat::m_t1
private

Definition at line 53 of file ODDelaysDat.h.

Referenced by getTimeOffset(), and setTimeOffset().

int ODDelaysDat::m_tt
private

Definition at line 52 of file ODDelaysDat.h.

Referenced by getTTId(), and setTTId().