CMS 3D CMS Logo

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 () override
 
int getWeightNumber () const
 
 ODWeightsSamplesDat ()
 
void setFedId (int dac)
 
void setId (int dac)
 
void setSampleId (int dac)
 
void setWeightNumber (int dac)
 
 ~ODWeightsSamplesDat () override
 
- 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 clear ()
 
void fetchData (std::vector< ODWeightsSamplesDat > *fillMap, ODFEWeightsInfo *iov) noexcept(false)
 
void fetchData (ODWeightsSamplesDat *p) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::vector< ODWeightsSamplesDat > &data, ODFEWeightsInfo *iov) noexcept(false)
 
void writeDB (const ODWeightsSamplesDat *item, ODFEWeightsInfo *iov) noexcept(false)
 

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 () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) 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 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.

11 {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
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
Statement * m_readStmt
Definition: IODConfig.h:37
ODWeightsSamplesDat::~ODWeightsSamplesDat ( )
override

Definition at line 23 of file ODWeightsSamplesDat.cc.

24 {
25 }

Member Function Documentation

void ODWeightsSamplesDat::clear ( void  )
private

Definition at line 27 of file ODWeightsSamplesDat.cc.

Referenced by getWeightNumber().

27  {
28  m_fed = 0;
29  m_ss = 0;
30  m_sn = 0;
31 }
void ODWeightsSamplesDat::fetchData ( std::vector< ODWeightsSamplesDat > *  fillMap,
ODFEWeightsInfo iov 
)
privatenoexcept

Definition at line 68 of file ODWeightsSamplesDat.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setFedId(), setSampleId(), setWeightNumber(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getWeightNumber().

70 {
71  this->checkConnection();
72 
73  iov->setConnection(m_env, m_conn);
74  int iovID = iov->fetchID();
75  if (!iovID) {
76  std::cout <<"ID not in the DB"<< endl;
77  return;
78  }
79 
80  try {
81  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by fed_id, sample_id");
82  m_readStmt->setInt(1, iovID);
83  ResultSet* rset = m_readStmt->executeQuery();
84 
85  // std::vector< ODWeightsSamplesDat > p;
87  while(rset->next()) {
88  // dat.setId( rset->getInt(1) );
89  dat.setFedId( rset->getInt(2) );
90  dat.setSampleId( rset->getInt(3) );
91  dat.setWeightNumber( rset->getInt(4) );
92 
93  p->push_back( dat);
94 
95  }
96 
97  } catch (SQLException &e) {
98  throw(std::runtime_error(std::string("ODWeightsSamplesDat::fetchData(): ")+getOraMessage(&e)));
99  }
100 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setWeightNumber(int dac)
int fetchID() noexcept(false)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getTable() override
Statement * m_readStmt
Definition: IODConfig.h:37
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void ODWeightsSamplesDat::fetchData ( ODWeightsSamplesDat p)
privatenoexcept

Definition at line 103 of file ODWeightsSamplesDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

105 {
106  this->checkConnection();
107 
108  try {
109  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :1 order by fed_id, sample_id");
110  m_readStmt->setInt(1, p->getId());
111  ResultSet* rset = m_readStmt->executeQuery();
112 
113  while(rset->next()) {
114  p->setFedId( rset->getInt(2) );
115  p->setSampleId( rset->getInt(3) );
116  p->setWeightNumber( rset->getInt(4) );
117  }
118 
119  } catch (SQLException &e) {
120  throw(std::runtime_error(std::string("ODWeightsSamplesDat::fetchData(): ")+getOraMessage(&e)));
121  }
122 }
void setWeightNumber(int dac)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getTable() override
Statement * m_readStmt
Definition: IODConfig.h:37
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 ( void  ) 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 popcon::EcalSRPHandler::getNewObjects(), and writeArrayDB().

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

Implements IODConfig.

Definition at line 19 of file ODWeightsSamplesDat.h.

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

Implements IODConfig.

Definition at line 33 of file ODWeightsSamplesDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getWeightNumber().

35 {
36  this->checkConnection();
37 
38  try {
39  m_writeStmt = m_conn->createStatement();
40  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, fed_id, sample_id, weight_number ) "
41  "VALUES (:1, :2, :3, :4 )");
42  } catch (SQLException &e) {
43  throw(std::runtime_error(std::string("ODWeightsSamplesDat::prepareWrite(): ")+getOraMessage(&e)));
44  }
45 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getTable() override
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.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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 
)
privatenoexcept

Definition at line 126 of file ODWeightsSamplesDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getFedId(), getSampleId(), getWeightNumber(), photons_cff::ids, createfilelist::int, AlCaHLTBitMon_QueryRunRegistry::string, geometryCSVtoXML::xx, geometryCSVtoXML::yy, and geometryCSVtoXML::zz.

Referenced by getWeightNumber().

128 {
129  this->checkConnection();
130 
131  int iovID = iov->fetchID();
132  if (!iovID) { throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB")); }
133 
134 
135  int nrows=data.size();
136  int* ids= new int[nrows];
137  int* xx= new int[nrows];
138  int* yy= new int[nrows];
139  int* zz= new int[nrows];
140 
141  ub2* ids_len= new ub2[nrows];
142  ub2* x_len= new ub2[nrows];
143  ub2* y_len= new ub2[nrows];
144  ub2* z_len= new ub2[nrows];
145 
146  ODWeightsSamplesDat dataitem;
147 
148  int n_data= (int) data.size();
149  for (int count = 0; count <n_data ; count++) {
150  dataitem=data[count];
151  ids[count]=iovID;
152  xx[count]=dataitem.getFedId();
153  yy[count]=dataitem.getSampleId();
154  zz[count]=dataitem.getWeightNumber();
155 
156 
157  ids_len[count]=sizeof(ids[count]);
158  x_len[count]=sizeof(xx[count]);
159  y_len[count]=sizeof(yy[count]);
160  z_len[count]=sizeof(zz[count]);
161 
162  }
163 
164 
165  try {
166  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]),ids_len);
167  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
168  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
169  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
170 
171 
172  m_writeStmt->executeArrayUpdate(nrows);
173 
174  delete [] ids;
175  delete [] xx;
176  delete [] yy;
177  delete [] zz;
178 
179  delete [] ids_len;
180  delete [] x_len;
181  delete [] y_len;
182  delete [] z_len;
183 
184  } catch (SQLException &e) {
185  throw(std::runtime_error(std::string("ODWeightsSamplesDat::writeArrayDB(): ")+getOraMessage(&e)));
186  }
187 }
Statement * m_writeStmt
Definition: IODConfig.h:36
int getWeightNumber() const
int fetchID() noexcept(false)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODWeightsSamplesDat::writeDB ( const ODWeightsSamplesDat item,
ODFEWeightsInfo iov 
)
privatenoexcept

Definition at line 49 of file ODWeightsSamplesDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getWeightNumber().

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

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 54 of file ODWeightsSamplesDat.h.

Referenced by getFedId(), and setFedId().

int ODWeightsSamplesDat::m_ID
private

Definition at line 57 of file ODWeightsSamplesDat.h.

Referenced by getId(), and setId().

int ODWeightsSamplesDat::m_sn
private

Definition at line 56 of file ODWeightsSamplesDat.h.

Referenced by getWeightNumber(), and setWeightNumber().

int ODWeightsSamplesDat::m_ss
private

Definition at line 55 of file ODWeightsSamplesDat.h.

Referenced by getSampleId(), and setSampleId().