CMS 3D CMS Logo

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

#include <CaliTempDat.h>

Inheritance diagram for CaliTempDat:
IDataItem IDBObject

Public Member Functions

 CaliTempDat ()
 
float getBeta () const
 
float getOffset () const
 
float getR25 () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
void setBeta (float c)
 
void setOffset (float c)
 
void setR25 (float c)
 
void setTaskStatus (bool s)
 
 ~CaliTempDat () 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, CaliTempDat > *fillVec, CaliIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, CaliTempDat > *data, CaliIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const CaliTempDat *item, CaliIOV *iov) noexcept(false)
 

Private Attributes

float m_beta
 
float m_offset
 
float m_r25
 
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 CaliTempDat.h.

Constructor & Destructor Documentation

◆ CaliTempDat()

CaliTempDat::CaliTempDat ( )

Definition at line 12 of file CaliTempDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16 
17  m_beta = 0;
18  m_r25 = 0;
19  m_offset = 0;
20  m_taskStatus = false;
21 }
bool m_taskStatus
Definition: CaliTempDat.h:46
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
float m_beta
Definition: CaliTempDat.h:43
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
float m_offset
Definition: CaliTempDat.h:45
float m_r25
Definition: CaliTempDat.h:44

◆ ~CaliTempDat()

CaliTempDat::~CaliTempDat ( )
override

Definition at line 23 of file CaliTempDat.cc.

23 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 69 of file CaliTempDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setBeta(), setOffset(), setR25(), and setTaskStatus().

69  {
70  this->checkConnection();
71  fillMap->clear();
72 
73  iov->setConnection(m_env, m_conn);
74  int iovID = iov->fetchID();
75  if (!iovID) {
76  // throw(std::runtime_error("CaliTempDat::writeDB: IOV not in DB"));
77  return;
78  }
79 
80  try {
81  m_readStmt->setSQL(
82  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
83  "d.beta, d.r25, d.offset, d.task_status "
84  "FROM channelview cv JOIN cali_temp_dat d "
85  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
86  "WHERE d.iov_id = :iov_id");
87  m_readStmt->setInt(1, iovID);
88  ResultSet* rset = m_readStmt->executeQuery();
89 
90  std::pair<EcalLogicID, CaliTempDat> p;
91  CaliTempDat dat;
92  while (rset->next()) {
93  p.first = EcalLogicID(rset->getString(1), // name
94  rset->getInt(2), // logic_id
95  rset->getInt(3), // id1
96  rset->getInt(4), // id2
97  rset->getInt(5), // id3
98  rset->getString(6)); // maps_to
99 
100  dat.setBeta(rset->getFloat(7));
101  dat.setR25(rset->getFloat(8));
102  dat.setOffset(rset->getFloat(9));
103  dat.setTaskStatus(rset->getInt(10));
104 
105  p.second = dat;
106  fillMap->insert(p);
107  }
108  } catch (SQLException& e) {
109  throw(std::runtime_error("CaliTempDat::fetchData(): " + e.getMessage()));
110  }
111 }
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 setBeta(float c)
Definition: CaliTempDat.h:21
void setOffset(float c)
Definition: CaliTempDat.h:27
void setR25(float c)
Definition: CaliTempDat.h:24
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
void setTaskStatus(bool s)
Definition: CaliTempDat.h:30

◆ getBeta()

float CaliTempDat::getBeta ( ) const
inline

Definition at line 22 of file CaliTempDat.h.

References m_beta.

Referenced by writeArrayDB().

22 { return m_beta; }
float m_beta
Definition: CaliTempDat.h:43

◆ getOffset()

float CaliTempDat::getOffset ( ) const
inline

Definition at line 28 of file CaliTempDat.h.

References m_offset.

Referenced by writeArrayDB().

28 { return m_offset; }
float m_offset
Definition: CaliTempDat.h:45

◆ getR25()

float CaliTempDat::getR25 ( ) const
inline

Definition at line 25 of file CaliTempDat.h.

References m_r25.

Referenced by writeArrayDB().

25 { return m_r25; }
float m_r25
Definition: CaliTempDat.h:44

◆ getTable()

std::string CaliTempDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file CaliTempDat.h.

19 { return "CALI_TEMP_DAT"; }

◆ getTaskStatus()

bool CaliTempDat::getTaskStatus ( ) const
inline

Definition at line 31 of file CaliTempDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

31 { return m_taskStatus; }
bool m_taskStatus
Definition: CaliTempDat.h:46

◆ prepareWrite()

void CaliTempDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file CaliTempDat.cc.

References MillePedeFileConverter_cfg::e.

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

◆ setBeta()

void CaliTempDat::setBeta ( float  c)
inline

Definition at line 21 of file CaliTempDat.h.

References DummyCfis::c, and m_beta.

Referenced by fetchData().

21 { m_beta = c; }
float m_beta
Definition: CaliTempDat.h:43

◆ setOffset()

void CaliTempDat::setOffset ( float  c)
inline

Definition at line 27 of file CaliTempDat.h.

References DummyCfis::c, and m_offset.

Referenced by fetchData().

27 { m_offset = c; }
float m_offset
Definition: CaliTempDat.h:45

◆ setR25()

void CaliTempDat::setR25 ( float  c)
inline

Definition at line 24 of file CaliTempDat.h.

References DummyCfis::c, and m_r25.

Referenced by fetchData().

24 { m_r25 = c; }
float m_r25
Definition: CaliTempDat.h:44

◆ setTaskStatus()

void CaliTempDat::setTaskStatus ( bool  s)
inline

Definition at line 30 of file CaliTempDat.h.

References m_taskStatus, and alignCSCRings::s.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 113 of file CaliTempDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getBeta(), EcalLogicID::getLogicID(), getOffset(), getR25(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

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

◆ writeDB()

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

Definition at line 40 of file CaliTempDat.cc.

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

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

Member Data Documentation

◆ m_beta

float CaliTempDat::m_beta
private

Definition at line 43 of file CaliTempDat.h.

Referenced by getBeta(), and setBeta().

◆ m_offset

float CaliTempDat::m_offset
private

Definition at line 45 of file CaliTempDat.h.

Referenced by getOffset(), and setOffset().

◆ m_r25

float CaliTempDat::m_r25
private

Definition at line 44 of file CaliTempDat.h.

Referenced by getR25(), and setR25().

◆ m_taskStatus

bool CaliTempDat::m_taskStatus
private

Definition at line 46 of file CaliTempDat.h.

Referenced by getTaskStatus(), and setTaskStatus().