CMS 3D CMS Logo

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

#include <MonPedestalOffsetsDat.h>

Inheritance diagram for MonPedestalOffsetsDat:
IDataItem IDBObject

Public Member Functions

int getDACG1 () const
 
int getDACG12 () const
 
int getDACG6 () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonPedestalOffsetsDat ()
 
void setDACG1 (int dac)
 
void setDACG12 (int dac)
 
void setDACG6 (int dac)
 
void setTaskStatus (bool status)
 
 ~MonPedestalOffsetsDat () 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, MonPedestalOffsetsDat > *fillMap, MonRunIOV *iov, std::string mappa=" cv.maps_to ") noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonPedestalOffsetsDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonPedestalOffsetsDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

int m_dacG1
 
int m_dacG12
 
int m_dacG6
 
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 MonPedestalOffsetsDat.h.

Constructor & Destructor Documentation

◆ MonPedestalOffsetsDat()

MonPedestalOffsetsDat::MonPedestalOffsetsDat ( )

Definition at line 12 of file MonPedestalOffsetsDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_dacG1 = 0;
19  m_dacG6 = 0;
20  m_dacG12 = 0;
21  m_taskStatus = false;
22 }
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

◆ ~MonPedestalOffsetsDat()

MonPedestalOffsetsDat::~MonPedestalOffsetsDat ( )
override

Definition at line 24 of file MonPedestalOffsetsDat.cc.

24 {}

Member Function Documentation

◆ fetchData()

void MonPedestalOffsetsDat::fetchData ( std::map< EcalLogicID, MonPedestalOffsetsDat > *  fillMap,
MonRunIOV iov,
std::string  mappa = " cv.maps_to " 
)
privatenoexcept

Definition at line 71 of file MonPedestalOffsetsDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setDACG1(), setDACG12(), setDACG6(), and setTaskStatus().

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

◆ getDACG1()

int MonPedestalOffsetsDat::getDACG1 ( ) const
inline

Definition at line 22 of file MonPedestalOffsetsDat.h.

References m_dacG1.

Referenced by writeArrayDB().

◆ getDACG12()

int MonPedestalOffsetsDat::getDACG12 ( ) const
inline

Definition at line 28 of file MonPedestalOffsetsDat.h.

References m_dacG12.

Referenced by writeArrayDB().

◆ getDACG6()

int MonPedestalOffsetsDat::getDACG6 ( ) const
inline

Definition at line 25 of file MonPedestalOffsetsDat.h.

References m_dacG6.

Referenced by writeArrayDB().

◆ getTable()

std::string MonPedestalOffsetsDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonPedestalOffsetsDat.h.

19 { return "MON_PEDESTAL_OFFSETS_DAT"; }

◆ getTaskStatus()

bool MonPedestalOffsetsDat::getTaskStatus ( ) const
inline

Definition at line 31 of file MonPedestalOffsetsDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

◆ prepareWrite()

void MonPedestalOffsetsDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 26 of file MonPedestalOffsetsDat.cc.

References MillePedeFileConverter_cfg::e.

26  {
27  this->checkConnection();
28 
29  try {
30  m_writeStmt = m_conn->createStatement();
31  m_writeStmt->setSQL(
32  "INSERT INTO mon_pedestal_offsets_dat (iov_id, logic_id, "
33  "dac_g1, dac_g6, dac_g12, task_status) "
34  "VALUES (:iov_id, :logic_id, "
35  ":dac_g1, :dac_g6, :dac_g12, :task_status)");
36  } catch (SQLException& e) {
37  throw(std::runtime_error("MonPedestalOffsetsDat::prepareWrite(): " + e.getMessage()));
38  }
39 }
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

◆ setDACG1()

void MonPedestalOffsetsDat::setDACG1 ( int  dac)
inline

Definition at line 21 of file MonPedestalOffsetsDat.h.

References m_dacG1.

Referenced by fetchData(), and EcalPedOffset::writeDb().

◆ setDACG12()

void MonPedestalOffsetsDat::setDACG12 ( int  dac)
inline

Definition at line 27 of file MonPedestalOffsetsDat.h.

References m_dacG12.

Referenced by fetchData(), and EcalPedOffset::writeDb().

◆ setDACG6()

void MonPedestalOffsetsDat::setDACG6 ( int  dac)
inline

Definition at line 24 of file MonPedestalOffsetsDat.h.

References m_dacG6.

Referenced by fetchData(), and EcalPedOffset::writeDb().

◆ setTaskStatus()

void MonPedestalOffsetsDat::setTaskStatus ( bool  status)
inline

◆ writeArrayDB()

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

Definition at line 117 of file MonPedestalOffsetsDat.cc.

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

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

◆ writeDB()

void MonPedestalOffsetsDat::writeDB ( const EcalLogicID ecid,
const MonPedestalOffsetsDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 41 of file MonPedestalOffsetsDat.cc.

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

43  {
44  this->checkConnection();
45  this->checkPrepare();
46 
47  int iovID = iov->fetchID();
48  if (!iovID) {
49  throw(std::runtime_error("MonPedestalOffsetsDat::writeDB: IOV not in DB"));
50  }
51 
52  int logicID = ecid->getLogicID();
53  if (!logicID) {
54  throw(std::runtime_error("MonPedestalOffsetsDat::writeDB: Bad EcalLogicID"));
55  }
56 
57  try {
58  m_writeStmt->setInt(1, iovID);
59  m_writeStmt->setInt(2, logicID);
60  m_writeStmt->setInt(3, item->getDACG1());
61  m_writeStmt->setInt(4, item->getDACG6());
62  m_writeStmt->setInt(5, item->getDACG12());
63  m_writeStmt->setInt(6, item->getTaskStatus());
64 
65  m_writeStmt->executeUpdate();
66  } catch (SQLException& e) {
67  throw(std::runtime_error("MonPedestalOffsetsDat::writeDB(): " + e.getMessage()));
68  }
69 }
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 fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
int getLogicID() const
Definition: EcalLogicID.cc:28

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonPedestalOffsetsDat.h.

Member Data Documentation

◆ m_dacG1

int MonPedestalOffsetsDat::m_dacG1
private

Definition at line 45 of file MonPedestalOffsetsDat.h.

Referenced by getDACG1(), and setDACG1().

◆ m_dacG12

int MonPedestalOffsetsDat::m_dacG12
private

Definition at line 47 of file MonPedestalOffsetsDat.h.

Referenced by getDACG12(), and setDACG12().

◆ m_dacG6

int MonPedestalOffsetsDat::m_dacG6
private

Definition at line 46 of file MonPedestalOffsetsDat.h.

Referenced by getDACG6(), and setDACG6().

◆ m_taskStatus

bool MonPedestalOffsetsDat::m_taskStatus
private

Definition at line 48 of file MonPedestalOffsetsDat.h.

Referenced by getTaskStatus(), and setTaskStatus().