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 hitfit::clear(), and 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

Definition at line 33 of file ODFEDAQConfig.cc.

References MY_NULL.

33  {
34  m_del=MY_NULL;
35  m_wei=MY_NULL;
36  m_ped=MY_NULL;
37 
38  m_bxt =MY_NULL;
39  m_btt =MY_NULL;
42 
43  m_version=0;
44  m_com="";
45 }
#define MY_NULL
std::string m_com
Definition: ODFEDAQConfig.h:71
void ODFEDAQConfig::fetchData ( ODFEDAQConfig result)
throw (std::runtime_error
)
private

Definition at line 157 of file ODFEDAQConfig.cc.

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

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

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  m_readStmt = m_conn->createStatement();
167  if(result->getConfigTag()!="" && result->getVersion() ==0 ){
168  int new_version=0;
169  std::cout<< "using new method : retrieving last version for this tag "<<endl;
170  try {
171  this->checkConnection();
172 
173  m_readStmt->setSQL("select max(version) from "+getTable()+" where tag=:tag " );
174  m_readStmt->setString(1, result->getConfigTag());
175  std::cout << "Getting last ver" << std::endl << std::flush;
176  ResultSet* rset = m_readStmt->executeQuery();
177  while (rset->next ()){
178  new_version= rset->getInt(1);
179  }
180  m_conn->terminateStatement(m_readStmt);
181 
182  // m_readStmt = m_conn->createStatement();
183 
184  result->setVersion(new_version);
185 
186  } catch (SQLException &e) {
187  throw(std::runtime_error("ODFEDAQConfig::fetchData(): "+e.getMessage()));
188  }
189 
190 
191 
192  }
193 
194  try {
195 
196  m_readStmt->setSQL("SELECT * FROM " + getTable() +
197  " where ( config_id = :1 or (tag=:2 AND version=:3 ) )" );
198  m_readStmt->setInt(1, result->getId());
199  m_readStmt->setString(2, result->getConfigTag());
200  m_readStmt->setInt(3, result->getVersion());
201  ResultSet* rset = m_readStmt->executeQuery();
202 
203  rset->next();
204 
205  // 1 is the id and 2 is the config tag and 3 is the version
206 
207  result->setId(rset->getInt(1));
208  result->setConfigTag(rset->getString(2));
209  result->setVersion(rset->getInt(3));
210 
211  result->setPedestalId( getInt(rset,4) );
212  result->setDelayId( getInt(rset,5) );
213  result->setWeightId( getInt(rset,6) );
214  result->setBadXtId( getInt(rset,7) );
215  result->setBadTTId( getInt(rset,8) );
216  result->setTriggerBadXtId( getInt(rset,9) );
217  result->setTriggerBadTTId( getInt(rset,10) );
218  result->setComment( rset->getString(11) );
219 
220  } catch (SQLException &e) {
221  throw(std::runtime_error("ODFEDAQConfig::fetchData(): "+e.getMessage()));
222  }
223 }
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:121
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 225 of file ODFEDAQConfig.cc.

References alignCSCRings::e.

226 {
227  // Return from memory if available
228  if (m_ID!=0) {
229  return m_ID;
230  }
231 
232  this->checkConnection();
233 
234  try {
235  Statement* stmt = m_conn->createStatement();
236  stmt->setSQL("SELECT config_id FROM "+ getTable()+
237  "WHERE tag=:1 and version=:2 " );
238 
239  stmt->setString(1, getConfigTag() );
240  stmt->setInt(2, getVersion() );
241 
242  ResultSet* rset = stmt->executeQuery();
243 
244  if (rset->next()) {
245  m_ID = rset->getInt(1);
246  } else {
247  m_ID = 0;
248  }
249  m_conn->terminateStatement(stmt);
250  } catch (SQLException &e) {
251  throw(std::runtime_error("ODFEDAQConfig::fetchID: "+e.getMessage()));
252  }
253 
254  return m_ID;
255 }
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 alignCSCRings::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.

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

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.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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

Implements IODConfig.

Definition at line 76 of file ODFEDAQConfig.cc.

References alignCSCRings::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

Definition at line 35 of file ODFEDAQConfig.h.

References m_btt, and vdt::x.

35 { m_btt = x; }
x
Definition: VDTMath.h:216
void ODFEDAQConfig::setBadXtId ( int  x)
inline

Definition at line 33 of file ODFEDAQConfig.h.

References m_bxt, and vdt::x.

33 { m_bxt = x; }
x
Definition: VDTMath.h:216
void ODFEDAQConfig::setComment ( std::string  x)
inline

Definition at line 42 of file ODFEDAQConfig.h.

References m_com, and vdt::x.

Referenced by jetTools.RunBTagging::apply().

42 { m_com = x; }
x
Definition: VDTMath.h:216
std::string m_com
Definition: ODFEDAQConfig.h:71
void ODFEDAQConfig::setDelayId ( int  x)
inline

Definition at line 28 of file ODFEDAQConfig.h.

References m_del, and vdt::x.

28 { m_del = x; }
x
Definition: VDTMath.h:216
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

Definition at line 26 of file ODFEDAQConfig.h.

References m_ped, and vdt::x.

26 { m_ped = x; }
x
Definition: VDTMath.h:216
void ODFEDAQConfig::setTriggerBadTTId ( int  x)
inline

Definition at line 39 of file ODFEDAQConfig.h.

References m_tbtt, and vdt::x.

39 { m_tbtt = x; }
x
Definition: VDTMath.h:216
void ODFEDAQConfig::setTriggerBadXtId ( int  x)
inline

Definition at line 37 of file ODFEDAQConfig.h.

References m_tbxt, and vdt::x.

37 { m_tbxt = x; }
x
Definition: VDTMath.h:216
void ODFEDAQConfig::setVersion ( int  id)
inline
void ODFEDAQConfig::setWeightId ( int  x)
inline

Definition at line 30 of file ODFEDAQConfig.h.

References m_wei, and vdt::x.

30 { m_wei = x; }
x
Definition: VDTMath.h:216
void ODFEDAQConfig::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 121 of file ODFEDAQConfig.cc.

References alignCSCRings::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().