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
CaliTempDat Class Reference

#include <CaliTempDat.h>

Inheritance diagram for CaliTempDat:
IDataItem IDBObject

Public Member Functions

 CaliTempDat ()
 
float getBeta () const
 
float getOffset () const
 
float getR25 () const
 
std::string getTable ()
 
bool getTaskStatus () const
 
void setBeta (float c)
 
void setOffset (float c)
 
void setR25 (float c)
 
void setTaskStatus (bool s)
 
 ~CaliTempDat ()
 
- 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, CaliTempDat > *fillVec, CaliIOV *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, CaliTempDat > *data, CaliIOV *iov) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const CaliTempDat *item, CaliIOV *iov) throw (std::runtime_error)
 

Private Attributes

float m_beta
 
float m_offset
 
float m_r25
 
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 () 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 CaliTempDat.h.

Constructor & Destructor Documentation

CaliTempDat::CaliTempDat ( )

Definition at line 12 of file CaliTempDat.cc.

References NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17 
18  m_beta = 0;
19  m_r25 = 0;
20  m_offset = 0;
21  m_taskStatus = false;
22 }
bool m_taskStatus
Definition: CaliTempDat.h:52
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
float m_beta
Definition: CaliTempDat.h:49
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
float m_offset
Definition: CaliTempDat.h:51
#define NULL
Definition: scimark2.h:8
float m_r25
Definition: CaliTempDat.h:50
CaliTempDat::~CaliTempDat ( )

Definition at line 26 of file CaliTempDat.cc.

27 {
28 }

Member Function Documentation

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

Definition at line 79 of file CaliTempDat.cc.

References alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setBeta(), setOffset(), setR25(), and setTaskStatus().

81 {
82  this->checkConnection();
83  fillMap->clear();
84 
85  iov->setConnection(m_env, m_conn);
86  int iovID = iov->fetchID();
87  if (!iovID) {
88  // throw(std::runtime_error("CaliTempDat::writeDB: IOV not in DB"));
89  return;
90  }
91 
92  try {
93 
94  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
95  "d.beta, d.r25, d.offset, d.task_status "
96  "FROM channelview cv JOIN cali_temp_dat d "
97  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
98  "WHERE d.iov_id = :iov_id");
99  m_readStmt->setInt(1, iovID);
100  ResultSet* rset = m_readStmt->executeQuery();
101 
102  std::pair< EcalLogicID, CaliTempDat > p;
103  CaliTempDat dat;
104  while(rset->next()) {
105  p.first = EcalLogicID( rset->getString(1), // name
106  rset->getInt(2), // logic_id
107  rset->getInt(3), // id1
108  rset->getInt(4), // id2
109  rset->getInt(5), // id3
110  rset->getString(6)); // maps_to
111 
112  dat.setBeta( rset->getFloat(7) );
113  dat.setR25( rset->getFloat(8) );
114  dat.setOffset( rset->getFloat(9) );
115  dat.setTaskStatus( rset->getInt(10) );
116 
117  p.second = dat;
118  fillMap->insert(p);
119  }
120  } catch (SQLException &e) {
121  throw(std::runtime_error("CaliTempDat::fetchData(): "+e.getMessage()));
122  }
123 }
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
void setBeta(float c)
Definition: CaliTempDat.h:21
void setOffset(float c)
Definition: CaliTempDat.h:27
void setR25(float c)
Definition: CaliTempDat.h:24
int fetchID()
Definition: CaliIOV.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 checkConnection() const
Definition: IDBObject.h:41
void setTaskStatus(bool s)
Definition: CaliTempDat.h:30
float CaliTempDat::getBeta ( ) const
inline

Definition at line 22 of file CaliTempDat.h.

References m_beta.

Referenced by writeArrayDB().

22 { return m_beta; }
float m_beta
Definition: CaliTempDat.h:49
float CaliTempDat::getOffset ( ) const
inline

Definition at line 28 of file CaliTempDat.h.

References m_offset.

Referenced by writeArrayDB().

28 { return m_offset; }
float m_offset
Definition: CaliTempDat.h:51
float CaliTempDat::getR25 ( ) const
inline

Definition at line 25 of file CaliTempDat.h.

References m_r25.

Referenced by writeArrayDB().

25 { return m_r25; }
float m_r25
Definition: CaliTempDat.h:50
std::string CaliTempDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 19 of file CaliTempDat.h.

19 { return "CALI_TEMP_DAT"; }
bool CaliTempDat::getTaskStatus ( ) const
inline

Definition at line 31 of file CaliTempDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

31 { return m_taskStatus; }
bool m_taskStatus
Definition: CaliTempDat.h:52
void CaliTempDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 32 of file CaliTempDat.cc.

References alignCSCRings::e.

34 {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL("INSERT INTO cali_temp_dat (iov_id, logic_id, "
40  " beta, r25, offset, task_status) "
41  "VALUES (:iov_id, :logic_id, "
42  ":3, :4, :5, :6 )");
43  } catch (SQLException &e) {
44  throw(std::runtime_error("CaliTempDat::prepareWrite(): "+e.getMessage()));
45  }
46 }
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 CaliTempDat::setBeta ( float  c)
inline

Definition at line 21 of file CaliTempDat.h.

References trackerHits::c, and m_beta.

Referenced by fetchData().

21 { m_beta = c; }
float m_beta
Definition: CaliTempDat.h:49
void CaliTempDat::setOffset ( float  c)
inline

Definition at line 27 of file CaliTempDat.h.

References trackerHits::c, and m_offset.

Referenced by fetchData().

27 { m_offset = c; }
float m_offset
Definition: CaliTempDat.h:51
void CaliTempDat::setR25 ( float  c)
inline

Definition at line 24 of file CaliTempDat.h.

References trackerHits::c, and m_r25.

Referenced by fetchData().

24 { m_r25 = c; }
float m_r25
Definition: CaliTempDat.h:50
void CaliTempDat::setTaskStatus ( bool  s)
inline

Definition at line 30 of file CaliTempDat.h.

References m_taskStatus, and alignCSCRings::s.

Referenced by fetchData().

30 { m_taskStatus = s; }
bool m_taskStatus
Definition: CaliTempDat.h:52
void CaliTempDat::writeArrayDB ( const std::map< EcalLogicID, CaliTempDat > *  data,
CaliIOV iov 
)
throw (std::runtime_error
)
private

Definition at line 125 of file CaliTempDat.cc.

References prof2calltree::count, data, alignCSCRings::e, getBeta(), EcalLogicID::getLogicID(), getOffset(), getR25(), getTaskStatus(), o2o::iov, AlCaHLTBitMon_ParallelJobs::p, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

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

Definition at line 50 of file CaliTempDat.cc.

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

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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file CaliTempDat.h.

Member Data Documentation

float CaliTempDat::m_beta
private

Definition at line 49 of file CaliTempDat.h.

Referenced by getBeta(), and setBeta().

float CaliTempDat::m_offset
private

Definition at line 51 of file CaliTempDat.h.

Referenced by getOffset(), and setOffset().

float CaliTempDat::m_r25
private

Definition at line 50 of file CaliTempDat.h.

Referenced by getR25(), and setR25().

bool CaliTempDat::m_taskStatus
private

Definition at line 52 of file CaliTempDat.h.

Referenced by getTaskStatus(), and setTaskStatus().