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

#include <ODWeightsDat.h>

Inheritance diagram for ODWeightsDat:
IODConfig IDBObject

Public Member Functions

int getCrystalId () const
 
int getFedId () const
 
int getId () const
 
int getSMId () const
 
std::string getTable ()
 
int getTTId () const
 
float getWeight0 () const
 
float getWeight1 () const
 
float getWeight2 () const
 
float getWeight3 () const
 
float getWeight4 () const
 
float getWeight5 () const
 
 ODWeightsDat ()
 
void setCrystalId (int dac)
 
void setFedId (int dac)
 
void setId (int dac)
 
void setSMId (int dac)
 
void setTTId (int dac)
 
void setWeight0 (float x)
 
void setWeight1 (float x)
 
void setWeight2 (float x)
 
void setWeight3 (float x)
 
void setWeight4 (float x)
 
void setWeight5 (float x)
 
 ~ODWeightsDat ()
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- 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::vector< ODWeightsDat > *fillMap, ODFEWeightsInfo *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::vector< ODWeightsDat > data, ODFEWeightsInfo *iov) throw (std::runtime_error)
 
void writeDB (const ODWeightsDat *item, ODFEWeightsInfo *iov) throw (std::runtime_error)
 

Private Attributes

int m_fed
 
int m_ID
 
int m_sm
 
int m_tt
 
float m_wei0
 
float m_wei1
 
float m_wei2
 
float m_wei3
 
float m_wei4
 
float m_wei5
 
int m_xt
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) 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 IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 12 of file ODWeightsDat.h.

Constructor & Destructor Documentation

ODWeightsDat::ODWeightsDat ( )

Definition at line 10 of file ODWeightsDat.cc.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16 
17  m_sm = 0;
18  m_fed = 0;
19  m_tt = 0;
20  m_xt = 0;
21 
22 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
#define NULL
Definition: scimark2.h:8
Statement * m_readStmt
Definition: IODConfig.h:37
ODWeightsDat::~ODWeightsDat ( )

Definition at line 26 of file ODWeightsDat.cc.

27 {
28 }

Member Function Documentation

void ODWeightsDat::fetchData ( std::vector< ODWeightsDat > *  fillMap,
ODFEWeightsInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 75 of file ODWeightsDat.cc.

References gather_cfg::cout, o2o::iov, L1TEmulatorMonitor_cff::p, setCrystalId(), setFedId(), setSMId(), setTTId(), setWeight0(), setWeight1(), setWeight2(), setWeight3(), setWeight4(), and setWeight5().

77 {
78  this->checkConnection();
79 
80  iov->setConnection(m_env, m_conn);
81  int iovID = iov->fetchID();
82  if (!iovID) {
83  std::cout <<"ID not in the DB"<< endl;
84  return;
85  }
86 
87  try {
88  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id, cry_id");
89  m_readStmt->setInt(1, iovID);
90  ResultSet* rset = m_readStmt->executeQuery();
91 
92  // std::vector< ODWeightsDat > p;
93  ODWeightsDat dat;
94  while(rset->next()) {
95  // dat.setId( rset->getInt(1) );
96  dat.setSMId( rset->getInt(2) );
97  dat.setFedId( rset->getInt(3) );
98  dat.setTTId( rset->getInt(4) );
99  dat.setCrystalId( rset->getInt(5) );
100  dat.setWeight0( rset->getFloat(6) );
101  dat.setWeight1( rset->getFloat(7) );
102  dat.setWeight2( rset->getFloat(8) );
103  dat.setWeight3( rset->getFloat(9) );
104  dat.setWeight4( rset->getFloat(10) );
105  dat.setWeight5( rset->getFloat(11) );
106 
107  p->push_back( dat);
108 
109  }
110 
111 
112  } catch (SQLException &e) {
113  throw(std::runtime_error("ODWeightsDat::fetchData(): "+e.getMessage()));
114  }
115 }
void setWeight3(float x)
Definition: ODWeightsDat.h:39
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setWeight2(float x)
Definition: ODWeightsDat.h:38
std::string getTable()
Definition: ODWeightsDat.h:19
void setSMId(int dac)
Definition: ODWeightsDat.h:24
void setWeight4(float x)
Definition: ODWeightsDat.h:40
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setWeight1(float x)
Definition: ODWeightsDat.h:37
void setTTId(int dac)
Definition: ODWeightsDat.h:30
void setWeight0(float x)
Definition: ODWeightsDat.h:36
void setCrystalId(int dac)
Definition: ODWeightsDat.h:33
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setWeight5(float x)
Definition: ODWeightsDat.h:41
Statement * m_readStmt
Definition: IODConfig.h:37
tuple cout
Definition: gather_cfg.py:41
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setFedId(int dac)
Definition: ODWeightsDat.h:27
void checkConnection() const
Definition: IDBObject.h:41
int ODWeightsDat::getCrystalId ( ) const
inline

Definition at line 34 of file ODWeightsDat.h.

References m_xt.

Referenced by writeArrayDB().

34 { return m_xt; }
int ODWeightsDat::getFedId ( ) const
inline

Definition at line 28 of file ODWeightsDat.h.

References m_fed.

Referenced by writeArrayDB().

28 { return m_fed; }
int ODWeightsDat::getId ( ) const
inline

Definition at line 22 of file ODWeightsDat.h.

References m_ID.

22 { return m_ID; }
int ODWeightsDat::getSMId ( ) const
inline

Definition at line 25 of file ODWeightsDat.h.

References m_sm.

Referenced by writeArrayDB().

25 { return m_sm; }
std::string ODWeightsDat::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 19 of file ODWeightsDat.h.

19 { return "DCC_WEIGHTS_DAT"; }
int ODWeightsDat::getTTId ( ) const
inline

Definition at line 31 of file ODWeightsDat.h.

References m_tt.

Referenced by writeArrayDB().

31 { return m_tt; }
float ODWeightsDat::getWeight0 ( ) const
inline

Definition at line 43 of file ODWeightsDat.h.

References m_wei0.

Referenced by writeArrayDB().

43 { return m_wei0; }
float ODWeightsDat::getWeight1 ( ) const
inline

Definition at line 44 of file ODWeightsDat.h.

References m_wei1.

Referenced by writeArrayDB().

44 { return m_wei1; }
float ODWeightsDat::getWeight2 ( ) const
inline

Definition at line 45 of file ODWeightsDat.h.

References m_wei2.

Referenced by writeArrayDB().

45 { return m_wei2; }
float ODWeightsDat::getWeight3 ( ) const
inline

Definition at line 46 of file ODWeightsDat.h.

References m_wei3.

Referenced by writeArrayDB().

46 { return m_wei3; }
float ODWeightsDat::getWeight4 ( ) const
inline

Definition at line 47 of file ODWeightsDat.h.

References m_wei4.

Referenced by writeArrayDB().

47 { return m_wei4; }
float ODWeightsDat::getWeight5 ( ) const
inline

Definition at line 48 of file ODWeightsDat.h.

References m_wei5.

Referenced by writeArrayDB().

48 { return m_wei5; }
void ODWeightsDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 32 of file ODWeightsDat.cc.

34 {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, sm_id, fed_id, tt_id, cry_id, wei0, wei1, wei2, wei3, wei4, wei5 ) "
40  "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11 )");
41  } catch (SQLException &e) {
42  throw(std::runtime_error("ODWeightsDat::prepareWrite(): "+e.getMessage()));
43  }
44 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getTable()
Definition: ODWeightsDat.h:19
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
void ODWeightsDat::setCrystalId ( int  dac)
inline

Definition at line 33 of file ODWeightsDat.h.

References m_xt.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

33 { m_xt = dac; }
void ODWeightsDat::setFedId ( int  dac)
inline

Definition at line 27 of file ODWeightsDat.h.

References m_fed.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

27 { m_fed = dac; }
void ODWeightsDat::setId ( int  dac)
inline

Definition at line 21 of file ODWeightsDat.h.

References m_ID.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

21 { m_ID = dac; }
void ODWeightsDat::setSMId ( int  dac)
inline

Definition at line 24 of file ODWeightsDat.h.

References m_sm.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

24 { m_sm = dac; }
void ODWeightsDat::setTTId ( int  dac)
inline

Definition at line 30 of file ODWeightsDat.h.

References m_tt.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

30 { m_tt = dac; }
void ODWeightsDat::setWeight0 ( float  x)
inline

Definition at line 36 of file ODWeightsDat.h.

References m_wei0, and x.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

36 { m_wei0 = x; }
Definition: DDAxes.h:10
void ODWeightsDat::setWeight1 ( float  x)
inline

Definition at line 37 of file ODWeightsDat.h.

References m_wei1, and x.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

37 { m_wei1 = x; }
Definition: DDAxes.h:10
void ODWeightsDat::setWeight2 ( float  x)
inline

Definition at line 38 of file ODWeightsDat.h.

References m_wei2, and x.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

38 { m_wei2 = x; }
Definition: DDAxes.h:10
void ODWeightsDat::setWeight3 ( float  x)
inline

Definition at line 39 of file ODWeightsDat.h.

References m_wei3, and x.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

39 { m_wei3 = x; }
Definition: DDAxes.h:10
void ODWeightsDat::setWeight4 ( float  x)
inline

Definition at line 40 of file ODWeightsDat.h.

References m_wei4, and x.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

40 { m_wei4 = x; }
Definition: DDAxes.h:10
void ODWeightsDat::setWeight5 ( float  x)
inline

Definition at line 41 of file ODWeightsDat.h.

References m_wei5, and x.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

41 { m_wei5 = x; }
Definition: DDAxes.h:10
void ODWeightsDat::writeArrayDB ( const std::vector< ODWeightsDat data,
ODFEWeightsInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 119 of file ODWeightsDat.cc.

References prof2calltree::count, runTheMatrix::data, getCrystalId(), getFedId(), getSMId(), getTTId(), getWeight0(), getWeight1(), getWeight2(), getWeight3(), getWeight4(), getWeight5(), and o2o::iov.

121 {
122  this->checkConnection();
123 
124  int iovID = iov->fetchID();
125  if (!iovID) { throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB")); }
126 
127 
128  int nrows=data.size();
129  int* ids= new int[nrows];
130  int* xx= new int[nrows];
131  int* yy= new int[nrows];
132  int* zz= new int[nrows];
133  int* st= new int[nrows];
134  float* xx1= new float[nrows];
135  float* yy1= new float[nrows];
136  float* zz1= new float[nrows];
137  float* xx2= new float[nrows];
138  float* yy2= new float[nrows];
139  float* zz2= new float[nrows];
140 
141 
142  ub2* ids_len= new ub2[nrows];
143  ub2* x_len= new ub2[nrows];
144  ub2* y_len= new ub2[nrows];
145  ub2* z_len= new ub2[nrows];
146  ub2* st_len= new ub2[nrows];
147  ub2* x1_len= new ub2[nrows];
148  ub2* y1_len= new ub2[nrows];
149  ub2* z1_len= new ub2[nrows];
150  ub2* x2_len= new ub2[nrows];
151  ub2* y2_len= new ub2[nrows];
152  ub2* z2_len= new ub2[nrows];
153 
154  ODWeightsDat dataitem;
155 
156  int n_data= (int) data.size();
157  for (int count = 0; count <n_data ; count++) {
158  dataitem=data[count];
159  ids[count]=iovID;
160  xx[count]=dataitem.getSMId();
161  yy[count]=dataitem.getFedId();
162  zz[count]=dataitem.getTTId();
163  st[count]=dataitem.getCrystalId();
164  xx1[count]=dataitem.getWeight0();
165  yy1[count]=dataitem.getWeight1();
166  zz1[count]=dataitem.getWeight2();
167  xx2[count]=dataitem.getWeight3();
168  yy2[count]=dataitem.getWeight4();
169  zz2[count]=dataitem.getWeight5();
170 
171 
172  ids_len[count]=sizeof(ids[count]);
173  x_len[count]=sizeof(xx[count]);
174  y_len[count]=sizeof(yy[count]);
175  z_len[count]=sizeof(zz[count]);
176  st_len[count]=sizeof(st[count]);
177  x1_len[count]=sizeof(xx1[count]);
178  y1_len[count]=sizeof(yy1[count]);
179  z1_len[count]=sizeof(zz1[count]);
180  x2_len[count]=sizeof(xx2[count]);
181  y2_len[count]=sizeof(yy2[count]);
182  z2_len[count]=sizeof(zz2[count]);
183 
184  }
185 
186 
187  try {
188  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]),ids_len);
189  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
190  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
191  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
192  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
193  m_writeStmt->setDataBuffer(6, (dvoid*)xx1, OCCIFLOAT , sizeof(xx1[0]), x1_len );
194  m_writeStmt->setDataBuffer(7, (dvoid*)yy1, OCCIFLOAT , sizeof(yy1[0]), y1_len );
195  m_writeStmt->setDataBuffer(8, (dvoid*)zz1, OCCIFLOAT , sizeof(zz1[0]), z1_len );
196  m_writeStmt->setDataBuffer(9, (dvoid*)xx2, OCCIFLOAT , sizeof(xx2[0]), x2_len );
197  m_writeStmt->setDataBuffer(10, (dvoid*)yy2, OCCIFLOAT , sizeof(yy2[0]), y2_len );
198  m_writeStmt->setDataBuffer(11, (dvoid*)zz2, OCCIFLOAT , sizeof(zz2[0]), z2_len );
199 
200 
201  m_writeStmt->executeArrayUpdate(nrows);
202 
203  delete [] ids;
204  delete [] xx;
205  delete [] yy;
206  delete [] zz;
207  delete [] st;
208  delete [] xx1;
209  delete [] yy1;
210  delete [] zz1;
211  delete [] xx2;
212  delete [] yy2;
213  delete [] zz2;
214 
215  delete [] ids_len;
216  delete [] x_len;
217  delete [] y_len;
218  delete [] z_len;
219  delete [] st_len;
220  delete [] x1_len;
221  delete [] y1_len;
222  delete [] z1_len;
223  delete [] x2_len;
224  delete [] y2_len;
225  delete [] z2_len;
226 
227  } catch (SQLException &e) {
228  throw(std::runtime_error("ODWeightsDat::writeArrayDB(): "+e.getMessage()));
229  }
230 }
float getWeight0() const
Definition: ODWeightsDat.h:43
Statement * m_writeStmt
Definition: IODConfig.h:36
float getWeight5() const
Definition: ODWeightsDat.h:48
int getCrystalId() const
Definition: ODWeightsDat.h:34
float getWeight3() const
Definition: ODWeightsDat.h:46
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
float getWeight4() const
Definition: ODWeightsDat.h:47
int getTTId() const
Definition: ODWeightsDat.h:31
float getWeight1() const
Definition: ODWeightsDat.h:44
float getWeight2() const
Definition: ODWeightsDat.h:45
int getSMId() const
Definition: ODWeightsDat.h:25
void checkConnection() const
Definition: IDBObject.h:41
int getFedId() const
Definition: ODWeightsDat.h:28
void ODWeightsDat::writeDB ( const ODWeightsDat item,
ODFEWeightsInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 48 of file ODWeightsDat.cc.

50 {
51  this->checkConnection();
52 
53  try {
54  m_writeStmt->setInt(1, item->getId());
55  m_writeStmt->setInt(2, item->getSMId());
56  m_writeStmt->setInt(3, item->getFedId() );
57  m_writeStmt->setInt(4, item->getTTId() );
58  m_writeStmt->setInt(5, item->getCrystalId() );
59 
60  m_writeStmt->setFloat(6, item->getWeight0() );
61  m_writeStmt->setFloat(7, item->getWeight1() );
62  m_writeStmt->setFloat(8, item->getWeight2() );
63  m_writeStmt->setFloat(9, item->getWeight3() );
64  m_writeStmt->setFloat(10, item->getWeight4() );
65  m_writeStmt->setFloat(11, item->getWeight5() );
66 
67  m_writeStmt->executeUpdate();
68  } catch (SQLException &e) {
69  throw(std::runtime_error("ODWeightsDat::writeDB(): "+e.getMessage()));
70  }
71 }
float getWeight0() const
Definition: ODWeightsDat.h:43
Statement * m_writeStmt
Definition: IODConfig.h:36
int getId() const
Definition: ODWeightsDat.h:22
float getWeight5() const
Definition: ODWeightsDat.h:48
int getCrystalId() const
Definition: ODWeightsDat.h:34
float getWeight3() const
Definition: ODWeightsDat.h:46
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
float getWeight4() const
Definition: ODWeightsDat.h:47
int getTTId() const
Definition: ODWeightsDat.h:31
float getWeight1() const
Definition: ODWeightsDat.h:44
float getWeight2() const
Definition: ODWeightsDat.h:45
int getSMId() const
Definition: ODWeightsDat.h:25
void checkConnection() const
Definition: IDBObject.h:41
int getFedId() const
Definition: ODWeightsDat.h:28

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file ODWeightsDat.h.

Member Data Documentation

int ODWeightsDat::m_fed
private

Definition at line 67 of file ODWeightsDat.h.

Referenced by getFedId(), and setFedId().

int ODWeightsDat::m_ID
private

Definition at line 70 of file ODWeightsDat.h.

Referenced by getId(), and setId().

int ODWeightsDat::m_sm
private

Definition at line 66 of file ODWeightsDat.h.

Referenced by getSMId(), and setSMId().

int ODWeightsDat::m_tt
private

Definition at line 68 of file ODWeightsDat.h.

Referenced by getTTId(), and setTTId().

float ODWeightsDat::m_wei0
private

Definition at line 71 of file ODWeightsDat.h.

Referenced by getWeight0(), and setWeight0().

float ODWeightsDat::m_wei1
private

Definition at line 72 of file ODWeightsDat.h.

Referenced by getWeight1(), and setWeight1().

float ODWeightsDat::m_wei2
private

Definition at line 73 of file ODWeightsDat.h.

Referenced by getWeight2(), and setWeight2().

float ODWeightsDat::m_wei3
private

Definition at line 74 of file ODWeightsDat.h.

Referenced by getWeight3(), and setWeight3().

float ODWeightsDat::m_wei4
private

Definition at line 75 of file ODWeightsDat.h.

Referenced by getWeight4(), and setWeight4().

float ODWeightsDat::m_wei5
private

Definition at line 76 of file ODWeightsDat.h.

Referenced by getWeight5(), and setWeight5().

int ODWeightsDat::m_xt
private

Definition at line 69 of file ODWeightsDat.h.

Referenced by getCrystalId(), and setCrystalId().