CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 () 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 28 of file ODFEDAQConfig.cc.

References clear().

28  {
29  m_env = nullptr;
30  m_conn = nullptr;
31  m_writeStmt = nullptr;
32  m_readStmt = nullptr;
33  m_config_tag = "";
34  m_ID = 0;
35  clear();
36 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
std::string m_config_tag
Definition: IODConfig.h:25
Statement * m_readStmt
Definition: IODConfig.h:34
ODFEDAQConfig::~ODFEDAQConfig ( )
override

Definition at line 52 of file ODFEDAQConfig.cc.

52 {}

Member Function Documentation

void ODFEDAQConfig::clear ( void  )
private

Definition at line 38 of file ODFEDAQConfig.cc.

References MY_NULL.

38  {
39  m_del = MY_NULL;
40  m_wei = MY_NULL;
41  m_ped = MY_NULL;
42 
43  m_bxt = MY_NULL;
44  m_btt = MY_NULL;
45  m_tbtt = MY_NULL;
46  m_tbxt = MY_NULL;
47 
48  m_version = 0;
49  m_com = "";
50 }
#define MY_NULL
std::string m_com
Definition: ODFEDAQConfig.h:70
void ODFEDAQConfig::fetchData ( ODFEDAQConfig result)
privatenoexcept

Definition at line 149 of file ODFEDAQConfig.cc.

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

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

149  {
150  this->checkConnection();
151  result->clear();
152  if (result->getId() == 0 && (result->getConfigTag().empty())) {
153  throw(std::runtime_error("ODFEDAQConfig::fetchData(): no Id defined for this ODFEDAQConfig "));
154  }
155 
156  m_readStmt = m_conn->createStatement();
157  if (!result->getConfigTag().empty() && result->getVersion() == 0) {
158  int new_version = 0;
159  std::cout << "using new method : retrieving last version for this tag " << endl;
160  try {
161  this->checkConnection();
162 
163  m_readStmt->setSQL("select max(version) from " + getTable() + " where tag=:tag ");
164  m_readStmt->setString(1, result->getConfigTag());
165  std::cout << "Getting last ver" << std::endl << std::flush;
166  ResultSet* rset = m_readStmt->executeQuery();
167  while (rset->next()) {
168  new_version = rset->getInt(1);
169  }
170  m_conn->terminateStatement(m_readStmt);
171 
172  // m_readStmt = m_conn->createStatement();
173 
174  result->setVersion(new_version);
175 
176  } catch (SQLException& e) {
177  throw(std::runtime_error(std::string("ODFEDAQConfig::fetchData(): ") + e.getMessage()));
178  }
179  }
180 
181  try {
182  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where ( config_id = :1 or (tag=:2 AND version=:3 ) )");
183  m_readStmt->setInt(1, result->getId());
184  m_readStmt->setString(2, result->getConfigTag());
185  m_readStmt->setInt(3, result->getVersion());
186  ResultSet* rset = m_readStmt->executeQuery();
187 
188  rset->next();
189 
190  // 1 is the id and 2 is the config tag and 3 is the version
191 
192  result->setId(rset->getInt(1));
193  result->setConfigTag(rset->getString(2));
194  result->setVersion(rset->getInt(3));
195 
196  result->setPedestalId(getInt(rset, 4));
197  result->setDelayId(getInt(rset, 5));
198  result->setWeightId(getInt(rset, 6));
199  result->setBadXtId(getInt(rset, 7));
200  result->setBadTTId(getInt(rset, 8));
201  result->setTriggerBadXtId(getInt(rset, 9));
202  result->setTriggerBadTTId(getInt(rset, 10));
203  result->setComment(rset->getString(11));
204 
205  } catch (SQLException& e) {
206  throw(std::runtime_error(std::string("ODFEDAQConfig::fetchData(): ") + e.getMessage()));
207  }
208 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setId(int id)
Definition: ODFEDAQConfig.h:18
int getVersion() const
Definition: ODFEDAQConfig.h:24
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
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
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:29
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void setComment(std::string x)
Definition: ODFEDAQConfig.h:42
Statement * m_readStmt
Definition: IODConfig.h:34
std::string getConfigTag()
Definition: IODConfig.h:30
tuple cout
Definition: gather_cfg.py:144
void setTriggerBadXtId(int x)
Definition: ODFEDAQConfig.h:37
int ODFEDAQConfig::fetchID ( )
privatenoexcept

Definition at line 210 of file ODFEDAQConfig.cc.

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

210  {
211  // Return from memory if available
212  if (m_ID != 0) {
213  return m_ID;
214  }
215 
216  this->checkConnection();
217 
218  try {
219  Statement* stmt = m_conn->createStatement();
220  stmt->setSQL("SELECT config_id FROM " + getTable() + "WHERE tag=:1 and version=:2 ");
221 
222  stmt->setString(1, getConfigTag());
223  stmt->setInt(2, getVersion());
224 
225  ResultSet* rset = stmt->executeQuery();
226 
227  if (rset->next()) {
228  m_ID = rset->getInt(1);
229  } else {
230  m_ID = 0;
231  }
232  m_conn->terminateStatement(stmt);
233  } catch (SQLException& e) {
234  throw(std::runtime_error(std::string("ODFEDAQConfig::fetchID: ") + e.getMessage()));
235  }
236 
237  return m_ID;
238 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int getVersion() const
Definition: ODFEDAQConfig.h:24
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
Definition: ODFEDAQConfig.h:16
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
int ODFEDAQConfig::fetchNextId ( )
noexcept

Definition at line 54 of file ODFEDAQConfig.cc.

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

54  {
55  int result = 0;
56  try {
57  this->checkConnection();
58 
59  m_readStmt = m_conn->createStatement();
60  m_readStmt->setSQL("select fe_daq_conDfig_sq.nextVal from dual");
61  ResultSet* rset = m_readStmt->executeQuery();
62  while (rset->next()) {
63  result = rset->getInt(1);
64  }
65  m_conn->terminateStatement(m_readStmt);
66  return result;
67 
68  } catch (SQLException& e) {
69  throw(std::runtime_error(std::string("ODFEDAQConfig::fetchNextId(): ") + e.getMessage()));
70  }
71 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
tuple result
Definition: mps_fire.py:311
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
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:70
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 73 of file ODFEDAQConfig.cc.

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

73  {
74  this->checkConnection();
75  int next_id = fetchNextId();
76 
77  try {
78  m_writeStmt = m_conn->createStatement();
79  m_writeStmt->setSQL(
80  "INSERT INTO FE_DAQ_CONFIG ( config_id, tag, version, ped_id, "
81  " del_id, wei_id,bxt_id, btt_id, tr_bxt_id, tr_btt_id, user_comment ) "
82  "VALUES ( :1, :2, :3, :4, :5, :6, :7 ,:8, :9, :10, :11 )");
83 
84  m_writeStmt->setInt(1, next_id);
85  m_ID = next_id;
86 
87  } catch (SQLException& e) {
88  throw(std::runtime_error(std::string("ODFEDAQConfig::prepareWrite(): ") + e.getMessage()));
89  }
90 }
int fetchNextId() noexcept(false)
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
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.

Referenced by ConfigToolBase.ConfigToolBase::apply().

42 { m_com = x; }
std::string m_com
Definition: ODFEDAQConfig.h:70
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 92 of file ODFEDAQConfig.cc.

92  {
93  // parses the result of the XML parser that is a map of
94  // string string with variable name variable value
95 
96  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
97  if (ci->first == "VERSION")
98  setVersion(atoi(ci->second.c_str()));
99  if (ci->first == "PED_ID")
100  setPedestalId(atoi(ci->second.c_str()));
101  if (ci->first == "DEL_ID")
102  setDelayId(atoi(ci->second.c_str()));
103  if (ci->first == "WEI_ID")
104  setWeightId(atoi(ci->second.c_str()));
105 
106  if (ci->first == "BXT_ID")
107  setBadXtId(atoi(ci->second.c_str()));
108  if (ci->first == "BTT_ID")
109  setBadTTId(atoi(ci->second.c_str()));
110  if (ci->first == "TRIG_BXT_ID")
111  setTriggerBadXtId(atoi(ci->second.c_str()));
112  if (ci->first == "TRIG_BTT_ID")
113  setTriggerBadTTId(atoi(ci->second.c_str()));
114 
115  if (ci->first == "COMMENT" || ci->first == "USER_COMMENT")
116  setComment(ci->second);
117  }
118 }
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 gpuClustering::id, and m_version.

23 { m_version = id; }
uint16_t *__restrict__ id
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 120 of file ODFEDAQConfig.cc.

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

120  {
121  this->checkConnection();
122  this->checkPrepare();
123 
124  try {
125  // number 1 is the id
126  m_writeStmt->setString(2, this->getConfigTag());
127  m_writeStmt->setInt(3, this->getVersion());
128  SET_INT(m_writeStmt, 4, this->getPedestalId());
129  SET_INT(m_writeStmt, 5, this->getDelayId());
130  SET_INT(m_writeStmt, 6, this->getWeightId());
131  SET_INT(m_writeStmt, 7, this->getBadXtId());
132  SET_INT(m_writeStmt, 8, this->getBadTTId());
134  SET_INT(m_writeStmt, 10, this->getTriggerBadTTId());
135 
136  m_writeStmt->setString(11, this->getComment());
137 
138  m_writeStmt->executeUpdate();
139 
140  } catch (SQLException& e) {
141  throw(std::runtime_error(std::string("ODFEDAQConfig::writeDB(): ") + e.getMessage()));
142  }
143  // Now get the ID
144  if (!this->fetchID()) {
145  throw(std::runtime_error("ODFEDAQConfig::writeDB: Failed to write"));
146  }
147 }
int getTriggerBadXtId() const
Definition: ODFEDAQConfig.h:38
Statement * m_writeStmt
Definition: IODConfig.h:33
int getVersion() const
Definition: ODFEDAQConfig.h:24
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
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)
int getBadTTId() const
Definition: ODFEDAQConfig.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
int getWeightId() const
Definition: ODFEDAQConfig.h:31
std::string getComment() const
Definition: ODFEDAQConfig.h:43
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

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 66 of file ODFEDAQConfig.h.

Referenced by getBadTTId(), and setBadTTId().

int ODFEDAQConfig::m_bxt
private

Definition at line 65 of file ODFEDAQConfig.h.

Referenced by getBadXtId(), and setBadXtId().

std::string ODFEDAQConfig::m_com
private

Definition at line 70 of file ODFEDAQConfig.h.

Referenced by getComment(), and setComment().

int ODFEDAQConfig::m_del
private

Definition at line 62 of file ODFEDAQConfig.h.

Referenced by getDelayId(), and setDelayId().

int ODFEDAQConfig::m_ID
private

Definition at line 60 of file ODFEDAQConfig.h.

Referenced by getId(), and setId().

int ODFEDAQConfig::m_ped
private

Definition at line 61 of file ODFEDAQConfig.h.

Referenced by getPedestalId(), and setPedestalId().

int ODFEDAQConfig::m_tbtt
private

Definition at line 68 of file ODFEDAQConfig.h.

Referenced by getTriggerBadTTId(), and setTriggerBadTTId().

int ODFEDAQConfig::m_tbxt
private

Definition at line 67 of file ODFEDAQConfig.h.

Referenced by getTriggerBadXtId(), and setTriggerBadXtId().

int ODFEDAQConfig::m_version
private

Definition at line 69 of file ODFEDAQConfig.h.

Referenced by getVersion(), and setVersion().

int ODFEDAQConfig::m_wei
private

Definition at line 63 of file ODFEDAQConfig.h.

Referenced by getWeightId(), and setWeightId().