CMS 3D CMS Logo

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

#include <FEConfigSpikeDat.h>

Inheritance diagram for FEConfigSpikeDat:
IDataItem IDBObject

Public Member Functions

 FEConfigSpikeDat ()
 
int getSpikeThreshold () const
 
std::string getTable () override
 
void setSpikeThreshold (int x)
 
 ~FEConfigSpikeDat () 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, FEConfigSpikeDat > *fillMap, FEConfigSpikeInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigSpikeDat > *data, FEConfigSpikeInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigSpikeDat *item, FEConfigSpikeInfo *iconf) noexcept(false)
 

Private Attributes

int m_thr
 

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 FEConfigSpikeDat.h.

Constructor & Destructor Documentation

◆ FEConfigSpikeDat()

FEConfigSpikeDat::FEConfigSpikeDat ( )

Definition at line 11 of file FEConfigSpikeDat.cc.

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

◆ ~FEConfigSpikeDat()

FEConfigSpikeDat::~FEConfigSpikeDat ( )
override

Definition at line 20 of file FEConfigSpikeDat.cc.

20 {}

Member Function Documentation

◆ fetchData()

void FEConfigSpikeDat::fetchData ( std::map< EcalLogicID, FEConfigSpikeDat > *  fillMap,
FEConfigSpikeInfo iconf 
)
privatenoexcept

Definition at line 64 of file FEConfigSpikeDat.cc.

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

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

◆ getSpikeThreshold()

int FEConfigSpikeDat::getSpikeThreshold ( ) const
inline

Definition at line 21 of file FEConfigSpikeDat.h.

21 { return m_thr; }

References m_thr.

Referenced by popcon::EcalTPGSpikeThresholdHandler::getNewObjects(), and writeArrayDB().

◆ getTable()

std::string FEConfigSpikeDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigSpikeDat.h.

18 { return "FE_CONFIG_SPIKE_DAT"; }

◆ prepareWrite()

void FEConfigSpikeDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 22 of file FEConfigSpikeDat.cc.

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

References MillePedeFileConverter_cfg::e.

◆ setSpikeThreshold()

void FEConfigSpikeDat::setSpikeThreshold ( int  x)
inline

Definition at line 20 of file FEConfigSpikeDat.h.

20 { m_thr = x; }

References m_thr, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

◆ writeArrayDB()

void FEConfigSpikeDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigSpikeDat > *  data,
FEConfigSpikeInfo iconf 
)
privatenoexcept

Definition at line 106 of file FEConfigSpikeDat.cc.

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

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

◆ writeDB()

void FEConfigSpikeDat::writeDB ( const EcalLogicID ecid,
const FEConfigSpikeDat item,
FEConfigSpikeInfo iconf 
)
privatenoexcept

Definition at line 37 of file FEConfigSpikeDat.cc.

39  {
40  this->checkConnection();
41  this->checkPrepare();
42 
43  int iconfID = iconf->fetchID();
44  if (!iconfID) {
45  throw(std::runtime_error("FEConfigSpikeDat::writeDB: ICONF not in DB"));
46  }
47 
48  int logicID = ecid->getLogicID();
49  if (!logicID) {
50  throw(std::runtime_error("FEConfigSpikeDat::writeDB: Bad EcalLogicID"));
51  }
52 
53  try {
54  m_writeStmt->setInt(1, iconfID);
55  m_writeStmt->setInt(2, logicID);
56  m_writeStmt->setInt(3, item->getSpikeThreshold());
57 
58  m_writeStmt->executeUpdate();
59  } catch (SQLException& e) {
60  throw(std::runtime_error("FEConfigSpikeDat::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 FEConfigSpikeDat.h.

Member Data Documentation

◆ m_thr

int FEConfigSpikeDat::m_thr
private

Definition at line 33 of file FEConfigSpikeDat.h.

Referenced by getSpikeThreshold(), and setSpikeThreshold().

FEConfigSpikeInfo::fetchID
int fetchID() noexcept(false)
Definition: FEConfigSpikeInfo.cc:156
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
IDataItem::checkPrepare
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
FEConfigSpikeDat::setSpikeThreshold
void setSpikeThreshold(int x)
Definition: FEConfigSpikeDat.h:20
DDAxes::x
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
IDataItem::m_readStmt
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
IDataItem::m_writeStmt
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
FEConfigSpikeDat
Definition: FEConfigSpikeDat.h:11
EcalLogicID
Definition: EcalLogicID.h:7
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
FEConfigSpikeDat::getTable
std::string getTable() override
Definition: FEConfigSpikeDat.h:18
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
FEConfigSpikeDat::m_thr
int m_thr
Definition: FEConfigSpikeDat.h:33
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
FEConfigSpikeDat::getSpikeThreshold
int getSpikeThreshold() const
Definition: FEConfigSpikeDat.h:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37