CMS 3D CMS Logo

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

#include <DCUCapsuleTempRawDat.h>

Inheritance diagram for DCUCapsuleTempRawDat:
IDataItem IDBObject

Public Member Functions

 DCUCapsuleTempRawDat ()
 
float getCapsuleTempADC () const
 
float getCapsuleTempRMS () const
 
std::string getTable ()
 
void setCapsuleTempADC (float adc)
 
void setCapsuleTempRMS (float rms)
 
 ~DCUCapsuleTempRawDat ()
 
- 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, DCUCapsuleTempRawDat > *fillVec, DCUIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false)
 
void writeArrayDB (const std::map< EcalLogicID, DCUCapsuleTempRawDat > *data, DCUIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const DCUCapsuleTempRawDat *item, DCUIOV *iov) noexcept(false)
 

Private Attributes

float m_capsuleTempADC
 
float m_capsuleTempRMS
 

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

Constructor & Destructor Documentation

DCUCapsuleTempRawDat::DCUCapsuleTempRawDat ( )

Definition at line 12 of file DCUCapsuleTempRawDat.cc.

References NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
18 
19  m_capsuleTempADC = 0;
20  m_capsuleTempRMS = 0;
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
#define NULL
Definition: scimark2.h:8
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
DCUCapsuleTempRawDat::~DCUCapsuleTempRawDat ( )

Definition at line 25 of file DCUCapsuleTempRawDat.cc.

26 {
27 }

Member Function Documentation

void DCUCapsuleTempRawDat::fetchData ( std::map< EcalLogicID, DCUCapsuleTempRawDat > *  fillVec,
DCUIOV iov 
)
privatenoexcept

Definition at line 76 of file DCUCapsuleTempRawDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setCapsuleTempADC(), and setCapsuleTempRMS().

Referenced by getCapsuleTempRMS().

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

Definition at line 22 of file DCUCapsuleTempRawDat.h.

References m_capsuleTempADC.

Referenced by writeArrayDB().

float DCUCapsuleTempRawDat::getCapsuleTempRMS ( ) const
inline
std::string DCUCapsuleTempRawDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 19 of file DCUCapsuleTempRawDat.h.

19 { return "DCU_CAPSULE_TEMP_RAW_DAT"; }
void DCUCapsuleTempRawDat::prepareWrite ( )
privatevirtualnoexcept

Implements IDataItem.

Definition at line 31 of file DCUCapsuleTempRawDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getCapsuleTempRMS().

33 {
34  this->checkConnection();
35 
36  try {
37  m_writeStmt = m_conn->createStatement();
38  m_writeStmt->setSQL("INSERT INTO dcu_capsule_temp_raw_dat (iov_id, logic_id, "
39  "capsule_temp_adc, capsule_temp_rms) "
40  "VALUES (:iov_id, :logic_id, "
41  ":3, :4)");
42  } catch (SQLException &e) {
43  throw(std::runtime_error("DCUCapsuleTempRawDat::prepareWrite(): "+e.getMessage()));
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 DCUCapsuleTempRawDat::setCapsuleTempADC ( float  adc)
inline

Definition at line 21 of file DCUCapsuleTempRawDat.h.

References ecalMGPA::adc(), and m_capsuleTempADC.

Referenced by fetchData().

21 { m_capsuleTempADC = adc; }
int adc(sample_type sample)
get the ADC sample (12 bits)
void DCUCapsuleTempRawDat::setCapsuleTempRMS ( float  rms)
inline
void DCUCapsuleTempRawDat::writeArrayDB ( const std::map< EcalLogicID, DCUCapsuleTempRawDat > *  data,
DCUIOV iov 
)
privatenoexcept

Definition at line 120 of file DCUCapsuleTempRawDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getCapsuleTempADC(), getCapsuleTempRMS(), EcalLogicID::getLogicID(), electrons_cff::ids, AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, and geometryCSVtoXML::yy.

Referenced by getCapsuleTempRMS().

122 {
123  this->checkConnection();
124  this->checkPrepare();
125 
126  int iovID = iov->fetchID();
127  if (!iovID) { throw(std::runtime_error("DCUCapsuleTempRawDat::writeArrayDB: IOV not in DB")); }
128 
129 
130  int nrows=data->size();
131  int* ids= new int[nrows];
132  int* iovid_vec= new int[nrows];
133  float* xx= new float[nrows];
134  float* yy= new float[nrows];
135 
136  ub2* ids_len= new ub2[nrows];
137  ub2* iov_len= new ub2[nrows];
138  ub2* x_len= new ub2[nrows];
139  ub2* y_len= new ub2[nrows];
140 
141 
142  const EcalLogicID* channel;
143  const DCUCapsuleTempRawDat* dataitem;
144  int count=0;
145  typedef map< EcalLogicID, DCUCapsuleTempRawDat >::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) { throw(std::runtime_error("DCUCapsuleTempRawDat::writeArrayDB: Bad EcalLogicID")); }
150  ids[count]=logicID;
151  iovid_vec[count]=iovID;
152 
153  dataitem = &(p->second);
154  // dataIface.writeDB( channel, dataitem, iov);
155  float x=dataitem->getCapsuleTempADC();
156  float y=dataitem->getCapsuleTempRMS();
157 
158  xx[count]=x;
159  yy[count]=y;
160 
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 
168  count++;
169  }
170 
171 
172  try {
173  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
174  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
175  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
176  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
177 
178 
179  m_writeStmt->executeArrayUpdate(nrows);
180 
181  delete [] ids;
182  delete [] iovid_vec;
183  delete [] xx;
184  delete [] yy;
185 
186  delete [] ids_len;
187  delete [] iov_len;
188  delete [] x_len;
189  delete [] y_len;
190 
191  } catch (SQLException &e) {
192  throw(std::runtime_error("DCUCapsuleTempRawDat::writeArrayDB(): "+e.getMessage()));
193  }
194 }
float getCapsuleTempADC() const
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int fetchID() noexcept(false)
Definition: DCUIOV.cc:79
float getCapsuleTempRMS() const
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
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
void DCUCapsuleTempRawDat::writeDB ( const EcalLogicID ecid,
const DCUCapsuleTempRawDat item,
DCUIOV iov 
)
privatenoexcept

Definition at line 49 of file DCUCapsuleTempRawDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getCapsuleTempRMS().

51 {
52  this->checkConnection();
53  this->checkPrepare();
54 
55  int iovID = iov->fetchID();
56  if (!iovID) { throw(std::runtime_error("DCUCapsuleTempRawDat::writeDB: IOV not in DB")); }
57 
58  int logicID = ecid->getLogicID();
59  if (!logicID) { throw(std::runtime_error("DCUCapsuleTempRawDat::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->getCapsuleTempADC() );
66  m_writeStmt->setFloat(4, item->getCapsuleTempRMS() );
67 
68  m_writeStmt->executeUpdate();
69  } catch (SQLException &e) {
70  throw(std::runtime_error("DCUCapsuleTempRawDat::writeDB(): "+e.getMessage()));
71  }
72 }
float getCapsuleTempADC() const
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
int fetchID() noexcept(false)
Definition: DCUIOV.cc:79
float getCapsuleTempRMS() const
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file DCUCapsuleTempRawDat.h.

Member Data Documentation

float DCUCapsuleTempRawDat::m_capsuleTempADC
private

Definition at line 41 of file DCUCapsuleTempRawDat.h.

Referenced by getCapsuleTempADC(), and setCapsuleTempADC().

float DCUCapsuleTempRawDat::m_capsuleTempRMS
private

Definition at line 42 of file DCUCapsuleTempRawDat.h.

Referenced by getCapsuleTempRMS(), and setCapsuleTempRMS().