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

#include <LMFLmrSubIOV.h>

Inheritance diagram for LMFLmrSubIOV:
LMFUnique IUniqueDBObject IDBObject

Public Member Functions

std::list< LMFLmrSubIOVfetchByLMFIOV (const LMFIOV &iov)
 
std::list< int > getIOVIDsLaterThan (const Tm &t) throw (std::runtime_error)
 
std::list< int > getIOVIDsLaterThan (const Tm &tmin, const Tm &tmax) throw (std::runtime_error)
 
std::list< int > getIOVIDsLaterThan (const Tm &t, int howMany) throw (std::runtime_error)
 
std::list< int > getIOVIDsLaterThan (const Tm &t, const Tm &tmax, int howMany) throw (std::runtime_error)
 
LMFIOV getLMFIOV () const
 
int getLMFIOVID () const
 
Tm getT1 ()
 
Tm getT2 ()
 
Tm getT3 ()
 
Tm getTime (int i)
 
void getTimes (Tm *t1, Tm *t2, Tm *t3) const
 
std::vector< TmgetTimes () const
 
void getTimes (Tm *t) const
 
 LMFLmrSubIOV ()
 
 LMFLmrSubIOV (EcalDBConnection *c)
 
 LMFLmrSubIOV (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
bool operator!= (const LMFLmrSubIOV &m) const
 
bool operator== (const LMFLmrSubIOV &m) const
 
LMFLmrSubIOVsetLMFIOV (const LMFIOV &iov)
 
LMFLmrSubIOVsetLMFIOV (int i)
 
LMFLmrSubIOVsetTimes (const Tm &t1, const Tm &t2, const Tm &t3)
 
LMFLmrSubIOVsetTimes (const std::vector< Tm > &t)
 
LMFLmrSubIOVsetTimes (Tm *t)
 
 ~LMFLmrSubIOV ()
 
- Public Member Functions inherited from LMFUnique
void attach (std::string name, LMFUnique *u)
 
void debug ()
 
virtual void dump () const
 
virtual void dump (int n) const
 
virtual bool exists ()
 
virtual boost::ptr_list
< LMFUnique
fetchAll () const throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
std::string getClassName ()
 
std::string getClassName () const
 
int getID () const
 
int getInt (std::string fieldname) const
 
std::string getString (std::string fieldname) const
 
virtual bool isValid () const
 
virtual bool isValid ()
 
 LMFUnique ()
 
 LMFUnique (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
 LMFUnique (EcalDBConnection *c)
 
void nodebug ()
 
virtual bool operator< (const LMFUnique &r)
 
virtual bool operator<= (const LMFUnique &r)
 
std::string sequencePostfix (const Tm &t)
 
void setByID (int id) throw (std::runtime_error)
 
LMFUniquesetInt (std::string key, int value)
 
LMFUniquesetString (std::string key, std::string value)
 
void startProfiling ()
 
void stopProfiling ()
 
virtual ~LMFUnique ()
 
- 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

std::string fetchIdSql (Statement *stmt)
 
void getParameters (ResultSet *rset)
 
void init ()
 
std::string setByIDSql (Statement *stmt, int id)
 
std::string writeDBSql (Statement *stmt)
 

Private Attributes

int m_lmfIOV
 
Tm m_t [3]
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Public Types inherited from LMFUnique
typedef oracle::occi::ResultSet ResultSet
 
typedef oracle::occi::Statement Statement
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from LMFUnique
virtual void setClassName (std::string s)
 
virtual int writeDB () throw (std::runtime_error)
 
virtual int writeForeignKeys () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- Protected Attributes inherited from LMFUnique
bool _profiling
 
std::string m_className
 
char m_debug
 
std::map< std::string,
LMFUnique * > 
m_foreignKeys
 
std::map< std::string, int > m_intFields
 
std::map< std::string,
std::string > 
m_stringFields
 
- 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

Definition at line 13 of file LMFLmrSubIOV.h.

Constructor & Destructor Documentation

LMFLmrSubIOV::LMFLmrSubIOV ( )

Definition at line 12 of file LMFLmrSubIOV.cc.

References init().

12  {
13  init();
14 }
LMFLmrSubIOV::LMFLmrSubIOV ( EcalDBConnection c)

Definition at line 16 of file LMFLmrSubIOV.cc.

References init().

16  : LMFUnique(c) {
17  init();
18 }
LMFUnique()
Definition: LMFUnique.h:23
LMFLmrSubIOV::LMFLmrSubIOV ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 20 of file LMFLmrSubIOV.cc.

References init().

21  : LMFUnique(env, conn)
22 {
23  init();
24 }
LMFUnique()
Definition: LMFUnique.h:23
tuple conn
Definition: results_mgr.py:53
LMFLmrSubIOV::~LMFLmrSubIOV ( )

Definition at line 26 of file LMFLmrSubIOV.cc.

26  {
27 }

Member Function Documentation

std::list<LMFLmrSubIOV> LMFLmrSubIOV::fetchByLMFIOV ( const LMFIOV iov)
std::string LMFLmrSubIOV::fetchIdSql ( Statement stmt)
privatevirtual

Reimplemented from LMFUnique.

Definition at line 52 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, i, LMFUnique::m_className, IDBObject::m_conn, LMFUnique::m_debug, IDBObject::m_env, m_lmfIOV, m_t, AlCaHLTBitMon_QueryRunRegistry::string, tree::t, and DateHandler::tmToDate().

52  {
53  if (!m_lmfIOV) {
54  if (m_debug) {
55  std::cout << m_className << ": LMFIOV not set" << std::endl;
56  }
57  return "";
58  }
59 
60  std::string sql = "SELECT LMR_SUB_IOV_ID FROM "
61  "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
62  "WHERE "
63  "IOV_ID = :1 AND "
64  "T1 = :2 AND "
65  "T2 = :3 AND "
66  "T3 = :4";
67  stmt->setSQL(sql);
68  stmt->setInt(1, m_lmfIOV);
70  for (int i = 0; i < 3; i++) {
71  oracle::occi::Date t = dh.tmToDate(m_t[i]);
72  stmt->setDate(i + 2, t);
73  }
74  return sql;
75 
76 }
std::string m_className
Definition: LMFUnique.h:99
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
tuple cout
Definition: gather_cfg.py:121
char m_debug
Definition: LMFUnique.h:100
tuple dh
Definition: cuy.py:353
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t)
throw (std::runtime_error
)

Definition at line 120 of file LMFLmrSubIOV.cc.

References Tm::setToString(), and tree::t.

Referenced by LMFCorrCoefDat::fetchBetween().

121  {
122  Tm tinf;
123  tinf.setToString("9999-12-31 23:59:59");
124  return getIOVIDsLaterThan(t, tinf, 0);
125 }
std::list< int > getIOVIDsLaterThan(const Tm &t)
void setToString(const std::string s)
Definition: Tm.cc:193
Definition: Tm.h:13
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm tmin,
const Tm tmax 
)
throw (std::runtime_error
)

Definition at line 134 of file LMFLmrSubIOV.cc.

References tmax.

136  {
137  return getIOVIDsLaterThan(tmin, tmax, 0);
138 }
std::list< int > getIOVIDsLaterThan(const Tm &t)
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
int  howMany 
)
throw (std::runtime_error
)

Definition at line 127 of file LMFLmrSubIOV.cc.

References Tm::setToString(), and tree::t.

128  {
129  Tm tinf;
130  tinf.setToString("9999-12-31 23:59:59");
131  return getIOVIDsLaterThan(t, tinf, howmany);
132 }
std::list< int > getIOVIDsLaterThan(const Tm &t)
void setToString(const std::string s)
Definition: Tm.cc:193
Definition: Tm.h:13
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
const Tm tmax,
int  howMany 
)
throw (std::runtime_error
)

Definition at line 140 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, alignCSCRings::e, NULL, run_regression::ret, Tm::setToString(), AlCaHLTBitMon_QueryRunRegistry::string, tmax, and DateHandler::tmToDate().

142  {
143  Tm tinf;
144  tinf.setToString("9999-12-31 23:59:59");
145  std::string sql = "SELECT * FROM (SELECT LMR_SUB_IOV_ID "
146  "FROM CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV WHERE T3 > :1 ";
147  if (tmax != tinf) {
148  sql += "AND T3 < :2 ORDER BY T3 ASC) ";
149  if (howMany > 0) {
150  sql += "WHERE ROWNUM <= :3";
151  }
152  } else {
153  sql += "ORDER BY T3 ASC) ";
154  if (howMany > 0) {
155  sql += "WHERE ROWNUM <= :2";
156  }
157  }
158  if (m_debug) {
159  std::cout << "Executing query: " << std::endl << sql << std::endl;
160  }
161  std::list<int> ret;
162  if (m_conn != NULL) {
163  try {
165  Statement *stmt = m_conn->createStatement();
166  stmt->setPrefetchRowCount(10000);
167  stmt->setSQL(sql);
168  stmt->setDate(1, dh.tmToDate(tmin));
169  if (tmax != tinf) {
170  stmt->setDate(2, dh.tmToDate(tmax));
171  if (howMany > 0) {
172  stmt->setInt(3, howMany);
173  }
174  } else {
175  if (howMany > 0) {
176  stmt->setInt(2, howMany);
177  }
178  }
179  ResultSet *rset = stmt->executeQuery();
180  int row = 1;
181  while (rset->next() != 0) {
182  if (m_debug) {
183  std::cout << "Getting row " << row++ << std::endl;
184  }
185  ret.push_back(rset->getInt(1));
186  }
187  stmt->setPrefetchRowCount(0);
188  m_conn->terminateStatement(stmt);
189  }
190  catch (oracle::occi::SQLException e) {
191  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " +
192  e.getMessage()));
193  }
194  } else {
195  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " +
196  "Connection not set"));
197  }
198  if (m_debug) {
199  std::cout << "Sorting..." << std::flush;
200  }
201  ret.sort();
202  if (m_debug) {
203  std::cout << "Done!" << std::endl << std::flush;
204  }
205  return ret;
206 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
void setToString(const std::string s)
Definition: Tm.cc:193
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple cout
Definition: gather_cfg.py:121
char m_debug
Definition: LMFUnique.h:100
Definition: Tm.h:13
tuple dh
Definition: cuy.py:353
LMFIOV LMFLmrSubIOV::getLMFIOV ( ) const
inline

Definition at line 32 of file LMFLmrSubIOV.h.

References o2o::iov, IDBObject::m_conn, IDBObject::m_env, m_lmfIOV, and LMFUnique::setByID().

32  {
34  iov.setByID(m_lmfIOV);
35  return iov;
36  };
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
tuple iov
Definition: o2o.py:307
Definition: LMFIOV.h:17
int LMFLmrSubIOV::getLMFIOVID ( ) const
inline

Definition at line 29 of file LMFLmrSubIOV.h.

References m_lmfIOV.

29  {
30  return m_lmfIOV;
31  };
void LMFLmrSubIOV::getParameters ( ResultSet rset)
privatevirtual

Reimplemented from LMFUnique.

Definition at line 112 of file LMFLmrSubIOV.cc.

References i, m_lmfIOV, m_t, Tm::setToString(), and tree::t.

112  {
113  m_lmfIOV = rset->getInt(1);
114  for (int i = 0; i < 3; i++) {
115  oracle::occi::Date t = rset->getDate(i + 2);
116  m_t[i].setToString(t.toText("YYYY-MM-DD HH24:MI:SS"));
117  }
118 }
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
void setToString(const std::string s)
Definition: Tm.cc:193
Tm LMFLmrSubIOV::getT1 ( )
inline

Definition at line 61 of file LMFLmrSubIOV.h.

References m_t.

61  {
62  return m_t[0];
63  }
Tm LMFLmrSubIOV::getT2 ( )
inline

Definition at line 64 of file LMFLmrSubIOV.h.

References m_t.

64  {
65  return m_t[1];
66  }
Tm LMFLmrSubIOV::getT3 ( )
inline

Definition at line 67 of file LMFLmrSubIOV.h.

References m_t.

67  {
68  return m_t[2];
69  }
Tm LMFLmrSubIOV::getTime ( int  i)
inline

Definition at line 54 of file LMFLmrSubIOV.h.

References m_t, and tree::t.

54  {
55  Tm t;
56  if ((i > 0) && (i < 4)) {
57  t = m_t[i - 1];
58  }
59  return t;
60  }
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
Definition: Tm.h:13
void LMFLmrSubIOV::getTimes ( Tm t1,
Tm t2,
Tm t3 
) const
inline

Definition at line 37 of file LMFLmrSubIOV.h.

References m_t.

Referenced by LMFCorrCoefDat::getTimes().

37  {
38  *t1 = m_t[0];
39  *t2 = m_t[1];
40  *t3 = m_t[2];
41  }
std::vector<Tm> LMFLmrSubIOV::getTimes ( ) const
inline

Definition at line 42 of file LMFLmrSubIOV.h.

References m_t, and findQualityFiles::v.

42  {
43  std::vector<Tm> v;
44  v.push_back(m_t[0]);
45  v.push_back(m_t[1]);
46  v.push_back(m_t[2]);
47  return v;
48  }
void LMFLmrSubIOV::getTimes ( Tm t) const
inline

Definition at line 49 of file LMFLmrSubIOV.h.

References m_t.

49  {
50  t[0] = m_t[0];
51  t[1] = m_t[1];
52  t[2] = m_t[2];
53  }
void LMFLmrSubIOV::init ( void  )
private

Definition at line 3 of file LMFLmrSubIOV.cc.

References LMFUnique::m_className, m_lmfIOV, and m_t.

Referenced by LMFLmrSubIOV().

3  {
4  m_className = "LMFLmrSubIOV";
5 
6  m_lmfIOV = 0;
7  m_t[0] = Tm();
8  m_t[1] = Tm();
9  m_t[2] = Tm();
10 }
std::string m_className
Definition: LMFUnique.h:99
Definition: Tm.h:13
bool LMFLmrSubIOV::operator!= ( const LMFLmrSubIOV m) const
inline

Definition at line 90 of file LMFLmrSubIOV.h.

References visualization-live-secondInstance_cfg::m.

bool LMFLmrSubIOV::operator== ( const LMFLmrSubIOV m) const
inline

Definition at line 82 of file LMFLmrSubIOV.h.

References m_lmfIOV, and m_t.

83  {
84  return ( (m_lmfIOV == m.m_lmfIOV) &&
85  (m_t[0] == m.m_t[0]) &&
86  (m_t[1] == m.m_t[1]) &&
87  (m_t[2] == m.m_t[2]));
88  }
std::string LMFLmrSubIOV::setByIDSql ( Statement stmt,
int  id 
)
privatevirtual

Reimplemented from LMFUnique.

Definition at line 78 of file LMFLmrSubIOV.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

78  {
79  std::string sql = "SELECT IOV_ID, T1, T2, T3 FROM "
80  "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
81  "WHERE LMR_SUB_IOV_ID = :1";
82  stmt->setSQL(sql);
83  stmt->setInt(1, id);
84  return sql;
85 }
LMFLmrSubIOV & LMFLmrSubIOV::setLMFIOV ( const LMFIOV iov)

Definition at line 29 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, LMFUnique::getID(), LMFUnique::m_debug, and m_lmfIOV.

29  {
30  if (m_debug) {
31  std::cout << "[LMFLmrSubIOV] Setting IOV_ID as " << iov.getID()
32  << std::endl << std::flush;
33  }
34  m_lmfIOV = iov.getID();
35  return *this;
36 }
int getID() const
Definition: LMFUnique.h:52
tuple cout
Definition: gather_cfg.py:121
char m_debug
Definition: LMFUnique.h:100
LMFLmrSubIOV& LMFLmrSubIOV::setLMFIOV ( int  i)
LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( const Tm t1,
const Tm t2,
const Tm t3 
)

Definition at line 45 of file LMFLmrSubIOV.cc.

References m_t.

45  {
46  m_t[0] = t1;
47  m_t[1] = t2;
48  m_t[2] = t3;
49  return *this;
50 }
LMFLmrSubIOV& LMFLmrSubIOV::setTimes ( const std::vector< Tm > &  t)
LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( Tm t)

Definition at line 38 of file LMFLmrSubIOV.cc.

References m_t.

38  {
39  m_t[0] = t[0];
40  m_t[1] = t[1];
41  m_t[2] = t[2];
42  return *this;
43 }
std::string LMFLmrSubIOV::writeDBSql ( Statement stmt)
privatevirtual

Reimplemented from LMFUnique.

Definition at line 87 of file LMFLmrSubIOV.cc.

References cuy::dh, DateHandler::getPlusInfTm(), i, LMFUnique::m_className, IDBObject::m_conn, IDBObject::m_env, m_lmfIOV, m_t, LMFUnique::sequencePostfix(), AlCaHLTBitMon_QueryRunRegistry::string, and DateHandler::tmToDate().

87  {
88  // Validate the data, use infinity-till convention
90 
91  for (int i = 0; i < 3; i++) {
92  if (m_t[i].isNull()) {
93  m_t[i] = dh.getPlusInfTm();
94  }
95  }
96 
97  if (m_lmfIOV == 0) {
98  throw(std::runtime_error(m_className + "::writeDB: LMFIOV not set"));
99  }
101  std::string sql = "INSERT INTO LMF_LMR_SUB_IOV (LMR_SUB_IOV_ID, "
102  "IOV_ID, T1, T2, T3) "
103  "VALUES (LMF_LMR_SUB_IOV_ID_" + sp + "_SQ.NextVal, :1, :2, :3, :4)";
104  stmt->setSQL(sql);
105  stmt->setInt(1, m_lmfIOV);
106  for (int i = 0; i < 3; i++) {
107  stmt->setDate(i + 2, dh.tmToDate(m_t[i]));
108  }
109  return sql;
110 }
std::string m_className
Definition: LMFUnique.h:99
int i
Definition: DBlmapReader.cc:9
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string sequencePostfix(const Tm &t)
Definition: LMFUnique.cc:10
tuple dh
Definition: cuy.py:353

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 15 of file LMFLmrSubIOV.h.

Member Data Documentation

int LMFLmrSubIOV::m_lmfIOV
private
Tm LMFLmrSubIOV::m_t[3]
private