CMS 3D CMS Logo

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

#include <RunList.h>

Inheritance diagram for RunList:
IDBObject

Public Member Functions

void fetchGlobalRunsByLocation (int min_run, int max_run, const LocationDef &locDef) noexcept(false)
 
void fetchLastNRuns (int max_run, int n_runs) noexcept(false)
 
void fetchNonEmptyGlobalRuns () noexcept(false)
 
void fetchNonEmptyGlobalRuns (int min_run, int max_run) noexcept(false)
 
void fetchNonEmptyRuns () noexcept(false)
 
void fetchNonEmptyRuns (int min_run, int max_run) noexcept(false)
 
void fetchRuns () noexcept(false)
 
void fetchRuns (int min_run, int max_run) noexcept(false)
 
void fetchRuns (int min_run, int max_run, bool withTriggers, bool withGlobalTriggers) noexcept(false)
 
void fetchRunsByLocation (int min_run, int max_run, const LocationDef &locDef) noexcept(false)
 
std::vector< RunIOVgetRuns ()
 
RunTag getRunTag () const
 
 RunList ()
 
void setRunTag (const RunTag &tag)
 
 ~RunList () 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

RunTag m_runTag
 
std::vector< RunIOVm_vec_runiov
 

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 RunList.h.

Constructor & Destructor Documentation

◆ RunList()

RunList::RunList ( )

Definition at line 13 of file RunList.cc.

13 { m_conn = nullptr; }

◆ ~RunList()

RunList::~RunList ( )
override

Definition at line 15 of file RunList.cc.

15 {}

Member Function Documentation

◆ fetchGlobalRunsByLocation()

void RunList::fetchGlobalRunsByLocation ( int  min_run,
int  max_run,
const LocationDef locDef 
)
noexcept

Definition at line 305 of file RunList.cc.

305  {
306  this->checkConnection();
307  int nruns = 0;
308 
309  int my_min_run = min_run - 1;
310  int my_max_run = max_run + 1;
311  try {
312  Statement* stmt0 = m_conn->createStatement();
313  stmt0->setSQL(
314  "SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l "
315  " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 "
316  " and t.gen_tag='GLOBAL' "
317  " and r.run_num> :2 and r.run_num< :3 ");
318  stmt0->setString(1, locDef.getLocation());
319  stmt0->setInt(2, my_min_run);
320  stmt0->setInt(3, my_max_run);
321 
322  ResultSet* rset0 = stmt0->executeQuery();
323  if (rset0->next()) {
324  nruns = rset0->getInt(1);
325  }
326  m_conn->terminateStatement(stmt0);
327 
328  cout << "number of runs=" << nruns << endl;
329 
330  m_vec_runiov.reserve(nruns);
331 
332  Statement* stmt = m_conn->createStatement();
333  stmt->setSQL(
334  "SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , "
335  " t.gen_tag, rt.RUN_TYPE "
336  " FROM run_iov r , run_tag t, location_def l, run_type_def rt "
337  " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID "
338  " AND l.LOCATION= :1 "
339  " and t.gen_tag='GLOBAL' "
340  " and r.run_num> :2 and r.run_num< :3 "
341  " order by run_num ");
342  stmt->setString(1, locDef.getLocation());
343  stmt->setInt(2, my_min_run);
344  stmt->setInt(3, my_max_run);
345 
347  Tm runStart;
348  Tm runEnd;
349  Tm dbtime;
350 
351  ResultSet* rset = stmt->executeQuery();
352  int i = 0;
353  while (i < nruns) {
354  rset->next();
355  int iovID = rset->getInt(1);
356  // int tagID = rset->getInt(2);
357  int runNum = rset->getInt(3);
358  Date startDate = rset->getDate(4);
359  Date endDate = rset->getDate(5);
360  Date dbDate = rset->getDate(6);
361 
362  runStart = dh.dateToTm(startDate);
363  runEnd = dh.dateToTm(endDate);
364  dbtime = dh.dateToTm(dbDate);
365 
366  RunTag atag;
367  atag.setLocationDef(locDef);
368  atag.setGeneralTag(rset->getString(7));
369  RunTypeDef rundef;
370  rundef.setRunType(rset->getString(8));
371  atag.setRunTypeDef(rundef);
372 
373  RunIOV r;
374  r.setRunNumber(runNum);
375  r.setRunStart(runStart);
376  r.setRunEnd(runEnd);
377  r.setDBInsertionTime(dbtime);
378  r.setRunTag(atag);
379  r.setID(iovID);
380  m_vec_runiov.push_back(r);
381 
382  i++;
383  }
384 
385  m_conn->terminateStatement(stmt);
386 
387  } catch (SQLException& e) {
388  throw(std::runtime_error(std::string("RunList::fetchRunsByLocation: ") + e.getMessage()));
389  }
390 }

References getBeamSpotDB::atag, gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, RunTypeDef::setRunType(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fetchLastNRuns()

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

Definition at line 154 of file RunList.cc.

154  {
155  // fetch the last n_runs that come just before max_run (including max_run)
156 
157  this->checkConnection();
158 
160  int tagID = m_runTag.fetchID();
161  cout << "tag id=" << tagID << endl;
162  if (!tagID) {
163  return;
164  }
165 
166  int my_max_run = max_run + 1;
167  try {
168  int nruns = n_runs + 1;
169  m_vec_runiov.reserve(nruns);
170 
171  Statement* stmt = m_conn->createStatement();
172  stmt->setSQL(
173  "select iov_id, tag_id, run_num, run_start, run_end, DB_TIMESTAMP from "
174  " (SELECT * from RUN_IOV "
175  " WHERE tag_id = :tag_id "
176  " and run_num< :max_run "
177  " order by run_num DESC ) where rownum< :n_runs ORDER BY run_num ASC ");
178  stmt->setInt(1, tagID);
179  stmt->setInt(2, my_max_run);
180  stmt->setInt(3, nruns);
181 
183  Tm runStart;
184  Tm runEnd;
185  Tm dbtime;
186 
187  ResultSet* rset = stmt->executeQuery();
188  int i = 0;
189  while (i < n_runs) {
190  rset->next();
191  int iovID = rset->getInt(1);
192  // int tagID = rset->getInt(2);
193  int runNum = rset->getInt(3);
194  Date startDate = rset->getDate(4);
195  Date endDate = rset->getDate(5);
196  Date dbDate = rset->getDate(6);
197 
198  runStart = dh.dateToTm(startDate);
199  runEnd = dh.dateToTm(endDate);
200  dbtime = dh.dateToTm(dbDate);
201 
202  RunIOV r;
203  r.setRunNumber(runNum);
204  r.setRunStart(runStart);
205  r.setRunEnd(runEnd);
206  r.setDBInsertionTime(dbtime);
207  r.setRunTag(m_runTag);
208  r.setID(iovID);
209  m_vec_runiov.push_back(r);
210 
211  i++;
212  }
213 
214  m_conn->terminateStatement(stmt);
215  } catch (SQLException& e) {
216  throw(std::runtime_error(std::string("RunList::fetchLastNRuns: ") + e.getMessage()));
217  }
218 }

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fetchNonEmptyGlobalRuns() [1/2]

void RunList::fetchNonEmptyGlobalRuns ( )
noexcept

Definition at line 29 of file RunList.cc.

29 { fetchRuns(-1, -1, false, true); }

◆ fetchNonEmptyGlobalRuns() [2/2]

void RunList::fetchNonEmptyGlobalRuns ( int  min_run,
int  max_run 
)
noexcept

Definition at line 33 of file RunList.cc.

33  {
34  fetchRuns(min_run, max_run, false, true);
35 }

◆ fetchNonEmptyRuns() [1/2]

void RunList::fetchNonEmptyRuns ( )
noexcept

Definition at line 27 of file RunList.cc.

27 { fetchRuns(-1, -1, true, false); }

◆ fetchNonEmptyRuns() [2/2]

void RunList::fetchNonEmptyRuns ( int  min_run,
int  max_run 
)
noexcept

Definition at line 31 of file RunList.cc.

31 { fetchRuns(min_run, max_run, true, false); }

◆ fetchRuns() [1/3]

void RunList::fetchRuns ( )
noexcept

Definition at line 37 of file RunList.cc.

37 { fetchRuns(-1, -1); }

◆ fetchRuns() [2/3]

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

Definition at line 39 of file RunList.cc.

39 { fetchRuns(min_run, max_run, false, false); }

◆ fetchRuns() [3/3]

void RunList::fetchRuns ( int  min_run,
int  max_run,
bool  withTriggers,
bool  withGlobalTriggers 
)
noexcept

Definition at line 41 of file RunList.cc.

41  {
42  /*
43  withTriggers and withGlobalTriggers selects those non empty runs.
44  Possible combinations are
45 
46  withTriggers withGlobalTriggers select
47  ------------ ------------------ ------------------------------
48  false false all
49  false true only runs with global triggers
50  true false only runs with any trigger
51  true true only runs with global triggers
52  */
53  this->checkConnection();
54  int nruns = 0;
55 
57  int tagID = m_runTag.fetchID();
58  cout << "tag id=" << tagID << endl;
59  if (!tagID) {
60  return;
61  }
62 
63  int my_min_run = min_run - 1;
64  int my_max_run = max_run + 1;
65  try {
66  Statement* stmt0 = m_conn->createStatement();
67  string sql =
68  "SELECT count(iov_id) FROM run_iov "
69  "WHERE tag_id = :tag_id ";
70  if (min_run > 0) {
71  // don't need to specify empty/non empty here. This is needed
72  // just to allocate the memory for the vector
73  sql += " and run_iov.run_num> :min_run and run_iov.run_num< :max_run ";
74  }
75  stmt0->setSQL(sql);
76  stmt0->setInt(1, tagID);
77  if (min_run > 0) {
78  stmt0->setInt(2, my_min_run);
79  stmt0->setInt(3, my_max_run);
80  }
81 
82  ResultSet* rset0 = stmt0->executeQuery();
83  if (rset0->next()) {
84  nruns = rset0->getInt(1);
85  }
86  m_conn->terminateStatement(stmt0);
87 
88  cout << "number of runs=" << nruns << endl;
89  m_vec_runiov.reserve(nruns);
90 
91  Statement* stmt = m_conn->createStatement();
92  sql =
93  "SELECT DISTINCT i.iov_id, tag_id, run_num, run_start, run_end, "
94  "db_timestamp FROM run_iov i ";
95  if ((withTriggers) || (withGlobalTriggers)) {
96  sql +=
97  "join cms_ecal_cond.run_dat d on d.iov_id = i.iov_id "
98  "left join CMS_WBM.RUNSUMMARY R on R.RUNNUMBER = i.RUN_NUM ";
99  }
100  sql += "WHERE tag_id = :tag_id ";
101  if (min_run > 0) {
102  sql += "and i.run_num> :min_run and i.run_num< :max_run ";
103  }
104  if (withGlobalTriggers) {
105  sql += "and R.TRIGGERS > 0 ";
106  } else if (withTriggers) {
107  sql += "and ((R.TRIGGERS > 0) or (num_events > 0)) ";
108  }
109  sql += " order by run_num ";
110  stmt->setSQL(sql);
111  stmt->setInt(1, tagID);
112  if (min_run > 0) {
113  stmt->setInt(2, my_min_run);
114  stmt->setInt(3, my_max_run);
115  }
116 
118  Tm runStart;
119  Tm runEnd;
120  Tm dbtime;
121 
122  ResultSet* rset = stmt->executeQuery();
123  int i = 0;
124  while ((i < nruns) && (rset->next())) {
125  int iovID = rset->getInt(1);
126  // int tagID = rset->getInt(2);
127  int runNum = rset->getInt(3);
128  Date startDate = rset->getDate(4);
129  Date endDate = rset->getDate(5);
130  Date dbDate = rset->getDate(6);
131 
132  runStart = dh.dateToTm(startDate);
133  runEnd = dh.dateToTm(endDate);
134  dbtime = dh.dateToTm(dbDate);
135 
136  RunIOV r;
137  r.setRunNumber(runNum);
138  r.setRunStart(runStart);
139  r.setRunEnd(runEnd);
140  r.setDBInsertionTime(dbtime);
141  r.setRunTag(m_runTag);
142  r.setID(iovID);
143  m_vec_runiov.push_back(r);
144 
145  i++;
146  }
147  m_vec_runiov.resize(i);
148  m_conn->terminateStatement(stmt);
149  } catch (SQLException& e) {
150  throw(std::runtime_error(std::string("RunList::fetchRuns: ") + e.getMessage()));
151  }
152 }

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fetchRunsByLocation()

void RunList::fetchRunsByLocation ( int  min_run,
int  max_run,
const LocationDef locDef 
)
noexcept

Definition at line 220 of file RunList.cc.

220  {
221  this->checkConnection();
222  int nruns = 0;
223 
224  int my_min_run = min_run - 1;
225  int my_max_run = max_run + 1;
226  try {
227  Statement* stmt0 = m_conn->createStatement();
228  stmt0->setSQL(
229  "SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l "
230  " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 "
231  " and r.run_num> :2 and r.run_num< :3 ");
232  stmt0->setString(1, locDef.getLocation());
233  stmt0->setInt(2, my_min_run);
234  stmt0->setInt(3, my_max_run);
235 
236  ResultSet* rset0 = stmt0->executeQuery();
237  if (rset0->next()) {
238  nruns = rset0->getInt(1);
239  }
240  m_conn->terminateStatement(stmt0);
241 
242  cout << "number of runs=" << nruns << endl;
243 
244  m_vec_runiov.reserve(nruns);
245 
246  Statement* stmt = m_conn->createStatement();
247  stmt->setSQL(
248  "SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , "
249  " t.gen_tag, rt.RUN_TYPE "
250  " FROM run_iov r , run_tag t, location_def l, run_type_def rt "
251  " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID "
252  " AND l.LOCATION= :1 "
253  " and r.run_num> :2 and r.run_num< :3 "
254  " order by run_num ");
255  stmt->setString(1, locDef.getLocation());
256  stmt->setInt(2, my_min_run);
257  stmt->setInt(3, my_max_run);
258 
260  Tm runStart;
261  Tm runEnd;
262  Tm dbtime;
263 
264  ResultSet* rset = stmt->executeQuery();
265  int i = 0;
266  while (i < nruns) {
267  rset->next();
268  int iovID = rset->getInt(1);
269  // int tagID = rset->getInt(2);
270  int runNum = rset->getInt(3);
271  Date startDate = rset->getDate(4);
272  Date endDate = rset->getDate(5);
273  Date dbDate = rset->getDate(6);
274 
275  runStart = dh.dateToTm(startDate);
276  runEnd = dh.dateToTm(endDate);
277  dbtime = dh.dateToTm(dbDate);
278 
279  RunTag atag;
280  atag.setLocationDef(locDef);
281  atag.setGeneralTag(rset->getString(7));
282  RunTypeDef rundef;
283  rundef.setRunType(rset->getString(8));
284  atag.setRunTypeDef(rundef);
285 
286  RunIOV r;
287  r.setRunNumber(runNum);
288  r.setRunStart(runStart);
289  r.setRunEnd(runEnd);
290  r.setDBInsertionTime(dbtime);
291  r.setRunTag(atag);
292  r.setID(iovID);
293  m_vec_runiov.push_back(r);
294 
295  i++;
296  }
297 
298  m_conn->terminateStatement(stmt);
299 
300  } catch (SQLException& e) {
301  throw(std::runtime_error(std::string("RunList::fetchRunsByLocation: ") + e.getMessage()));
302  }
303 }

References getBeamSpotDB::atag, gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::i, alignCSCRings::r, DeadROC_duringRun::runNum, RunTypeDef::setRunType(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ getRuns()

std::vector< RunIOV > RunList::getRuns ( )

◆ getRunTag()

RunTag RunList::getRunTag ( ) const

Definition at line 23 of file RunList.cc.

23 { return m_runTag; }

◆ setRunTag()

void RunList::setRunTag ( const RunTag tag)

Definition at line 17 of file RunList.cc.

17  {
18  if (tag != m_runTag) {
19  m_runTag = tag;
20  }
21 }

References makeGlobalPositionRcd_cfg::tag.

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 18 of file RunList.h.

Member Data Documentation

◆ m_runTag

RunTag RunList::m_runTag
private

Definition at line 44 of file RunList.h.

◆ m_vec_runiov

std::vector<RunIOV> RunList::m_vec_runiov
private

Definition at line 43 of file RunList.h.

DeadROC_duringRun.runNum
runNum
Definition: DeadROC_duringRun.py:21
RunIOV
Definition: RunIOV.h:13
mps_fire.i
i
Definition: mps_fire.py:428
getBeamSpotDB.atag
atag
Definition: getBeamSpotDB.py:123
RunTag
Definition: RunTag.h:13
gather_cfg.cout
cout
Definition: gather_cfg.py:144
LocationDef::getLocation
std::string getLocation() const
Definition: LocationDef.cc:18
RunTag::fetchID
int fetchID() noexcept(false) override
Definition: RunTag.cc:49
RunTypeDef::setRunType
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:21
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunList::m_runTag
RunTag m_runTag
Definition: RunList.h:44
Tm
Definition: Tm.h:13
RunTypeDef
Definition: RunTypeDef.h:12
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
RunList::fetchRuns
void fetchRuns() noexcept(false)
Definition: RunList.cc:37
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunList::m_vec_runiov
std::vector< RunIOV > m_vec_runiov
Definition: RunList.h:43
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
DateHandler
Definition: DateHandler.h:7
cuy.dh
dh
Definition: cuy.py:354
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37