CMS 3D CMS Logo

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

#include <FEConfigPedDat.h>

Inheritance diagram for FEConfigPedDat:
IDataItem IDBObject

Public Member Functions

 FEConfigPedDat ()
 
int getId () const
 
float getPedMeanG1 () const
 
float getPedMeanG12 () const
 
float getPedMeanG6 () const
 
std::string getTable ()
 
void setId (int x)
 
void setPedMeanG1 (float mean)
 
void setPedMeanG12 (float mean)
 
void setPedMeanG6 (float mean)
 
 ~FEConfigPedDat ()
 
- Public Member Functions inherited from IDataItem
 IDataItem ()
 
- 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::map< EcalLogicID, FEConfigPedDat > *fillMap, FEConfigPedInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false)
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigPedDat > *data, FEConfigPedInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigPedDat *item, FEConfigPedInfo *iconf) noexcept(false)
 

Private Attributes

int m_ID
 
float m_pedMeanG1
 
float m_pedMeanG12
 
float m_pedMeanG6
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IDataItem
void checkPrepare () noexcept(false)
 
void createReadStatement () 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 IDataItem
oracle::occi::Statement * m_readStmt
 
oracle::occi::Statement * m_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 11 of file FEConfigPedDat.h.

Constructor & Destructor Documentation

FEConfigPedDat::FEConfigPedDat ( )

Definition at line 11 of file FEConfigPedDat.cc.

References NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_readStmt = NULL;
17  m_ID=0;
18  m_pedMeanG1 = 0;
19  m_pedMeanG6 = 0;
20  m_pedMeanG12 = 0;
21 
22 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
FEConfigPedDat::~FEConfigPedDat ( )

Definition at line 26 of file FEConfigPedDat.cc.

27 {
28 }

Member Function Documentation

void FEConfigPedDat::fetchData ( std::map< EcalLogicID, FEConfigPedDat > *  fillMap,
FEConfigPedInfo iconf 
)
privatenoexcept

Definition at line 75 of file FEConfigPedDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setPedMeanG1(), setPedMeanG12(), and setPedMeanG6().

Referenced by getPedMeanG12().

77 {
78  this->checkConnection();
79  fillMap->clear();
80 
81  iconf->setConnection(m_env, m_conn);
82  int iconfID = iconf->fetchID();
83  if (!iconfID) {
84  // throw(std::runtime_error("FEConfigPedDat::writeDB: ICONF not in DB"));
85  return;
86  }
87 
88  try {
89 
90  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
91  "d.mean_12, d.mean_6, d.mean_1 "
92  "FROM channelview cv JOIN fe_config_ped_dat d "
93  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
94  "WHERE ped_conf_id = :ped_conf_id");
95  m_readStmt->setInt(1, iconfID);
96  ResultSet* rset = m_readStmt->executeQuery();
97 
98  std::pair< EcalLogicID, FEConfigPedDat > p;
99  FEConfigPedDat dat;
100  while(rset->next()) {
101  p.first = EcalLogicID( rset->getString(1), // name
102  rset->getInt(2), // logic_id
103  rset->getInt(3), // id1
104  rset->getInt(4), // id2
105  rset->getInt(5), // id3
106  rset->getString(6)); // maps_to
107 
108  dat.setPedMeanG12( rset->getFloat(7) );
109  dat.setPedMeanG6( rset->getFloat(8) );
110  dat.setPedMeanG1( rset->getFloat(9) );
111 
112  p.second = dat;
113  fillMap->insert(p);
114  }
115  } catch (SQLException &e) {
116  throw(std::runtime_error("FEConfigPedDat::fetchData: "+e.getMessage()));
117  }
118 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setPedMeanG6(float mean)
void setPedMeanG1(float mean)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setPedMeanG12(float mean)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false)
int FEConfigPedDat::getId ( void  ) const
inline

Definition at line 21 of file FEConfigPedDat.h.

References m_ID.

21 { return m_ID; }
float FEConfigPedDat::getPedMeanG1 ( ) const
inline
float FEConfigPedDat::getPedMeanG12 ( ) const
inline
float FEConfigPedDat::getPedMeanG6 ( ) const
inline
std::string FEConfigPedDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigPedDat.h.

18 { return "FE_CONFIG_PED_DAT"; }
void FEConfigPedDat::prepareWrite ( )
privatevirtualnoexcept

Implements IDataItem.

Definition at line 31 of file FEConfigPedDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getPedMeanG12().

33 {
34  this->checkConnection();
35 
36  try {
37  m_writeStmt = m_conn->createStatement();
38 
39  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (ped_conf_id, logic_id, "
40  "mean_12, mean_6, mean_1 ) "
41  "VALUES (:ped_conf_id, :logic_id, "
42  ":ped_mean_g12, :ped_mean_g6, :ped_mean_g1 )" );
43  } catch (SQLException &e) {
44  throw(std::runtime_error("FEConfigPedDat::prepareWrite(): "+e.getMessage()));
45  }
46 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string getTable()
void FEConfigPedDat::setId ( int  x)
inline

Definition at line 20 of file FEConfigPedDat.h.

References m_ID, and x.

void FEConfigPedDat::setPedMeanG1 ( float  mean)
inline
void FEConfigPedDat::setPedMeanG12 ( float  mean)
inline
void FEConfigPedDat::setPedMeanG6 ( float  mean)
inline
void FEConfigPedDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigPedDat > *  data,
FEConfigPedInfo iconf 
)
privatenoexcept

Definition at line 120 of file FEConfigPedDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getPedMeanG1(), getPedMeanG12(), getPedMeanG6(), AlCaHLTBitMon_ParallelJobs::p, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

Referenced by getPedMeanG12().

122 {
123  this->checkConnection();
124  this->checkPrepare();
125 
126  int iconfID = iconf->fetchID();
127  if (!iconfID) { throw(std::runtime_error("FEConfigPedDat::writeArrayDB: ICONF not in DB")); }
128 
129 
130  int nrows=data->size();
131  int* ids= new int[nrows];
132  int* iconfid_vec= new int[nrows];
133  float* xx= new float[nrows];
134  float* yy= new float[nrows];
135  float* zz= new float[nrows];
136 
137 
138  ub2* ids_len= new ub2[nrows];
139  ub2* iconf_len= new ub2[nrows];
140  ub2* x_len= new ub2[nrows];
141  ub2* y_len= new ub2[nrows];
142  ub2* z_len= new ub2[nrows];
143 
144 
145  const EcalLogicID* channel;
146  const FEConfigPedDat* dataitem;
147  int count=0;
148  typedef map< EcalLogicID, FEConfigPedDat >::const_iterator CI;
149  for (CI p = data->begin(); p != data->end(); ++p) {
150  channel = &(p->first);
151  int logicID = channel->getLogicID();
152  if (!logicID) { throw(std::runtime_error("FEConfigPedDat::writeArrayDB: Bad EcalLogicID")); }
153  ids[count]=logicID;
154  iconfid_vec[count]=iconfID;
155 
156  dataitem = &(p->second);
157  // dataIface.writeDB( channel, dataitem, iconf);
158  float x=dataitem->getPedMeanG12();
159  float y=dataitem->getPedMeanG6();
160  float z=dataitem->getPedMeanG1();
161 
162  xx[count]=x;
163  yy[count]=y;
164  zz[count]=z;
165 
166  ids_len[count]=sizeof(ids[count]);
167  iconf_len[count]=sizeof(iconfid_vec[count]);
168 
169  x_len[count]=sizeof(xx[count]);
170  y_len[count]=sizeof(yy[count]);
171  z_len[count]=sizeof(zz[count]);
172 
173  count++;
174  }
175 
176 
177  try {
178  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
179  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
180  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
181  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
182  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len );
183 
184  m_writeStmt->executeArrayUpdate(nrows);
185 
186  delete [] ids;
187  delete [] iconfid_vec;
188  delete [] xx;
189  delete [] yy;
190  delete [] zz;
191 
192  delete [] ids_len;
193  delete [] iconf_len;
194  delete [] x_len;
195  delete [] y_len;
196  delete [] z_len;
197 
198  } catch (SQLException &e) {
199  throw(std::runtime_error("FEConfigPedDat::writeArrayDB(): "+e.getMessage()));
200  }
201 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
float getPedMeanG1() const
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
float getPedMeanG12() const
float getPedMeanG6() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int fetchID() noexcept(false)
void FEConfigPedDat::writeDB ( const EcalLogicID ecid,
const FEConfigPedDat item,
FEConfigPedInfo iconf 
)
privatenoexcept

Definition at line 50 of file FEConfigPedDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getPedMeanG12().

52 {
53  this->checkConnection();
54 
55  int iconfID = iconf->fetchID();
56  if (!iconfID) { throw(std::runtime_error("FEConfigPedDat::writeDB: ICONF not in DB")); }
57 
58  int logicID = ecid->getLogicID();
59  if (!logicID) { throw(std::runtime_error("FEConfigPedDat::writeDB: Bad EcalLogicID")); }
60 
61  try {
62  m_writeStmt->setInt(1, iconfID);
63  m_writeStmt->setInt(2, logicID);
64  m_writeStmt->setFloat(3, item->getPedMeanG12());
65  m_writeStmt->setFloat(4, item->getPedMeanG6());
66  m_writeStmt->setFloat(5, item->getPedMeanG1());
67 
68  m_writeStmt->executeUpdate();
69  } catch (SQLException &e) {
70  throw(std::runtime_error("FEConfigPedDat::writeDB(): "+e.getMessage()));
71  }
72 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
float getPedMeanG1() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
float getPedMeanG12() const
float getPedMeanG6() const
int fetchID() noexcept(false)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigPedDat.h.

Member Data Documentation

int FEConfigPedDat::m_ID
private

Definition at line 46 of file FEConfigPedDat.h.

Referenced by getId(), and setId().

float FEConfigPedDat::m_pedMeanG1
private

Definition at line 43 of file FEConfigPedDat.h.

Referenced by getPedMeanG1(), and setPedMeanG1().

float FEConfigPedDat::m_pedMeanG12
private

Definition at line 45 of file FEConfigPedDat.h.

Referenced by getPedMeanG12(), and setPedMeanG12().

float FEConfigPedDat::m_pedMeanG6
private

Definition at line 44 of file FEConfigPedDat.h.

Referenced by getPedMeanG6(), and setPedMeanG6().