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 () override
 
- 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 std::list< std::unique_ptr< LMFUnique > > fetchAll () const noexcept(false)
 
int fetchID () noexcept(false) override
 
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) override
 
LMFUniquesetInt (std::string key, int value)
 
LMFUniquesetString (std::string key, std::string value)
 
void startProfiling ()
 
void stopProfiling ()
 
 ~LMFUnique () override
 
- 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) override
 
void getParameters (ResultSet *rset) override
 
void init ()
 
std::string setByIDSql (Statement *stmt, int id) override
 
std::string writeDBSql (Statement *stmt) override
 

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() [1/3]

LMFLmrSubIOV::LMFLmrSubIOV ( )

Definition at line 15 of file LMFLmrSubIOV.cc.

References init().

15 { init(); }

◆ LMFLmrSubIOV() [2/3]

LMFLmrSubIOV::LMFLmrSubIOV ( EcalDBConnection c)

Definition at line 17 of file LMFLmrSubIOV.cc.

References init().

◆ LMFLmrSubIOV() [3/3]

LMFLmrSubIOV::LMFLmrSubIOV ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 19 of file LMFLmrSubIOV.cc.

References init().

19  : LMFUnique(env, conn) {
20  init();
21 }
LMFUnique()
Definition: LMFUnique.h:27
conn
Definition: getInfo.py:9

◆ ~LMFLmrSubIOV()

LMFLmrSubIOV::~LMFLmrSubIOV ( )
override

Definition at line 23 of file LMFLmrSubIOV.cc.

23 {}

Member Function Documentation

◆ fetchByLMFIOV()

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

◆ fetchIdSql()

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

Reimplemented from LMFUnique.

Definition at line 47 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, mps_fire::i, LMFUnique::m_className, IDBObject::m_conn, LMFUnique::m_debug, IDBObject::m_env, m_lmfIOV, m_t, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

47  {
48  if (!m_lmfIOV) {
49  if (m_debug) {
50  std::cout << m_className << ": LMFIOV not set" << std::endl;
51  }
52  return "";
53  }
54 
55  std::string sql =
56  "SELECT LMR_SUB_IOV_ID FROM "
57  "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
58  "WHERE "
59  "IOV_ID = :1 AND "
60  "T1 = :2 AND "
61  "T2 = :3 AND "
62  "T3 = :4";
63  stmt->setSQL(sql);
64  stmt->setInt(1, m_lmfIOV);
66  for (int i = 0; i < 3; i++) {
67  oracle::occi::Date t = dh.tmToDate(m_t[i]);
68  stmt->setDate(i + 2, t);
69  }
70  return sql;
71 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
char m_debug
Definition: LMFUnique.h:100
dh
Definition: cuy.py:354

◆ getIOVIDsLaterThan() [1/4]

std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t)
noexcept

Definition at line 145 of file LMFLmrSubIOV.cc.

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

Referenced by LMFCorrCoefDat::fetchBetween().

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

◆ getIOVIDsLaterThan() [2/4]

std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm tmin,
const Tm tmax 
)
noexcept

Definition at line 157 of file LMFLmrSubIOV.cc.

References tmax, and muonTiming_cfi::tmin.

157  {
158  return getIOVIDsLaterThan(tmin, tmax, 0);
159 }
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
static const double tmax[3]

◆ getIOVIDsLaterThan() [3/4]

std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
int  howMany 
)
noexcept

Definition at line 151 of file LMFLmrSubIOV.cc.

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

151  {
152  Tm tinf;
153  tinf.setToString("9999-12-31 23:59:59");
154  return getIOVIDsLaterThan(t, tinf, howmany);
155 }
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:148
Definition: Tm.h:13

◆ getIOVIDsLaterThan() [4/4]

std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
const Tm tmax,
int  howMany 
)
noexcept

Definition at line 161 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, runTheMatrix::ret, Tm::setToString(), AlCaHLTBitMon_QueryRunRegistry::string, tmax, muonTiming_cfi::tmin, and to_string().

161  {
162  Tm tinf;
163  tinf.setToString("9999-12-31 23:59:59");
164  std::string sql =
165  "SELECT * FROM (SELECT LMR_SUB_IOV_ID "
166  "FROM CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV WHERE T3 > :1 ";
167  if (tmax != tinf) {
168  sql += "AND T3 < :2 ORDER BY T3 ASC) ";
169  if (howMany > 0) {
170  sql += "WHERE ROWNUM <= :3";
171  }
172  } else {
173  sql += "ORDER BY T3 ASC) ";
174  if (howMany > 0) {
175  sql += "WHERE ROWNUM <= :2";
176  }
177  }
178  if (m_debug) {
179  std::cout << "Executing query: " << std::endl << sql << std::endl;
180  }
181  std::list<int> ret;
182  if (m_conn != nullptr) {
183  try {
185  Statement *stmt = m_conn->createStatement();
186  stmt->setPrefetchRowCount(10000);
187  stmt->setSQL(sql);
188  stmt->setDate(1, dh.tmToDate(tmin));
189  if (tmax != tinf) {
190  stmt->setDate(2, dh.tmToDate(tmax));
191  if (howMany > 0) {
192  stmt->setInt(3, howMany);
193  }
194  } else {
195  if (howMany > 0) {
196  stmt->setInt(2, howMany);
197  }
198  }
199  ResultSet *rset = stmt->executeQuery();
200  int row = 1;
201  while (rset->next() != 0) {
202  if (m_debug) {
203  std::cout << "Getting row " << row++ << std::endl;
204  }
205  ret.push_back(rset->getInt(1));
206  }
207  stmt->setPrefetchRowCount(0);
208  m_conn->terminateStatement(stmt);
209  } catch (oracle::occi::SQLException &e) {
210 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
211  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " + e.getMessage()));
212 #else
213  throw(
214  std::runtime_error(m_className + "::getLmrSubIOVLaterThan: error code " + std::to_string(e.getErrorCode())));
215 #endif
216  }
217  } else {
218  throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " + "Connection not set"));
219  }
220  if (m_debug) {
221  std::cout << "Sorting..." << std::flush;
222  }
223  ret.sort();
224  if (m_debug) {
225  std::cout << "Done!" << std::endl << std::flush;
226  }
227  return ret;
228 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
ret
prodAgent to be discontinued
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
static std::string to_string(const XMLCh *ch)
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
static const double tmax[3]
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:148
char m_debug
Definition: LMFUnique.h:100
dh
Definition: cuy.py:354
Definition: Tm.h:13

◆ getLMFIOV()

LMFIOV LMFLmrSubIOV::getLMFIOV ( ) const
inline

Definition at line 29 of file LMFLmrSubIOV.h.

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

29  {
30  LMFIOV iov(m_env, m_conn);
31  iov.setByID(m_lmfIOV);
32  return iov;
33  };
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Definition: LMFIOV.h:17

◆ getLMFIOVID()

int LMFLmrSubIOV::getLMFIOVID ( ) const
inline

Definition at line 28 of file LMFLmrSubIOV.h.

References m_lmfIOV.

28 { return m_lmfIOV; };

◆ getParameters()

void LMFLmrSubIOV::getParameters ( ResultSet rset)
overrideprivatevirtualnoexcept

Reimplemented from LMFUnique.

Definition at line 110 of file LMFLmrSubIOV.cc.

References util.getRunInfo::day(), mps_fire::i, SiStripPI::min, seconds(), AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, groupFilesInBlocks::tt, and HLT_2023v12_cff::year.

110  {
111  m_lmfIOV = rset->getInt(1);
112  for (int i = 0; i < 3; i++) {
113  oracle::occi::Date t = rset->getDate(i + 2);
114 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
115  m_t[i].setToString(t.toText("YYYY-MM-DD HH24:MI:SS"));
116 #else
117  int year = 0;
118  unsigned int month = 0;
119  unsigned int day = 0;
120  unsigned int hour = 0;
121  unsigned int min = 0;
122  unsigned int seconds = 0;
123  t.getDate(year, month, day, hour, min, seconds);
124  const std::tm tt = {.tm_sec = static_cast<int>(seconds),
125  .tm_min = static_cast<int>(min),
126  .tm_hour = static_cast<int>(hour),
127  .tm_mday = static_cast<int>(day),
128  .tm_mon = static_cast<int>(month),
129  .tm_year = year - 1900,
130  .tm_wday = 0,
131  .tm_yday = 0,
132  .tm_isdst = 0,
133  .tm_gmtoff = 0,
134  .tm_zone = nullptr};
135  char tt_str[30] = {0};
136  if (std::strftime(tt_str, sizeof(tt_str), "%F %T", &tt)) {
137  m_t[i].setToString(std::string(tt_str));
138  } else {
139  throw std::runtime_error("LMFLmrSubIOV::writeDBSql: failed to generate the date string");
140  }
141 #endif
142  }
143 }
double seconds()
Definition: TTTypes.h:54
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:148
def day(string)
Definition: getRunInfo.py:11

◆ getT1()

Tm LMFLmrSubIOV::getT1 ( )
inline

Definition at line 58 of file LMFLmrSubIOV.h.

References m_t.

58 { return m_t[0]; }

◆ getT2()

Tm LMFLmrSubIOV::getT2 ( )
inline

Definition at line 59 of file LMFLmrSubIOV.h.

References m_t.

59 { return m_t[1]; }

◆ getT3()

Tm LMFLmrSubIOV::getT3 ( )
inline

Definition at line 60 of file LMFLmrSubIOV.h.

References m_t.

60 { return m_t[2]; }

◆ getTime()

Tm LMFLmrSubIOV::getTime ( int  i)
inline

Definition at line 51 of file LMFLmrSubIOV.h.

References mps_fire::i, m_t, and submitPVValidationJobs::t.

51  {
52  Tm t;
53  if ((i > 0) && (i < 4)) {
54  t = m_t[i - 1];
55  }
56  return t;
57  }
Definition: Tm.h:13

◆ getTimes() [1/3]

void LMFLmrSubIOV::getTimes ( Tm t1,
Tm t2,
Tm t3 
) const
inline

◆ getTimes() [2/3]

std::vector<Tm> LMFLmrSubIOV::getTimes ( ) const
inline

Definition at line 39 of file LMFLmrSubIOV.h.

References m_t, and findQualityFiles::v.

39  {
40  std::vector<Tm> v;
41  v.push_back(m_t[0]);
42  v.push_back(m_t[1]);
43  v.push_back(m_t[2]);
44  return v;
45  }

◆ getTimes() [3/3]

void LMFLmrSubIOV::getTimes ( Tm t) const
inline

Definition at line 46 of file LMFLmrSubIOV.h.

References m_t, and submitPVValidationJobs::t.

46  {
47  t[0] = m_t[0];
48  t[1] = m_t[1];
49  t[2] = m_t[2];
50  }

◆ init()

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:99
Definition: Tm.h:13

◆ operator!=()

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

◆ operator==()

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

Definition at line 68 of file LMFLmrSubIOV.h.

References visualization-live-secondInstance_cfg::m, m_lmfIOV, and m_t.

68  {
69  return ((m_lmfIOV == m.m_lmfIOV) && (m_t[0] == m.m_t[0]) && (m_t[1] == m.m_t[1]) && (m_t[2] == m.m_t[2]));
70  }

◆ setByIDSql()

std::string LMFLmrSubIOV::setByIDSql ( Statement stmt,
int  id 
)
overrideprivatevirtual

Reimplemented from LMFUnique.

Definition at line 73 of file LMFLmrSubIOV.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

73  {
74  std::string sql =
75  "SELECT IOV_ID, T1, T2, T3 FROM "
76  "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
77  "WHERE LMR_SUB_IOV_ID = :1";
78  stmt->setSQL(sql);
79  stmt->setInt(1, id);
80  return sql;
81 }

◆ setLMFIOV() [1/2]

LMFLmrSubIOV & LMFLmrSubIOV::setLMFIOV ( const LMFIOV iov)

Definition at line 25 of file LMFLmrSubIOV.cc.

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

25  {
26  if (m_debug) {
27  std::cout << "[LMFLmrSubIOV] Setting IOV_ID as " << iov.getID() << std::endl << std::flush;
28  }
29  m_lmfIOV = iov.getID();
30  return *this;
31 }
int getID() const
Definition: LMFUnique.h:58
char m_debug
Definition: LMFUnique.h:100

◆ setLMFIOV() [2/2]

LMFLmrSubIOV& LMFLmrSubIOV::setLMFIOV ( int  i)

◆ setTimes() [1/3]

LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( const Tm t1,
const Tm t2,
const Tm t3 
)

Definition at line 40 of file LMFLmrSubIOV.cc.

References m_t, RandomServiceHelper::t1, RandomServiceHelper::t2, and RandomServiceHelper::t3.

40  {
41  m_t[0] = t1;
42  m_t[1] = t2;
43  m_t[2] = t3;
44  return *this;
45 }

◆ setTimes() [2/3]

LMFLmrSubIOV& LMFLmrSubIOV::setTimes ( const std::vector< Tm > &  t)

◆ setTimes() [3/3]

LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( Tm t)

Definition at line 33 of file LMFLmrSubIOV.cc.

References m_t, and submitPVValidationJobs::t.

33  {
34  m_t[0] = t[0];
35  m_t[1] = t[1];
36  m_t[2] = t[2];
37  return *this;
38 }

◆ writeDBSql()

std::string LMFLmrSubIOV::writeDBSql ( Statement stmt)
overrideprivatevirtual

Reimplemented from LMFUnique.

Definition at line 83 of file LMFLmrSubIOV.cc.

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

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 15 of file LMFLmrSubIOV.h.

Member Data Documentation

◆ m_lmfIOV

int LMFLmrSubIOV::m_lmfIOV
private

Definition at line 77 of file LMFLmrSubIOV.h.

Referenced by fetchIdSql(), getLMFIOV(), getLMFIOVID(), init(), operator==(), setLMFIOV(), and writeDBSql().

◆ m_t

Tm LMFLmrSubIOV::m_t[3]
private