CMS 3D CMS Logo

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

#include <MonRunList.h>

Inheritance diagram for MonRunList:
IDBObject

Public Member Functions

void fetchLastNRuns (int max_run, int n_runs) noexcept(false)
 
void fetchRuns () noexcept(false)
 
void fetchRuns (int min_run, int max_run) noexcept(false)
 
MonRunTag getMonRunTag () const
 
std::vector< MonRunIOVgetRuns ()
 
RunTag getRunTag () const
 
 MonRunList ()
 
void setMonRunTag (const MonRunTag &tag)
 
void setRunTag (const RunTag &tag)
 
 ~MonRunList () 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 Attributes

MonRunTag m_monrunTag
 
RunTag m_runTag
 
std::vector< MonRunIOVm_vec_monruniov
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

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

Detailed Description

Definition at line 16 of file MonRunList.h.

Constructor & Destructor Documentation

◆ MonRunList()

MonRunList::MonRunList ( )

Definition at line 14 of file MonRunList.cc.

14 { m_conn = nullptr; }

◆ ~MonRunList()

MonRunList::~MonRunList ( )
override

Definition at line 16 of file MonRunList.cc.

16 {}

Member Function Documentation

◆ fetchLastNRuns()

void MonRunList::fetchLastNRuns ( int  max_run,
int  n_runs 
)
noexcept

Definition at line 235 of file MonRunList.cc.

235  {
236  // fetch the last n_runs that come just before max_run (including max_run)
237 
238  this->checkConnection();
239 
241  int tagID = m_runTag.fetchID();
242  cout << "tag id=" << tagID << endl;
243  if (!tagID) {
244  return;
245  }
247  int montagID = m_monrunTag.fetchID();
248  cout << "mon tag id=" << montagID << endl;
249  if (!montagID) {
250  return;
251  }
252 
253  int my_max_run = max_run + 1;
254  try {
255  int nruns = n_runs;
256  m_vec_monruniov.reserve(nruns);
257 
258  Statement* stmt = m_conn->createStatement();
259  stmt->setSQL(
260  "select run_num, run_start, run_end, tag_id, run_iov_id, subrun_num, subrun_start, subrun_end, mon_iov_id from "
261  "(SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, "
262  "mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id as mon_iov_id "
263  "FROM run_iov, mon_run_iov "
264  "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id "
265  " and mon_run_iov.tag_id=:montag_id "
266  " and run_iov.run_num< :max_run "
267  " order by run_iov.run_num DESC ) where rownum< :n_runs order by run_num DESC ");
268  stmt->setInt(1, tagID);
269  stmt->setInt(2, montagID);
270  stmt->setInt(3, my_max_run);
271  stmt->setInt(4, n_runs);
272 
274  Tm runStart;
275  Tm runEnd;
276  Tm lrunStart;
277  Tm lrunEnd;
278 
279  ResultSet* rset = stmt->executeQuery();
280  int i = 0;
281  while (i < nruns) {
282  rset->next();
283  int runNum = rset->getInt(1);
284  Date startDate = rset->getDate(2);
285  Date endDate = rset->getDate(3);
286  // int ltag = rset->getInt(4);
287  int lid = rset->getInt(5);
288  int subrun = rset->getInt(6);
289  Date monstartDate = rset->getDate(7);
290  Date monendDate = rset->getDate(8);
291  int liov_id = rset->getInt(9);
292 
293  runStart = dh.dateToTm(startDate);
294  runEnd = dh.dateToTm(endDate);
295  lrunStart = dh.dateToTm(monstartDate);
296  lrunEnd = dh.dateToTm(monendDate);
297 
298  RunIOV r;
299  r.setRunNumber(runNum);
300  r.setRunStart(runStart);
301  r.setRunEnd(runEnd);
302  r.setRunTag(m_runTag);
303  r.setID(lid);
304 
305  MonRunIOV lr;
306  // da correggere qui
307  lr.setRunIOV(r);
308  lr.setSubRunNumber(subrun);
309  lr.setSubRunStart(lrunStart);
310  lr.setSubRunEnd(lrunEnd);
312  lr.setID(liov_id);
313  m_vec_monruniov.push_back(lr);
314 
315  i++;
316  }
317 
318  m_conn->terminateStatement(stmt);
319  } catch (SQLException& e) {
320  throw(std::runtime_error("MonRunList::fetchLastNRuns: " + e.getMessage()));
321  }
322 }

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, MonRunIOV::setID(), MonRunIOV::setMonRunTag(), MonRunIOV::setRunIOV(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), and MonRunIOV::setSubRunStart().

◆ fetchRuns() [1/2]

void MonRunList::fetchRuns ( )
noexcept

Definition at line 34 of file MonRunList.cc.

34  {
35  this->checkConnection();
36  int nruns = 0;
37 
39  int tagID = m_runTag.fetchID();
40  cout << "tag id=" << tagID << endl;
41  if (!tagID) {
42  return;
43  }
45  int montagID = m_monrunTag.fetchID();
46  cout << "mon tag id=" << montagID << endl;
47  if (!montagID) {
48  return;
49  }
50 
51  try {
52  Statement* stmt0 = m_conn->createStatement();
53  stmt0->setSQL(
54  "SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov "
55  "WHERE mon_run_iov.run_iov_id= run_iov.iov_id and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id ");
56  stmt0->setInt(1, tagID);
57  stmt0->setInt(2, montagID);
58 
59  ResultSet* rset0 = stmt0->executeQuery();
60  if (rset0->next()) {
61  nruns = rset0->getInt(1);
62  }
63  m_conn->terminateStatement(stmt0);
64 
65  cout << "nruns=" << nruns << endl;
66 
67  m_vec_monruniov.reserve(nruns);
68 
69  Statement* stmt = m_conn->createStatement();
70  stmt->setSQL(
71  "SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, "
72  "mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, "
73  "mon_run_iov "
74  "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id order by run_iov.run_num, "
75  "mon_run_iov.subrun_num ASC ");
76  stmt->setInt(1, tagID);
77 
79  Tm runStart;
80  Tm runEnd;
81  Tm lrunStart;
82  Tm lrunEnd;
83 
84  ResultSet* rset = stmt->executeQuery();
85  int i = 0;
86  while (i < nruns) {
87  rset->next();
88  int runNum = rset->getInt(1);
89  Date startDate = rset->getDate(2);
90  Date endDate = rset->getDate(3);
91  //int ltag = rset->getInt(4);
92  int lid = rset->getInt(5);
93  int subrun = rset->getInt(6);
94  Date monstartDate = rset->getDate(7);
95  Date monendDate = rset->getDate(8);
96  int liov_id = rset->getInt(9);
97 
98  runStart = dh.dateToTm(startDate);
99  runEnd = dh.dateToTm(endDate);
100  lrunStart = dh.dateToTm(monstartDate);
101  lrunEnd = dh.dateToTm(monendDate);
102 
103  RunIOV r;
104  r.setRunNumber(runNum);
105  r.setRunStart(runStart);
106  r.setRunEnd(runEnd);
107  r.setRunTag(m_runTag);
108  r.setID(lid);
109 
110  MonRunIOV lr;
111  // da correggere qui
112  lr.setRunIOV(r);
113  lr.setSubRunNumber(subrun);
114  lr.setSubRunStart(lrunStart);
115  lr.setSubRunEnd(lrunEnd);
117  lr.setID(liov_id);
118  m_vec_monruniov.push_back(lr);
119 
120  i++;
121  }
122 
123  m_conn->terminateStatement(stmt);
124  } catch (SQLException& e) {
125  throw(std::runtime_error("RunIOV::fetchID: " + e.getMessage()));
126  }
127 }

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, MonRunIOV::setID(), MonRunIOV::setMonRunTag(), MonRunIOV::setRunIOV(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), and MonRunIOV::setSubRunStart().

◆ fetchRuns() [2/2]

void MonRunList::fetchRuns ( int  min_run,
int  max_run 
)
noexcept

Definition at line 129 of file MonRunList.cc.

129  {
130  this->checkConnection();
131  int nruns = 0;
132 
134  int tagID = m_runTag.fetchID();
135  cout << "tag id=" << tagID << endl;
136  if (!tagID) {
137  return;
138  }
140  int montagID = m_monrunTag.fetchID();
141  cout << "mon tag id=" << montagID << endl;
142  if (!montagID) {
143  return;
144  }
145 
146  int my_min_run = min_run - 1;
147  int my_max_run = max_run + 1;
148  try {
149  Statement* stmt0 = m_conn->createStatement();
150  stmt0->setSQL(
151  "SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov "
152  "WHERE mon_run_iov.run_iov_id= run_iov.iov_id "
153  "and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id "
154  " and run_iov.run_num> :min_run and run_iov.run_num< :max_run ");
155  stmt0->setInt(1, tagID);
156  stmt0->setInt(2, montagID);
157  stmt0->setInt(3, my_min_run);
158  stmt0->setInt(4, my_max_run);
159 
160  ResultSet* rset0 = stmt0->executeQuery();
161  if (rset0->next()) {
162  nruns = rset0->getInt(1);
163  }
164  m_conn->terminateStatement(stmt0);
165 
166  cout << "nruns=" << nruns << endl;
167 
168  m_vec_monruniov.reserve(nruns);
169 
170  Statement* stmt = m_conn->createStatement();
171  stmt->setSQL(
172  "SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, "
173  "mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, "
174  "mon_run_iov "
175  "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id "
176  " and mon_run_iov.tag_id=:montag_id "
177  " and run_iov.run_num> :min_run and run_iov.run_num< :max_run "
178  " order by run_iov.run_num, mon_run_iov.subrun_num ASC ");
179  stmt->setInt(1, tagID);
180  stmt->setInt(2, montagID);
181  stmt->setInt(3, my_min_run);
182  stmt->setInt(4, my_max_run);
183 
185  Tm runStart;
186  Tm runEnd;
187  Tm lrunStart;
188  Tm lrunEnd;
189 
190  ResultSet* rset = stmt->executeQuery();
191  int i = 0;
192  while (i < nruns) {
193  rset->next();
194  int runNum = rset->getInt(1);
195  Date startDate = rset->getDate(2);
196  Date endDate = rset->getDate(3);
197  // int ltag = rset->getInt(4);
198  int lid = rset->getInt(5);
199  int subrun = rset->getInt(6);
200  Date monstartDate = rset->getDate(7);
201  Date monendDate = rset->getDate(8);
202  int liov_id = rset->getInt(9);
203 
204  runStart = dh.dateToTm(startDate);
205  runEnd = dh.dateToTm(endDate);
206  lrunStart = dh.dateToTm(monstartDate);
207  lrunEnd = dh.dateToTm(monendDate);
208 
209  RunIOV r;
210  r.setRunNumber(runNum);
211  r.setRunStart(runStart);
212  r.setRunEnd(runEnd);
213  r.setRunTag(m_runTag);
214  r.setID(lid);
215 
216  MonRunIOV lr;
217  // da correggere qui
218  lr.setRunIOV(r);
219  lr.setSubRunNumber(subrun);
220  lr.setSubRunStart(lrunStart);
221  lr.setSubRunEnd(lrunEnd);
223  lr.setID(liov_id);
224  m_vec_monruniov.push_back(lr);
225 
226  i++;
227  }
228 
229  m_conn->terminateStatement(stmt);
230  } catch (SQLException& e) {
231  throw(std::runtime_error("RunIOV::fetchID: " + e.getMessage()));
232  }
233 }

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, MonRunIOV::setID(), MonRunIOV::setMonRunTag(), MonRunIOV::setRunIOV(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), and MonRunIOV::setSubRunStart().

◆ getMonRunTag()

MonRunTag MonRunList::getMonRunTag ( ) const

Definition at line 30 of file MonRunList.cc.

30 { return m_monrunTag; }

◆ getRuns()

std::vector< MonRunIOV > MonRunList::getRuns ( )

◆ getRunTag()

RunTag MonRunList::getRunTag ( ) const

Definition at line 29 of file MonRunList.cc.

29 { return m_runTag; }

◆ setMonRunTag()

void MonRunList::setMonRunTag ( const MonRunTag tag)

◆ setRunTag()

void MonRunList::setRunTag ( const RunTag tag)

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 18 of file MonRunList.h.

Member Data Documentation

◆ m_monrunTag

MonRunTag MonRunList::m_monrunTag
private

Definition at line 40 of file MonRunList.h.

◆ m_runTag

RunTag MonRunList::m_runTag
private

Definition at line 39 of file MonRunList.h.

◆ m_vec_monruniov

std::vector<MonRunIOV> MonRunList::m_vec_monruniov
private

Definition at line 38 of file MonRunList.h.

DeadROC_duringRun.runNum
runNum
Definition: DeadROC_duringRun.py:21
RunIOV
Definition: RunIOV.h:13
mps_fire.i
i
Definition: mps_fire.py:355
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MonRunIOV::setRunIOV
void setRunIOV(const RunIOV &iov)
Definition: MonRunIOV.cc:36
MonRunIOV::setSubRunEnd
void setSubRunEnd(const Tm &end)
Definition: MonRunIOV.cc:63
RunTag::fetchID
int fetchID() noexcept(false) override
Definition: RunTag.cc:49
MonRunIOV::setID
void setID(int id)
Definition: MonRunIOV.cc:25
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
MonRunList::m_monrunTag
MonRunTag m_monrunTag
Definition: MonRunList.h:40
Tm
Definition: Tm.h:13
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
MonRunList::m_vec_monruniov
std::vector< MonRunIOV > m_vec_monruniov
Definition: MonRunList.h:38
MonRunIOV
Definition: MonRunIOV.h:14
MonRunIOV::setSubRunNumber
void setSubRunNumber(subrun_t subrun)
Definition: MonRunIOV.cc:45
MonRunIOV::setMonRunTag
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunIOV.cc:27
alignCSCRings.r
r
Definition: alignCSCRings.py:93
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
MonRunTag::fetchID
int fetchID() noexcept(false) override
Definition: MonRunTag.cc:37
MonRunList::m_runTag
RunTag m_runTag
Definition: MonRunList.h:39
MonRunIOV::setSubRunStart
void setSubRunStart(const Tm &start)
Definition: MonRunIOV.cc:54
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
DateHandler
Definition: DateHandler.h:7
cuy.dh
dh
Definition: cuy.py:355
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37