CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
FEConfigFgrDat Class Reference

#include <FEConfigFgrDat.h>

Inheritance diagram for FEConfigFgrDat:
IDataItem IDBObject

Public Member Functions

 FEConfigFgrDat ()
 
int getFgrGroupId () const
 
std::string getTable ()
 
void setFgrGroupId (int x)
 
 ~FEConfigFgrDat ()
 
- 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, FEConfigFgrDat > *fillMap, FEConfigFgrInfo *iconf) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigFgrDat > *data, FEConfigFgrInfo *iconf) throw (std::runtime_error)
 
void writeDB (const EcalLogicID *ecid, const FEConfigFgrDat *item, FEConfigFgrInfo *iconf) throw (std::runtime_error)
 

Private Attributes

int m_group_id
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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 FEConfigFgrDat.h.

Constructor & Destructor Documentation

FEConfigFgrDat::FEConfigFgrDat ( )

Definition at line 11 of file FEConfigFgrDat.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 
20 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:24
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:25
FEConfigFgrDat::~FEConfigFgrDat ( )

Definition at line 24 of file FEConfigFgrDat.cc.

25 {
26 }

Member Function Documentation

void FEConfigFgrDat::fetchData ( std::map< EcalLogicID, FEConfigFgrDat > *  fillMap,
FEConfigFgrInfo iconf 
)
throw (std::runtime_error
)
private

Definition at line 72 of file FEConfigFgrDat.cc.

References alignCSCRings::e, edm::pset::fillMap(), AlCaHLTBitMon_ParallelJobs::p, and setFgrGroupId().

74 {
75  this->checkConnection();
76  fillMap->clear();
77 
78  iconf->setConnection(m_env, m_conn);
79  int iconfID = iconf->fetchID();
80  if (!iconfID) {
81  // throw(std::runtime_error("FEConfigFgrDat::writeDB: ICONF not in DB"));
82  return;
83  }
84 
85  try {
86 
87  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
88  "d.group_id "
89  "FROM channelview cv JOIN fe_config_fgr_dat d "
90  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
91  "WHERE fgr_conf_id = :fgr_conf_id");
92  m_readStmt->setInt(1, iconfID);
93  ResultSet* rset = m_readStmt->executeQuery();
94 
95  std::pair< EcalLogicID, FEConfigFgrDat > p;
96  FEConfigFgrDat dat;
97  while(rset->next()) {
98  p.first = EcalLogicID( rset->getString(1), // name
99  rset->getInt(2), // logic_id
100  rset->getInt(3), // id1
101  rset->getInt(4), // id2
102  rset->getInt(5), // id3
103  rset->getString(6)); // maps_to
104 
105  dat.setFgrGroupId( rset->getInt(7) );
106 
107  p.second = dat;
108  fillMap->insert(p);
109  }
110  } catch (SQLException &e) {
111  throw(std::runtime_error("FEConfigFgrDat::fetchData: "+e.getMessage()));
112  }
113 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setFgrGroupId(int x)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:25
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void fillMap(Registry *reg, regmap_type &fillme)
Definition: Registry.cc:24
void checkConnection() const
Definition: IDBObject.h:41
int FEConfigFgrDat::getFgrGroupId ( ) const
inline

Definition at line 21 of file FEConfigFgrDat.h.

References m_group_id.

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

21 { return m_group_id; }
std::string FEConfigFgrDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigFgrDat.h.

18 { return "FE_CONFIG_FGR_DAT"; }
void FEConfigFgrDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 30 of file FEConfigFgrDat.cc.

References alignCSCRings::e.

32 {
33  this->checkConnection();
34 
35  try {
36  m_writeStmt = m_conn->createStatement();
37  m_writeStmt->setSQL("INSERT INTO fe_config_fgr_dat (fgr_conf_id, logic_id, "
38  "group_id ) "
39  "VALUES (:fgr_conf_id, :logic_id, "
40  ":group_id )" );
41  } catch (SQLException &e) {
42  throw(std::runtime_error("FEConfigFgrDat::prepareWrite(): "+e.getMessage()));
43  }
44 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:24
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
void FEConfigFgrDat::setFgrGroupId ( int  x)
inline

Definition at line 20 of file FEConfigFgrDat.h.

References m_group_id, and vdt::x.

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

20 { m_group_id = x; }
x
Definition: VDTMath.h:216
void FEConfigFgrDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigFgrDat > *  data,
FEConfigFgrInfo iconf 
)
throw (std::runtime_error
)
private

Definition at line 115 of file FEConfigFgrDat.cc.

References prof2calltree::count, data, alignCSCRings::e, getFgrGroupId(), EcalLogicID::getLogicID(), AlCaHLTBitMon_ParallelJobs::p, and vdt::x.

117 {
118  this->checkConnection();
119  this->checkPrepare();
120 
121  int iconfID = iconf->fetchID();
122  if (!iconfID) { throw(std::runtime_error("FEConfigFgrDat::writeArrayDB: ICONF not in DB")); }
123 
124 
125  int nrows=data->size();
126  int* ids= new int[nrows];
127  int* iconfid_vec= new int[nrows];
128  int* xx= new int[nrows];
129 
130  ub2* ids_len= new ub2[nrows];
131  ub2* iconf_len= new ub2[nrows];
132  ub2* x_len= new ub2[nrows];
133 
134 
135  const EcalLogicID* channel;
136  const FEConfigFgrDat* dataitem;
137  int count=0;
138  typedef map< EcalLogicID, FEConfigFgrDat >::const_iterator CI;
139  for (CI p = data->begin(); p != data->end(); ++p) {
140  channel = &(p->first);
141  int logicID = channel->getLogicID();
142  if (!logicID) { throw(std::runtime_error("FEConfigFgrDat::writeArrayDB: Bad EcalLogicID")); }
143  ids[count]=logicID;
144  iconfid_vec[count]=iconfID;
145 
146  dataitem = &(p->second);
147  // dataIface.writeDB( channel, dataitem, iconf);
148  int x=dataitem->getFgrGroupId();
149 
150  xx[count]=x;
151 
152  ids_len[count]=sizeof(ids[count]);
153  iconf_len[count]=sizeof(iconfid_vec[count]);
154 
155  x_len[count]=sizeof(xx[count]);
156 
157  count++;
158  }
159 
160 
161  try {
162  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
163  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
164  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
165 
166  m_writeStmt->executeArrayUpdate(nrows);
167 
168  delete [] ids;
169  delete [] iconfid_vec;
170  delete [] xx;
171 
172  delete [] ids_len;
173  delete [] iconf_len;
174  delete [] x_len;
175 
176  } catch (SQLException &e) {
177  throw(std::runtime_error("FEConfigFgrDat::writeArrayDB(): "+e.getMessage()));
178  }
179 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:24
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getLogicID() const
Definition: EcalLogicID.cc:42
void checkPrepare()
Definition: IDataItem.h:27
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
x
Definition: VDTMath.h:216
int getFgrGroupId() const
void checkConnection() const
Definition: IDBObject.h:41
void FEConfigFgrDat::writeDB ( const EcalLogicID ecid,
const FEConfigFgrDat item,
FEConfigFgrInfo iconf 
)
throw (std::runtime_error
)
private

Definition at line 47 of file FEConfigFgrDat.cc.

References alignCSCRings::e.

49 {
50  this->checkConnection();
51  this->checkPrepare();
52 
53  int iconfID = iconf->fetchID();
54  if (!iconfID) { throw(std::runtime_error("FEConfigFgrDat::writeDB: ICONF not in DB")); }
55 
56  int logicID = ecid->getLogicID();
57  if (!logicID) { throw(std::runtime_error("FEConfigFgrDat::writeDB: Bad EcalLogicID")); }
58 
59  try {
60  m_writeStmt->setInt(1, iconfID);
61  m_writeStmt->setInt(2, logicID);
62  m_writeStmt->setInt(3, item->getFgrGroupId());
63 
64  m_writeStmt->executeUpdate();
65  } catch (SQLException &e) {
66  throw(std::runtime_error("FEConfigFgrDat::writeDB(): "+e.getMessage()));
67  }
68 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:24
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getLogicID() const
Definition: EcalLogicID.cc:42
void checkPrepare()
Definition: IDataItem.h:27
int getFgrGroupId() const
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigFgrDat.h.

Member Data Documentation

int FEConfigFgrDat::m_group_id
private

Definition at line 39 of file FEConfigFgrDat.h.

Referenced by getFgrGroupId(), and setFgrGroupId().