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_RUNINFO.RUNSESSION_PARAMETER G on " 135 "(i.run_num = G.RUNNUMBER and G.NAME = 'CMS.TRG:NumTriggers') ";
137 sql +=
"WHERE tag_id = :tag_id ";
139 sql +=
"and i.run_num> :min_run and i.run_num< :max_run ";
141 if (withGlobalTriggers) {
142 sql +=
"and G.STRING_VALUE != '0' ";
143 }
else if (withTriggers) {
144 sql +=
"and (G.STRING_VALUE != '0' or num_events > 0) ";
146 sql +=
" order by run_num ";
148 stmt->setInt(1, tagID);
150 stmt->setInt(2, my_min_run);
151 stmt->setInt(3, my_max_run);
159 ResultSet* rset = stmt->executeQuery();
161 while ((i<nruns) && (rset->next())) {
162 int iovID = rset->getInt(1);
164 int runNum = rset->getInt(3);
165 Date startDate = rset->getDate(4);
166 Date endDate = rset->getDate(5);
167 Date dbDate = rset->getDate(6);
169 runStart = dh.
dateToTm( startDate );
180 m_vec_runiov.push_back(r);
184 m_vec_runiov.resize(i);
185 m_conn->terminateStatement(stmt);
186 }
catch (SQLException &
e) {
187 throw(std::runtime_error(
"RunList::fetchRuns: "+e.getMessage()));
197 this->checkConnection();
200 m_runTag.setConnection(m_env, m_conn);
201 int tagID = m_runTag.fetchID();
202 cout <<
"tag id="<< tagID << endl;
207 int my_max_run=max_run+1;
211 m_vec_runiov.reserve(nruns);
213 Statement* stmt = m_conn->createStatement();
214 stmt->setSQL(
"select iov_id, tag_id, run_num, run_start, run_end, DB_TIMESTAMP from " 215 " (SELECT * from RUN_IOV " 216 " WHERE tag_id = :tag_id " 217 " and run_num< :max_run " 218 " order by run_num DESC ) where rownum< :n_runs ORDER BY run_num ASC " );
219 stmt->setInt(1, tagID);
220 stmt->setInt(2, my_max_run);
221 stmt->setInt(3, nruns);
228 ResultSet* rset = stmt->executeQuery();
232 int iovID = rset->getInt(1);
234 int runNum = rset->getInt(3);
235 Date startDate = rset->getDate(4);
236 Date endDate = rset->getDate(5);
237 Date dbDate = rset->getDate(6);
239 runStart = dh.
dateToTm( startDate );
250 m_vec_runiov.push_back(r);
255 m_conn->terminateStatement(stmt);
256 }
catch (SQLException &
e) {
257 throw(std::runtime_error(
"RunList::fetchLastNRuns: "+e.getMessage()));
269 this->checkConnection();
272 int my_min_run=min_run-1;
273 int my_max_run=max_run+1;
275 Statement* stmt0 = m_conn->createStatement();
276 stmt0->setSQL(
"SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l " 277 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 " 278 " and r.run_num> :2 and r.run_num< :3 ");
279 stmt0->setString(1,locDef.getLocation() );
280 stmt0->setInt(2, my_min_run);
281 stmt0->setInt(3, my_max_run);
283 ResultSet* rset0 = stmt0->executeQuery();
285 nruns = rset0->getInt(1);
287 m_conn->terminateStatement(stmt0);
289 cout <<
"number of runs="<< nruns << endl;
291 m_vec_runiov.reserve(nruns);
293 Statement* stmt = m_conn->createStatement();
294 stmt->setSQL(
"SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , " 295 " t.gen_tag, rt.RUN_TYPE " 296 " FROM run_iov r , run_tag t, location_def l, run_type_def rt " 297 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID " 298 " AND l.LOCATION= :1 " 299 " and r.run_num> :2 and r.run_num< :3 " 300 " order by run_num " );
301 stmt->setString(1,locDef.getLocation() );
302 stmt->setInt(2, my_min_run);
303 stmt->setInt(3, my_max_run);
310 ResultSet* rset = stmt->executeQuery();
314 int iovID = rset->getInt(1);
316 int runNum = rset->getInt(3);
317 Date startDate = rset->getDate(4);
318 Date endDate = rset->getDate(5);
319 Date dbDate = rset->getDate(6);
321 runStart = dh.
dateToTm( startDate );
339 m_vec_runiov.push_back(r);
345 m_conn->terminateStatement(stmt);
347 }
catch (SQLException &
e) {
348 throw(std::runtime_error(
"RunList::fetchRunsByLocation: "+e.getMessage()));
358 this->checkConnection();
361 int my_min_run=min_run-1;
362 int my_max_run=max_run+1;
364 Statement* stmt0 = m_conn->createStatement();
365 stmt0->setSQL(
"SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l " 366 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 " 367 " and t.gen_tag='GLOBAL' " 368 " and r.run_num> :2 and r.run_num< :3 ");
369 stmt0->setString(1,locDef.getLocation() );
370 stmt0->setInt(2, my_min_run);
371 stmt0->setInt(3, my_max_run);
373 ResultSet* rset0 = stmt0->executeQuery();
375 nruns = rset0->getInt(1);
377 m_conn->terminateStatement(stmt0);
379 cout <<
"number of runs="<< nruns << endl;
381 m_vec_runiov.reserve(nruns);
383 Statement* stmt = m_conn->createStatement();
384 stmt->setSQL(
"SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , " 385 " t.gen_tag, rt.RUN_TYPE " 386 " FROM run_iov r , run_tag t, location_def l, run_type_def rt " 387 " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID " 388 " AND l.LOCATION= :1 " 389 " and t.gen_tag='GLOBAL' " 390 " and r.run_num> :2 and r.run_num< :3 " 391 " order by run_num " );
392 stmt->setString(1,locDef.getLocation() );
393 stmt->setInt(2, my_min_run);
394 stmt->setInt(3, my_max_run);
401 ResultSet* rset = stmt->executeQuery();
405 int iovID = rset->getInt(1);
407 int runNum = rset->getInt(3);
408 Date startDate = rset->getDate(4);
409 Date endDate = rset->getDate(5);
410 Date dbDate = rset->getDate(6);
412 runStart = dh.
dateToTm( startDate );
430 m_vec_runiov.push_back(r);
436 m_conn->terminateStatement(stmt);
438 }
catch (SQLException &
e) {
439 throw(std::runtime_error(
"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)
return(e1-e2)*(e1-e2)+dp *dp
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)