CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODPedestalOffsetsDat Class Reference

#include <ODPedestalOffsetsDat.h>

Inheritance diagram for ODPedestalOffsetsDat:
IODConfig IDBObject

Public Member Functions

int getCrystalId () const
 
int getFedId () const
 
int getHigh () const
 
int getId () const
 
int getLow () const
 
int getMid () const
 
int getSMId () const
 
std::string getTable () override
 
int getTTId () const
 
 ODPedestalOffsetsDat ()
 
void setCrystalId (int dac)
 
void setFedId (int dac)
 
void setHigh (int dac)
 
void setId (int dac)
 
void setLow (int dac)
 
void setMid (int dac)
 
void setSMId (int dac)
 
void setTTId (int dac)
 
 ~ODPedestalOffsetsDat () 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 fetchData (std::vector< ODPedestalOffsetsDat > *fillMap, ODFEPedestalOffsetInfo *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::vector< ODPedestalOffsetsDat > &data, ODFEPedestalOffsetInfo *iov) noexcept(false)
 
void writeDB (const ODPedestalOffsetsDat *item, ODFEPedestalOffsetInfo *iov) noexcept(false)
 

Private Attributes

int m_fed
 
int m_high
 
int m_ID
 
int m_low
 
int m_mid
 
int m_sm
 
int m_tt
 
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 () 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 11 of file ODPedestalOffsetsDat.h.

Constructor & Destructor Documentation

ODPedestalOffsetsDat::ODPedestalOffsetsDat ( )

Definition at line 10 of file ODPedestalOffsetsDat.cc.

11 {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_sm = 0;
18  m_fed = 0;
19  m_tt = 0;
20  m_xt = 0;
21  m_low = 0;
22  m_mid = 0;
23  m_high = 0;
24 }
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
ODPedestalOffsetsDat::~ODPedestalOffsetsDat ( )
override

Definition at line 28 of file ODPedestalOffsetsDat.cc.

29 {
30 }

Member Function Documentation

void ODPedestalOffsetsDat::fetchData ( std::vector< ODPedestalOffsetsDat > *  fillMap,
ODFEPedestalOffsetInfo iov 
)
privatenoexcept

Definition at line 73 of file ODPedestalOffsetsDat.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setCrystalId(), setFedId(), setHigh(), setLow(), setMid(), setSMId(), and setTTId().

Referenced by getHigh().

75 {
76  this->checkConnection();
77 
78  iov->setConnection(m_env, m_conn);
79  int iovID = iov->fetchID();
80  if (!iovID) {
81  std::cout <<"ID not in the DB"<< endl;
82  return;
83  }
84 
85  try {
86  m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id, cry_id");
87  m_readStmt->setInt(1, iovID);
88  ResultSet* rset = m_readStmt->executeQuery();
89 
90  // std::vector< ODPedestalOffsetsDat > p;
92  while(rset->next()) {
93  // dat.setId( rset->getInt(1) );
94  dat.setSMId( rset->getInt(2) );
95  dat.setFedId( rset->getInt(3) );
96  dat.setTTId( rset->getInt(4) );
97  dat.setCrystalId( rset->getInt(5) );
98  dat.setLow( rset->getInt(6) );
99  dat.setMid( rset->getInt(7) );
100  dat.setHigh( rset->getInt(8) );
101 
102  p->push_back( dat);
103 
104  }
105 
106 
107  } catch (SQLException &e) {
108  throw(std::runtime_error("ODPedestalOffsetsDat::fetchData(): "+e.getMessage()));
109  }
110 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int ODPedestalOffsetsDat::getCrystalId ( ) const
inline

Definition at line 33 of file ODPedestalOffsetsDat.h.

References m_xt.

Referenced by writeArrayDB().

33 { return m_xt; }
int ODPedestalOffsetsDat::getFedId ( ) const
inline

Definition at line 27 of file ODPedestalOffsetsDat.h.

References m_fed.

Referenced by writeArrayDB().

27 { return m_fed; }
int ODPedestalOffsetsDat::getHigh ( ) const
inline

Definition at line 42 of file ODPedestalOffsetsDat.h.

References data, fetchData(), m_high, noexcept, prepareWrite(), writeArrayDB(), and writeDB().

Referenced by writeArrayDB().

42 { return m_high; }
int ODPedestalOffsetsDat::getId ( void  ) const
inline

Definition at line 21 of file ODPedestalOffsetsDat.h.

References m_ID.

21 { return m_ID; }
int ODPedestalOffsetsDat::getLow ( ) const
inline

Definition at line 36 of file ODPedestalOffsetsDat.h.

References m_low.

Referenced by writeArrayDB().

36 { return m_low; }
int ODPedestalOffsetsDat::getMid ( ) const
inline

Definition at line 39 of file ODPedestalOffsetsDat.h.

References m_mid.

Referenced by writeArrayDB().

39 { return m_mid; }
int ODPedestalOffsetsDat::getSMId ( ) const
inline

Definition at line 24 of file ODPedestalOffsetsDat.h.

References m_sm.

Referenced by writeArrayDB().

24 { return m_sm; }
std::string ODPedestalOffsetsDat::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 18 of file ODPedestalOffsetsDat.h.

18 { return "PEDESTAL_OFFSETS_DAT"; }
int ODPedestalOffsetsDat::getTTId ( ) const
inline

Definition at line 30 of file ODPedestalOffsetsDat.h.

References m_tt.

Referenced by writeArrayDB().

30 { return m_tt; }
void ODPedestalOffsetsDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 34 of file ODPedestalOffsetsDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getHigh().

36 {
37  this->checkConnection();
38 
39  try {
40  m_writeStmt = m_conn->createStatement();
41  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, sm_id, fed_id, tt_id, cry_id, low, mid, high) "
42  "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 )");
43  } catch (SQLException &e) {
44  throw(std::runtime_error("ODPedestalOffsetsDat::prepareWrite(): "+e.getMessage()));
45  }
46 }
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
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODPedestalOffsetsDat::setCrystalId ( int  dac)
inline

Definition at line 32 of file ODPedestalOffsetsDat.h.

References m_xt.

Referenced by fetchData().

32 { m_xt = dac; }
void ODPedestalOffsetsDat::setFedId ( int  dac)
inline

Definition at line 26 of file ODPedestalOffsetsDat.h.

References m_fed.

Referenced by fetchData().

26 { m_fed = dac; }
void ODPedestalOffsetsDat::setHigh ( int  dac)
inline

Definition at line 41 of file ODPedestalOffsetsDat.h.

References m_high.

Referenced by fetchData().

void ODPedestalOffsetsDat::setId ( int  dac)
inline

Definition at line 20 of file ODPedestalOffsetsDat.h.

References m_ID.

20 { m_ID = dac; }
void ODPedestalOffsetsDat::setLow ( int  dac)
inline

Definition at line 35 of file ODPedestalOffsetsDat.h.

References m_low.

Referenced by fetchData().

35 { m_low = dac; }
void ODPedestalOffsetsDat::setMid ( int  dac)
inline

Definition at line 38 of file ODPedestalOffsetsDat.h.

References m_mid.

Referenced by fetchData().

38 { m_mid = dac; }
void ODPedestalOffsetsDat::setSMId ( int  dac)
inline

Definition at line 23 of file ODPedestalOffsetsDat.h.

References m_sm.

Referenced by fetchData().

23 { m_sm = dac; }
void ODPedestalOffsetsDat::setTTId ( int  dac)
inline

Definition at line 29 of file ODPedestalOffsetsDat.h.

References m_tt.

Referenced by fetchData().

29 { m_tt = dac; }
void ODPedestalOffsetsDat::writeArrayDB ( const std::vector< ODPedestalOffsetsDat > &  data,
ODFEPedestalOffsetInfo iov 
)
privatenoexcept

Definition at line 114 of file ODPedestalOffsetsDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getCrystalId(), getFedId(), getHigh(), getLow(), getMid(), getSMId(), getTTId(), createfilelist::int, geometryCSVtoXML::xx, geometryCSVtoXML::yy, and geometryCSVtoXML::zz.

Referenced by getHigh().

116 {
117  this->checkConnection();
118 
119  int iovID = iov->fetchID();
120  if (!iovID) { throw(std::runtime_error("ODDelays::writeArrayDB: ODFEDelaysInfo not in DB")); }
121 
122 
123  int nrows=data.size();
124  int* ids= new int[nrows];
125  int* xx= new int[nrows];
126  int* yy= new int[nrows];
127  int* zz= new int[nrows];
128  int* st= new int[nrows];
129  int* xx1= new int[nrows];
130  int* yy1= new int[nrows];
131  int* zz1= new int[nrows];
132 
133 
134  ub2* ids_len= new ub2[nrows];
135  ub2* x_len= new ub2[nrows];
136  ub2* y_len= new ub2[nrows];
137  ub2* z_len= new ub2[nrows];
138  ub2* st_len= new ub2[nrows];
139  ub2* x1_len= new ub2[nrows];
140  ub2* y1_len= new ub2[nrows];
141  ub2* z1_len= new ub2[nrows];
142 
143  ODPedestalOffsetsDat dataitem;
144 
145  int n_data= (int) data.size();
146  for (int count = 0; count <n_data ; count++) {
147  dataitem=data[count];
148  ids[count]=iovID;
149  xx[count]=dataitem.getSMId();
150  yy[count]=dataitem.getFedId();
151  zz[count]=dataitem.getTTId();
152  st[count]=dataitem.getCrystalId();
153  xx1[count]=dataitem.getLow();
154  yy1[count]=dataitem.getMid();
155  zz1[count]=dataitem.getHigh();
156 
157 
158  ids_len[count]=sizeof(ids[count]);
159  x_len[count]=sizeof(xx[count]);
160  y_len[count]=sizeof(yy[count]);
161  z_len[count]=sizeof(zz[count]);
162  st_len[count]=sizeof(st[count]);
163  x1_len[count]=sizeof(xx1[count]);
164  y1_len[count]=sizeof(yy1[count]);
165  z1_len[count]=sizeof(zz1[count]);
166 
167 
168  }
169 
170 
171  try {
172  m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]),ids_len);
173  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
174  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
175  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
176  m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
177  m_writeStmt->setDataBuffer(6, (dvoid*)xx1, OCCIINT , sizeof(xx1[0]), x1_len );
178  m_writeStmt->setDataBuffer(7, (dvoid*)yy1, OCCIINT , sizeof(yy1[0]), y1_len );
179  m_writeStmt->setDataBuffer(8, (dvoid*)zz1, OCCIINT , sizeof(zz1[0]), z1_len );
180 
181 
182  m_writeStmt->executeArrayUpdate(nrows);
183 
184  delete [] ids;
185  delete [] xx;
186  delete [] yy;
187  delete [] zz;
188  delete [] st;
189  delete [] xx1;
190  delete [] yy1;
191  delete [] zz1;
192 
193  delete [] ids_len;
194  delete [] x_len;
195  delete [] y_len;
196  delete [] z_len;
197  delete [] st_len;
198  delete [] x1_len;
199  delete [] y1_len;
200  delete [] z1_len;
201 
202  } catch (SQLException &e) {
203  throw(std::runtime_error("ODPedestalOffsetsDat::writeArrayDB(): "+e.getMessage()));
204  }
205 }
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODPedestalOffsetsDat::writeDB ( const ODPedestalOffsetsDat item,
ODFEPedestalOffsetInfo iov 
)
privatenoexcept

Definition at line 50 of file ODPedestalOffsetsDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getHigh().

52 {
53  this->checkConnection();
54 
55  try {
56  m_writeStmt->setInt(1, item->getId());
57  m_writeStmt->setInt(2, item->getSMId());
58  m_writeStmt->setInt(3, item->getFedId() );
59  m_writeStmt->setInt(4, item->getTTId() );
60  m_writeStmt->setInt(5, item->getCrystalId() );
61  m_writeStmt->setInt(6, item->getLow() );
62  m_writeStmt->setInt(7, item->getMid() );
63  m_writeStmt->setInt(8, item->getHigh() );
64 
65  m_writeStmt->executeUpdate();
66  } catch (SQLException &e) {
67  throw(std::runtime_error("ODPedestalOffsetsDat::writeDB(): "+e.getMessage()));
68  }
69 }
Statement * m_writeStmt
Definition: IODConfig.h:36
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 13 of file ODPedestalOffsetsDat.h.

Member Data Documentation

int ODPedestalOffsetsDat::m_fed
private

Definition at line 61 of file ODPedestalOffsetsDat.h.

Referenced by getFedId(), and setFedId().

int ODPedestalOffsetsDat::m_high
private

Definition at line 66 of file ODPedestalOffsetsDat.h.

Referenced by getHigh(), and setHigh().

int ODPedestalOffsetsDat::m_ID
private

Definition at line 67 of file ODPedestalOffsetsDat.h.

Referenced by getId(), and setId().

int ODPedestalOffsetsDat::m_low
private

Definition at line 64 of file ODPedestalOffsetsDat.h.

Referenced by getLow(), and setLow().

int ODPedestalOffsetsDat::m_mid
private

Definition at line 65 of file ODPedestalOffsetsDat.h.

Referenced by getMid(), and setMid().

int ODPedestalOffsetsDat::m_sm
private

Definition at line 60 of file ODPedestalOffsetsDat.h.

Referenced by getSMId(), and setSMId().

int ODPedestalOffsetsDat::m_tt
private

Definition at line 62 of file ODPedestalOffsetsDat.h.

Referenced by getTTId(), and setTTId().

int ODPedestalOffsetsDat::m_xt
private

Definition at line 63 of file ODPedestalOffsetsDat.h.

Referenced by getCrystalId(), and setCrystalId().