CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODLTSConfig Class Reference

#include <ODLTSConfig.h>

Inheritance diagram for ODLTSConfig:
IODConfig IDBObject

Public Member Functions

int getId () const
 
int getNumberOfEvents () const
 
int getRate () const
 
std::string getTable () override
 
std::string getTriggerType () const
 
int getTrigLocL1Delay () const
 
 ODLTSConfig ()
 
void setId (int id)
 
void setNumberOfEvents (int x)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setRate (int x)
 
void setTriggerType (std::string x)
 
void setTrigLocL1Delay (int x)
 
 ~ODLTSConfig () 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 (ODLTSConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

int m_delay
 
int m_ID
 
int m_num
 
int m_rate
 
std::string m_trg_type
 

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 const int 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 ODLTSConfig.h.

Constructor & Destructor Documentation

◆ ODLTSConfig()

ODLTSConfig::ODLTSConfig ( )

Definition at line 11 of file ODLTSConfig.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16  m_config_tag = "";
17  m_ID = 0;
18  clear();
19 }

References clear().

◆ ~ODLTSConfig()

ODLTSConfig::~ODLTSConfig ( )
override

Definition at line 28 of file ODLTSConfig.cc.

28 {}

Member Function Documentation

◆ clear()

void ODLTSConfig::clear ( void  )
private

Definition at line 21 of file ODLTSConfig.cc.

21  {
22  m_trg_type = "";
23  m_num = 0;
24  m_rate = 0;
25  m_delay = 0;
26 }

◆ fetchData()

void ODLTSConfig::fetchData ( ODLTSConfig result)
privatenoexcept

Definition at line 108 of file ODLTSConfig.cc.

108  {
109  this->checkConnection();
110  result->clear();
111  if (result->getId() == 0 && (result->getConfigTag().empty())) {
112  throw(std::runtime_error("ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
113  }
114 
115  try {
116  m_readStmt->setSQL(
117  "SELECT * "
118  "FROM ECAL_LTS_CONFIGURATION "
119  " where ( lts_configuration_id = :1 or lts_tag=:2 ) ");
120  m_readStmt->setInt(1, result->getId());
121  m_readStmt->setString(2, result->getConfigTag());
122  ResultSet* rset = m_readStmt->executeQuery();
123 
124  rset->next();
125  // 1 is the id and 2 is the config tag
126  result->setId(rset->getInt(1));
127  result->setConfigTag(rset->getString(2));
128 
129  result->setTriggerType(rset->getString(3));
130  result->setNumberOfEvents(rset->getInt(4));
131  result->setRate(rset->getInt(5));
132  result->setTrigLocL1Delay(rset->getInt(6));
133 
134  } catch (SQLException& e) {
135  throw(std::runtime_error(std::string("ODLTSConfig::fetchData(): ") + e.getMessage()));
136  }
137 }

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

◆ fetchID()

int ODLTSConfig::fetchID ( )
privatenoexcept

Definition at line 139 of file ODLTSConfig.cc.

139  {
140  // Return from memory if available
141  if (m_ID != 0) {
142  return m_ID;
143  }
144 
145  this->checkConnection();
146 
147  try {
148  Statement* stmt = m_conn->createStatement();
149  stmt->setSQL(
150  "SELECT lts_configuration_id FROM ecal_lts_configuration "
151  "WHERE lts_tag=:lts_tag ");
152 
153  stmt->setString(1, getConfigTag());
154 
155  ResultSet* rset = stmt->executeQuery();
156 
157  if (rset->next()) {
158  m_ID = rset->getInt(1);
159  } else {
160  m_ID = 0;
161  }
162  m_conn->terminateStatement(stmt);
163  } catch (SQLException& e) {
164  throw(std::runtime_error(std::string("ODLTSConfig::fetchID: ") + e.getMessage()));
165  }
166 
167  return m_ID;
168 }

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

◆ fetchNextId()

int ODLTSConfig::fetchNextId ( )
privatenoexcept

Definition at line 48 of file ODLTSConfig.cc.

48  {
49  int result = 0;
50  try {
51  this->checkConnection();
52 
53  m_readStmt = m_conn->createStatement();
54  m_readStmt->setSQL("select ecal_lts_config_sq.NextVal from dual");
55  ResultSet* rset = m_readStmt->executeQuery();
56  while (rset->next()) {
57  result = rset->getInt(1);
58  }
59  m_conn->terminateStatement(m_readStmt);
60  return result;
61 
62  } catch (SQLException& e) {
63  throw(std::runtime_error(std::string("ODLTSConfig::fetchNextId(): ") + e.getMessage()));
64  }
65 }

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

◆ getId()

int ODLTSConfig::getId ( void  ) const
inline

Definition at line 19 of file ODLTSConfig.h.

19 { return m_ID; }

References m_ID.

◆ getNumberOfEvents()

int ODLTSConfig::getNumberOfEvents ( ) const
inline

Definition at line 25 of file ODLTSConfig.h.

25 { return m_num; }

References m_num.

◆ getRate()

int ODLTSConfig::getRate ( ) const
inline

Definition at line 28 of file ODLTSConfig.h.

28 { return m_rate; }

References m_rate.

◆ getTable()

std::string ODLTSConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODLTSConfig.h.

16 { return "ECAL_LTS_CONFIGURATION"; }

◆ getTriggerType()

std::string ODLTSConfig::getTriggerType ( ) const
inline

Definition at line 22 of file ODLTSConfig.h.

22 { return m_trg_type; }

References m_trg_type.

◆ getTrigLocL1Delay()

int ODLTSConfig::getTrigLocL1Delay ( ) const
inline

Definition at line 31 of file ODLTSConfig.h.

31 { return m_delay; }

References m_delay.

◆ prepareWrite()

void ODLTSConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 67 of file ODLTSConfig.cc.

67  {
68  this->checkConnection();
69  int next_id = fetchNextId();
70 
71  try {
72  m_writeStmt = m_conn->createStatement();
73  m_writeStmt->setSQL(
74  "INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, "
75  "trigger_type, num_of_events, rate, trig_loc_l1_delay ) "
76  "VALUES ( "
77  ":1, :2, :3, :4 , :5, :6 )");
78  m_writeStmt->setInt(1, next_id);
79  m_ID = next_id;
80 
81  } catch (SQLException& e) {
82  throw(std::runtime_error(std::string("ODLTSConfig::prepareWrite(): ") + e.getMessage()));
83  }
84 }

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

◆ setId()

void ODLTSConfig::setId ( int  id)
inline

Definition at line 18 of file ODLTSConfig.h.

18 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

◆ setNumberOfEvents()

void ODLTSConfig::setNumberOfEvents ( int  x)
inline

Definition at line 24 of file ODLTSConfig.h.

24 { m_num = x; }

References m_num, and x.

◆ setParameters()

void ODLTSConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 30 of file ODLTSConfig.cc.

30  {
31  // parses the result of the XML parser that is a map of
32  // string string with variable name variable value
33 
34  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
35  if (ci->first == "LTS_CONFIGURATION_ID")
36  setConfigTag(ci->second);
37  if (ci->first == "NUM_OF_EVENTS")
38  setNumberOfEvents(atoi(ci->second.c_str()));
39  if (ci->first == "RATE")
40  setRate(atoi(ci->second.c_str()));
41  if (ci->first == "TRIGGER_TYPE")
42  setTriggerType(ci->second);
43  if (ci->first == "TRIG_LOC_L1_DELAY")
44  setTrigLocL1Delay(atoi(ci->second.c_str()));
45  }
46 }

◆ setRate()

void ODLTSConfig::setRate ( int  x)
inline

Definition at line 27 of file ODLTSConfig.h.

27 { m_rate = x; }

References m_rate, and x.

◆ setTriggerType()

void ODLTSConfig::setTriggerType ( std::string  x)
inline

Definition at line 21 of file ODLTSConfig.h.

21 { m_trg_type = x; }

References m_trg_type, and x.

◆ setTrigLocL1Delay()

void ODLTSConfig::setTrigLocL1Delay ( int  x)
inline

Definition at line 30 of file ODLTSConfig.h.

30 { m_delay = x; }

References m_delay, and x.

◆ writeDB()

void ODLTSConfig::writeDB ( )
privatenoexcept

Definition at line 86 of file ODLTSConfig.cc.

86  {
87  this->checkConnection();
88  this->checkPrepare();
89 
90  try {
91  m_writeStmt->setString(2, this->getConfigTag());
92  m_writeStmt->setString(3, this->getTriggerType());
93  m_writeStmt->setInt(4, this->getNumberOfEvents());
94  m_writeStmt->setInt(5, this->getRate());
95  m_writeStmt->setInt(6, this->getTrigLocL1Delay());
96 
97  m_writeStmt->executeUpdate();
98 
99  } catch (SQLException& e) {
100  throw(std::runtime_error(std::string("ODLTSConfig::writeDB(): ") + e.getMessage()));
101  }
102  // Now get the ID
103  if (!this->fetchID()) {
104  throw(std::runtime_error("ODLTSConfig::writeDB: Failed to write"));
105  }
106 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODLTSConfig.h.

Member Data Documentation

◆ m_delay

int ODLTSConfig::m_delay
private

Definition at line 47 of file ODLTSConfig.h.

Referenced by getTrigLocL1Delay(), and setTrigLocL1Delay().

◆ m_ID

int ODLTSConfig::m_ID
private

Definition at line 43 of file ODLTSConfig.h.

Referenced by getId(), and setId().

◆ m_num

int ODLTSConfig::m_num
private

Definition at line 45 of file ODLTSConfig.h.

Referenced by getNumberOfEvents(), and setNumberOfEvents().

◆ m_rate

int ODLTSConfig::m_rate
private

Definition at line 46 of file ODLTSConfig.h.

Referenced by getRate(), and setRate().

◆ m_trg_type

std::string ODLTSConfig::m_trg_type
private

Definition at line 44 of file ODLTSConfig.h.

Referenced by getTriggerType(), and setTriggerType().

ODLTSConfig::m_delay
int m_delay
Definition: ODLTSConfig.h:47
ODLTSConfig::clear
void clear()
Definition: ODLTSConfig.cc:21
ODLTSConfig::setTriggerType
void setTriggerType(std::string x)
Definition: ODLTSConfig.h:21
ODLTSConfig::getRate
int getRate() const
Definition: ODLTSConfig.h:28
ODLTSConfig::setNumberOfEvents
void setNumberOfEvents(int x)
Definition: ODLTSConfig.h:24
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
ODLTSConfig::setRate
void setRate(int x)
Definition: ODLTSConfig.h:27
ODLTSConfig::m_rate
int m_rate
Definition: ODLTSConfig.h:46
DDAxes::x
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
ODLTSConfig::m_num
int m_num
Definition: ODLTSConfig.h:45
ODLTSConfig::getTrigLocL1Delay
int getTrigLocL1Delay() const
Definition: ODLTSConfig.h:31
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
ODLTSConfig::getNumberOfEvents
int getNumberOfEvents() const
Definition: ODLTSConfig.h:25
IODConfig::checkPrepare
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
ODLTSConfig::fetchNextId
int fetchNextId() noexcept(false)
Definition: ODLTSConfig.cc:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IODConfig::getConfigTag
std::string getConfigTag()
Definition: IODConfig.h:30
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
IODConfig::m_readStmt
Statement * m_readStmt
Definition: IODConfig.h:34
ODLTSConfig::setTrigLocL1Delay
void setTrigLocL1Delay(int x)
Definition: ODLTSConfig.h:30
ODLTSConfig::fetchID
int fetchID() noexcept(false)
Definition: ODLTSConfig.cc:139
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
ODLTSConfig::getTriggerType
std::string getTriggerType() const
Definition: ODLTSConfig.h:22
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
IODConfig::m_config_tag
std::string m_config_tag
Definition: IODConfig.h:25
ODLTSConfig::m_ID
int m_ID
Definition: ODLTSConfig.h:43
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
mps_fire.result
result
Definition: mps_fire.py:303
IODConfig::setConfigTag
void setConfigTag(std::string x)
Definition: IODConfig.h:29
ODLTSConfig::m_trg_type
std::string m_trg_type
Definition: ODLTSConfig.h:44
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37