CMS 3D CMS Logo

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

#include <MODDCCOperationDat.h>

Inheritance diagram for MODDCCOperationDat:
IDataItem IDBObject

Public Member Functions

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

Private Attributes

std::string m_word
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static const int 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 MODDCCOperationDat.h.

Constructor & Destructor Documentation

◆ MODDCCOperationDat()

MODDCCOperationDat::MODDCCOperationDat ( )

Definition at line 11 of file MODDCCOperationDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_word = "";
18 }

◆ ~MODDCCOperationDat()

MODDCCOperationDat::~MODDCCOperationDat ( )
override

Definition at line 20 of file MODDCCOperationDat.cc.

20 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 64 of file MODDCCOperationDat.cc.

64  {
65  this->checkConnection();
66  fillMap->clear();
67 
68  iov->setConnection(m_env, m_conn);
69  int iovID = iov->fetchID();
70  if (!iovID) {
71  // throw(std::runtime_error("MODDCCOperationDat::writeDB: IOV not in DB"));
72  return;
73  }
74 
75  try {
76  m_readStmt->setSQL(
77  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
78  " d.operationMode "
79  "FROM channelview cv JOIN " +
80  getTable() +
81  " d "
82  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
83  "WHERE d.iov_id = :iov_id");
84  m_readStmt->setInt(1, iovID);
85  ResultSet* rset = m_readStmt->executeQuery();
86 
87  std::pair<EcalLogicID, MODDCCOperationDat> p;
89  while (rset->next()) {
90  p.first = EcalLogicID(rset->getString(1), // name
91  rset->getInt(2), // logic_id
92  rset->getInt(3), // id1
93  rset->getInt(4), // id2
94  rset->getInt(5), // id3
95  rset->getString(6)); // maps_to
96 
97  dat.setOperation(rset->getString(7));
98 
99  p.second = dat;
100  fillMap->insert(p);
101  }
102  } catch (SQLException& e) {
103  throw(std::runtime_error("MODDCCOperationDat::fetchData(): " + e.getMessage()));
104  }
105 }

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, and setOperation().

◆ getOperation()

std::string MODDCCOperationDat::getOperation ( ) const
inline

Definition at line 21 of file MODDCCOperationDat.h.

21 { return m_word; }

References m_word.

Referenced by writeArrayDB().

◆ getTable()

std::string MODDCCOperationDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file MODDCCOperationDat.h.

18 { return "OD_DCC_OPERATION_DAT"; }

◆ prepareWrite()

void MODDCCOperationDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 22 of file MODDCCOperationDat.cc.

22  {
23  this->checkConnection();
24 
25  try {
26  m_writeStmt = m_conn->createStatement();
27  m_writeStmt->setSQL("INSERT INTO " + getTable() +
28  " (iov_id, logic_id, "
29  "operationMode) "
30  "VALUES (:iov_id, :logic_id, "
31  ":1) ");
32  } catch (SQLException& e) {
33  throw(std::runtime_error("MODDCCOperationDat::prepareWrite(): " + e.getMessage()));
34  }
35 }

References MillePedeFileConverter_cfg::e.

◆ setOperation()

void MODDCCOperationDat::setOperation ( std::string  x)
inline

Definition at line 20 of file MODDCCOperationDat.h.

20 { m_word = x; }

References m_word, and x.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 107 of file MODDCCOperationDat.cc.

108  {
109  this->checkConnection();
110  this->checkPrepare();
111 
112  int iovID = iov->fetchID();
113  if (!iovID) {
114  throw(std::runtime_error("MODDCCOperationDat::writeArrayDB: IOV not in DB"));
115  }
116 
117  int nrows = data->size();
118  int* ids = new int[nrows];
119  int* iovid_vec = new int[nrows];
120  std::string* xx = new std::string[nrows];
121 
122  ub2* ids_len = new ub2[nrows];
123  ub2* iov_len = new ub2[nrows];
124  ub2* x_len = new ub2[nrows];
125 
126  const EcalLogicID* channel;
127  const MODDCCOperationDat* dataitem;
128  int count = 0;
129  typedef map<EcalLogicID, MODDCCOperationDat>::const_iterator CI;
130  for (CI p = data->begin(); p != data->end(); ++p) {
131  channel = &(p->first);
132  int logicID = channel->getLogicID();
133  if (!logicID) {
134  throw(std::runtime_error("MODDCCOperationDat::writeArrayDB: Bad EcalLogicID"));
135  }
136  ids[count] = logicID;
137  iovid_vec[count] = iovID;
138 
139  dataitem = &(p->second);
140  // dataIface.writeDB( channel, dataitem, iov);
141  std::string x = dataitem->getOperation();
142 
143  xx[count] = x;
144 
145  ids_len[count] = sizeof(ids[count]);
146  iov_len[count] = sizeof(iovid_vec[count]);
147 
148  x_len[count] = sizeof(xx[count]);
149 
150  count++;
151  }
152 
153  try {
154  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
155  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
156  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCISTRING, sizeof(xx[0]), x_len);
157 
158  m_writeStmt->executeArrayUpdate(nrows);
159 
160  delete[] ids;
161  delete[] iovid_vec;
162  delete[] xx;
163 
164  delete[] ids_len;
165  delete[] iov_len;
166  delete[] x_len;
167 
168  } catch (SQLException& e) {
169  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): " + e.getMessage()));
170  }
171 }

References KineDebug3::count(), std::data(), MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getOperation(), AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, x, and geometryCSVtoXML::xx.

◆ writeDB()

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

Definition at line 37 of file MODDCCOperationDat.cc.

39  {
40  this->checkConnection();
41  this->checkPrepare();
42 
43  int iovID = iov->fetchID();
44  if (!iovID) {
45  throw(std::runtime_error("MODDCCOperationDat::writeDB: IOV not in DB"));
46  }
47 
48  int logicID = ecid->getLogicID();
49  if (!logicID) {
50  throw(std::runtime_error("MODDCCOperationDat::writeDB: Bad EcalLogicID"));
51  }
52 
53  try {
54  m_writeStmt->setInt(1, iovID);
55  m_writeStmt->setInt(2, logicID);
56  m_writeStmt->setString(3, item->getOperation());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("MODDCCOperationDat::writeDB(): " + e.getMessage()));
61  }
62 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file MODDCCOperationDat.h.

Member Data Documentation

◆ m_word

std::string MODDCCOperationDat::m_word
private

Definition at line 33 of file MODDCCOperationDat.h.

Referenced by getOperation(), and setOperation().

MODDCCOperationDat::m_word
std::string m_word
Definition: MODDCCOperationDat.h:33
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
IDataItem::checkPrepare
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
DDAxes::x
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
IDataItem::m_readStmt
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
MODRunIOV::fetchID
int fetchID() noexcept(false) override
Definition: MODRunIOV.cc:61
MODDCCOperationDat
Definition: MODDCCOperationDat.h:11
IDataItem::m_writeStmt
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
EcalLogicID
Definition: EcalLogicID.h:7
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MODDCCOperationDat::getTable
std::string getTable() override
Definition: MODDCCOperationDat.h:18
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
MODDCCOperationDat::getOperation
std::string getOperation() const
Definition: MODDCCOperationDat.h:21
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
MODDCCOperationDat::setOperation
void setOperation(std::string x)
Definition: MODDCCOperationDat.h:20
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37