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
FEConfigSpikeDat Class Reference

#include <FEConfigSpikeDat.h>

Inheritance diagram for FEConfigSpikeDat:
IDataItem IDBObject

Public Member Functions

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

Private Attributes

int m_thr
 

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

Constructor & Destructor Documentation

FEConfigSpikeDat::FEConfigSpikeDat ( )

Definition at line 11 of file FEConfigSpikeDat.cc.

References NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_readStmt = NULL;
17 
18  m_thr = 0;
19 
20 }
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
FEConfigSpikeDat::~FEConfigSpikeDat ( )

Definition at line 24 of file FEConfigSpikeDat.cc.

25 {
26 }

Member Function Documentation

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

Definition at line 72 of file FEConfigSpikeDat.cc.

References alignCSCRings::e, AlCaHLTBitMon_ParallelJobs::p, and setSpikeThreshold().

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("FEConfigSpikeDat::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.spike_threshold FROM channelview cv JOIN "+getTable()+" d ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
89  "WHERE spi_conf_id = :spi_conf_id");
90  m_readStmt->setInt(1, iconfID);
91  ResultSet* rset = m_readStmt->executeQuery();
92 
93  std::pair< EcalLogicID, FEConfigSpikeDat > p;
94  FEConfigSpikeDat dat;
95  while(rset->next()) {
96  p.first = EcalLogicID( rset->getString(1), // name
97  rset->getInt(2), // logic_id
98  rset->getInt(3), // id1
99  rset->getInt(4), // id2
100  rset->getInt(5), // id3
101  rset->getString(6)); // maps_to
102 
103  dat.setSpikeThreshold( rset->getInt(7) );
104 
105  p.second = dat;
106  fillMap->insert(p);
107  }
108  } catch (SQLException &e) {
109  throw(std::runtime_error("FEConfigSpikeDat::fetchData: "+e.getMessage()));
110  }
111 }
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:27
std::string getTable()
void setSpikeThreshold(int x)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
int FEConfigSpikeDat::getSpikeThreshold ( ) const
inline

Definition at line 21 of file FEConfigSpikeDat.h.

References m_thr.

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

21 { return m_thr; }
std::string FEConfigSpikeDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigSpikeDat.h.

18 { return "FE_CONFIG_SPIKE_DAT"; }
void FEConfigSpikeDat::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IDataItem.

Definition at line 30 of file FEConfigSpikeDat.cc.

References alignCSCRings::e.

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

Definition at line 20 of file FEConfigSpikeDat.h.

References m_thr, and x.

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

void FEConfigSpikeDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigSpikeDat > *  data,
FEConfigSpikeInfo iconf 
)
throw (std::runtime_error
)
private

Definition at line 113 of file FEConfigSpikeDat.cc.

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

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

Definition at line 47 of file FEConfigSpikeDat.cc.

References alignCSCRings::e.

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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigSpikeDat.h.

Member Data Documentation

int FEConfigSpikeDat::m_thr
private

Definition at line 39 of file FEConfigSpikeDat.h.

Referenced by getSpikeThreshold(), and setSpikeThreshold().