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

#include <ODFEDAQConfig.h>

Inheritance diagram for ODFEDAQConfig:
IODConfig IDBObject

Public Member Functions

int fetchNextId () throw (std::runtime_error)
 
int getBadTTId () const
 
int getBadXtId () const
 
std::string getComment () const
 
int getDelayId () const
 
int getId () const
 
int getPedestalId () const
 
std::string getTable ()
 
int getTriggerBadTTId () const
 
int getTriggerBadXtId () const
 
int getVersion () const
 
int getWeightId () const
 
 ODFEDAQConfig ()
 
void setBadTTId (int x)
 
void setBadXtId (int x)
 
void setComment (std::string x)
 
void setDelayId (int x)
 
void setId (int id)
 
void setParameters (std::map< std::string, std::string > my_keys_map)
 
void setPedestalId (int x)
 
void setTriggerBadTTId (int x)
 
void setTriggerBadXtId (int x)
 
void setVersion (int id)
 
void setWeightId (int x)
 
 ~ODFEDAQConfig ()
 
- 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 clear ()
 
void fetchData (ODFEDAQConfig *result) throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

Private Attributes

int m_btt
 
int m_bxt
 
std::string m_com
 
int m_del
 
int m_ID
 
int m_ped
 
int m_tbtt
 
int m_tbxt
 
int m_version
 
int m_wei
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) 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 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 9 of file ODFEDAQConfig.h.

Constructor & Destructor Documentation

ODFEDAQConfig::ODFEDAQConfig ( )

Definition at line 21 of file ODFEDAQConfig.cc.

References NULL.

22 {
23  m_env = NULL;
24  m_conn = NULL;
25  m_writeStmt = NULL;
26  m_readStmt = NULL;
27  m_config_tag="";
28  m_ID=0;
29  clear();
30 }
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
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODFEDAQConfig::~ODFEDAQConfig ( )

Definition at line 49 of file ODFEDAQConfig.cc.

50 {
51 }

Member Function Documentation

void ODFEDAQConfig::clear ( void  )
private
void ODFEDAQConfig::fetchData ( ODFEDAQConfig result)
throw (std::runtime_error
)
private

Definition at line 157 of file ODFEDAQConfig.cc.

References gather_cfg::cout, ExpressReco_HICollisions_FallBack::e, getInt(), and query::result.

159 {
160  this->checkConnection();
161  result->clear();
162  if(result->getId()==0 && (result->getConfigTag()=="") ){
163  throw(std::runtime_error("ODFEDAQConfig::fetchData(): no Id defined for this ODFEDAQConfig "));
164  }
165 
166  if(result->getConfigTag()!="" && result->getVersion() ==0 ){
167  int new_version=0;
168  std::cout<< "using new method : retrieving last version for this tag "<<endl;
169  try {
170  this->checkConnection();
171 
172  m_readStmt->setSQL("select max(version) from "+getTable()+" where tag=:tag " );
173  m_readStmt->setString(1, result->getConfigTag());
174  ResultSet* rset = m_readStmt->executeQuery();
175  while (rset->next ()){
176  new_version= rset->getInt(1);
177  }
178  m_conn->terminateStatement(m_readStmt);
179 
180  m_readStmt = m_conn->createStatement();
181 
182  result->setVersion(new_version);
183 
184  } catch (SQLException &e) {
185  throw(std::runtime_error("ODFEDAQConfig::fetchData(): "+e.getMessage()));
186  }
187 
188 
189 
190  }
191 
192  try {
193 
194  m_readStmt->setSQL("SELECT * FROM " + getTable() +
195  " where ( config_id = :1 or (tag=:2 AND version=:3 ) )" );
196  m_readStmt->setInt(1, result->getId());
197  m_readStmt->setString(2, result->getConfigTag());
198  m_readStmt->setInt(3, result->getVersion());
199  ResultSet* rset = m_readStmt->executeQuery();
200 
201  rset->next();
202 
203  // 1 is the id and 2 is the config tag and 3 is the version
204 
205  result->setId(rset->getInt(1));
206  result->setConfigTag(rset->getString(2));
207  result->setVersion(rset->getInt(3));
208 
209  result->setPedestalId( getInt(rset,4) );
210  result->setDelayId( getInt(rset,5) );
211  result->setWeightId( getInt(rset,6) );
212  result->setBadXtId( getInt(rset,7) );
213  result->setBadTTId( getInt(rset,8) );
214  result->setTriggerBadXtId( getInt(rset,9) );
215  result->setTriggerBadTTId( getInt(rset,10) );
216  result->setComment( rset->getString(11) );
217 
218  } catch (SQLException &e) {
219  throw(std::runtime_error("ODFEDAQConfig::fetchData(): "+e.getMessage()));
220  }
221 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setId(int id)
Definition: ODFEDAQConfig.h:18
int getVersion() const
Definition: ODFEDAQConfig.h:24
void setBadXtId(int x)
Definition: ODFEDAQConfig.h:33
void setDelayId(int x)
Definition: ODFEDAQConfig.h:28
void setTriggerBadTTId(int x)
Definition: ODFEDAQConfig.h:39
int getInt(ResultSet *rset, int ipar)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setVersion(int id)
Definition: ODFEDAQConfig.h:23
void setPedestalId(int x)
Definition: ODFEDAQConfig.h:26
int getId() const
Definition: ODFEDAQConfig.h:19
void setWeightId(int x)
Definition: ODFEDAQConfig.h:30
void setBadTTId(int x)
Definition: ODFEDAQConfig.h:35
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setComment(std::string x)
Definition: ODFEDAQConfig.h:42
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
std::string getTable()
Definition: ODFEDAQConfig.h:16
tuple cout
Definition: gather_cfg.py:41
void setTriggerBadXtId(int x)
Definition: ODFEDAQConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
int ODFEDAQConfig::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 223 of file ODFEDAQConfig.cc.

References ExpressReco_HICollisions_FallBack::e.

224 {
225  // Return from memory if available
226  if (m_ID!=0) {
227  return m_ID;
228  }
229 
230  this->checkConnection();
231 
232  try {
233  Statement* stmt = m_conn->createStatement();
234  stmt->setSQL("SELECT config_id FROM "+ getTable()+
235  "WHERE tag=:1 and version=:2 " );
236 
237  stmt->setString(1, getConfigTag() );
238  stmt->setInt(2, getVersion() );
239 
240  ResultSet* rset = stmt->executeQuery();
241 
242  if (rset->next()) {
243  m_ID = rset->getInt(1);
244  } else {
245  m_ID = 0;
246  }
247  m_conn->terminateStatement(stmt);
248  } catch (SQLException &e) {
249  throw(std::runtime_error("ODFEDAQConfig::fetchID: "+e.getMessage()));
250  }
251 
252  return m_ID;
253 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getVersion() const
Definition: ODFEDAQConfig.h:24
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
std::string getConfigTag()
Definition: IODConfig.h:32
std::string getTable()
Definition: ODFEDAQConfig.h:16
void checkConnection() const
Definition: IDBObject.h:41
int ODFEDAQConfig::fetchNextId ( )
throw (std::runtime_error
)

Definition at line 55 of file ODFEDAQConfig.cc.

References ExpressReco_HICollisions_FallBack::e, and query::result.

55  {
56 
57  int result=0;
58  try {
59  this->checkConnection();
60 
61  m_readStmt = m_conn->createStatement();
62  m_readStmt->setSQL("select fe_daq_conDfig_sq.nextVal from dual");
63  ResultSet* rset = m_readStmt->executeQuery();
64  while (rset->next ()){
65  result= rset->getInt(1);
66  }
67  m_conn->terminateStatement(m_readStmt);
68  return result;
69 
70  } catch (SQLException &e) {
71  throw(std::runtime_error("ODFEDAQConfig::fetchNextId(): "+e.getMessage()));
72  }
73 
74 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
int ODFEDAQConfig::getBadTTId ( ) const
inline

Definition at line 36 of file ODFEDAQConfig.h.

References m_btt.

Referenced by popcon::EcalChannelStatusHandler::daqOut(), and popcon::EcalDAQHandler::getNewObjects().

36 { return m_btt; }
int ODFEDAQConfig::getBadXtId ( ) const
inline

Definition at line 34 of file ODFEDAQConfig.h.

References m_bxt.

34 { return m_bxt; }
std::string ODFEDAQConfig::getComment ( ) const
inline

Definition at line 43 of file ODFEDAQConfig.h.

References m_com.

43 { return m_com; }
std::string m_com
Definition: ODFEDAQConfig.h:71
int ODFEDAQConfig::getDelayId ( ) const
inline

Definition at line 29 of file ODFEDAQConfig.h.

References m_del.

29 { return m_del; }
int ODFEDAQConfig::getId ( ) const
inline

Definition at line 19 of file ODFEDAQConfig.h.

References m_ID.

19 { return m_ID; }
int ODFEDAQConfig::getPedestalId ( ) const
inline

Definition at line 27 of file ODFEDAQConfig.h.

References m_ped.

27 { return m_ped; }
std::string ODFEDAQConfig::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 16 of file ODFEDAQConfig.h.

16 { return "FE_DAQ_CONFIG"; }
int ODFEDAQConfig::getTriggerBadTTId ( ) const
inline

Definition at line 40 of file ODFEDAQConfig.h.

References m_tbtt.

40 { return m_tbtt; }
int ODFEDAQConfig::getTriggerBadXtId ( ) const
inline

Definition at line 38 of file ODFEDAQConfig.h.

References m_tbxt.

38 { return m_tbxt; }
int ODFEDAQConfig::getVersion ( ) const
inline

Definition at line 24 of file ODFEDAQConfig.h.

References m_version.

24 { return m_version; }
int ODFEDAQConfig::getWeightId ( ) const
inline

Definition at line 31 of file ODFEDAQConfig.h.

References m_wei.

31 { return m_wei; }
void ODFEDAQConfig::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 76 of file ODFEDAQConfig.cc.

References ExpressReco_HICollisions_FallBack::e.

78 {
79  this->checkConnection();
80  int next_id=fetchNextId();
81 
82  try {
83  m_writeStmt = m_conn->createStatement();
84  m_writeStmt->setSQL("INSERT INTO FE_DAQ_CONFIG ( config_id, tag, version, ped_id, "
85  " del_id, wei_id,bxt_id, btt_id, tr_bxt_id, tr_btt_id, user_comment ) "
86  "VALUES ( :1, :2, :3, :4, :5, :6, :7 ,:8, :9, :10, :11 )" );
87 
88  m_writeStmt->setInt(1, next_id);
89  m_ID=next_id;
90 
91  } catch (SQLException &e) {
92  throw(std::runtime_error("ODFEDAQConfig::prepareWrite(): "+e.getMessage()));
93  }
94 
95 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
void ODFEDAQConfig::setBadTTId ( int  x)
inline
void ODFEDAQConfig::setBadXtId ( int  x)
inline
void ODFEDAQConfig::setComment ( std::string  x)
inline
void ODFEDAQConfig::setDelayId ( int  x)
inline
void ODFEDAQConfig::setId ( int  id)
inline
void ODFEDAQConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)

Definition at line 97 of file ODFEDAQConfig.cc.

97  {
98 
99  // parses the result of the XML parser that is a map of
100  // string string with variable name variable value
101 
102  for( std::map<std::string, std::string >::iterator ci=
103  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
104 
105  if(ci->first== "VERSION") setVersion(atoi(ci->second.c_str()) );
106  if(ci->first== "PED_ID") setPedestalId(atoi(ci->second.c_str()) );
107  if(ci->first== "DEL_ID") setDelayId(atoi(ci->second.c_str()));
108  if(ci->first== "WEI_ID") setWeightId(atoi(ci->second.c_str()));
109 
110  if(ci->first== "BXT_ID") setBadXtId(atoi(ci->second.c_str()));
111  if(ci->first== "BTT_ID") setBadTTId(atoi(ci->second.c_str()));
112  if(ci->first== "TRIG_BXT_ID") setTriggerBadXtId(atoi(ci->second.c_str()));
113  if(ci->first== "TRIG_BTT_ID") setTriggerBadTTId(atoi(ci->second.c_str()));
114 
115  if(ci->first== "COMMENT" || ci->first== "USER_COMMENT") setComment(ci->second);
116 
117  }
118 
119 }
void setBadXtId(int x)
Definition: ODFEDAQConfig.h:33
void setDelayId(int x)
Definition: ODFEDAQConfig.h:28
void setTriggerBadTTId(int x)
Definition: ODFEDAQConfig.h:39
void setVersion(int id)
Definition: ODFEDAQConfig.h:23
void setPedestalId(int x)
Definition: ODFEDAQConfig.h:26
void setWeightId(int x)
Definition: ODFEDAQConfig.h:30
void setBadTTId(int x)
Definition: ODFEDAQConfig.h:35
void setComment(std::string x)
Definition: ODFEDAQConfig.h:42
void setTriggerBadXtId(int x)
Definition: ODFEDAQConfig.h:37
void ODFEDAQConfig::setPedestalId ( int  x)
inline
void ODFEDAQConfig::setTriggerBadTTId ( int  x)
inline
void ODFEDAQConfig::setTriggerBadXtId ( int  x)
inline
void ODFEDAQConfig::setVersion ( int  id)
inline
void ODFEDAQConfig::setWeightId ( int  x)
inline
void ODFEDAQConfig::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 121 of file ODFEDAQConfig.cc.

References ExpressReco_HICollisions_FallBack::e, and SET_INT.

123 {
124  this->checkConnection();
125  this->checkPrepare();
126 
127  try {
128 
129  // number 1 is the id
130  m_writeStmt->setString(2, this->getConfigTag());
131  m_writeStmt->setInt(3, this->getVersion());
132  SET_INT(m_writeStmt,4, this->getPedestalId());
133  SET_INT(m_writeStmt,5, this->getDelayId());
134  SET_INT(m_writeStmt,6, this->getWeightId());
135  SET_INT(m_writeStmt,7, this->getBadXtId());
136  SET_INT(m_writeStmt,8, this->getBadTTId());
139 
140  m_writeStmt->setString(11, this->getComment());
141 
142  m_writeStmt->executeUpdate();
143 
144 
145  } catch (SQLException &e) {
146  throw(std::runtime_error("ODFEDAQConfig::writeDB(): "+e.getMessage()));
147  }
148  // Now get the ID
149  if (!this->fetchID()) {
150  throw(std::runtime_error("ODFEDAQConfig::writeDB: Failed to write"));
151  }
152 
153 
154 }
int getTriggerBadXtId() const
Definition: ODFEDAQConfig.h:38
Statement * m_writeStmt
Definition: IODConfig.h:36
int getVersion() const
Definition: ODFEDAQConfig.h:24
int getDelayId() const
Definition: ODFEDAQConfig.h:29
int getTriggerBadTTId() const
Definition: ODFEDAQConfig.h:40
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getPedestalId() const
Definition: ODFEDAQConfig.h:27
int getBadXtId() const
Definition: ODFEDAQConfig.h:34
#define SET_INT(statement, paramNum, paramVal)
int getBadTTId() const
Definition: ODFEDAQConfig.h:36
void checkPrepare()
Definition: IODConfig.h:39
std::string getConfigTag()
Definition: IODConfig.h:32
int getWeightId() const
Definition: ODFEDAQConfig.h:31
std::string getComment() const
Definition: ODFEDAQConfig.h:43
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODFEDAQConfig.h.

Member Data Documentation

int ODFEDAQConfig::m_btt
private

Definition at line 67 of file ODFEDAQConfig.h.

Referenced by getBadTTId(), and setBadTTId().

int ODFEDAQConfig::m_bxt
private

Definition at line 66 of file ODFEDAQConfig.h.

Referenced by getBadXtId(), and setBadXtId().

std::string ODFEDAQConfig::m_com
private

Definition at line 71 of file ODFEDAQConfig.h.

Referenced by getComment(), and setComment().

int ODFEDAQConfig::m_del
private

Definition at line 63 of file ODFEDAQConfig.h.

Referenced by getDelayId(), and setDelayId().

int ODFEDAQConfig::m_ID
private

Definition at line 61 of file ODFEDAQConfig.h.

Referenced by getId(), and setId().

int ODFEDAQConfig::m_ped
private

Definition at line 62 of file ODFEDAQConfig.h.

Referenced by getPedestalId(), and setPedestalId().

int ODFEDAQConfig::m_tbtt
private

Definition at line 69 of file ODFEDAQConfig.h.

Referenced by getTriggerBadTTId(), and setTriggerBadTTId().

int ODFEDAQConfig::m_tbxt
private

Definition at line 68 of file ODFEDAQConfig.h.

Referenced by getTriggerBadXtId(), and setTriggerBadXtId().

int ODFEDAQConfig::m_version
private

Definition at line 70 of file ODFEDAQConfig.h.

Referenced by getVersion(), and setVersion().

int ODFEDAQConfig::m_wei
private

Definition at line 64 of file ODFEDAQConfig.h.

Referenced by getWeightId(), and setWeightId().