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 () override
 
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 () override
 
- 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) override
 
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::ODDelaysDat ( )

Definition at line 10 of file ODDelaysDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
16  m_sm = 0;
17  m_fed = 0;
18  m_tt = 0;
19  m_t1 = 0;
20 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
Statement * m_readStmt
Definition: IODConfig.h:34

◆ ~ODDelaysDat()

ODDelaysDat::~ODDelaysDat ( )
override

Definition at line 22 of file ODDelaysDat.cc.

22 {}

Member Function Documentation

◆ fetchData() [1/2]

void ODDelaysDat::fetchData ( std::vector< ODDelaysDat > *  fillMap,
int  id 
)
privatenoexcept

Definition at line 59 of file ODDelaysDat.cc.

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

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

59  {
60  this->checkConnection();
61 
62  if (!iovID) {
63  // throw(std::runtime_error("ODDelaysDat::writeDB: IOV not in DB"));
64  return;
65  }
66 
67  try {
68  m_readStmt = m_conn->createStatement();
69  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id");
70  m_readStmt->setInt(1, iovID);
71  ResultSet* rset = m_readStmt->executeQuery();
72 
73  // std::vector< ODDelaysDat > p;
74  ODDelaysDat dat;
75  while (rset->next()) {
76  // dat.setId( rset->getInt(1) );
77  dat.setSMId(rset->getInt(2));
78  dat.setFedId(rset->getInt(3));
79  dat.setTTId(rset->getInt(4));
80  dat.setTimeOffset(rset->getInt(5));
81 
82  p->push_back(dat);
83  }
84  } catch (SQLException& e) {
85  throw(std::runtime_error("ODDelaysDat::fetchData(): " + e.getMessage()));
86  }
87 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setTimeOffset(int dac)
Definition: ODDelaysDat.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setTTId(int dac)
Definition: ODDelaysDat.h:28
std::string getTable() override
Definition: ODDelaysDat.h:17
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void setSMId(int dac)
Definition: ODDelaysDat.h:22
Statement * m_readStmt
Definition: IODConfig.h:34
void setFedId(int dac)
Definition: ODDelaysDat.h:25

◆ fetchData() [2/2]

void ODDelaysDat::fetchData ( std::vector< ODDelaysDat > *  fillMap,
ODFEDelaysInfo iov 
)
privatenoexcept

Definition at line 53 of file ODDelaysDat.cc.

References AlCaHLTBitMon_ParallelJobs::p.

53  {
54  iov->setConnection(m_env, m_conn);
55  int iovID = iov->fetchID();
56  fetchData(p, iovID);
57 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int fetchID() noexcept(false)
void fetchData(std::vector< ODDelaysDat > *fillMap, int id) noexcept(false)
Definition: ODDelaysDat.cc:59
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getFedId()

int ODDelaysDat::getFedId ( ) const
inline

Definition at line 26 of file ODDelaysDat.h.

References m_fed.

Referenced by writeArrayDB().

26 { return m_fed; }

◆ getId()

int ODDelaysDat::getId ( void  ) const
inline

Definition at line 20 of file ODDelaysDat.h.

References m_ID.

20 { return m_ID; }

◆ getSMId()

int ODDelaysDat::getSMId ( ) const
inline

Definition at line 23 of file ODDelaysDat.h.

References m_sm.

Referenced by writeArrayDB().

23 { return m_sm; }

◆ getTable()

std::string ODDelaysDat::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 17 of file ODDelaysDat.h.

17 { return "DELAYS_DAT"; }

◆ getTimeOffset()

int ODDelaysDat::getTimeOffset ( ) const
inline

Definition at line 32 of file ODDelaysDat.h.

References m_t1.

Referenced by writeArrayDB().

32 { return m_t1; }

◆ getTTId()

int ODDelaysDat::getTTId ( ) const
inline

Definition at line 29 of file ODDelaysDat.h.

References m_tt.

Referenced by writeArrayDB().

29 { return m_tt; }

◆ prepareWrite()

void ODDelaysDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 24 of file ODDelaysDat.cc.

References MillePedeFileConverter_cfg::e.

24  {
25  this->checkConnection();
26 
27  try {
28  m_writeStmt = m_conn->createStatement();
29  m_writeStmt->setSQL("INSERT INTO " + getTable() +
30  " (rec_id, sm_id, fed_id, tt_id, time_offset ) "
31  "VALUES (:1, :2, :3, :4, :5 )");
32  } catch (SQLException& e) {
33  throw(std::runtime_error("ODDelaysDat::prepareWrite(): " + e.getMessage()));
34  }
35 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
Definition: ODDelaysDat.h:17
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

◆ setFedId()

void ODDelaysDat::setFedId ( int  dac)
inline

Definition at line 25 of file ODDelaysDat.h.

References m_fed.

Referenced by fetchData().

25 { m_fed = dac; }

◆ setId()

void ODDelaysDat::setId ( int  dac)
inline

Definition at line 19 of file ODDelaysDat.h.

References m_ID.

19 { m_ID = dac; }

◆ setSMId()

void ODDelaysDat::setSMId ( int  dac)
inline

Definition at line 22 of file ODDelaysDat.h.

References m_sm.

Referenced by fetchData().

22 { m_sm = dac; }

◆ setTimeOffset()

void ODDelaysDat::setTimeOffset ( int  dac)
inline

Definition at line 31 of file ODDelaysDat.h.

References m_t1.

Referenced by fetchData().

31 { m_t1 = dac; }

◆ setTTId()

void ODDelaysDat::setTTId ( int  dac)
inline

Definition at line 28 of file ODDelaysDat.h.

References m_tt.

Referenced by fetchData().

28 { m_tt = dac; }

◆ writeArrayDB()

void ODDelaysDat::writeArrayDB ( const std::vector< ODDelaysDat > &  data,
ODFEDelaysInfo iov 
)
privatenoexcept

Definition at line 91 of file ODDelaysDat.cc.

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

91  {
92  this->checkConnection();
93 
94  int iovID = iov->fetchID();
95  if (!iovID) {
96  throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB"));
97  }
98 
99  int nrows = data.size();
100  int* ids = new int[nrows];
101  int* xx = new int[nrows];
102  int* yy = new int[nrows];
103  int* zz = new int[nrows];
104  int* st = new int[nrows];
105 
106  ub2* ids_len = new ub2[nrows];
107  ub2* x_len = new ub2[nrows];
108  ub2* y_len = new ub2[nrows];
109  ub2* z_len = new ub2[nrows];
110  ub2* st_len = new ub2[nrows];
111 
112  ODDelaysDat dataitem;
113 
114  int n_data = (int)data.size();
115 
116  for (int count = 0; count < n_data; count++) {
117  dataitem = data[count];
118  ids[count] = iovID;
119  xx[count] = dataitem.getSMId();
120  yy[count] = dataitem.getFedId();
121  zz[count] = dataitem.getTTId();
122  st[count] = dataitem.getTimeOffset();
123 
124  ids_len[count] = sizeof(ids[count]);
125  x_len[count] = sizeof(xx[count]);
126  y_len[count] = sizeof(yy[count]);
127  z_len[count] = sizeof(zz[count]);
128  st_len[count] = sizeof(st[count]);
129  }
130 
131  try {
132  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
133  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
134  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
135  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT, sizeof(zz[0]), z_len);
136  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
137 
138  m_writeStmt->executeArrayUpdate(nrows);
139 
140  delete[] ids;
141  delete[] xx;
142  delete[] yy;
143  delete[] zz;
144  delete[] st;
145 
146  delete[] ids_len;
147  delete[] x_len;
148  delete[] y_len;
149  delete[] z_len;
150  delete[] st_len;
151 
152  } catch (SQLException& e) {
153  throw(std::runtime_error("ODDelaysDat::writeArrayDB(): " + e.getMessage()));
154  }
155 }
Statement * m_writeStmt
Definition: IODConfig.h:33
int getFedId() const
Definition: ODDelaysDat.h:26
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false)
int getTimeOffset() const
Definition: ODDelaysDat.h:32
int getTTId() const
Definition: ODDelaysDat.h:29
int getSMId() const
Definition: ODDelaysDat.h:23
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

◆ writeDB()

void ODDelaysDat::writeDB ( const ODDelaysDat item,
ODFEDelaysInfo iov 
)
privatenoexcept

Definition at line 37 of file ODDelaysDat.cc.

References MillePedeFileConverter_cfg::e, and B2GTnPMonitor_cfi::item.

37  {
38  this->checkConnection();
39 
40  try {
41  m_writeStmt->setInt(1, item->getId());
42  m_writeStmt->setInt(2, item->getSMId());
43  m_writeStmt->setInt(3, item->getFedId());
44  m_writeStmt->setInt(4, item->getTTId());
45  m_writeStmt->setInt(5, item->getTimeOffset());
46 
47  m_writeStmt->executeUpdate();
48  } catch (SQLException& e) {
49  throw(std::runtime_error("ODDelaysDat::writeDB(): " + e.getMessage()));
50  }
51 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getId() const
Definition: ODDelaysDat.h:20
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 12 of file ODDelaysDat.h.

Member Data Documentation

◆ m_fed

int ODDelaysDat::m_fed
private

Definition at line 46 of file ODDelaysDat.h.

Referenced by getFedId(), and setFedId().

◆ m_ID

int ODDelaysDat::m_ID
private

Definition at line 49 of file ODDelaysDat.h.

Referenced by getId(), and setId().

◆ m_sm

int ODDelaysDat::m_sm
private

Definition at line 45 of file ODDelaysDat.h.

Referenced by getSMId(), and setSMId().

◆ m_t1

int ODDelaysDat::m_t1
private

Definition at line 48 of file ODDelaysDat.h.

Referenced by getTimeOffset(), and setTimeOffset().

◆ m_tt

int ODDelaysDat::m_tt
private

Definition at line 47 of file ODDelaysDat.h.

Referenced by getTTId(), and setTTId().