CMS 3D CMS Logo

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, int id) noexcept(false)
 
void fetchData (std::vector< ODDelaysDat > *fillMap, ODFEDelaysInfo *iov) noexcept(false)
 
void prepareWrite () noexcept(false)
 
void writeArrayDB (const std::vector< ODDelaysDat > &data, ODFEDelaysInfo *iov) noexcept(false)
 
void writeDB (const ODDelaysDat *item, ODFEDelaysInfo *iov) noexcept(false)
 

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 () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) 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 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,
int  id 
)
privatenoexcept

Definition at line 73 of file ODDelaysDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setFedId(), setSMId(), setTimeOffset(), and setTTId().

Referenced by EcalCondDBInterface::fetchFEDelaysForRun(), and getTimeOffset().

75 {
76  this->checkConnection();
77 
78  if (!iovID) {
79  // throw(std::runtime_error("ODDelaysDat::writeDB: IOV not in DB"));
80  return;
81  }
82 
83  try {
84  m_readStmt = m_conn->createStatement();
85  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id");
86  m_readStmt->setInt(1, iovID);
87  ResultSet* rset = m_readStmt->executeQuery();
88 
89  // std::vector< ODDelaysDat > p;
90  ODDelaysDat dat;
91  while(rset->next()) {
92  // dat.setId( rset->getInt(1) );
93  dat.setSMId( rset->getInt(2) );
94  dat.setFedId( rset->getInt(3) );
95  dat.setTTId( rset->getInt(4) );
96  dat.setTimeOffset( rset->getInt(5) );
97 
98  p->push_back( dat);
99 
100  }
101  } catch (SQLException &e) {
102  throw(std::runtime_error("ODDelaysDat::fetchData(): "+e.getMessage()));
103  }
104 }
std::string getTable()
Definition: ODDelaysDat.h:17
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
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void setSMId(int dac)
Definition: ODDelaysDat.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
void setFedId(int dac)
Definition: ODDelaysDat.h:25
void ODDelaysDat::fetchData ( std::vector< ODDelaysDat > *  fillMap,
ODFEDelaysInfo iov 
)
privatenoexcept

Definition at line 66 of file ODDelaysDat.cc.

References AlCaHLTBitMon_ParallelJobs::p.

67  {
68  iov->setConnection(m_env, m_conn);
69  int iovID = iov->fetchID();
70  fetchData(p, iovID);
71 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID() noexcept(false)
void fetchData(std::vector< ODDelaysDat > *fillMap, int id) noexcept(false)
Definition: ODDelaysDat.cc:73
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
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 ( void  ) 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 data, fetchData(), m_t1, noexcept, prepareWrite(), writeArrayDB(), and writeDB().

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

Implements IODConfig.

Definition at line 32 of file ODDelaysDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getTimeOffset().

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
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
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 
)
privatenoexcept

Definition at line 108 of file ODDelaysDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getFedId(), getSMId(), getTimeOffset(), getTTId(), createfilelist::int, geometryCSVtoXML::xx, geometryCSVtoXML::yy, and geometryCSVtoXML::zz.

Referenced by getTimeOffset().

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

Definition at line 48 of file ODDelaysDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getTimeOffset().

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
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getFedId() const
Definition: ODDelaysDat.h:26
int getTTId() const
Definition: ODDelaysDat.h:29
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int getTimeOffset() const
Definition: ODDelaysDat.h:33

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 48 of file ODDelaysDat.h.

Referenced by getFedId(), and setFedId().

int ODDelaysDat::m_ID
private

Definition at line 51 of file ODDelaysDat.h.

Referenced by getId(), and setId().

int ODDelaysDat::m_sm
private

Definition at line 47 of file ODDelaysDat.h.

Referenced by getSMId(), and setSMId().

int ODDelaysDat::m_t1
private

Definition at line 50 of file ODDelaysDat.h.

Referenced by getTimeOffset(), and setTimeOffset().

int ODDelaysDat::m_tt
private

Definition at line 49 of file ODDelaysDat.h.

Referenced by getTTId(), and setTTId().