CMS 3D CMS Logo

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

#include <FEConfigWeightGroupDat.h>

Inheritance diagram for FEConfigWeightGroupDat:
IDataItem IDBObject

Public Member Functions

 FEConfigWeightGroupDat ()
 
std::string getTable ()
 
float getWeight0 () const
 
float getWeight1 () const
 
float getWeight2 () const
 
float getWeight3 () const
 
float getWeight4 () const
 
int getWeightGroupId () const
 
void setWeight0 (float x)
 
void setWeight1 (float x)
 
void setWeight2 (float x)
 
void setWeight3 (float x)
 
void setWeight4 (float x)
 
void setWeightGroupId (int x)
 
 ~FEConfigWeightGroupDat ()
 
- 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, FEConfigWeightGroupDat > *fillMap, FEConfigWeightInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false)
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigWeightGroupDat > *data, FEConfigWeightInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigWeightGroupDat *item, FEConfigWeightInfo *iconf) noexcept(false)
 

Private Attributes

int m_group_id
 
float m_w0
 
float m_w1
 
float m_w2
 
float m_w3
 
float m_w4
 

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

Constructor & Destructor Documentation

FEConfigWeightGroupDat::FEConfigWeightGroupDat ( )

Definition at line 11 of file FEConfigWeightGroupDat.cc.

References NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_readStmt = NULL;
17 
18  m_group_id=0;
19  m_w0 = 0;
20  m_w1 = 0;
21  m_w2 = 0;
22  m_w3 = 0;
23  m_w4 = 0;
24 
25 }
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
FEConfigWeightGroupDat::~FEConfigWeightGroupDat ( )

Definition at line 29 of file FEConfigWeightGroupDat.cc.

30 {
31 }

Member Function Documentation

void FEConfigWeightGroupDat::fetchData ( std::map< EcalLogicID, FEConfigWeightGroupDat > *  fillMap,
FEConfigWeightInfo iconf 
)
privatenoexcept

Definition at line 84 of file FEConfigWeightGroupDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setWeight0(), setWeight1(), setWeight2(), setWeight3(), setWeight4(), and setWeightGroupId().

Referenced by getWeight4().

86 {
87  this->checkConnection();
88  fillMap->clear();
89 
90  iconf->setConnection(m_env, m_conn);
91  int iconfID = iconf->fetchID();
92  if (!iconfID) {
93  throw(std::runtime_error("FEConfigWeightGroupDat::fetchData: ICONF not in DB"));
94  return;
95  }
96 
97  try {
98 
99  m_readStmt->setSQL("SELECT d.group_id, d.w0, d.w1, d.w2, d.w3, d.w4 "
100  "FROM fe_weight_per_group_dat d "
101  "WHERE wei_conf_id = :wei_conf_id order by d.group_id ");
102  m_readStmt->setInt(1, iconfID);
103  ResultSet* rset = m_readStmt->executeQuery();
104 
105  std::pair< EcalLogicID, FEConfigWeightGroupDat > p;
107  int ig=-1;
108  while(rset->next()) {
109  ig++; // we create a dummy logic_id
110  p.first = EcalLogicID( "Group_id", // name
111  ig ); // logic_id
112 
113  dat.setWeightGroupId( rset->getInt(1) );
114  dat.setWeight0( rset->getFloat(2) );
115  dat.setWeight1( rset->getFloat(3) );
116  dat.setWeight2( rset->getFloat(4) );
117  dat.setWeight3( rset->getFloat(5) );
118  dat.setWeight4( rset->getFloat(6) );
119 
120  p.second = dat;
121  fillMap->insert(p);
122  }
123  } catch (SQLException &e) {
124  throw(std::runtime_error("FEConfigWeightGroupDat::fetchData: "+e.getMessage()));
125  }
126 }
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
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID() noexcept(false)
std::string FEConfigWeightGroupDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigWeightGroupDat.h.

18 { return "FE_CONFIG_WEIGHT_PER_GROUP_DAT"; }
float FEConfigWeightGroupDat::getWeight0 ( ) const
inline

Definition at line 24 of file FEConfigWeightGroupDat.h.

References m_w0.

Referenced by popcon::EcalTPGWeightIdMapHandler::getNewObjects(), and writeArrayDB().

24 { return m_w0; }
float FEConfigWeightGroupDat::getWeight1 ( ) const
inline

Definition at line 26 of file FEConfigWeightGroupDat.h.

References m_w1.

Referenced by popcon::EcalTPGWeightIdMapHandler::getNewObjects(), and writeArrayDB().

26 { return m_w1; }
float FEConfigWeightGroupDat::getWeight2 ( ) const
inline

Definition at line 28 of file FEConfigWeightGroupDat.h.

References m_w2.

Referenced by popcon::EcalTPGWeightIdMapHandler::getNewObjects(), and writeArrayDB().

28 { return m_w2; }
float FEConfigWeightGroupDat::getWeight3 ( ) const
inline

Definition at line 30 of file FEConfigWeightGroupDat.h.

References m_w3.

Referenced by popcon::EcalTPGWeightIdMapHandler::getNewObjects(), and writeArrayDB().

30 { return m_w3; }
float FEConfigWeightGroupDat::getWeight4 ( ) const
inline
int FEConfigWeightGroupDat::getWeightGroupId ( ) const
inline
void FEConfigWeightGroupDat::prepareWrite ( )
privatevirtualnoexcept

Implements IDataItem.

Definition at line 35 of file FEConfigWeightGroupDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getWeight4().

37 {
38  this->checkConnection();
39 
40  try {
41  m_writeStmt = m_conn->createStatement();
42  m_writeStmt->setSQL("INSERT INTO fe_weight_per_group_dat (wei_conf_id, group_id, "
43  " w0, w1, w2, w3, w4 ) "
44  "VALUES (:wei_conf_id, :group_id, "
45  ":w0, :w1, :w2, :w3, :w4 )" );
46  } catch (SQLException &e) {
47  throw(std::runtime_error("FEConfigWeightGroupDat::prepareWrite(): "+e.getMessage()));
48  }
49 }
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
void FEConfigWeightGroupDat::setWeight0 ( float  x)
inline

Definition at line 23 of file FEConfigWeightGroupDat.h.

References m_w0, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigWeightGroupDat::setWeight1 ( float  x)
inline

Definition at line 25 of file FEConfigWeightGroupDat.h.

References m_w1, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigWeightGroupDat::setWeight2 ( float  x)
inline

Definition at line 27 of file FEConfigWeightGroupDat.h.

References m_w2, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigWeightGroupDat::setWeight3 ( float  x)
inline

Definition at line 29 of file FEConfigWeightGroupDat.h.

References m_w3, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigWeightGroupDat::setWeight4 ( float  x)
inline

Definition at line 31 of file FEConfigWeightGroupDat.h.

References m_w4, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigWeightGroupDat::setWeightGroupId ( int  x)
inline

Definition at line 20 of file FEConfigWeightGroupDat.h.

References m_group_id, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigWeightGroupDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigWeightGroupDat > *  data,
FEConfigWeightInfo iconf 
)
privatenoexcept

Definition at line 128 of file FEConfigWeightGroupDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, getWeight0(), getWeight1(), getWeight2(), getWeight3(), getWeight4(), getWeightGroupId(), electrons_cff::ids, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, findQualityFiles::rr, alignCSCRings::s, lumiQTWidget::t, groupFilesInBlocks::tt, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

Referenced by getWeight4().

130 {
131  this->checkConnection();
132  this->checkPrepare();
133 
134  int iconfID = iconf->fetchID();
135  if (!iconfID) { throw(std::runtime_error("FEConfigWeightGroupDat::writeArrayDB: ICONF not in DB")); }
136 
137 
138  int nrows=data->size();
139  int* ids= new int[nrows];
140  int* iconfid_vec= new int[nrows];
141  int* xx= new int[nrows];
142  float* yy= new float[nrows];
143  float* zz= new float[nrows];
144  float* rr= new float[nrows];
145  float* ss= new float[nrows];
146  float* tt= new float[nrows];
147 
148 
149  ub2* ids_len= new ub2[nrows];
150  ub2* iconf_len= new ub2[nrows];
151  ub2* x_len= new ub2[nrows];
152  ub2* y_len= new ub2[nrows];
153  ub2* z_len= new ub2[nrows];
154  ub2* r_len= new ub2[nrows];
155  ub2* s_len= new ub2[nrows];
156  ub2* t_len= new ub2[nrows];
157 
158 
159  // const EcalLogicID* channel;
160  const FEConfigWeightGroupDat* dataitem;
161  int count=0;
162  typedef map< EcalLogicID, FEConfigWeightGroupDat >::const_iterator CI;
163  for (CI p = data->begin(); p != data->end(); ++p) {
164  // channel = &(p->first);
165  // int logicID = channel->getLogicID();
166  // if (!logicID) { throw(std::runtime_error("FEConfigWeightGroupDat::writeArrayDB: Bad EcalLogicID")); }
167  // ids[count]=logicID;
168  iconfid_vec[count]=iconfID;
169 
170  dataitem = &(p->second);
171  // dataIface.writeDB( channel, dataitem, iconf);
172  int x=dataitem->getWeightGroupId();
173  float y=dataitem->getWeight0();
174  float z=dataitem->getWeight1();
175  float r=dataitem->getWeight2();
176  float s=dataitem->getWeight3();
177  float t=dataitem->getWeight4();
178 
179  xx[count]=x;
180  yy[count]=y;
181  zz[count]=z;
182  rr[count]=r;
183  ss[count]=s;
184  tt[count]=t;
185 
186  // ids_len[count]=sizeof(ids[count]);
187  iconf_len[count]=sizeof(iconfid_vec[count]);
188 
189  x_len[count]=sizeof(xx[count]);
190  y_len[count]=sizeof(yy[count]);
191  z_len[count]=sizeof(zz[count]);
192  r_len[count]=sizeof(rr[count]);
193  s_len[count]=sizeof(ss[count]);
194  t_len[count]=sizeof(tt[count]);
195 
196  count++;
197  }
198 
199 
200  try {
201  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
202  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len );
203  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
204  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len );
205  m_writeStmt->setDataBuffer(5, (dvoid*)rr, OCCIFLOAT , sizeof(rr[0]), r_len );
206  m_writeStmt->setDataBuffer(6, (dvoid*)ss, OCCIFLOAT , sizeof(ss[0]), s_len );
207  m_writeStmt->setDataBuffer(7, (dvoid*)tt, OCCIFLOAT , sizeof(tt[0]), t_len );
208 
209  m_writeStmt->executeArrayUpdate(nrows);
210 
211  delete [] ids;
212  delete [] iconfid_vec;
213  delete [] xx;
214  delete [] yy;
215  delete [] zz;
216  delete [] rr;
217  delete [] ss;
218  delete [] tt;
219 
220  delete [] ids_len;
221  delete [] iconf_len;
222  delete [] x_len;
223  delete [] y_len;
224  delete [] z_len;
225  delete [] r_len;
226  delete [] s_len;
227  delete [] t_len;
228 
229  } catch (SQLException &e) {
230  throw(std::runtime_error("FEConfigWeightGroupDat::writeArrayDB(): "+e.getMessage()));
231  }
232 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int fetchID() noexcept(false)
void FEConfigWeightGroupDat::writeDB ( const EcalLogicID ecid,
const FEConfigWeightGroupDat item,
FEConfigWeightInfo iconf 
)
privatenoexcept

Definition at line 53 of file FEConfigWeightGroupDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getWeight4().

55 {
56  this->checkConnection();
57  this->checkPrepare();
58 
59  int iconfID = iconf->fetchID();
60  if (!iconfID) { throw(std::runtime_error("FEConfigWeightGroupDat::writeDB: ICONF not in DB")); }
61  /* no need for the logic id in this table
62  int logicID = ecid->getLogicID();
63  if (!logicID) { throw(std::runtime_error("FEConfigWeightGroupDat::writeDB: Bad EcalLogicID")); }
64  */
65 
66  try {
67  m_writeStmt->setInt(1, iconfID);
68 
69  m_writeStmt->setInt(2, item->getWeightGroupId());
70  m_writeStmt->setFloat(3, item->getWeight0());
71  m_writeStmt->setFloat(4, item->getWeight1());
72  m_writeStmt->setFloat(5, item->getWeight2());
73  m_writeStmt->setFloat(6, item->getWeight3());
74  m_writeStmt->setFloat(7, item->getWeight4());
75 
76  m_writeStmt->executeUpdate();
77  } catch (SQLException &e) {
78  throw(std::runtime_error("FEConfigWeightGroupDat::writeDB(): "+e.getMessage()));
79  }
80 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigWeightGroupDat.h.

Member Data Documentation

int FEConfigWeightGroupDat::m_group_id
private

Definition at line 46 of file FEConfigWeightGroupDat.h.

Referenced by getWeightGroupId(), and setWeightGroupId().

float FEConfigWeightGroupDat::m_w0
private

Definition at line 47 of file FEConfigWeightGroupDat.h.

Referenced by getWeight0(), and setWeight0().

float FEConfigWeightGroupDat::m_w1
private

Definition at line 48 of file FEConfigWeightGroupDat.h.

Referenced by getWeight1(), and setWeight1().

float FEConfigWeightGroupDat::m_w2
private

Definition at line 49 of file FEConfigWeightGroupDat.h.

Referenced by getWeight2(), and setWeight2().

float FEConfigWeightGroupDat::m_w3
private

Definition at line 50 of file FEConfigWeightGroupDat.h.

Referenced by getWeight3(), and setWeight3().

float FEConfigWeightGroupDat::m_w4
private

Definition at line 51 of file FEConfigWeightGroupDat.h.

Referenced by getWeight4(), and setWeight4().