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::ODWeightsSamplesDat ( )

Definition at line 10 of file ODWeightsSamplesDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
16  m_fed = 0;
17 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
Statement * m_readStmt
Definition: IODConfig.h:34

◆ ~ODWeightsSamplesDat()

ODWeightsSamplesDat::~ODWeightsSamplesDat ( )
override

Definition at line 19 of file ODWeightsSamplesDat.cc.

19 {}

Member Function Documentation

◆ clear()

void ODWeightsSamplesDat::clear ( void  )
private

Definition at line 21 of file ODWeightsSamplesDat.cc.

21  {
22  m_fed = 0;
23  m_ss = 0;
24  m_sn = 0;
25 }

◆ fetchData() [1/2]

void ODWeightsSamplesDat::fetchData ( std::vector< ODWeightsSamplesDat > *  fillMap,
ODFEWeightsInfo iov 
)
privatenoexcept

Definition at line 55 of file ODWeightsSamplesDat.cc.

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

55  {
56  this->checkConnection();
57 
58  iov->setConnection(m_env, m_conn);
59  int iovID = iov->fetchID();
60  if (!iovID) {
61  std::cout << "ID not in the DB" << endl;
62  return;
63  }
64 
65  try {
66  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by fed_id, sample_id");
67  m_readStmt->setInt(1, iovID);
68  ResultSet* rset = m_readStmt->executeQuery();
69 
70  // std::vector< ODWeightsSamplesDat > p;
72  while (rset->next()) {
73  // dat.setId( rset->getInt(1) );
74  dat.setFedId(rset->getInt(2));
75  dat.setSampleId(rset->getInt(3));
76  dat.setWeightNumber(rset->getInt(4));
77 
78  p->push_back(dat);
79  }
80 
81  } catch (SQLException& e) {
82  throw(std::runtime_error("ODWeightsSamplesDat::fetchData(): " + e.getMessage()));
83  }
84 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setWeightNumber(int dac)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getTable() override
Statement * m_readStmt
Definition: IODConfig.h:34
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ fetchData() [2/2]

void ODWeightsSamplesDat::fetchData ( ODWeightsSamplesDat p)
privatenoexcept

Definition at line 86 of file ODWeightsSamplesDat.cc.

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

86  {
87  this->checkConnection();
88 
89  try {
90  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :1 order by fed_id, sample_id");
91  m_readStmt->setInt(1, p->getId());
92  ResultSet* rset = m_readStmt->executeQuery();
93 
94  while (rset->next()) {
95  p->setFedId(rset->getInt(2));
96  p->setSampleId(rset->getInt(3));
97  p->setWeightNumber(rset->getInt(4));
98  }
99 
100  } catch (SQLException& e) {
101  throw(std::runtime_error("ODWeightsSamplesDat::fetchData(): " + e.getMessage()));
102  }
103 }
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getTable() override
Statement * m_readStmt
Definition: IODConfig.h:34

◆ getFedId()

int ODWeightsSamplesDat::getFedId ( ) const
inline

Definition at line 25 of file ODWeightsSamplesDat.h.

References m_fed.

Referenced by writeArrayDB().

25 { return m_fed; }

◆ getId()

int ODWeightsSamplesDat::getId ( void  ) const
inline

Definition at line 22 of file ODWeightsSamplesDat.h.

References m_ID.

22 { return m_ID; }

◆ getSampleId()

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; }

◆ getTable()

std::string ODWeightsSamplesDat::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file ODWeightsSamplesDat.h.

19 { return "DCC_WEIGHTSAMPLE_DAT"; }

◆ getWeightNumber()

int ODWeightsSamplesDat::getWeightNumber ( ) const
inline

Definition at line 31 of file ODWeightsSamplesDat.h.

References m_sn.

Referenced by writeArrayDB().

31 { return m_sn; }

◆ prepareWrite()

void ODWeightsSamplesDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 27 of file ODWeightsSamplesDat.cc.

References MillePedeFileConverter_cfg::e.

27  {
28  this->checkConnection();
29 
30  try {
31  m_writeStmt = m_conn->createStatement();
32  m_writeStmt->setSQL("INSERT INTO " + getTable() +
33  " (rec_id, fed_id, sample_id, weight_number ) "
34  "VALUES (:1, :2, :3, :4 )");
35  } catch (SQLException& e) {
36  throw(std::runtime_error("ODWeightsSamplesDat::prepareWrite(): " + e.getMessage()));
37  }
38 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getTable() override

◆ setFedId()

void ODWeightsSamplesDat::setFedId ( int  dac)
inline

Definition at line 24 of file ODWeightsSamplesDat.h.

References m_fed.

Referenced by fetchData().

24 { m_fed = dac; }

◆ setId()

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; }

◆ setSampleId()

void ODWeightsSamplesDat::setSampleId ( int  dac)
inline

Definition at line 27 of file ODWeightsSamplesDat.h.

References m_ss.

Referenced by fetchData().

27 { m_ss = dac; }

◆ setWeightNumber()

void ODWeightsSamplesDat::setWeightNumber ( int  dac)
inline

Definition at line 30 of file ODWeightsSamplesDat.h.

References m_sn.

Referenced by fetchData().

30 { m_sn = dac; }

◆ writeArrayDB()

void ODWeightsSamplesDat::writeArrayDB ( const std::vector< ODWeightsSamplesDat > &  data,
ODFEWeightsInfo iov 
)
privatenoexcept

Definition at line 107 of file ODWeightsSamplesDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, getFedId(), getSampleId(), getWeightNumber(), createfilelist::int, geometryCSVtoXML::xx, geometryCSVtoXML::yy, and geometryCSVtoXML::zz.

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

◆ writeDB()

void ODWeightsSamplesDat::writeDB ( const ODWeightsSamplesDat item,
ODFEWeightsInfo iov 
)
privatenoexcept

Definition at line 40 of file ODWeightsSamplesDat.cc.

References MillePedeFileConverter_cfg::e, and B2GTnPMonitor_cfi::item.

40  {
41  this->checkConnection();
42 
43  try {
44  m_writeStmt->setInt(1, item->getId());
45  m_writeStmt->setInt(2, item->getFedId());
46  m_writeStmt->setInt(3, item->getSampleId());
47  m_writeStmt->setInt(4, item->getWeightNumber());
48 
49  m_writeStmt->executeUpdate();
50  } catch (SQLException& e) {
51  throw(std::runtime_error("ODWeightsSamplesDat::writeDB(): " + e.getMessage()));
52  }
53 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file ODWeightsSamplesDat.h.

Member Data Documentation

◆ m_fed

int ODWeightsSamplesDat::m_fed
private

Definition at line 47 of file ODWeightsSamplesDat.h.

Referenced by getFedId(), and setFedId().

◆ m_ID

int ODWeightsSamplesDat::m_ID
private

Definition at line 50 of file ODWeightsSamplesDat.h.

Referenced by getId(), and setId().

◆ m_sn

int ODWeightsSamplesDat::m_sn
private

Definition at line 49 of file ODWeightsSamplesDat.h.

Referenced by getWeightNumber(), and setWeightNumber().

◆ m_ss

int ODWeightsSamplesDat::m_ss
private

Definition at line 48 of file ODWeightsSamplesDat.h.

Referenced by getSampleId(), and setSampleId().