CMS 3D CMS Logo

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) noexcept(false)
 
std::list< int > getIOVIDsLaterThan (const Tm &tmin, const Tm &tmax) noexcept(false)
 
std::list< int > getIOVIDsLaterThan (const Tm &t, int howMany) noexcept(false)
 
std::list< int > getIOVIDsLaterThan (const Tm &t, const Tm &tmax, int howMany) noexcept(false)
 
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< LMFUniquefetchAll () const noexcept(false)
 
int fetchID () noexcept(false)
 
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) noexcept(false)
 
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 () noexcept(false)
 
virtual int writeForeignKeys () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- 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 15 of file LMFLmrSubIOV.cc.

References init().

15  {
16  init();
17 }
LMFLmrSubIOV::LMFLmrSubIOV ( EcalDBConnection c)

Definition at line 19 of file LMFLmrSubIOV.cc.

References init().

19  : LMFUnique(c) {
20  init();
21 }
LMFUnique()
Definition: LMFUnique.h:23
LMFLmrSubIOV::LMFLmrSubIOV ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 23 of file LMFLmrSubIOV.cc.

References init().

24  : LMFUnique(env, conn)
25 {
26  init();
27 }
LMFUnique()
Definition: LMFUnique.h:23
LMFLmrSubIOV::~LMFLmrSubIOV ( )

Definition at line 29 of file LMFLmrSubIOV.cc.

29  {
30 }

Member Function Documentation

std::list<LMFLmrSubIOV> LMFLmrSubIOV::fetchByLMFIOV ( const LMFIOV iov)

Referenced by operator!=().

std::string LMFLmrSubIOV::fetchIdSql ( Statement stmt)
privatevirtual

Reimplemented from LMFUnique.

Definition at line 55 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, lumiQTWidget::t, and DateHandler::tmToDate().

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

Definition at line 147 of file LMFLmrSubIOV.cc.

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

Referenced by LMFCorrCoefDat::fetchBetween(), getIOVIDsLaterThan(), and getT3().

148  {
149  Tm tinf;
150  tinf.setToString("9999-12-31 23:59:59");
151  return getIOVIDsLaterThan(t, tinf, 0);
152 }
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:193
Definition: Tm.h:13
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm tmin,
const Tm tmax 
)
noexcept

Definition at line 161 of file LMFLmrSubIOV.cc.

References getIOVIDsLaterThan(), and tmax.

163  {
164  return getIOVIDsLaterThan(tmin, tmax, 0);
165 }
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
int  howMany 
)
noexcept

Definition at line 154 of file LMFLmrSubIOV.cc.

References getIOVIDsLaterThan(), Tm::setToString(), and lumiQTWidget::t.

155  {
156  Tm tinf;
157  tinf.setToString("9999-12-31 23:59:59");
158  return getIOVIDsLaterThan(t, tinf, howmany);
159 }
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:193
Definition: Tm.h:13
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
const Tm tmax,
int  howMany 
)
noexcept

Definition at line 167 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, LMFUnique::m_className, IDBObject::m_conn, LMFUnique::m_debug, IDBObject::m_env, NULL, Tm::setToString(), AlCaHLTBitMon_QueryRunRegistry::string, tmax, and DateHandler::tmToDate().

169  {
170  Tm tinf;
171  tinf.setToString("9999-12-31 23:59:59");
172  std::string sql = "SELECT * FROM (SELECT LMR_SUB_IOV_ID "
173  "FROM CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV WHERE T3 > :1 ";
174  if (tmax != tinf) {
175  sql += "AND T3 < :2 ORDER BY T3 ASC) ";
176  if (howMany > 0) {
177  sql += "WHERE ROWNUM <= :3";
178  }
179  } else {
180  sql += "ORDER BY T3 ASC) ";
181  if (howMany > 0) {
182  sql += "WHERE ROWNUM <= :2";
183  }
184  }
185  if (m_debug) {
186  std::cout << "Executing query: " << std::endl << sql << std::endl;
187  }
188  std::list<int> ret;
189  if (m_conn != NULL) {
190  try {
192  Statement *stmt = m_conn->createStatement();
193  stmt->setPrefetchRowCount(10000);
194  stmt->setSQL(sql);
195  stmt->setDate(1, dh.tmToDate(tmin));
196  if (tmax != tinf) {
197  stmt->setDate(2, dh.tmToDate(tmax));
198  if (howMany > 0) {
199  stmt->setInt(3, howMany);
200  }
201  } else {
202  if (howMany > 0) {
203  stmt->setInt(2, howMany);
204  }
205  }
206  ResultSet *rset = stmt->executeQuery();
207  int row = 1;
208  while (rset->next() != 0) {
209  if (m_debug) {
210  std::cout << "Getting row " << row++ << std::endl;
211  }
212  ret.push_back(rset->getInt(1));
213  }
214  stmt->setPrefetchRowCount(0);
215  m_conn->terminateStatement(stmt);
216  }
217  catch (oracle::occi::SQLException e) {
218 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
219  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " +
220  e.getMessage()));
221 #else
222  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: error code " +
223  std::to_string(e.getErrorCode())));
224 #endif
225  }
226  } else {
227  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " +
228  "Connection not set"));
229  }
230  if (m_debug) {
231  std::cout << "Sorting..." << std::flush;
232  }
233  ret.sort();
234  if (m_debug) {
235  std::cout << "Done!" << std::endl << std::flush;
236  }
237  return ret;
238 }
std::string m_className
Definition: LMFUnique.h:98
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) noexcept(false)
Definition: Tm.cc:193
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
char m_debug
Definition: LMFUnique.h:99
dh
Definition: cuy.py:353
Definition: Tm.h:13
LMFIOV LMFLmrSubIOV::getLMFIOV ( ) const
inline

Definition at line 32 of file LMFLmrSubIOV.h.

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

32  {
33  LMFIOV iov(m_env, m_conn);
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
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)
privatevirtualnoexcept

Reimplemented from LMFUnique.

Definition at line 115 of file LMFLmrSubIOV.cc.

References util.getRunInfo::day(), i, m_lmfIOV, m_t, min(), seconds(), Tm::setToString(), AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, groupFilesInBlocks::tt, and create_public_lumi_plots::year.

115  {
116  m_lmfIOV = rset->getInt(1);
117  for (int i = 0; i < 3; i++) {
118  oracle::occi::Date t = rset->getDate(i + 2);
119 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
120  m_t[i].setToString(t.toText("YYYY-MM-DD HH24:MI:SS"));
121 #else
122  int year = 0;
123  unsigned int month = 0;
124  unsigned int day = 0;
125  unsigned int hour = 0;
126  unsigned int min = 0;
127  unsigned int seconds = 0;
128  t.getDate(year, month, day, hour, min, seconds);
129  const std::tm tt = {
130  .tm_sec = static_cast<int>(seconds),
131  .tm_min = static_cast<int>(min),
132  .tm_hour = static_cast<int>(hour),
133  .tm_mday = static_cast<int>(day),
134  .tm_mon = static_cast<int>(month),
135  .tm_year = year - 1900
136  };
137  char tt_str[30] = { 0 };
138  if (std::strftime(tt_str, sizeof(tt_str), "%F %T", &tt)) {
139  m_t[i].setToString(std::string(tt_str));
140  } else {
141  throw std::runtime_error("LMFLmrSubIOV::writeDBSql: failed to generate the date string");
142  }
143 #endif
144  }
145 }
int i
Definition: DBlmapReader.cc:9
double seconds()
T min(T a, T b)
Definition: MathUtil.h:58
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:193
def day(string)
Definition: getRunInfo.py:11
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 getIOVIDsLaterThan(), m_t, noexcept, lumiQTWidget::t, and tmax.

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 lumiQTWidget::t.

54  {
55  Tm t;
56  if ((i > 0) && (i < 4)) {
57  t = m_t[i - 1];
58  }
59  return t;
60  }
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 6 of file LMFLmrSubIOV.cc.

References LMFUnique::m_className, m_lmfIOV, and m_t.

Referenced by LMFLmrSubIOV().

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

Definition at line 85 of file LMFLmrSubIOV.h.

References fetchByLMFIOV(), and funct::m.

85 { return !(*this == m); }
bool LMFLmrSubIOV::operator== ( const LMFLmrSubIOV m) const
inline

Definition at line 77 of file LMFLmrSubIOV.h.

References m_lmfIOV, and m_t.

78  {
79  return ( (m_lmfIOV == m.m_lmfIOV) &&
80  (m_t[0] == m.m_t[0]) &&
81  (m_t[1] == m.m_t[1]) &&
82  (m_t[2] == m.m_t[2]));
83  }
std::string LMFLmrSubIOV::setByIDSql ( Statement stmt,
int  id 
)
privatevirtual

Reimplemented from LMFUnique.

Definition at line 81 of file LMFLmrSubIOV.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 32 of file LMFLmrSubIOV.cc.

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

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

Definition at line 48 of file LMFLmrSubIOV.cc.

References m_t, and reco::t2.

48  {
49  m_t[0] = t1;
50  m_t[1] = t2;
51  m_t[2] = t3;
52  return *this;
53 }
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
LMFLmrSubIOV& LMFLmrSubIOV::setTimes ( const std::vector< Tm > &  t)
LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( Tm t)

Definition at line 41 of file LMFLmrSubIOV.cc.

References m_t.

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

Reimplemented from LMFUnique.

Definition at line 90 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().

90  {
91  // Validate the data, use infinity-till convention
93 
94  for (int i = 0; i < 3; i++) {
95  if (m_t[i].isNull()) {
96  m_t[i] = dh.getPlusInfTm();
97  }
98  }
99 
100  if (m_lmfIOV == 0) {
101  throw(std::runtime_error(m_className + "::writeDB: LMFIOV not set"));
102  }
104  std::string sql = "INSERT INTO LMF_LMR_SUB_IOV (LMR_SUB_IOV_ID, "
105  "IOV_ID, T1, T2, T3) "
106  "VALUES (LMF_LMR_SUB_IOV_ID_" + sp + "_SQ.NextVal, :1, :2, :3, :4)";
107  stmt->setSQL(sql);
108  stmt->setInt(1, m_lmfIOV);
109  for (int i = 0; i < 3; i++) {
110  stmt->setDate(i + 2, dh.tmToDate(m_t[i]));
111  }
112  return sql;
113 }
std::string m_className
Definition: LMFUnique.h:98
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
Definition: sp.h:21
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