CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MODCCSFEDat Class Reference

#include <MODCCSFEDat.h>

Inheritance diagram for MODCCSFEDat:
IDataItem IDBObject

Public Member Functions

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

Constructor & Destructor Documentation

◆ MODCCSFEDat()

MODCCSFEDat::MODCCSFEDat ( )

Definition at line 11 of file MODCCSFEDat.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

◆ ~MODCCSFEDat()

MODCCSFEDat::~MODCCSFEDat ( )
override

Definition at line 20 of file MODCCSFEDat.cc.

20 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 62 of file MODCCSFEDat.cc.

References MillePedeFileConverter_cfg::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("MODCCSFEDat::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_FE_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, MODCCSFEDat> p;
84  MODCCSFEDat dat;
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("MODCCSFEDat::fetchData(): " + e.getMessage()));
100  }
101 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setWord(int x)
Definition: MODCCSFEDat.h:20
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
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getTable()

std::string MODCCSFEDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MODCCSFEDat.h.

18 { return "OD_CCS_FE_DAT"; }

◆ getWord()

int MODCCSFEDat::getWord ( ) const
inline

Definition at line 21 of file MODCCSFEDat.h.

References m_word.

Referenced by writeArrayDB().

21 { return m_word; }

◆ prepareWrite()

void MODCCSFEDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 22 of file MODCCSFEDat.cc.

References MillePedeFileConverter_cfg::e.

22  {
23  this->checkConnection();
24 
25  try {
26  m_writeStmt = m_conn->createStatement();
27  m_writeStmt->setSQL(
28  "INSERT INTO OD_CCS_FE_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("MODCCSFEDat::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

◆ setWord()

void MODCCSFEDat::setWord ( int  x)
inline

Definition at line 20 of file MODCCSFEDat.h.

References m_word, and x.

Referenced by fetchData().

20 { m_word = x; }

◆ writeArrayDB()

void MODCCSFEDat::writeArrayDB ( const std::map< EcalLogicID, MODCCSFEDat > *  data,
MODRunIOV iov 
)
privatenoexcept

Definition at line 103 of file MODCCSFEDat.cc.

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

103  {
104  this->checkConnection();
105  this->checkPrepare();
106 
107  int iovID = iov->fetchID();
108  if (!iovID) {
109  throw(std::runtime_error("MODCCSFEDat::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 MODCCSFEDat* dataitem;
123  int count = 0;
124  typedef map<EcalLogicID, MODCCSFEDat>::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("MODCCSFEDat::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
int getWord() const
Definition: MODCCSFEDat.h:21
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ writeDB()

void MODCCSFEDat::writeDB ( const EcalLogicID ecid,
const MODCCSFEDat item,
MODRunIOV iov 
)
privatenoexcept

Definition at line 37 of file MODCCSFEDat.cc.

References MillePedeFileConverter_cfg::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("MODCCSFEDat::writeDB: IOV not in DB"));
44  }
45 
46  int logicID = ecid->getLogicID();
47  if (!logicID) {
48  throw(std::runtime_error("MODCCSFEDat::writeDB: Bad EcalLogicID"));
49  }
50 
51  try {
52  m_writeStmt->setInt(1, iovID);
53  m_writeStmt->setInt(2, logicID);
54  m_writeStmt->setInt(3, item->getWord());
55 
56  m_writeStmt->executeUpdate();
57  } catch (SQLException& e) {
58  throw(std::runtime_error("MODCCSFEDat::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 getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file MODCCSFEDat.h.

Member Data Documentation

◆ m_word

int MODCCSFEDat::m_word
private

Definition at line 33 of file MODCCSFEDat.h.

Referenced by getWord(), and setWord().