CMS 3D CMS Logo

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

#include <FEConfigPedDat.h>

Inheritance diagram for FEConfigPedDat:
IDataItem IDBObject

Public Member Functions

 FEConfigPedDat ()
 
int getId () const
 
float getPedMeanG1 () const
 
float getPedMeanG12 () const
 
float getPedMeanG6 () const
 
std::string getTable () override
 
void setId (int x)
 
void setPedMeanG1 (float mean)
 
void setPedMeanG12 (float mean)
 
void setPedMeanG6 (float mean)
 
 ~FEConfigPedDat () 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, FEConfigPedDat > *fillMap, FEConfigPedInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigPedDat > *data, FEConfigPedInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigPedDat *item, FEConfigPedInfo *iconf) noexcept(false)
 

Private Attributes

int m_ID
 
float m_pedMeanG1
 
float m_pedMeanG12
 
float m_pedMeanG6
 

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

Constructor & Destructor Documentation

◆ FEConfigPedDat()

FEConfigPedDat::FEConfigPedDat ( )

Definition at line 11 of file FEConfigPedDat.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16  m_ID = 0;
17  m_pedMeanG1 = 0;
18  m_pedMeanG6 = 0;
19  m_pedMeanG12 = 0;
20 }
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

◆ ~FEConfigPedDat()

FEConfigPedDat::~FEConfigPedDat ( )
override

Definition at line 22 of file FEConfigPedDat.cc.

22 {}

Member Function Documentation

◆ fetchData()

void FEConfigPedDat::fetchData ( std::map< EcalLogicID, FEConfigPedDat > *  fillMap,
FEConfigPedInfo iconf 
)
privatenoexcept

Definition at line 68 of file FEConfigPedDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setPedMeanG1(), setPedMeanG12(), and setPedMeanG6().

68  {
69  this->checkConnection();
70  fillMap->clear();
71 
72  iconf->setConnection(m_env, m_conn);
73  int iconfID = iconf->fetchID();
74  if (!iconfID) {
75  // throw(std::runtime_error("FEConfigPedDat::writeDB: ICONF not in DB"));
76  return;
77  }
78 
79  try {
80  m_readStmt->setSQL(
81  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
82  "d.mean_12, d.mean_6, d.mean_1 "
83  "FROM channelview cv JOIN fe_config_ped_dat d "
84  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
85  "WHERE ped_conf_id = :ped_conf_id");
86  m_readStmt->setInt(1, iconfID);
87  ResultSet* rset = m_readStmt->executeQuery();
88 
89  std::pair<EcalLogicID, FEConfigPedDat> p;
90  FEConfigPedDat dat;
91  while (rset->next()) {
92  p.first = EcalLogicID(rset->getString(1), // name
93  rset->getInt(2), // logic_id
94  rset->getInt(3), // id1
95  rset->getInt(4), // id2
96  rset->getInt(5), // id3
97  rset->getString(6)); // maps_to
98 
99  dat.setPedMeanG12(rset->getFloat(7));
100  dat.setPedMeanG6(rset->getFloat(8));
101  dat.setPedMeanG1(rset->getFloat(9));
102 
103  p.second = dat;
104  fillMap->insert(p);
105  }
106  } catch (SQLException& e) {
107  throw(std::runtime_error("FEConfigPedDat::fetchData: " + e.getMessage()));
108  }
109 }
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
void setPedMeanG6(float mean)
void setPedMeanG1(float mean)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setPedMeanG12(float mean)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false)

◆ getId()

int FEConfigPedDat::getId ( void  ) const
inline

Definition at line 21 of file FEConfigPedDat.h.

References m_ID.

21 { return m_ID; }

◆ getPedMeanG1()

float FEConfigPedDat::getPedMeanG1 ( ) const
inline

◆ getPedMeanG12()

float FEConfigPedDat::getPedMeanG12 ( ) const
inline

◆ getPedMeanG6()

float FEConfigPedDat::getPedMeanG6 ( ) const
inline

◆ getTable()

std::string FEConfigPedDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigPedDat.h.

18 { return "FE_CONFIG_PED_DAT"; }

◆ prepareWrite()

void FEConfigPedDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 24 of file FEConfigPedDat.cc.

References MillePedeFileConverter_cfg::e.

24  {
25  this->checkConnection();
26 
27  try {
28  m_writeStmt = m_conn->createStatement();
29 
30  m_writeStmt->setSQL("INSERT INTO " + getTable() +
31  " (ped_conf_id, logic_id, "
32  "mean_12, mean_6, mean_1 ) "
33  "VALUES (:ped_conf_id, :logic_id, "
34  ":ped_mean_g12, :ped_mean_g6, :ped_mean_g1 )");
35  } catch (SQLException& e) {
36  throw(std::runtime_error("FEConfigPedDat::prepareWrite(): " + e.getMessage()));
37  }
38 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36

◆ setId()

void FEConfigPedDat::setId ( int  x)
inline

Definition at line 20 of file FEConfigPedDat.h.

References m_ID, and x.

◆ setPedMeanG1()

void FEConfigPedDat::setPedMeanG1 ( float  mean)
inline

◆ setPedMeanG12()

void FEConfigPedDat::setPedMeanG12 ( float  mean)
inline

◆ setPedMeanG6()

void FEConfigPedDat::setPedMeanG6 ( float  mean)
inline

◆ writeArrayDB()

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

Definition at line 111 of file FEConfigPedDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getPedMeanG1(), getPedMeanG12(), getPedMeanG6(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

112  {
113  this->checkConnection();
114  this->checkPrepare();
115 
116  int iconfID = iconf->fetchID();
117  if (!iconfID) {
118  throw(std::runtime_error("FEConfigPedDat::writeArrayDB: ICONF not in DB"));
119  }
120 
121  int nrows = data->size();
122  int* ids = new int[nrows];
123  int* iconfid_vec = new int[nrows];
124  float* xx = new float[nrows];
125  float* yy = new float[nrows];
126  float* zz = new float[nrows];
127 
128  ub2* ids_len = new ub2[nrows];
129  ub2* iconf_len = new ub2[nrows];
130  ub2* x_len = new ub2[nrows];
131  ub2* y_len = new ub2[nrows];
132  ub2* z_len = new ub2[nrows];
133 
134  const EcalLogicID* channel;
135  const FEConfigPedDat* dataitem;
136  int count = 0;
137  typedef map<EcalLogicID, FEConfigPedDat>::const_iterator CI;
138  for (CI p = data->begin(); p != data->end(); ++p) {
139  channel = &(p->first);
140  int logicID = channel->getLogicID();
141  if (!logicID) {
142  throw(std::runtime_error("FEConfigPedDat::writeArrayDB: Bad EcalLogicID"));
143  }
144  ids[count] = logicID;
145  iconfid_vec[count] = iconfID;
146 
147  dataitem = &(p->second);
148  // dataIface.writeDB( channel, dataitem, iconf);
149  float x = dataitem->getPedMeanG12();
150  float y = dataitem->getPedMeanG6();
151  float z = dataitem->getPedMeanG1();
152 
153  xx[count] = x;
154  yy[count] = y;
155  zz[count] = z;
156 
157  ids_len[count] = sizeof(ids[count]);
158  iconf_len[count] = sizeof(iconfid_vec[count]);
159 
160  x_len[count] = sizeof(xx[count]);
161  y_len[count] = sizeof(yy[count]);
162  z_len[count] = sizeof(zz[count]);
163 
164  count++;
165  }
166 
167  try {
168  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]), iconf_len);
169  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
170  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
171  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
172  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT, sizeof(zz[0]), z_len);
173 
174  m_writeStmt->executeArrayUpdate(nrows);
175 
176  delete[] ids;
177  delete[] iconfid_vec;
178  delete[] xx;
179  delete[] yy;
180  delete[] zz;
181 
182  delete[] ids_len;
183  delete[] iconf_len;
184  delete[] x_len;
185  delete[] y_len;
186  delete[] z_len;
187 
188  } catch (SQLException& e) {
189  throw(std::runtime_error("FEConfigPedDat::writeArrayDB(): " + e.getMessage()));
190  }
191 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
float getPedMeanG6() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
float getPedMeanG1() const
int getLogicID() const
Definition: EcalLogicID.cc:28
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int fetchID() noexcept(false)
float getPedMeanG12() const

◆ writeDB()

void FEConfigPedDat::writeDB ( const EcalLogicID ecid,
const FEConfigPedDat item,
FEConfigPedInfo iconf 
)
privatenoexcept

Definition at line 40 of file FEConfigPedDat.cc.

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

42  {
43  this->checkConnection();
44 
45  int iconfID = iconf->fetchID();
46  if (!iconfID) {
47  throw(std::runtime_error("FEConfigPedDat::writeDB: ICONF not in DB"));
48  }
49 
50  int logicID = ecid->getLogicID();
51  if (!logicID) {
52  throw(std::runtime_error("FEConfigPedDat::writeDB: Bad EcalLogicID"));
53  }
54 
55  try {
56  m_writeStmt->setInt(1, iconfID);
57  m_writeStmt->setInt(2, logicID);
58  m_writeStmt->setFloat(3, item->getPedMeanG12());
59  m_writeStmt->setFloat(4, item->getPedMeanG6());
60  m_writeStmt->setFloat(5, item->getPedMeanG1());
61 
62  m_writeStmt->executeUpdate();
63  } catch (SQLException& e) {
64  throw(std::runtime_error("FEConfigPedDat::writeDB(): " + e.getMessage()));
65  }
66 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getLogicID() const
Definition: EcalLogicID.cc:28
int fetchID() noexcept(false)

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigPedDat.h.

Member Data Documentation

◆ m_ID

int FEConfigPedDat::m_ID
private

Definition at line 45 of file FEConfigPedDat.h.

Referenced by getId(), and setId().

◆ m_pedMeanG1

float FEConfigPedDat::m_pedMeanG1
private

Definition at line 42 of file FEConfigPedDat.h.

Referenced by getPedMeanG1(), and setPedMeanG1().

◆ m_pedMeanG12

float FEConfigPedDat::m_pedMeanG12
private

Definition at line 44 of file FEConfigPedDat.h.

Referenced by getPedMeanG12(), and setPedMeanG12().

◆ m_pedMeanG6

float FEConfigPedDat::m_pedMeanG6
private

Definition at line 43 of file FEConfigPedDat.h.

Referenced by getPedMeanG6(), and setPedMeanG6().