CMS 3D CMS Logo

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

#include <ODRunConfigSeqInfo.h>

Inheritance diagram for ODRunConfigSeqInfo:
IODConfig IDBObject

Public Member Functions

std::string getDescription () const
 
int getEcalConfigId () const
 
int getId () const
 
int getNumberOfCycles () const
 
RunSeqDef getRunSeqDef () const
 
int getSequenceId () const
 
int getSequenceNumber () const
 
std::string getTable () override
 
 ODRunConfigSeqInfo ()
 
bool operator!= (const ODRunConfigSeqInfo &r) const
 
bool operator== (const ODRunConfigSeqInfo &r) const
 
void setDescription (std::string x)
 
void setEcalConfigId (int x)
 
void setId (int id)
 
void setNumberOfCycles (int x)
 
void setRunSeqDef (const RunSeqDef &runSeqDef)
 
void setSequenceId (int x)
 
void setSequenceNumber (int x)
 
 ~ODRunConfigSeqInfo () 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 (ODRunConfigSeqInfo *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchIDLast () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void setByID (int id) noexcept(false)
 
void writeDB () noexcept(false)
 

Private Attributes

int m_cycles
 
std::string m_description
 
int m_ecal_config_id
 
int m_ID
 
RunSeqDef m_run_seq
 
int m_seq_num
 
int m_sequence_id
 

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 15 of file ODRunConfigSeqInfo.h.

Constructor & Destructor Documentation

◆ ODRunConfigSeqInfo()

ODRunConfigSeqInfo::ODRunConfigSeqInfo ( )

Definition at line 11 of file ODRunConfigSeqInfo.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_ID = 0;
18  //
19  m_ecal_config_id = 0;
20  m_seq_num = 0;
21  m_cycles = 0;
22  m_run_seq = RunSeqDef();
23  m_description = "";
24 }

◆ ~ODRunConfigSeqInfo()

ODRunConfigSeqInfo::~ODRunConfigSeqInfo ( )
override

Definition at line 26 of file ODRunConfigSeqInfo.cc.

26 {}

Member Function Documentation

◆ clear()

void ODRunConfigSeqInfo::clear ( void  )
private

Definition at line 172 of file ODRunConfigSeqInfo.cc.

172  {
173  // m_ecal_config_id =0;
174  // m_seq_num =0;
175  m_ID = 0;
176  m_cycles = 0;
177  m_run_seq = RunSeqDef();
178  m_description = "";
179 }

◆ fetchData()

void ODRunConfigSeqInfo::fetchData ( ODRunConfigSeqInfo result)
privatenoexcept

Definition at line 181 of file ODRunConfigSeqInfo.cc.

181  {
182  this->checkConnection();
183  // result->clear();
184  if (result->getId() == 0) {
185  // throw(std::runtime_error("ODRunConfigSeqInfo::fetchData(): no Id defined for this record "));
186  result->fetchID();
187  }
188 
189  try {
190  m_readStmt->setSQL(
191  "SELECT ecal_config_id, sequence_num, num_of_cycles, "
192  "sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
193 
194  m_readStmt->setInt(1, result->getId());
195  ResultSet* rset = m_readStmt->executeQuery();
196 
197  rset->next();
198 
199  result->setEcalConfigId(rset->getInt(1));
200  result->setSequenceNumber(rset->getInt(2));
201  result->setNumberOfCycles(rset->getInt(3));
202  int seq_def_id = rset->getInt(4);
203 
205  m_run_seq.setByID(seq_def_id);
206  result->setDescription(rset->getString(5));
207 
208  } catch (SQLException& e) {
209  throw(std::runtime_error("ODRunConfigSeqInfo::fetchData(): " + e.getMessage()));
210  }
211 }

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

◆ fetchID()

int ODRunConfigSeqInfo::fetchID ( )
privatenoexcept

Definition at line 37 of file ODRunConfigSeqInfo.cc.

37  {
38  // Return from memory if available
39  if (m_ID > 0) {
40  return m_ID;
41  }
42 
43  this->checkConnection();
44 
46 
47  try {
48  Statement* stmt = m_conn->createStatement();
49  stmt->setSQL(
50  "SELECT sequence_id from ECAL_sequence_DAT "
51  "WHERE ecal_config_id = :id1 "
52  " and sequence_num = :id2 ");
53  stmt->setInt(1, m_ecal_config_id);
54  stmt->setInt(2, m_seq_num);
55 
56  ResultSet* rset = stmt->executeQuery();
57 
58  if (rset->next()) {
59  m_ID = rset->getInt(1);
60  } else {
61  m_ID = 0;
62  }
63  m_conn->terminateStatement(stmt);
64  } catch (SQLException& e) {
65  throw(std::runtime_error("ODRunConfigSeqInfo::fetchID: " + e.getMessage()));
66  }
67  setByID(m_ID);
68  return m_ID;
69 }

References cuy::dh, and MillePedeFileConverter_cfg::e.

◆ fetchIDLast()

int ODRunConfigSeqInfo::fetchIDLast ( )
privatenoexcept

Definition at line 71 of file ODRunConfigSeqInfo.cc.

71  {
72  this->checkConnection();
73 
75 
76  try {
77  Statement* stmt = m_conn->createStatement();
78  stmt->setSQL("SELECT max(sequence_id) FROM ecal_sequence_dat ");
79  ResultSet* rset = stmt->executeQuery();
80 
81  if (rset->next()) {
82  m_ID = rset->getInt(1);
83  } else {
84  m_ID = 0;
85  }
86  m_conn->terminateStatement(stmt);
87  } catch (SQLException& e) {
88  throw(std::runtime_error("ODRunConfigSeqInfo::fetchIDLast: " + e.getMessage()));
89  }
90 
91  setByID(m_ID);
92  return m_ID;
93 }

References cuy::dh, and MillePedeFileConverter_cfg::e.

◆ getDescription()

std::string ODRunConfigSeqInfo::getDescription ( ) const
inline

Definition at line 30 of file ODRunConfigSeqInfo.h.

30 { return m_description; }

References m_description.

◆ getEcalConfigId()

int ODRunConfigSeqInfo::getEcalConfigId ( ) const
inline

Definition at line 32 of file ODRunConfigSeqInfo.h.

32 { return m_ecal_config_id; }

References m_ecal_config_id.

◆ getId()

int ODRunConfigSeqInfo::getId ( void  ) const
inline

Definition at line 27 of file ODRunConfigSeqInfo.h.

27 { return m_ID; }

References m_ID.

◆ getNumberOfCycles()

int ODRunConfigSeqInfo::getNumberOfCycles ( ) const
inline

Definition at line 36 of file ODRunConfigSeqInfo.h.

36 { return m_cycles; }

References m_cycles.

◆ getRunSeqDef()

RunSeqDef ODRunConfigSeqInfo::getRunSeqDef ( ) const

Definition at line 29 of file ODRunConfigSeqInfo.cc.

29 { return m_run_seq; }

◆ getSequenceId()

int ODRunConfigSeqInfo::getSequenceId ( ) const
inline

Definition at line 35 of file ODRunConfigSeqInfo.h.

35 { return m_ID; }

References m_ID.

◆ getSequenceNumber()

int ODRunConfigSeqInfo::getSequenceNumber ( ) const
inline

Definition at line 38 of file ODRunConfigSeqInfo.h.

38 { return m_seq_num; }

References m_seq_num.

◆ getTable()

std::string ODRunConfigSeqInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODRunConfigSeqInfo.h.

22 { return "ECAL_SEQUENCE_DAT"; }

◆ operator!=()

bool ODRunConfigSeqInfo::operator!= ( const ODRunConfigSeqInfo r) const
inline

Definition at line 45 of file ODRunConfigSeqInfo.h.

45 { return !(*this == r); }

References alignCSCRings::r.

◆ operator==()

bool ODRunConfigSeqInfo::operator== ( const ODRunConfigSeqInfo r) const
inline

Definition at line 44 of file ODRunConfigSeqInfo.h.

44 { return (m_ID == r.m_ID); }

References m_ID, and alignCSCRings::r.

◆ prepareWrite()

void ODRunConfigSeqInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 129 of file ODRunConfigSeqInfo.cc.

129  {
130  this->checkConnection();
131 
132  try {
133  m_writeStmt = m_conn->createStatement();
134  m_writeStmt->setSQL(
135  "INSERT INTO ECAL_SEQUENCE_DAT ( ecal_config_id, "
136  "sequence_num, num_of_cycles, sequence_type_def_id, description ) "
137  "VALUES (:1, :2, :3 , :4, :5 )");
138  } catch (SQLException& e) {
139  throw(std::runtime_error("ODRunConfigSeqInfo::prepareWrite(): " + e.getMessage()));
140  }
141 }

References MillePedeFileConverter_cfg::e.

◆ setByID()

void ODRunConfigSeqInfo::setByID ( int  id)
privatenoexcept

Definition at line 95 of file ODRunConfigSeqInfo.cc.

95  {
96  this->checkConnection();
97 
99 
100  cout << "ODRunConfigSeqInfo::setByID called for id " << id << endl;
101 
102  try {
103  Statement* stmt = m_conn->createStatement();
104 
105  stmt->setSQL(
106  "SELECT ecal_config_id, sequence_num, num_of_cycles, sequence_type_def_id, description FROM ECAL_sequence_DAT "
107  "WHERE sequence_id = :1 ");
108  stmt->setInt(1, id);
109 
110  ResultSet* rset = stmt->executeQuery();
111  if (rset->next()) {
112  m_ecal_config_id = rset->getInt(1);
113  m_seq_num = rset->getInt(2);
114  m_cycles = rset->getInt(3);
115  int seq_def_id = rset->getInt(4);
116  m_description = rset->getString(5);
117  m_ID = id;
119  m_run_seq.setByID(seq_def_id);
120  } else {
121  throw(std::runtime_error("ODRunConfigSeqInfo::setByID: Given config_id is not in the database"));
122  }
123  m_conn->terminateStatement(stmt);
124  } catch (SQLException& e) {
125  throw(std::runtime_error("ODRunConfigSeqInfo::setByID: " + e.getMessage()));
126  }
127 }

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, and triggerObjects_cff::id.

◆ setDescription()

void ODRunConfigSeqInfo::setDescription ( std::string  x)
inline

Definition at line 29 of file ODRunConfigSeqInfo.h.

29 { m_description = x; }

References m_description, and x.

◆ setEcalConfigId()

void ODRunConfigSeqInfo::setEcalConfigId ( int  x)
inline

Definition at line 31 of file ODRunConfigSeqInfo.h.

31 { m_ecal_config_id = x; }

References m_ecal_config_id, and x.

◆ setId()

void ODRunConfigSeqInfo::setId ( int  id)
inline

Definition at line 26 of file ODRunConfigSeqInfo.h.

26 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

◆ setNumberOfCycles()

void ODRunConfigSeqInfo::setNumberOfCycles ( int  x)
inline

Definition at line 33 of file ODRunConfigSeqInfo.h.

33 { m_cycles = x; }

References m_cycles, and x.

◆ setRunSeqDef()

void ODRunConfigSeqInfo::setRunSeqDef ( const RunSeqDef runSeqDef)

Definition at line 30 of file ODRunConfigSeqInfo.cc.

30  {
31  if (run_seq != m_run_seq) {
32  m_run_seq = run_seq;
33  }
34 }

◆ setSequenceId()

void ODRunConfigSeqInfo::setSequenceId ( int  x)
inline

Definition at line 34 of file ODRunConfigSeqInfo.h.

34 { m_ID = x; }

References m_ID, and x.

◆ setSequenceNumber()

void ODRunConfigSeqInfo::setSequenceNumber ( int  x)
inline

Definition at line 37 of file ODRunConfigSeqInfo.h.

37 { m_seq_num = x; }

References m_seq_num, and x.

◆ writeDB()

void ODRunConfigSeqInfo::writeDB ( )
privatenoexcept

Definition at line 142 of file ODRunConfigSeqInfo.cc.

142  {
143  this->checkConnection();
144  this->checkPrepare();
145 
146  // Validate the data, use infinity-till convention
148 
149  try {
150  // get the run mode
151 
153  int seq_def_id = m_run_seq.writeDB();
154 
155  m_writeStmt->setInt(1, this->getEcalConfigId());
156  m_writeStmt->setInt(2, this->getSequenceNumber());
157  m_writeStmt->setInt(3, this->getNumberOfCycles());
158  m_writeStmt->setInt(4, seq_def_id);
159  m_writeStmt->setString(5, this->getDescription());
160 
161  m_writeStmt->executeUpdate();
162 
163  } catch (SQLException& e) {
164  throw(std::runtime_error("ODRunConfigSeqInfo::writeDB(): " + e.getMessage()));
165  }
166  if (!this->fetchID()) {
167  throw(std::runtime_error("ODRunConfigSeqInfo::writeDB: Failed to write"));
168  }
169  cout << "ODRunConfigSeqInfo::writeDB>> done inserting ODRunConfigSeqInfo with id=" << m_ID << endl;
170 }

References gather_cfg::cout, cuy::dh, and MillePedeFileConverter_cfg::e.

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODRunConfigSeqInfo.h.

Member Data Documentation

◆ m_cycles

int ODRunConfigSeqInfo::m_cycles
private

Definition at line 52 of file ODRunConfigSeqInfo.h.

Referenced by getNumberOfCycles(), and setNumberOfCycles().

◆ m_description

std::string ODRunConfigSeqInfo::m_description
private

Definition at line 54 of file ODRunConfigSeqInfo.h.

Referenced by getDescription(), and setDescription().

◆ m_ecal_config_id

int ODRunConfigSeqInfo::m_ecal_config_id
private

Definition at line 49 of file ODRunConfigSeqInfo.h.

Referenced by getEcalConfigId(), and setEcalConfigId().

◆ m_ID

int ODRunConfigSeqInfo::m_ID
private

Definition at line 48 of file ODRunConfigSeqInfo.h.

Referenced by getId(), getSequenceId(), operator==(), setId(), and setSequenceId().

◆ m_run_seq

RunSeqDef ODRunConfigSeqInfo::m_run_seq
private

Definition at line 53 of file ODRunConfigSeqInfo.h.

◆ m_seq_num

int ODRunConfigSeqInfo::m_seq_num
private

Definition at line 50 of file ODRunConfigSeqInfo.h.

Referenced by getSequenceNumber(), and setSequenceNumber().

◆ m_sequence_id

int ODRunConfigSeqInfo::m_sequence_id
private

Definition at line 51 of file ODRunConfigSeqInfo.h.

RunSeqDef::setByID
void setByID(int id) noexcept(false) override
Definition: RunSeqDef.cc:63
ODRunConfigSeqInfo::m_cycles
int m_cycles
Definition: ODRunConfigSeqInfo.h:52
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDAxes::x
ODRunConfigSeqInfo::getSequenceNumber
int getSequenceNumber() const
Definition: ODRunConfigSeqInfo.h:38
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
ODRunConfigSeqInfo::m_ecal_config_id
int m_ecal_config_id
Definition: ODRunConfigSeqInfo.h:49
RunSeqDef::writeDB
int writeDB() noexcept(false)
Definition: RunSeqDef.cc:110
IODConfig::checkPrepare
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
RunSeqDef
Definition: RunSeqDef.h:13
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
IODConfig::m_readStmt
Statement * m_readStmt
Definition: IODConfig.h:34
ODRunConfigSeqInfo::m_seq_num
int m_seq_num
Definition: ODRunConfigSeqInfo.h:50
alignCSCRings.r
r
Definition: alignCSCRings.py:93
ODRunConfigSeqInfo::getNumberOfCycles
int getNumberOfCycles() const
Definition: ODRunConfigSeqInfo.h:36
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ODRunConfigSeqInfo::getEcalConfigId
int getEcalConfigId() const
Definition: ODRunConfigSeqInfo.h:32
ODRunConfigSeqInfo::m_description
std::string m_description
Definition: ODRunConfigSeqInfo.h:54
ODRunConfigSeqInfo::m_ID
int m_ID
Definition: ODRunConfigSeqInfo.h:48
ODRunConfigSeqInfo::m_run_seq
RunSeqDef m_run_seq
Definition: ODRunConfigSeqInfo.h:53
ODRunConfigSeqInfo::setByID
void setByID(int id) noexcept(false)
Definition: ODRunConfigSeqInfo.cc:95
ODRunConfigSeqInfo::fetchID
int fetchID() noexcept(false)
Definition: ODRunConfigSeqInfo.cc:37
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
mps_fire.result
result
Definition: mps_fire.py:311
ODRunConfigSeqInfo::getDescription
std::string getDescription() const
Definition: ODRunConfigSeqInfo.h:30
DateHandler
Definition: DateHandler.h:7
cuy.dh
dh
Definition: cuy.py:355
ODRunConfigSeqInfo::getId
int getId() const
Definition: ODRunConfigSeqInfo.h:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37