18 if (
tag != m_runTag) {
34 fetchRuns(min_run, max_run,
false,
true);
39 void RunList::fetchRuns(
int min_run,
int max_run) noexcept(
false) { fetchRuns(min_run, max_run,
false,
false); }
41 void RunList::fetchRuns(
int min_run,
int max_run,
bool withTriggers,
bool withGlobalTriggers) noexcept(
false) {
53 this->checkConnection();
56 m_runTag.setConnection(m_env, m_conn);
57 int tagID = m_runTag.fetchID();
58 cout <<
"tag id=" << tagID << endl;
63 int my_min_run = min_run - 1;
64 int my_max_run = max_run + 1;
66 Statement* stmt0 = m_conn->createStatement();
68 "SELECT count(iov_id) FROM run_iov " 69 "WHERE tag_id = :tag_id ";
73 sql +=
" and run_iov.run_num> :min_run and run_iov.run_num< :max_run ";
76 stmt0->setInt(1, tagID);
78 stmt0->setInt(2, my_min_run);
79 stmt0->setInt(3, my_max_run);
82 ResultSet* rset0 = stmt0->executeQuery();
84 nruns = rset0->getInt(1);
86 m_conn->terminateStatement(stmt0);
88 cout <<
"number of runs=" << nruns << endl;
89 m_vec_runiov.reserve(nruns);
91 Statement* stmt = m_conn->createStatement();
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)) {
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 ";
100 sql +=
"WHERE tag_id = :tag_id ";
102 sql +=
"and i.run_num> :min_run and i.run_num< :max_run ";
104 if (withGlobalTriggers) {
105 sql +=
"and R.TRIGGERS > 0 ";
106 }
else if (withTriggers) {
107 sql +=
"and ((R.TRIGGERS > 0) or (num_events > 0)) ";
109 sql +=
" order by run_num ";
111 stmt->setInt(1, tagID);
113 stmt->setInt(2, my_min_run);
114 stmt->setInt(3, my_max_run);
122 ResultSet* rset = stmt->executeQuery();
124 while ((
i < nruns) && (rset->next())) {
125 int iovID = rset->getInt(1);
127 int runNum = rset->getInt(3);
128 Date startDate = rset->getDate(4);
129 Date endDate = rset->getDate(5);
130 Date dbDate = rset->getDate(6);
132 runStart =
dh.dateToTm(startDate);
133 runEnd =
dh.dateToTm(endDate);
134 dbtime =
dh.dateToTm(dbDate);
138 r.setRunStart(runStart);
140 r.setDBInsertionTime(dbtime);
141 r.setRunTag(m_runTag);
143 m_vec_runiov.push_back(
r);
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()));
157 this->checkConnection();
159 m_runTag.setConnection(m_env, m_conn);
160 int tagID = m_runTag.fetchID();
161 cout <<
"tag id=" << tagID << endl;
166 int my_max_run = max_run + 1;
168 int nruns = n_runs + 1;
169 m_vec_runiov.reserve(nruns);
171 Statement* stmt = m_conn->createStatement();
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);
187 ResultSet* rset = stmt->executeQuery();
191 int iovID = rset->getInt(1);
193 int runNum = rset->getInt(3);
194 Date startDate = rset->getDate(4);
195 Date endDate = rset->getDate(5);
196 Date dbDate = rset->getDate(6);
198 runStart =
dh.dateToTm(startDate);
199 runEnd =
dh.dateToTm(endDate);
200 dbtime =
dh.dateToTm(dbDate);
204 r.setRunStart(runStart);
206 r.setDBInsertionTime(dbtime);
207 r.setRunTag(m_runTag);
209 m_vec_runiov.push_back(
r);
214 m_conn->terminateStatement(stmt);
215 }
catch (SQLException&
e) {
216 throw(std::runtime_error(
std::string(
"RunList::fetchLastNRuns: ") +
e.getMessage()));
221 this->checkConnection();
224 int my_min_run = min_run - 1;
225 int my_max_run = max_run + 1;
227 Statement* stmt0 = m_conn->createStatement();
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);
236 ResultSet* rset0 = stmt0->executeQuery();
238 nruns = rset0->getInt(1);
240 m_conn->terminateStatement(stmt0);
242 cout <<
"number of runs=" << nruns << endl;
244 m_vec_runiov.reserve(nruns);
246 Statement* stmt = m_conn->createStatement();
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);
264 ResultSet* rset = stmt->executeQuery();
268 int iovID = rset->getInt(1);
270 int runNum = rset->getInt(3);
271 Date startDate = rset->getDate(4);
272 Date endDate = rset->getDate(5);
273 Date dbDate = rset->getDate(6);
275 runStart =
dh.dateToTm(startDate);
276 runEnd =
dh.dateToTm(endDate);
277 dbtime =
dh.dateToTm(dbDate);
280 atag.setLocationDef(locDef);
281 atag.setGeneralTag(rset->getString(7));
284 atag.setRunTypeDef(rundef);
288 r.setRunStart(runStart);
290 r.setDBInsertionTime(dbtime);
293 m_vec_runiov.push_back(
r);
298 m_conn->terminateStatement(stmt);
300 }
catch (SQLException&
e) {
301 throw(std::runtime_error(
std::string(
"RunList::fetchRunsByLocation: ") +
e.getMessage()));
306 this->checkConnection();
309 int my_min_run = min_run - 1;
310 int my_max_run = max_run + 1;
312 Statement* stmt0 = m_conn->createStatement();
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);
322 ResultSet* rset0 = stmt0->executeQuery();
324 nruns = rset0->getInt(1);
326 m_conn->terminateStatement(stmt0);
328 cout <<
"number of runs=" << nruns << endl;
330 m_vec_runiov.reserve(nruns);
332 Statement* stmt = m_conn->createStatement();
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);
351 ResultSet* rset = stmt->executeQuery();
355 int iovID = rset->getInt(1);
357 int runNum = rset->getInt(3);
358 Date startDate = rset->getDate(4);
359 Date endDate = rset->getDate(5);
360 Date dbDate = rset->getDate(6);
362 runStart =
dh.dateToTm(startDate);
363 runEnd =
dh.dateToTm(endDate);
364 dbtime =
dh.dateToTm(dbDate);
367 atag.setLocationDef(locDef);
368 atag.setGeneralTag(rset->getString(7));
371 atag.setRunTypeDef(rundef);
375 r.setRunStart(runStart);
377 r.setDBInsertionTime(dbtime);
380 m_vec_runiov.push_back(
r);
385 m_conn->terminateStatement(stmt);
387 }
catch (SQLException&
e) {
388 throw(std::runtime_error(
std::string(
"RunList::fetchRunsByLocation: ") +
e.getMessage()));
std::vector< RunIOV > getRuns()
void fetchRuns() noexcept(false)
void setRunTag(const RunTag &tag)
void fetchRunsByLocation(int min_run, int max_run, const LocationDef &locDef) noexcept(false)
void fetchNonEmptyRuns() noexcept(false)
void setRunType(std::string runtype)
void fetchLastNRuns(int max_run, int n_runs) noexcept(false)
void fetchNonEmptyGlobalRuns() noexcept(false)
void fetchGlobalRunsByLocation(int min_run, int max_run, const LocationDef &locDef) noexcept(false)