CMS 3D CMS Logo

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

#include <CaliGainRatioDat.h>

Inheritance diagram for CaliGainRatioDat:
IDataItem IDBObject

Public Member Functions

 CaliGainRatioDat ()
 
float getG1G12 () const
 
float getG6G12 () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
void setG1G12 (float c)
 
void setG6G12 (float c)
 
void setTaskStatus (bool s)
 
 ~CaliGainRatioDat () 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, CaliGainRatioDat > *fillVec, CaliIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, CaliGainRatioDat > *data, CaliIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const CaliGainRatioDat *item, CaliIOV *iov) noexcept(false)
 

Private Attributes

float m_g1_g12
 
float m_g6_g12
 
bool m_taskStatus
 

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 12 of file CaliGainRatioDat.h.

Constructor & Destructor Documentation

◆ CaliGainRatioDat()

CaliGainRatioDat::CaliGainRatioDat ( )

Definition at line 12 of file CaliGainRatioDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16 
17  m_g1_g12 = 0;
18  m_g6_g12 = 0;
19  m_taskStatus = false;
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

◆ ~CaliGainRatioDat()

CaliGainRatioDat::~CaliGainRatioDat ( )
override

Definition at line 22 of file CaliGainRatioDat.cc.

22 {}

Member Function Documentation

◆ fetchData()

void CaliGainRatioDat::fetchData ( std::map< EcalLogicID, CaliGainRatioDat > *  fillVec,
CaliIOV iov 
)
privatenoexcept

Definition at line 67 of file CaliGainRatioDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setG1G12(), setG6G12(), and setTaskStatus().

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

◆ getG1G12()

float CaliGainRatioDat::getG1G12 ( ) const
inline

Definition at line 22 of file CaliGainRatioDat.h.

References m_g1_g12.

Referenced by writeArrayDB().

22 { return m_g1_g12; }

◆ getG6G12()

float CaliGainRatioDat::getG6G12 ( ) const
inline

Definition at line 25 of file CaliGainRatioDat.h.

References m_g6_g12.

Referenced by writeArrayDB().

25 { return m_g6_g12; }

◆ getTable()

std::string CaliGainRatioDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file CaliGainRatioDat.h.

19 { return "CALI_GAIN_RATIO_DAT"; }

◆ getTaskStatus()

bool CaliGainRatioDat::getTaskStatus ( ) const
inline

Definition at line 28 of file CaliGainRatioDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

28 { return m_taskStatus; }

◆ prepareWrite()

void CaliGainRatioDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 24 of file CaliGainRatioDat.cc.

References MillePedeFileConverter_cfg::e.

24  {
25  this->checkConnection();
26 
27  try {
28  m_writeStmt = m_conn->createStatement();
29  m_writeStmt->setSQL(
30  "INSERT INTO cali_gain_ratio_dat (iov_id, logic_id, "
31  "g1_g6, g6_g12, task_status) "
32  "VALUES (:iov_id, :logic_id, "
33  ":3, :4, :5)");
34  } catch (SQLException& e) {
35  throw(std::runtime_error("CaliGainRatioDat::prepareWrite(): " + e.getMessage()));
36  }
37 }
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

◆ setG1G12()

void CaliGainRatioDat::setG1G12 ( float  c)
inline

Definition at line 21 of file CaliGainRatioDat.h.

References DummyCfis::c, and m_g1_g12.

Referenced by fetchData().

◆ setG6G12()

void CaliGainRatioDat::setG6G12 ( float  c)
inline

Definition at line 24 of file CaliGainRatioDat.h.

References DummyCfis::c, and m_g6_g12.

Referenced by fetchData().

◆ setTaskStatus()

void CaliGainRatioDat::setTaskStatus ( bool  s)
inline

Definition at line 27 of file CaliGainRatioDat.h.

References m_taskStatus, and alignCSCRings::s.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 110 of file CaliGainRatioDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getG1G12(), getG6G12(), EcalLogicID::getLogicID(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, and geometryCSVtoXML::yy.

110  {
111  this->checkConnection();
112  this->checkPrepare();
113 
114  int iovID = iov->fetchID();
115  if (!iovID) {
116  throw(std::runtime_error("CaliGainRatioDat::writeArrayDB: IOV not in DB"));
117  }
118 
119  int nrows = data->size();
120  int* ids = new int[nrows];
121  int* iovid_vec = new int[nrows];
122  float* xx = new float[nrows];
123  float* yy = new float[nrows];
124  int* st = new int[nrows];
125 
126  ub2* ids_len = new ub2[nrows];
127  ub2* iov_len = new ub2[nrows];
128  ub2* x_len = new ub2[nrows];
129  ub2* y_len = new ub2[nrows];
130  ub2* st_len = new ub2[nrows];
131 
132  const EcalLogicID* channel;
133  const CaliGainRatioDat* dataitem;
134  int count = 0;
135  typedef map<EcalLogicID, CaliGainRatioDat>::const_iterator CI;
136  for (CI p = data->begin(); p != data->end(); ++p) {
137  channel = &(p->first);
138  int logicID = channel->getLogicID();
139  if (!logicID) {
140  throw(std::runtime_error("CaliGainRatioDat::writeArrayDB: Bad EcalLogicID"));
141  }
142  ids[count] = logicID;
143  iovid_vec[count] = iovID;
144 
145  dataitem = &(p->second);
146  // dataIface.writeDB( channel, dataitem, iov);
147  float x = dataitem->getG1G12();
148  float y = dataitem->getG6G12();
149  int statu = dataitem->getTaskStatus();
150 
151  xx[count] = x;
152  yy[count] = y;
153  st[count] = statu;
154 
155  ids_len[count] = sizeof(ids[count]);
156  iov_len[count] = sizeof(iovid_vec[count]);
157 
158  x_len[count] = sizeof(xx[count]);
159  y_len[count] = sizeof(yy[count]);
160  st_len[count] = sizeof(st[count]);
161 
162  count++;
163  }
164 
165  try {
166  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
167  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
168  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT, sizeof(xx[0]), x_len);
169  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT, sizeof(yy[0]), y_len);
170  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
171 
172  m_writeStmt->executeArrayUpdate(nrows);
173 
174  delete[] ids;
175  delete[] iovid_vec;
176  delete[] xx;
177  delete[] yy;
178  delete[] st;
179 
180  delete[] ids_len;
181  delete[] iov_len;
182  delete[] x_len;
183  delete[] y_len;
184  delete[] st_len;
185 
186  } catch (SQLException& e) {
187  throw(std::runtime_error("CaliGainRatio::writeArrayDB(): " + e.getMessage()));
188  }
189 }
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
float getG1G12() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
bool getTaskStatus() const
int fetchID() noexcept(false) override
Definition: CaliIOV.cc:48
float getG6G12() const

◆ writeDB()

void CaliGainRatioDat::writeDB ( const EcalLogicID ecid,
const CaliGainRatioDat item,
CaliIOV iov 
)
privatenoexcept

Definition at line 39 of file CaliGainRatioDat.cc.

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

39  {
40  this->checkConnection();
41  this->checkPrepare();
42 
43  int iovID = iov->fetchID();
44  if (!iovID) {
45  throw(std::runtime_error("CaliGainRatioDat::writeDB: IOV not in DB"));
46  }
47 
48  int logicID = ecid->getLogicID();
49  if (!logicID) {
50  throw(std::runtime_error("CaliGainRatioDat::writeDB: Bad EcalLogicID"));
51  }
52 
53  try {
54  m_writeStmt->setInt(1, iovID);
55  m_writeStmt->setInt(2, logicID);
56 
57  m_writeStmt->setFloat(3, item->getG1G12());
58  m_writeStmt->setFloat(4, item->getG6G12());
59  m_writeStmt->setInt(5, item->getTaskStatus());
60 
61  m_writeStmt->executeUpdate();
62  } catch (SQLException& e) {
63  throw(std::runtime_error("CaliGainRatioDat::writeDB(): " + e.getMessage()));
64  }
65 }
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: CaliIOV.cc:48

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file CaliGainRatioDat.h.

Member Data Documentation

◆ m_g1_g12

float CaliGainRatioDat::m_g1_g12
private

Definition at line 40 of file CaliGainRatioDat.h.

Referenced by getG1G12(), and setG1G12().

◆ m_g6_g12

float CaliGainRatioDat::m_g6_g12
private

Definition at line 41 of file CaliGainRatioDat.h.

Referenced by getG6G12(), and setG6G12().

◆ m_taskStatus

bool CaliGainRatioDat::m_taskStatus
private

Definition at line 42 of file CaliGainRatioDat.h.

Referenced by getTaskStatus(), and setTaskStatus().