CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
DCUVFETempDat Class Reference

#include <DCUVFETempDat.h>

Inheritance diagram for DCUVFETempDat:
IDataItem IDBObject

Public Member Functions

 DCUVFETempDat ()
 
std::string getTable ()
 
float getVFETemp () const
 
void setVFETemp (float temp)
 
 ~DCUVFETempDat ()
 
- 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, DCUVFETempDat > *fillVec, DCUIOV *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, DCUVFETempDat > *data, DCUIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const DCUVFETempDat *item, DCUIOV *iov) throw (std::runtime_error)
 

Private Attributes

float m_vfeTemp
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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 DCUVFETempDat.h.

Constructor & Destructor Documentation

DCUVFETempDat::DCUVFETempDat ( )

Definition at line 12 of file DCUVFETempDat.cc.

References NULL.

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

Definition at line 24 of file DCUVFETempDat.cc.

25 {
26 }

Member Function Documentation

void DCUVFETempDat::fetchData ( std::map< EcalLogicID, DCUVFETempDat > *  fillVec,
DCUIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 74 of file DCUVFETempDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, and setVFETemp().

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("DCUVFETempDat::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.vfe_temp "
91  "FROM channelview cv JOIN dcu_vfe_temp_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, DCUVFETempDat > p;
98  DCUVFETempDat dat;
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.setVFETemp( rset->getFloat(7) );
108 
109  p.second = dat;
110  fillMap->insert(p);
111  }
112  } catch (SQLException &e) {
113  throw(std::runtime_error("DCUVFETempDat::fetchData(): "+e.getMessage()));
114  }
115 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int fetchID()
Definition: DCUIOV.cc:79
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setVFETemp(float temp)
Definition: DCUVFETempDat.h:21
void checkConnection() const
Definition: IDBObject.h:41
std::string DCUVFETempDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 19 of file DCUVFETempDat.h.

19 { return "DCU_VFE_TEMP_DAT"; }
float DCUVFETempDat::getVFETemp ( ) const
inline

Definition at line 22 of file DCUVFETempDat.h.

References m_vfeTemp.

Referenced by writeArrayDB().

22 { return m_vfeTemp; }
void DCUVFETempDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 30 of file DCUVFETempDat.cc.

References alignCSCRings::e.

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

Definition at line 21 of file DCUVFETempDat.h.

References m_vfeTemp, and groupFilesInBlocks::temp.

Referenced by fetchData().

void DCUVFETempDat::writeArrayDB ( const std::map< EcalLogicID, DCUVFETempDat > *  data,
DCUIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 117 of file DCUVFETempDat.cc.

References prof2calltree::count, data, alignCSCRings::e, EcalLogicID::getLogicID(), getVFETemp(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, and x.

119 {
120  this->checkConnection();
121  this->checkPrepare();
122 
123  int iovID = iov->fetchID();
124  if (!iovID) { throw(std::runtime_error("DCUVFETempDat::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  ub2* ids_len= new ub2[nrows];
133  ub2* iov_len= new ub2[nrows];
134  ub2* x_len= new ub2[nrows];
135 
136  const EcalLogicID* channel;
137  const DCUVFETempDat* dataitem;
138  int count=0;
139  typedef map< EcalLogicID, DCUVFETempDat >::const_iterator CI;
140  for (CI p = data->begin(); p != data->end(); ++p) {
141  channel = &(p->first);
142  int logicID = channel->getLogicID();
143  if (!logicID) { throw(std::runtime_error("DCUVFETempDat::writeArrayDB: Bad EcalLogicID")); }
144  ids[count]=logicID;
145  iovid_vec[count]=iovID;
146 
147  dataitem = &(p->second);
148  // dataIface.writeDB( channel, dataitem, iov);
149  float x=dataitem->getVFETemp();
150 
151  xx[count]=x;
152 
153 
154  ids_len[count]=sizeof(ids[count]);
155  iov_len[count]=sizeof(iovid_vec[count]);
156 
157  x_len[count]=sizeof(xx[count]);
158 
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 
170  m_writeStmt->executeArrayUpdate(nrows);
171 
172  delete [] ids;
173  delete [] iovid_vec;
174  delete [] xx;
175 
176  delete [] ids_len;
177  delete [] iov_len;
178  delete [] x_len;
179 
180 
181  } catch (SQLException &e) {
182  throw(std::runtime_error("DCUVFETempDat::writeArrayDB(): "+e.getMessage()));
183  }
184 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int fetchID()
Definition: DCUIOV.cc:79
int getLogicID() const
Definition: EcalLogicID.cc:41
void checkPrepare()
Definition: IDataItem.h:31
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
float getVFETemp() const
Definition: DCUVFETempDat.h:22
void checkConnection() const
Definition: IDBObject.h:41
void DCUVFETempDat::writeDB ( const EcalLogicID ecid,
const DCUVFETempDat item,
DCUIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 48 of file DCUVFETempDat.cc.

References alignCSCRings::e, and o2o::iov.

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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file DCUVFETempDat.h.

Member Data Documentation

float DCUVFETempDat::m_vfeTemp
private

Definition at line 38 of file DCUVFETempDat.h.

Referenced by getVFETemp(), and setVFETemp().