CMS 3D CMS Logo

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 () noexcept(false)
 
int getBadTTId () const
 
int getBadXtId () const
 
std::string getComment () const
 
int getDelayId () const
 
int getId () const
 
int getPedestalId () const
 
std::string getTable () override
 
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 (const 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 () override
 
- 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) noexcept(false)
 
int fetchID () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

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 () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) 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 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().

22 {
23  m_env = nullptr;
24  m_conn = nullptr;
25  m_writeStmt = nullptr;
26  m_readStmt = nullptr;
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
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODFEDAQConfig::~ODFEDAQConfig ( )
override

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.

Referenced by getComment().

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)
privatenoexcept

Definition at line 157 of file ODFEDAQConfig.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, getInt(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EcalCondDBInterface::fetchFEDelaysForRun(), and getComment().

159 {
160  this->checkConnection();
161  result->clear();
162  if(result->getId()==0 && (result->getConfigTag().empty()) ){
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().empty() && 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(std::string("ODFEDAQConfig::fetchData(): ")+getOraMessage(&e)));
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(getOraString(rset,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( getOraString(rset,11) );
219 
220  } catch (SQLException &e) {
221  throw(std::runtime_error(std::string("ODFEDAQConfig::fetchData(): ")+getOraMessage(&e)));
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
std::string getTable() override
Definition: ODFEDAQConfig.h:16
void setDelayId(int x)
Definition: ODFEDAQConfig.h:28
void setTriggerBadTTId(int x)
Definition: ODFEDAQConfig.h:39
int getInt(ResultSet *rset, int ipar)
void setVersion(int id)
Definition: ODFEDAQConfig.h:23
void setPedestalId(int x)
Definition: ODFEDAQConfig.h:26
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getId() const
Definition: ODFEDAQConfig.h:19
void setWeightId(int x)
Definition: ODFEDAQConfig.h:30
void setBadTTId(int x)
Definition: ODFEDAQConfig.h:35
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void setComment(std::string x)
Definition: ODFEDAQConfig.h:42
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void setTriggerBadXtId(int x)
Definition: ODFEDAQConfig.h:37
int ODFEDAQConfig::fetchID ( )
privatenoexcept

Definition at line 225 of file ODFEDAQConfig.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComment().

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(std::string("ODFEDAQConfig::fetchID: ")+getOraMessage(&e)));
252  }
253 
254  return m_ID;
255 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getVersion() const
Definition: ODFEDAQConfig.h:24
std::string getTable() override
Definition: ODFEDAQConfig.h:16
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
int ODFEDAQConfig::fetchNextId ( )
noexcept

Definition at line 55 of file ODFEDAQConfig.cc.

References MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComment().

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(std::string("ODFEDAQConfig::fetchNextId(): ")+getOraMessage(&e)));
72  }
73 
74 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
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 clear(), fetchData(), fetchID(), fetchNextId(), m_com, noexcept, prepareWrite(), mps_fire::result, setParameters(), and writeDB().

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 ( void  ) 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 ( )
inlineoverridevirtual

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 ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 76 of file ODFEDAQConfig.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComment().

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(std::string("ODFEDAQConfig::prepareWrite(): ")+getOraMessage(&e)));
93  }
94 
95 }
int fetchNextId() noexcept(false)
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODFEDAQConfig::setBadTTId ( int  x)
inline

Definition at line 35 of file ODFEDAQConfig.h.

References m_btt, and x.

35 { m_btt = x; }
void ODFEDAQConfig::setBadXtId ( int  x)
inline

Definition at line 33 of file ODFEDAQConfig.h.

References m_bxt, and x.

33 { m_bxt = x; }
void ODFEDAQConfig::setComment ( std::string  x)
inline

Definition at line 42 of file ODFEDAQConfig.h.

References m_com, and x.

42 { m_com = x; }
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 x.

28 { m_del = x; }
void ODFEDAQConfig::setId ( int  id)
inline
void ODFEDAQConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 97 of file ODFEDAQConfig.cc.

Referenced by getComment().

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 >::const_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 x.

26 { m_ped = x; }
void ODFEDAQConfig::setTriggerBadTTId ( int  x)
inline

Definition at line 39 of file ODFEDAQConfig.h.

References m_tbtt, and x.

39 { m_tbtt = x; }
void ODFEDAQConfig::setTriggerBadXtId ( int  x)
inline

Definition at line 37 of file ODFEDAQConfig.h.

References m_tbxt, and x.

37 { m_tbxt = x; }
void ODFEDAQConfig::setVersion ( int  id)
inline

Definition at line 23 of file ODFEDAQConfig.h.

References triggerObjects_cff::id, and m_version.

void ODFEDAQConfig::setWeightId ( int  x)
inline

Definition at line 30 of file ODFEDAQConfig.h.

References m_wei, and x.

30 { m_wei = x; }
void ODFEDAQConfig::writeDB ( )
privatenoexcept

Definition at line 121 of file ODFEDAQConfig.cc.

References MillePedeFileConverter_cfg::e, SET_INT, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getComment().

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(std::string("ODFEDAQConfig::writeDB(): ")+getOraMessage(&e)));
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
int fetchID() noexcept(false)
int getPedestalId() const
Definition: ODFEDAQConfig.h:27
int getBadXtId() const
Definition: ODFEDAQConfig.h:34
#define SET_INT(statement, paramNum, paramVal)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getBadTTId() const
Definition: ODFEDAQConfig.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
int getWeightId() const
Definition: ODFEDAQConfig.h:31
std::string getComment() const
Definition: ODFEDAQConfig.h:43
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

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().