24 if (tag != m_runTag) {
43 fetchRuns(-1, -1,
true,
false);
49 fetchRuns(-1, -1,
false,
true);
55 fetchRuns(min_run, max_run,
true,
false);
61 fetchRuns(min_run, max_run,
false,
true);
73 fetchRuns(min_run, max_run,
false,
false);
77 bool withGlobalTriggers)
92 this->checkConnection();
95 m_runTag.setConnection(m_env, m_conn);
96 int tagID = m_runTag.fetchID();
97 cout <<
"tag id="<< tagID << endl;
102 int my_min_run=min_run-1;
103 int my_max_run=max_run+1;
105 Statement* stmt0 = m_conn->createStatement();
106 string sql =
"SELECT count(iov_id) FROM run_iov " 107 "WHERE tag_id = :tag_id ";
111 sql +=
" and run_iov.run_num> :min_run and run_iov.run_num< :max_run ";
114 stmt0->setInt(1, tagID);
116 stmt0->setInt(2, my_min_run);
117 stmt0->setInt(3, my_max_run);
120 ResultSet* rset0 = stmt0->executeQuery();
122 nruns = rset0->getInt(1);
124 m_conn->terminateStatement(stmt0);
126 cout <<
"number of runs="<< nruns << endl;
127 m_vec_runiov.reserve(nruns);
129 Statement* stmt = m_conn->createStatement();
130 sql =
"SELECT DISTINCT i.iov_id, tag_id, run_num, run_start, run_end, " 131 "db_timestamp FROM run_iov i ";
132 if ((withTriggers) || (withGlobalTriggers)) {
133 sql +=
"join cms_ecal_cond.run_dat d on d.iov_id = i.iov_id " 134 "left join CMS_WBM.RUNSUMMARY R on R.RUNNUMBER = i.RUN_NUM ";
136 sql +=
"WHERE tag_id = :tag_id ";
138 sql +=
"and i.run_num> :min_run and i.run_num< :max_run ";
140 if (withGlobalTriggers) {
141 sql +=
"and R.TRIGGERS > 0 ";
142 }
else if (withTriggers) {
143 sql +=
"and ((R.TRIGGERS > 0) or (num_events > 0)) ";
145 sql +=
" order by run_num ";
147 stmt->setInt(1, tagID);
149 stmt->setInt(2, my_min_run);
150 stmt->setInt(3, my_max_run);
158 ResultSet* rset = stmt->executeQuery();
160 while ((i<nruns) && (rset->next())) {
161 int iovID = rset->getInt(1);
163 int runNum = rset->getInt(3);
164 Date startDate = rset->getDate(4);
165 Date endDate = rset->getDate(5);
166 Date dbDate = rset->getDate(6);
168 runStart = dh.
dateToTm( startDate );
179 m_vec_runiov.push_back(r);
183 m_vec_runiov.resize(i);
184 m_conn->terminateStatement(stmt);
185 }
catch (SQLException &
e) {
186 throw(std::runtime_error(
std::string(
"RunList::fetchRuns: ")+e.getMessage()));
196 this->checkConnection();
199 m_runTag.setConnection(m_env, m_conn);
200 int tagID = m_runTag.fetchID();
201 cout <<
"tag id="<< tagID << endl;
206 int my_max_run=max_run+1;
210 m_vec_runiov.reserve(nruns);
212 Statement* stmt = m_conn->createStatement();
213 stmt->setSQL(
"select iov_id, tag_id, run_num, run_start, run_end, DB_TIMESTAMP from " 214 " (SELECT * from RUN_IOV " 215 " WHERE tag_id = :tag_id " 216 " and run_num< :max_run " 217 " order by run_num DESC ) where rownum< :n_runs ORDER BY run_num ASC " );
218 stmt->setInt(1, tagID);
219 stmt->setInt(2, my_max_run);
220 stmt->setInt(3, nruns);
227 ResultSet* rset = stmt->executeQuery();
231 int iovID = rset->getInt(1);
233 int runNum = rset->getInt(3);
234 Date startDate = rset->getDate(4);
235 Date endDate = rset->getDate(5);
236 Date dbDate = rset->getDate(6);
238 runStart = dh.
dateToTm( startDate );
249 m_vec_runiov.push_back(r);
254 m_conn->terminateStatement(stmt);
255 }
catch (SQLException &
e) {
256 throw(std::runtime_error(
std::string(
"RunList::fetchLastNRuns: ")+e.getMessage()));
268 this->checkConnection();
271 int my_min_run=min_run-1;
272 int my_max_run=max_run+1;
274 Statement* stmt0 = m_conn->createStatement();
275 stmt0->setSQL(
"SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l " 276 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 " 277 " and r.run_num> :2 and r.run_num< :3 ");
278 stmt0->setString(1,locDef.getLocation() );
279 stmt0->setInt(2, my_min_run);
280 stmt0->setInt(3, my_max_run);
282 ResultSet* rset0 = stmt0->executeQuery();
284 nruns = rset0->getInt(1);
286 m_conn->terminateStatement(stmt0);
288 cout <<
"number of runs="<< nruns << endl;
290 m_vec_runiov.reserve(nruns);
292 Statement* stmt = m_conn->createStatement();
293 stmt->setSQL(
"SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , " 294 " t.gen_tag, rt.RUN_TYPE " 295 " FROM run_iov r , run_tag t, location_def l, run_type_def rt " 296 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID " 297 " AND l.LOCATION= :1 " 298 " and r.run_num> :2 and r.run_num< :3 " 299 " order by run_num " );
300 stmt->setString(1,locDef.getLocation() );
301 stmt->setInt(2, my_min_run);
302 stmt->setInt(3, my_max_run);
309 ResultSet* rset = stmt->executeQuery();
313 int iovID = rset->getInt(1);
315 int runNum = rset->getInt(3);
316 Date startDate = rset->getDate(4);
317 Date endDate = rset->getDate(5);
318 Date dbDate = rset->getDate(6);
320 runStart = dh.
dateToTm( startDate );
338 m_vec_runiov.push_back(r);
344 m_conn->terminateStatement(stmt);
346 }
catch (SQLException &
e) {
347 throw(std::runtime_error(
std::string(
"RunList::fetchRunsByLocation: ")+e.getMessage()));
357 this->checkConnection();
360 int my_min_run=min_run-1;
361 int my_max_run=max_run+1;
363 Statement* stmt0 = m_conn->createStatement();
364 stmt0->setSQL(
"SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l " 365 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 " 366 " and t.gen_tag='GLOBAL' " 367 " and r.run_num> :2 and r.run_num< :3 ");
368 stmt0->setString(1,locDef.getLocation() );
369 stmt0->setInt(2, my_min_run);
370 stmt0->setInt(3, my_max_run);
372 ResultSet* rset0 = stmt0->executeQuery();
374 nruns = rset0->getInt(1);
376 m_conn->terminateStatement(stmt0);
378 cout <<
"number of runs="<< nruns << endl;
380 m_vec_runiov.reserve(nruns);
382 Statement* stmt = m_conn->createStatement();
383 stmt->setSQL(
"SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , " 384 " t.gen_tag, rt.RUN_TYPE " 385 " FROM run_iov r , run_tag t, location_def l, run_type_def rt " 386 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID " 387 " AND l.LOCATION= :1 " 388 " and t.gen_tag='GLOBAL' " 389 " and r.run_num> :2 and r.run_num< :3 " 390 " order by run_num " );
391 stmt->setString(1,locDef.getLocation() );
392 stmt->setInt(2, my_min_run);
393 stmt->setInt(3, my_max_run);
400 ResultSet* rset = stmt->executeQuery();
404 int iovID = rset->getInt(1);
406 int runNum = rset->getInt(3);
407 Date startDate = rset->getDate(4);
408 Date endDate = rset->getDate(5);
409 Date dbDate = rset->getDate(6);
411 runStart = dh.
dateToTm( startDate );
429 m_vec_runiov.push_back(r);
435 m_conn->terminateStatement(stmt);
437 }
catch (SQLException &
e) {
438 throw(std::runtime_error(
std::string(
"RunList::fetchRunsByLocation: ")+e.getMessage()));
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
void fetchRuns() noexcept(false)
void setRunStart(const Tm &start)
void setRunTag(const RunTag &tag)
void fetchRunsByLocation(int min_run, int max_run, const LocationDef &locDef) noexcept(false)
void setDBInsertionTime(const Tm &dbtime)
void setRunTag(const RunTag &tag)
void fetchNonEmptyRuns() noexcept(false)
void setRunNumber(run_t run)
void setLocationDef(const LocationDef &locDef)
void setRunType(std::string runtype)
void setRunEnd(const Tm &end)
void fetchLastNRuns(int max_run, int n_runs) noexcept(false)
void setGeneralTag(std::string tag)
Tm dateToTm(oracle::occi::Date &date) const
void fetchNonEmptyGlobalRuns() noexcept(false)
void fetchGlobalRunsByLocation(int min_run, int max_run, const LocationDef &locDef) noexcept(false)