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

Definition at line 12 of file CaliGainRatioDat.cc.

13 {
14  m_env = nullptr;
15  m_conn = nullptr;
16  m_writeStmt = nullptr;
17 
18  m_g1_g12 = 0;
19  m_g6_g12 = 0;
20  m_taskStatus = false;
21 }
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
CaliGainRatioDat::~CaliGainRatioDat ( )
override

Definition at line 25 of file CaliGainRatioDat.cc.

26 {
27 }

Member Function Documentation

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

Definition at line 77 of file CaliGainRatioDat.cc.

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

Referenced by getTaskStatus().

79 {
80  this->checkConnection();
81  fillMap->clear();
82 
83  iov->setConnection(m_env, m_conn);
84  int iovID = iov->fetchID();
85  if (!iovID) {
86  // throw(std::runtime_error("CaliGainRatioDat::writeDB: IOV not in DB"));
87  return;
88  }
89 
90  try {
91 
92  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
93  "d.g1_g6, d.g6_g12, d.task_status "
94  "FROM channelview cv JOIN cali_gain_ratio_dat d "
95  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
96  "WHERE d.iov_id = :iov_id");
97  m_readStmt->setInt(1, iovID);
98  ResultSet* rset = m_readStmt->executeQuery();
99 
100  std::pair< EcalLogicID, CaliGainRatioDat > p;
101  CaliGainRatioDat dat;
102  while(rset->next()) {
103  p.first = EcalLogicID( getOraString(rset,1), // name
104  rset->getInt(2), // logic_id
105  rset->getInt(3), // id1
106  rset->getInt(4), // id2
107  rset->getInt(5), // id3
108  getOraString(rset,6)); // maps_to
109 
110  dat.setG1G12( rset->getFloat(7) );
111  dat.setG6G12( rset->getFloat(8) );
112  dat.setTaskStatus( rset->getInt(9) );
113 
114  p.second = dat;
115  fillMap->insert(p);
116  }
117  } catch (SQLException &e) {
118  throw(std::runtime_error(std::string("CaliGainRatioDat::fetchData(): ")+getOraMessage(&e)));
119  }
120 }
void setG1G12(float c)
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setTaskStatus(bool s)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setG6G12(float c)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false) override
Definition: CaliIOV.cc:79
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; }
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; }
std::string CaliGainRatioDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file CaliGainRatioDat.h.

19 { return "CALI_GAIN_RATIO_DAT"; }
bool CaliGainRatioDat::getTaskStatus ( ) const
inline

Definition at line 28 of file CaliGainRatioDat.h.

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

Referenced by writeArrayDB().

28 { return m_taskStatus; }
void CaliGainRatioDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 31 of file CaliGainRatioDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getTaskStatus().

33 {
34  this->checkConnection();
35 
36  try {
37  m_writeStmt = m_conn->createStatement();
38  m_writeStmt->setSQL("INSERT INTO cali_gain_ratio_dat (iov_id, logic_id, "
39  "g1_g6, g6_g12, task_status) "
40  "VALUES (:iov_id, :logic_id, "
41  ":3, :4, :5)");
42  } catch (SQLException &e) {
43  throw(std::runtime_error(std::string("CaliGainRatioDat::prepareWrite(): ")+getOraMessage(&e)));
44  }
45 }
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 CaliGainRatioDat::setG1G12 ( float  c)
inline

Definition at line 21 of file CaliGainRatioDat.h.

References EnergyCorrector::c, and m_g1_g12.

Referenced by fetchData().

void CaliGainRatioDat::setG6G12 ( float  c)
inline

Definition at line 24 of file CaliGainRatioDat.h.

References EnergyCorrector::c, and m_g6_g12.

Referenced by fetchData().

void CaliGainRatioDat::setTaskStatus ( bool  s)
inline

Definition at line 27 of file CaliGainRatioDat.h.

References m_taskStatus, and alignCSCRings::s.

Referenced by fetchData().

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

Definition at line 122 of file CaliGainRatioDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getG1G12(), getG6G12(), EcalLogicID::getLogicID(), getTaskStatus(), photons_cff::ids, AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, x, geometryCSVtoXML::xx, y, and geometryCSVtoXML::yy.

Referenced by getTaskStatus().

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

Definition at line 49 of file CaliGainRatioDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getTaskStatus().

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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file CaliGainRatioDat.h.

Member Data Documentation

float CaliGainRatioDat::m_g1_g12
private

Definition at line 44 of file CaliGainRatioDat.h.

Referenced by getG1G12(), and setG1G12().

float CaliGainRatioDat::m_g6_g12
private

Definition at line 45 of file CaliGainRatioDat.h.

Referenced by getG6G12(), and setG6G12().

bool CaliGainRatioDat::m_taskStatus
private

Definition at line 46 of file CaliGainRatioDat.h.

Referenced by getTaskStatus(), and setTaskStatus().