CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MODCCSTRDat Class Reference

#include <MODCCSTRDat.h>

Inheritance diagram for MODCCSTRDat:
IDataItem IDBObject

Public Member Functions

std::string getTable () override
 
int getWord () const
 
 MODCCSTRDat ()
 
void setWord (int x)
 
 ~MODCCSTRDat () override
 
- 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, MODCCSTRDat > *fillMap, MODRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MODCCSTRDat > *data, MODRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MODCCSTRDat *item, MODRunIOV *iov) noexcept(false)
 

Private Attributes

int m_word
 

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 () noexcept(false)
 
void createReadStatement () 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 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 MODCCSTRDat.h.

Constructor & Destructor Documentation

MODCCSTRDat::MODCCSTRDat ( )

Definition at line 11 of file MODCCSTRDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_word = 0;
18 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
MODCCSTRDat::~MODCCSTRDat ( )
override

Definition at line 20 of file MODCCSTRDat.cc.

20 {}

Member Function Documentation

void MODCCSTRDat::fetchData ( std::map< EcalLogicID, MODCCSTRDat > *  fillMap,
MODRunIOV iov 
)
privatenoexcept

Definition at line 62 of file MODCCSTRDat.cc.

References dat, alignCSCRings::e, AlCaHLTBitMon_ParallelJobs::p, and setWord().

62  {
63  this->checkConnection();
64  fillMap->clear();
65 
66  iov->setConnection(m_env, m_conn);
67  int iovID = iov->fetchID();
68  if (!iovID) {
69  // throw(std::runtime_error("MODCCSTRDat::writeDB: IOV not in DB"));
70  return;
71  }
72 
73  try {
74  m_readStmt->setSQL(
75  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
76  " d.ccs_word "
77  "FROM channelview cv JOIN OD_CCS_TR_dat d "
78  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
79  "WHERE d.iov_id = :iov_id");
80  m_readStmt->setInt(1, iovID);
81  ResultSet* rset = m_readStmt->executeQuery();
82 
83  std::pair<EcalLogicID, MODCCSTRDat> p;
85  while (rset->next()) {
86  p.first = EcalLogicID(rset->getString(1), // name
87  rset->getInt(2), // logic_id
88  rset->getInt(3), // id1
89  rset->getInt(4), // id2
90  rset->getInt(5), // id3
91  rset->getString(6)); // maps_to
92 
93  dat.setWord(rset->getInt(7));
94 
95  p.second = dat;
96  fillMap->insert(p);
97  }
98  } catch (SQLException& e) {
99  throw(std::runtime_error("MODCCSTRDat::fetchData(): " + e.getMessage()));
100  }
101 }
void setWord(int x)
Definition: MODCCSTRDat.h:20
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
static std::vector< std::string > checklist dat
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
std::string MODCCSTRDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MODCCSTRDat.h.

18 { return "OD_CCS_TR_DAT"; }
int MODCCSTRDat::getWord ( ) const
inline

Definition at line 21 of file MODCCSTRDat.h.

References m_word.

Referenced by writeArrayDB().

21 { return m_word; }
void MODCCSTRDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 22 of file MODCCSTRDat.cc.

References alignCSCRings::e.

22  {
23  this->checkConnection();
24 
25  try {
26  m_writeStmt = m_conn->createStatement();
27  m_writeStmt->setSQL(
28  "INSERT INTO OD_CCS_TR_dat (iov_id, logic_id, "
29  "ccs_word) "
30  "VALUES (:iov_id, :logic_id, "
31  ":ccs_word)");
32  } catch (SQLException& e) {
33  throw(std::runtime_error("MODCCSTRDat::prepareWrite(): " + e.getMessage()));
34  }
35 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void MODCCSTRDat::setWord ( int  x)
inline

Definition at line 20 of file MODCCSTRDat.h.

References m_word, and x.

Referenced by fetchData().

20 { m_word = x; }
void MODCCSTRDat::writeArrayDB ( const std::map< EcalLogicID, MODCCSTRDat > *  data,
MODRunIOV iov 
)
privatenoexcept

Definition at line 103 of file MODCCSTRDat.cc.

References submitPVResolutionJobs::count, data, alignCSCRings::e, EcalLogicID::getLogicID(), getWord(), AlCaHLTBitMon_ParallelJobs::p, and x.

103  {
104  this->checkConnection();
105  this->checkPrepare();
106 
107  int iovID = iov->fetchID();
108  if (!iovID) {
109  throw(std::runtime_error("MODCCSTRDat::writeArrayDB: IOV not in DB"));
110  }
111 
112  int nrows = data->size();
113  int* ids = new int[nrows];
114  int* iovid_vec = new int[nrows];
115  int* xx = new int[nrows];
116 
117  ub2* ids_len = new ub2[nrows];
118  ub2* iov_len = new ub2[nrows];
119  ub2* x_len = new ub2[nrows];
120 
121  const EcalLogicID* channel;
122  const MODCCSTRDat* dataitem;
123  int count = 0;
124  typedef map<EcalLogicID, MODCCSTRDat>::const_iterator CI;
125  for (CI p = data->begin(); p != data->end(); ++p) {
126  channel = &(p->first);
127  int logicID = channel->getLogicID();
128  if (!logicID) {
129  throw(std::runtime_error("MODCCSTRDat::writeArrayDB: Bad EcalLogicID"));
130  }
131  ids[count] = logicID;
132  iovid_vec[count] = iovID;
133 
134  dataitem = &(p->second);
135  // dataIface.writeDB( channel, dataitem, iov);
136  int x = dataitem->getWord();
137 
138  xx[count] = x;
139 
140  ids_len[count] = sizeof(ids[count]);
141  iov_len[count] = sizeof(iovid_vec[count]);
142 
143  x_len[count] = sizeof(xx[count]);
144 
145  count++;
146  }
147 
148  try {
149  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
150  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
151  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
152 
153  m_writeStmt->executeArrayUpdate(nrows);
154 
155  delete[] ids;
156  delete[] iovid_vec;
157  delete[] xx;
158 
159  delete[] ids_len;
160  delete[] iov_len;
161  delete[] x_len;
162 
163  } catch (SQLException& e) {
164  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): " + e.getMessage()));
165  }
166 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int getWord() const
Definition: MODCCSTRDat.h:21
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61
int getLogicID() const
Definition: EcalLogicID.cc:28
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void MODCCSTRDat::writeDB ( const EcalLogicID ecid,
const MODCCSTRDat item,
MODRunIOV iov 
)
privatenoexcept

Definition at line 37 of file MODCCSTRDat.cc.

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

37  {
38  this->checkConnection();
39  this->checkPrepare();
40 
41  int iovID = iov->fetchID();
42  if (!iovID) {
43  throw(std::runtime_error("MODCCSTRDat::writeDB: IOV not in DB"));
44  }
45 
46  int logicID = ecid->getLogicID();
47  if (!logicID) {
48  throw(std::runtime_error("MODCCSTRDat::writeDB: Bad EcalLogicID"));
49  }
50 
51  try {
52  m_writeStmt->setInt(1, iovID);
53  m_writeStmt->setInt(2, logicID);
54  m_writeStmt->setFloat(3, item->getWord());
55 
56  m_writeStmt->executeUpdate();
57  } catch (SQLException& e) {
58  throw(std::runtime_error("MODCCSTRDat::writeDB(): " + e.getMessage()));
59  }
60 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int getWord() const
Definition: MODCCSTRDat.h:21
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61
int getLogicID() const
Definition: EcalLogicID.cc:28

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file MODCCSTRDat.h.

Member Data Documentation

int MODCCSTRDat::m_word
private

Definition at line 33 of file MODCCSTRDat.h.

Referenced by getWord(), and setWord().