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 ( )

Definition at line 12 of file MonShapeQualityDat.cc.

13 {
14  m_env = nullptr;
15  m_conn = nullptr;
16  m_writeStmt = nullptr;
17  m_readStmt = nullptr;
18 
19  m_avgChi2 = 0;
20 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
MonShapeQualityDat::~MonShapeQualityDat ( )
override

Definition at line 24 of file MonShapeQualityDat.cc.

25 {
26 }

Member Function Documentation

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

Definition at line 74 of file MonShapeQualityDat.cc.

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

Referenced by getAvgChi2().

76 {
77  this->checkConnection();
78  fillMap->clear();
79 
80  iov->setConnection(m_env, m_conn);
81  int iovID = iov->fetchID();
82  if (!iovID) {
83  // throw(std::runtime_error("MonShapeQualityDat::writeDB: IOV not in DB"));
84  return;
85  }
86 
87  try {
88 
89  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
90  "d.avg_chi2 "
91  "FROM channelview cv JOIN mon_shape_quality_dat d "
92  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
93  "WHERE d.iov_id = :iov_id");
94  m_readStmt->setInt(1, iovID);
95  ResultSet* rset = m_readStmt->executeQuery();
96 
97  std::pair< EcalLogicID, MonShapeQualityDat > p;
99  while(rset->next()) {
100  p.first = EcalLogicID( rset->getString(1), // name
101  rset->getInt(2), // logic_id
102  rset->getInt(3), // id1
103  rset->getInt(4), // id2
104  rset->getInt(5), // id3
105  rset->getString(6)); // maps_to
106 
107  dat.setAvgChi2( rset->getFloat(7) );
108 
109  p.second = dat;
110  fillMap->insert(p);
111  }
112  } catch (SQLException &e) {
113  throw(std::runtime_error("MonShapeQualityDat::fetchData(): "+e.getMessage()));
114  }
115 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
void setAvgChi2(float chi2)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
float MonShapeQualityDat::getAvgChi2 ( ) const
inline

Definition at line 22 of file MonShapeQualityDat.h.

References data, fetchData(), m_avgChi2, noexcept, prepareWrite(), writeArrayDB(), and writeDB().

Referenced by writeArrayDB().

22 { return m_avgChi2; }
std::string MonShapeQualityDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonShapeQualityDat.h.

19 { return "MON_SHAPE_QUALITY_DAT"; }
void MonShapeQualityDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 30 of file MonShapeQualityDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getAvgChi2().

32 {
33  this->checkConnection();
34 
35  try {
36  m_writeStmt = m_conn->createStatement();
37  m_writeStmt->setSQL("INSERT INTO mon_shape_quality_dat (iov_id, logic_id, "
38  "avg_chi2) "
39  "VALUES (:iov_id, :logic_id, "
40  ":avg_chi2)");
41  } catch (SQLException &e) {
42  throw(std::runtime_error("MonShapeQualityDat::prepareWrite(): "+e.getMessage()));
43  }
44 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void MonShapeQualityDat::setAvgChi2 ( float  chi2)
inline

Definition at line 21 of file MonShapeQualityDat.h.

References vertices_cff::chi2, and m_avgChi2.

Referenced by fetchData().

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

Definition at line 117 of file MonShapeQualityDat.cc.

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

Referenced by getAvgChi2().

119 {
120  this->checkConnection();
121  this->checkPrepare();
122 
123  int iovID = iov->fetchID();
124  if (!iovID) { throw(std::runtime_error("MonShapeQualityDat::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 
132 
133  ub2* ids_len= new ub2[nrows];
134  ub2* iov_len= new ub2[nrows];
135  ub2* x_len= new ub2[nrows];
136 
137 
138  const EcalLogicID* channel;
139  const MonShapeQualityDat* dataitem;
140  int count=0;
141  typedef map< EcalLogicID, MonShapeQualityDat >::const_iterator CI;
142  for (CI p = data->begin(); p != data->end(); ++p) {
143  channel = &(p->first);
144  int logicID = channel->getLogicID();
145  if (!logicID) { throw(std::runtime_error("MonShapeQualityDat::writeArrayDB: Bad EcalLogicID")); }
146  ids[count]=logicID;
147  iovid_vec[count]=iovID;
148 
149  dataitem = &(p->second);
150  // dataIface.writeDB( channel, dataitem, iov);
151  float x=dataitem->getAvgChi2();
152 
153  xx[count]=x;
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 
160  count++;
161  }
162 
163 
164  try {
165  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
166  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
167  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
168 
169  m_writeStmt->executeArrayUpdate(nrows);
170 
171  delete [] ids;
172  delete [] iovid_vec;
173  delete [] xx;
174 
175  delete [] ids_len;
176  delete [] iov_len;
177  delete [] x_len;
178 
179 
180  } catch (SQLException &e) {
181  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): "+e.getMessage()));
182  }
183 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
float getAvgChi2() const
void MonShapeQualityDat::writeDB ( const EcalLogicID ecid,
const MonShapeQualityDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 48 of file MonShapeQualityDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getAvgChi2().

50 {
51  this->checkConnection();
52  this->checkPrepare();
53 
54  int iovID = iov->fetchID();
55  if (!iovID) { throw(std::runtime_error("MonShapeQualityDat::writeDB: IOV not in DB")); }
56 
57  int logicID = ecid->getLogicID();
58  if (!logicID) { throw(std::runtime_error("MonShapeQualityDat::writeDB: Bad EcalLogicID")); }
59 
60  try {
61  m_writeStmt->setInt(1, iovID);
62  m_writeStmt->setInt(2, logicID);
63 
64  m_writeStmt->setFloat(3, item->getAvgChi2() );
65 
66  m_writeStmt->executeUpdate();
67  } catch (SQLException &e) {
68  throw(std::runtime_error("MonShapeQualityDat::writeDB(): "+e.getMessage()));
69  }
70 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:118
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
float getAvgChi2() const

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonShapeQualityDat.h.

Member Data Documentation

float MonShapeQualityDat::m_avgChi2
private

Definition at line 38 of file MonShapeQualityDat.h.

Referenced by getAvgChi2(), and setAvgChi2().