CMS 3D CMS Logo

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

#include <MonShapeQualityDat.h>

Inheritance diagram for MonShapeQualityDat:
IDataItem IDBObject

Public Member Functions

float getAvgChi2 () const
 
std::string getTable () override
 
 MonShapeQualityDat ()
 
void setAvgChi2 (float chi2)
 
 ~MonShapeQualityDat () 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, MonShapeQualityDat > *fillVec, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonShapeQualityDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonShapeQualityDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

float m_avgChi2
 

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

Constructor & Destructor Documentation

◆ MonShapeQualityDat()

MonShapeQualityDat::MonShapeQualityDat ( )

Definition at line 12 of file MonShapeQualityDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_avgChi2 = 0;
19 }
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

◆ ~MonShapeQualityDat()

MonShapeQualityDat::~MonShapeQualityDat ( )
override

Definition at line 21 of file MonShapeQualityDat.cc.

21 {}

Member Function Documentation

◆ fetchData()

void MonShapeQualityDat::fetchData ( std::map< EcalLogicID, MonShapeQualityDat > *  fillVec,
MonRunIOV iov 
)
privatenoexcept

Definition at line 66 of file MonShapeQualityDat.cc.

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

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

◆ getAvgChi2()

float MonShapeQualityDat::getAvgChi2 ( ) const
inline

Definition at line 22 of file MonShapeQualityDat.h.

References m_avgChi2.

Referenced by writeArrayDB().

22 { return m_avgChi2; }

◆ getTable()

std::string MonShapeQualityDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonShapeQualityDat.h.

19 { return "MON_SHAPE_QUALITY_DAT"; }

◆ prepareWrite()

void MonShapeQualityDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 23 of file MonShapeQualityDat.cc.

References MillePedeFileConverter_cfg::e.

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

◆ setAvgChi2()

void MonShapeQualityDat::setAvgChi2 ( float  chi2)
inline

Definition at line 21 of file MonShapeQualityDat.h.

References hltPixelTracks_cff::chi2, and m_avgChi2.

Referenced by fetchData().

◆ writeArrayDB()

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

Definition at line 107 of file MonShapeQualityDat.cc.

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

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

◆ writeDB()

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

Definition at line 38 of file MonShapeQualityDat.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("MonShapeQualityDat::writeDB: IOV not in DB"));
47  }
48 
49  int logicID = ecid->getLogicID();
50  if (!logicID) {
51  throw(std::runtime_error("MonShapeQualityDat::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->getAvgChi2());
59 
60  m_writeStmt->executeUpdate();
61  } catch (SQLException& e) {
62  throw(std::runtime_error("MonShapeQualityDat::writeDB(): " + e.getMessage()));
63  }
64 }
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 MonShapeQualityDat.h.

Member Data Documentation

◆ m_avgChi2

float MonShapeQualityDat::m_avgChi2
private

Definition at line 34 of file MonShapeQualityDat.h.

Referenced by getAvgChi2(), and setAvgChi2().