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
RunTag Class Reference

#include <RunTag.h>

Inheritance diagram for RunTag:
ITag IUniqueDBObject IDBObject

Public Member Functions

int fetchID () throw (std::runtime_error)
 
std::string getGeneralTag () const
 
LocationDef getLocationDef () const
 
RunTypeDef getRunTypeDef () const
 
bool operator!= (const RunTag &t) const
 
bool operator== (const RunTag &t) const
 
 RunTag ()
 
void setByID (int id) throw (std::runtime_error)
 
void setGeneralTag (std::string tag)
 
void setLocationDef (const LocationDef locDef)
 
void setRunTypeDef (const RunTypeDef runTypeDef)
 
 ~RunTag ()
 
- 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 fetchAllTags (std::vector< RunTag > *fillVec) throw (std::runtime_error)
 
void fetchParentIDs (int *locId, int *runTypeID) throw (std::runtime_error)
 
int writeDB () throw (std::runtime_error)
 

Private Attributes

std::string m_genTag
 
LocationDef m_locDef
 
RunTypeDef m_runTypeDef
 

Friends

class EcalCondDBInterface
 
class RunIOV
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Tag for Run information

Definition at line 13 of file RunTag.h.

Constructor & Destructor Documentation

RunTag::RunTag ( )

Definition at line 9 of file RunTag.cc.

References NULL.

10 {
11  m_env = NULL;
12  m_conn = NULL;
13  m_ID = 0;
14  m_genTag = "default";
17 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
RunTypeDef m_runTypeDef
Definition: RunTag.h:49
#define NULL
Definition: scimark2.h:8
LocationDef m_locDef
Definition: RunTag.h:48
std::string m_genTag
Definition: RunTag.h:47
RunTag::~RunTag ( )

Definition at line 21 of file RunTag.cc.

22 {
23 }

Member Function Documentation

void RunTag::fetchAllTags ( std::vector< RunTag > *  fillVec)
throw (std::runtime_error
)
private

Definition at line 204 of file RunTag.cc.

References alignCSCRings::e, setByID(), and IDBObject::setConnection().

206 {
207  this->checkConnection();
208  try {
209  Statement* stmt = m_conn->createStatement();
210  stmt->setSQL("SELECT tag_id FROM run_tag ORDER BY tag_id");
211  ResultSet* rset = stmt->executeQuery();
212 
213  RunTag runtag;
214  runtag.setConnection(m_env, m_conn);
215  while(rset->next()) {
216  runtag.setByID( rset->getInt(1) );
217  fillVec->push_back( runtag );
218  }
219  m_conn->terminateStatement(stmt);
220  } catch (SQLException &e) {
221  throw(std::runtime_error("RunTag::fetchAllTags: "+e.getMessage()));
222  }
223 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Definition: RunTag.h:13
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setByID(int id)
Definition: RunTag.cc:127
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
int RunTag::fetchID ( )
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 80 of file RunTag.cc.

References alignCSCRings::e.

82 {
83 
84 
85 
86  // Return tag from memory if available
87  if (m_ID) {
88  return m_ID;
89  }
90 
91 
92  this->checkConnection();
93 
94 
95  // fetch the parent IDs
96  int locID, runTypeID;
97  this->fetchParentIDs(&locID, &runTypeID);
98 
99  // fetch this ID
100  try {
101  Statement* stmt = m_conn->createStatement();
102  stmt->setSQL("SELECT tag_id FROM run_tag WHERE "
103  "gen_tag = :1 AND "
104  "location_id = :2 AND "
105  "run_type_id = :3");
106  stmt->setString(1, m_genTag);
107  stmt->setInt(2, locID);
108  stmt->setInt(3, runTypeID);
109 
110  ResultSet* rset = stmt->executeQuery();
111 
112  if (rset->next()) {
113  m_ID = rset->getInt(1);
114  } else {
115  m_ID = 0;
116  }
117  m_conn->terminateStatement(stmt);
118  } catch (SQLException &e) {
119  throw(std::runtime_error("RunTag::fetchID: "+e.getMessage()));
120  }
121 
122  return m_ID;
123 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void fetchParentIDs(int *locId, int *runTypeID)
Definition: RunTag.cc:227
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
std::string m_genTag
Definition: RunTag.h:47
void checkConnection() const
Definition: IDBObject.h:41
void RunTag::fetchParentIDs ( int *  locId,
int *  runTypeID 
)
throw (std::runtime_error
)
private

Definition at line 227 of file RunTag.cc.

229 {
230  // get the location
232  *locID = m_locDef.fetchID();
233 
234  // get the run type
236  *runTypeID = m_runTypeDef.fetchID();
237 
238 
239 
240  if (! *locID) {
241  throw(std::runtime_error("RunTag::fetchparentids: Given location does not exist in DB"));
242  }
243 
244  if (! *runTypeID) {
245  throw(std::runtime_error("RunTag::fetchParentIDs: Given run type does not exist in DB"));
246  }
247 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID()
Definition: RunTypeDef.cc:50
RunTypeDef m_runTypeDef
Definition: RunTag.h:49
LocationDef m_locDef
Definition: RunTag.h:48
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int fetchID()
Definition: LocationDef.cc:43
string RunTag::getGeneralTag ( ) const

Definition at line 27 of file RunTag.cc.

Referenced by EcalTPGDBApp::printTag().

28 {
29  return m_genTag;
30 }
std::string m_genTag
Definition: RunTag.h:47
LocationDef RunTag::getLocationDef ( ) const

Definition at line 46 of file RunTag.cc.

Referenced by EcalTPGDBApp::printTag(), and EcalErrorMask::readDB().

47 {
48  return m_locDef;
49 }
LocationDef m_locDef
Definition: RunTag.h:48
RunTypeDef RunTag::getRunTypeDef ( ) const

Definition at line 63 of file RunTag.cc.

Referenced by EcalTPGDBApp::printTag().

64 {
65  return m_runTypeDef;
66 }
RunTypeDef m_runTypeDef
Definition: RunTag.h:49
bool RunTag::operator!= ( const RunTag t) const
inline

Definition at line 43 of file RunTag.h.

References lumiQTWidget::t.

43 { return !(*this == t); }
bool RunTag::operator== ( const RunTag t) const
inline

Definition at line 36 of file RunTag.h.

References m_genTag, m_locDef, and m_runTypeDef.

37  {
38  return (m_genTag == t.m_genTag &&
39  m_locDef == t.m_locDef &&
41  }
RunTypeDef m_runTypeDef
Definition: RunTag.h:49
LocationDef m_locDef
Definition: RunTag.h:48
std::string m_genTag
Definition: RunTag.h:47
void RunTag::setByID ( int  id)
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 127 of file RunTag.cc.

References alignCSCRings::e, and errorMatrix2Lands_multiChannel::id.

Referenced by fetchAllTags().

129 {
130  this->checkConnection();
131 
132  try {
133  Statement* stmt = m_conn->createStatement();
134 
135  stmt->setSQL("SELECT gen_tag, location_id, run_type_id FROM run_tag WHERE tag_id = :1");
136  stmt->setInt(1, id);
137 
138  ResultSet* rset = stmt->executeQuery();
139  if (rset->next()) {
140  m_genTag = rset->getString(1);
141  int locID = rset->getInt(2);
142  int runTypeID = rset->getInt(3);
143 
145  m_locDef.setByID(locID);
146 
148  m_runTypeDef.setByID(runTypeID);
149 
150  m_ID = id;
151  } else {
152  throw(std::runtime_error("RunTag::setByID: Given tag_id is not in the database"));
153  }
154 
155  m_conn->terminateStatement(stmt);
156  } catch (SQLException &e) {
157  throw(std::runtime_error("RunTag::setByID: "+e.getMessage()));
158  }
159 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
RunTypeDef m_runTypeDef
Definition: RunTag.h:49
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
LocationDef m_locDef
Definition: RunTag.h:48
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setByID(int id)
Definition: RunTypeDef.cc:84
std::string m_genTag
Definition: RunTag.h:47
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setByID(int id)
Definition: LocationDef.cc:76
void checkConnection() const
Definition: IDBObject.h:41
void RunTag::setGeneralTag ( std::string  tag)
void RunTag::setLocationDef ( const LocationDef  locDef)

Definition at line 53 of file RunTag.cc.

Referenced by EcalBarrelMonitorClient::beginRunDb(), EcalEndcapMonitorClient::beginRunDb(), RunList::fetchGlobalRunsByLocation(), RunList::fetchRunsByLocation(), popcon::EcalSRPHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGBadStripHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), popcon::EcalTPGLutGroupHandler::getNewObjects(), popcon::EcalTPGSpikeThresholdHandler::getNewObjects(), popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().

54 {
55  if (locDef != m_locDef) {
56  m_ID = 0;
57  m_locDef = locDef;
58  }
59 }
LocationDef m_locDef
Definition: RunTag.h:48
void RunTag::setRunTypeDef ( const RunTypeDef  runTypeDef)
int RunTag::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 162 of file RunTag.cc.

References alignCSCRings::e.

164 {
165  // see if this data is already in the DB
166  if (this->fetchID()) {
167  return m_ID;
168  }
169 
170  // check the connectioin
171  this->checkConnection();
172 
173  // fetch the parent IDs
174  int locID, runTypeID;
175  this->fetchParentIDs(&locID, &runTypeID);
176 
177  // write new tag to the DB
178  try {
179  Statement* stmt = m_conn->createStatement();
180 
181  stmt->setSQL("INSERT INTO run_tag (tag_id, gen_tag, location_id, run_type_id) "
182  "VALUES (run_tag_sq.NextVal, :1, :2, :3)");
183  stmt->setString(1, m_genTag);
184  stmt->setInt(2, locID);
185  stmt->setInt(3, runTypeID);
186 
187  stmt->executeUpdate();
188 
189  m_conn->terminateStatement(stmt);
190  } catch (SQLException &e) {
191  throw(std::runtime_error("RunTag::writeDB: "+e.getMessage()));
192  }
193 
194  // now get the tag_id
195  if (!this->fetchID()) {
196  throw(std::runtime_error("RunTag::writeDB: Failed to write"));
197  }
198 
199  return m_ID;
200 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void fetchParentIDs(int *locId, int *runTypeID)
Definition: RunTag.cc:227
int fetchID()
Definition: RunTag.cc:80
std::string m_genTag
Definition: RunTag.h:47
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 16 of file RunTag.h.

friend class RunIOV
friend

Definition at line 15 of file RunTag.h.

Member Data Documentation

std::string RunTag::m_genTag
private

Definition at line 47 of file RunTag.h.

Referenced by operator==().

LocationDef RunTag::m_locDef
private

Definition at line 48 of file RunTag.h.

Referenced by operator==().

RunTypeDef RunTag::m_runTypeDef
private

Definition at line 49 of file RunTag.h.

Referenced by operator==().