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

#include <ODWeightsSamplesDat.h>

Inheritance diagram for ODWeightsSamplesDat:
IODConfig IDBObject

Public Member Functions

int getFedId () const
 
int getId () const
 
int getSampleId () const
 
std::string getTable ()
 
int getWeightNumber () const
 
 ODWeightsSamplesDat ()
 
void setFedId (int dac)
 
void setId (int dac)
 
void setSampleId (int dac)
 
void setWeightNumber (int dac)
 
 ~ODWeightsSamplesDat ()
 
- 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< ODWeightsSamplesDat > *fillMap, ODFEWeightsInfo *iov) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::vector< ODWeightsSamplesDat > data, ODFEWeightsInfo *iov) throw (std::runtime_error)
 
void writeDB (const ODWeightsSamplesDat *item, ODFEWeightsInfo *iov) throw (std::runtime_error)
 

Private Attributes

int m_fed
 
int m_ID
 
int m_sn
 
int m_ss
 

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

Constructor & Destructor Documentation

ODWeightsSamplesDat::ODWeightsSamplesDat ( )

Definition at line 10 of file ODWeightsSamplesDat.cc.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16 
17  m_fed = 0;
18 
19 }
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
ODWeightsSamplesDat::~ODWeightsSamplesDat ( )

Definition at line 23 of file ODWeightsSamplesDat.cc.

24 {
25 }

Member Function Documentation

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

Definition at line 64 of file ODWeightsSamplesDat.cc.

References gather_cfg::cout, o2o::iov, L1TEmulatorMonitor_cff::p, setFedId(), setSampleId(), and setWeightNumber().

66 {
67  this->checkConnection();
68 
69  iov->setConnection(m_env, m_conn);
70  int iovID = iov->fetchID();
71  if (!iovID) {
72  std::cout <<"ID not in the DB"<< endl;
73  return;
74  }
75 
76  try {
77  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by fed_id, sample_id");
78  m_readStmt->setInt(1, iovID);
79  ResultSet* rset = m_readStmt->executeQuery();
80 
81  // std::vector< ODWeightsSamplesDat > p;
83  while(rset->next()) {
84  // dat.setId( rset->getInt(1) );
85  dat.setFedId( rset->getInt(2) );
86  dat.setSampleId( rset->getInt(3) );
87  dat.setWeightNumber( rset->getInt(4) );
88 
89  p->push_back( dat);
90 
91  }
92 
93  } catch (SQLException &e) {
94  throw(std::runtime_error("ODWeightsSamplesDat::fetchData(): "+e.getMessage()));
95  }
96 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setWeightNumber(int dac)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
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 checkConnection() const
Definition: IDBObject.h:41
int ODWeightsSamplesDat::getFedId ( ) const
inline

Definition at line 25 of file ODWeightsSamplesDat.h.

References m_fed.

Referenced by writeArrayDB().

25 { return m_fed; }
int ODWeightsSamplesDat::getId ( ) const
inline

Definition at line 22 of file ODWeightsSamplesDat.h.

References m_ID.

22 { return m_ID; }
int ODWeightsSamplesDat::getSampleId ( ) const
inline

Definition at line 28 of file ODWeightsSamplesDat.h.

References m_ss.

Referenced by writeArrayDB().

28 { return m_ss; }
std::string ODWeightsSamplesDat::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 19 of file ODWeightsSamplesDat.h.

19 { return "DCC_WEIGHTSAMPLE_DAT"; }
int ODWeightsSamplesDat::getWeightNumber ( ) const
inline

Definition at line 31 of file ODWeightsSamplesDat.h.

References m_sn.

Referenced by writeArrayDB().

31 { return m_sn; }
void ODWeightsSamplesDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 29 of file ODWeightsSamplesDat.cc.

31 {
32  this->checkConnection();
33 
34  try {
35  m_writeStmt = m_conn->createStatement();
36  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, fed_id, sample_id, weight_number ) "
37  "VALUES (:1, :2, :3, :4 )");
38  } catch (SQLException &e) {
39  throw(std::runtime_error("ODWeightsSamplesDat::prepareWrite(): "+e.getMessage()));
40  }
41 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
void ODWeightsSamplesDat::setFedId ( int  dac)
inline

Definition at line 24 of file ODWeightsSamplesDat.h.

References m_fed.

Referenced by fetchData().

24 { m_fed = dac; }
void ODWeightsSamplesDat::setId ( int  dac)
inline

Definition at line 21 of file ODWeightsSamplesDat.h.

References m_ID.

21 { m_ID = dac; }
void ODWeightsSamplesDat::setSampleId ( int  dac)
inline

Definition at line 27 of file ODWeightsSamplesDat.h.

References m_ss.

Referenced by fetchData().

27 { m_ss = dac; }
void ODWeightsSamplesDat::setWeightNumber ( int  dac)
inline

Definition at line 30 of file ODWeightsSamplesDat.h.

References m_sn.

Referenced by fetchData().

30 { m_sn = dac; }
void ODWeightsSamplesDat::writeArrayDB ( const std::vector< ODWeightsSamplesDat data,
ODFEWeightsInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 100 of file ODWeightsSamplesDat.cc.

References prof2calltree::count, runTheMatrix::data, getFedId(), getSampleId(), getWeightNumber(), and o2o::iov.

102 {
103  this->checkConnection();
104 
105  int iovID = iov->fetchID();
106  if (!iovID) { throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB")); }
107 
108 
109  int nrows=data.size();
110  int* ids= new int[nrows];
111  int* xx= new int[nrows];
112  int* yy= new int[nrows];
113  int* zz= new int[nrows];
114 
115  ub2* ids_len= new ub2[nrows];
116  ub2* x_len= new ub2[nrows];
117  ub2* y_len= new ub2[nrows];
118  ub2* z_len= new ub2[nrows];
119 
120  ODWeightsSamplesDat dataitem;
121 
122  int n_data= (int) data.size();
123  for (int count = 0; count <n_data ; count++) {
124  dataitem=data[count];
125  ids[count]=iovID;
126  xx[count]=dataitem.getFedId();
127  yy[count]=dataitem.getSampleId();
128  zz[count]=dataitem.getWeightNumber();
129 
130 
131  ids_len[count]=sizeof(ids[count]);
132  x_len[count]=sizeof(xx[count]);
133  y_len[count]=sizeof(yy[count]);
134  z_len[count]=sizeof(zz[count]);
135 
136  }
137 
138 
139  try {
140  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]),ids_len);
141  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
142  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
143  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
144 
145 
146  m_writeStmt->executeArrayUpdate(nrows);
147 
148  delete [] ids;
149  delete [] xx;
150  delete [] yy;
151  delete [] zz;
152 
153  delete [] ids_len;
154  delete [] x_len;
155  delete [] y_len;
156  delete [] z_len;
157 
158  } catch (SQLException &e) {
159  throw(std::runtime_error("ODWeightsSamplesDat::writeArrayDB(): "+e.getMessage()));
160  }
161 }
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getWeightNumber() const
void checkConnection() const
Definition: IDBObject.h:41
void ODWeightsSamplesDat::writeDB ( const ODWeightsSamplesDat item,
ODFEWeightsInfo iov 
)
throw (std::runtime_error
)
private

Definition at line 45 of file ODWeightsSamplesDat.cc.

47 {
48  this->checkConnection();
49 
50  try {
51  m_writeStmt->setInt(1, item->getId());
52  m_writeStmt->setInt(2, item->getFedId() );
53  m_writeStmt->setInt(3, item->getSampleId() );
54  m_writeStmt->setInt(4, item->getWeightNumber() );
55 
56  m_writeStmt->executeUpdate();
57  } catch (SQLException &e) {
58  throw(std::runtime_error("ODWeightsSamplesDat::writeDB(): "+e.getMessage()));
59  }
60 }
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getWeightNumber() const
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file ODWeightsSamplesDat.h.

Member Data Documentation

int ODWeightsSamplesDat::m_fed
private

Definition at line 51 of file ODWeightsSamplesDat.h.

Referenced by getFedId(), and setFedId().

int ODWeightsSamplesDat::m_ID
private

Definition at line 54 of file ODWeightsSamplesDat.h.

Referenced by getId(), and setId().

int ODWeightsSamplesDat::m_sn
private

Definition at line 53 of file ODWeightsSamplesDat.h.

Referenced by getWeightNumber(), and setWeightNumber().

int ODWeightsSamplesDat::m_ss
private

Definition at line 52 of file ODWeightsSamplesDat.h.

Referenced by getSampleId(), and setSampleId().