CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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) throw (std::runtime_error)
 
void fetchLastNRuns (int max_run, int n_runs) throw (std::runtime_error)
 
void fetchRuns () throw (std::runtime_error)
 
void fetchRuns (int min_run, int max_run) throw (std::runtime_error)
 
void fetchRunsByLocation (int min_run, int max_run, const LocationDef locDef) throw (std::runtime_error)
 
std::vector< RunIOVgetRuns ()
 
RunTag getRunTag () const
 
 RunList ()
 
void setRunTag (RunTag tag)
 
 ~RunList ()
 
- 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 int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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 ( )

Definition at line 13 of file RunList.cc.

References NULL.

14 {
15  m_conn = NULL;
16 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
RunList::~RunList ( )

Definition at line 18 of file RunList.cc.

19 {
20 }

Member Function Documentation

void RunList::fetchGlobalRunsByLocation ( int  min_run,
int  max_run,
const LocationDef  locDef 
)
throw (std::runtime_error
)

Definition at line 300 of file RunList.cc.

References getBeamSpotDB::atag, gather_cfg::cout, DateHandler::dateToTm(), i, csvReporter::r, RunIOV::setDBInsertionTime(), RunTag::setGeneralTag(), RunIOV::setID(), RunTag::setLocationDef(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), RunTypeDef::setRunType(), and RunTag::setRunTypeDef().

Referenced by EcalCondDBInterface::fetchGlobalRunListByLocation().

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

Definition at line 137 of file RunList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), i, csvReporter::r, mathSSE::return(), RunIOV::setDBInsertionTime(), RunIOV::setID(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), and RunIOV::setRunTag().

Referenced by EcalCondDBInterface::fetchRunListLastNRuns().

139 {
140 
141  // fetch the last n_runs that come just before max_run (including max_run)
142 
143  this->checkConnection();
144 
145 
147  int tagID = m_runTag.fetchID();
148  cout <<"tag id="<< tagID << endl;
149  if (!tagID) {
150  return ;
151  }
152 
153  int my_max_run=max_run+1;
154  try {
155 
156  int nruns=n_runs+1;
157  m_vec_runiov.reserve(nruns);
158 
159  Statement* stmt = m_conn->createStatement();
160  stmt->setSQL("select iov_id, tag_id, run_num, run_start, run_end, DB_TIMESTAMP from "
161  " (SELECT * from RUN_IOV "
162  " WHERE tag_id = :tag_id "
163  " and run_num< :max_run "
164  " order by run_num DESC ) where rownum< :n_runs ORDER BY run_num ASC " );
165  stmt->setInt(1, tagID);
166  stmt->setInt(2, my_max_run);
167  stmt->setInt(3, nruns);
168 
169  DateHandler dh(m_env, m_conn);
170  Tm runStart;
171  Tm runEnd;
172  Tm dbtime;
173 
174  ResultSet* rset = stmt->executeQuery();
175  int i=0;
176  while (i<n_runs) {
177  rset->next();
178  int iovID = rset->getInt(1);
179  // int tagID = rset->getInt(2);
180  int runNum = rset->getInt(3);
181  Date startDate = rset->getDate(4);
182  Date endDate = rset->getDate(5);
183  Date dbDate = rset->getDate(6);
184 
185  runStart = dh.dateToTm( startDate );
186  runEnd = dh.dateToTm( endDate );
187  dbtime = dh.dateToTm( dbDate );
188 
189  RunIOV r ;
190  r.setRunNumber(runNum);
191  r.setRunStart(runStart);
192  r.setRunEnd(runEnd);
193  r.setDBInsertionTime(dbtime);
194  r.setRunTag(m_runTag);
195  r.setID(iovID);
196  m_vec_runiov.push_back(r);
197 
198  i++;
199  }
200 
201  m_conn->terminateStatement(stmt);
202  } catch (SQLException &e) {
203  throw(std::runtime_error("RunList::fetchLastNRuns: "+e.getMessage()));
204  }
205 
206 
207 }
int i
Definition: DBlmapReader.cc:9
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setRunEnd(Tm end)
Definition: RunIOV.cc:69
return((rh^lh)&mask)
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
void setDBInsertionTime(Tm dbtime)
Definition: RunIOV.h:31
void setRunTag(RunTag tag)
Definition: RunIOV.cc:86
int fetchID()
Definition: RunTag.cc:80
void setRunStart(Tm start)
Definition: RunIOV.cc:52
RunTag m_runTag
Definition: RunList.h:40
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: RunIOV.h:13
Definition: Tm.h:14
void checkConnection() const
Definition: IDBObject.h:41
void setID(int id)
Definition: RunIOV.cc:37
std::vector< RunIOV > m_vec_runiov
Definition: RunList.h:39
void RunList::fetchRuns ( )
throw (std::runtime_error
)

Definition at line 40 of file RunList.cc.

Referenced by EcalCondDBInterface::fetchRunList().

42 {
43  fetchRuns(-1, -1);
44 }
void fetchRuns()
Definition: RunList.cc:40
void RunList::fetchRuns ( int  min_run,
int  max_run 
)
throw (std::runtime_error
)

Definition at line 46 of file RunList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), i, csvReporter::r, mathSSE::return(), RunIOV::setDBInsertionTime(), RunIOV::setID(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), and RunIOV::setRunTag().

48 {
49 
50  this->checkConnection();
51  int nruns=0;
52 
54  int tagID = m_runTag.fetchID();
55  cout <<"tag id="<< tagID << endl;
56  if (!tagID) {
57  return ;
58  }
59 
60  int my_min_run=min_run-1;
61  int my_max_run=max_run+1;
62  try {
63  Statement* stmt0 = m_conn->createStatement();
64  string sql = "SELECT count(iov_id) FROM run_iov "
65  "WHERE tag_id = :tag_id ";
66  if (min_run > 0) {
67  sql += " and run_iov.run_num> :min_run and run_iov.run_num< :max_run ";
68  }
69  stmt0->setSQL(sql);
70  stmt0->setInt(1, tagID);
71  if (min_run > 0) {
72  stmt0->setInt(2, my_min_run);
73  stmt0->setInt(3, my_max_run);
74  }
75 
76  ResultSet* rset0 = stmt0->executeQuery();
77  if (rset0->next()) {
78  nruns = rset0->getInt(1);
79  }
80  m_conn->terminateStatement(stmt0);
81 
82  cout <<"number of runs="<< nruns << endl;
83  m_vec_runiov.reserve(nruns);
84 
85  Statement* stmt = m_conn->createStatement();
86  sql = "SELECT iov_id, tag_id, run_num, run_start, run_end, "
87  "db_timestamp FROM run_iov "
88  " WHERE tag_id = :tag_id ";
89  if (min_run > 0) {
90  sql += " and run_iov.run_num> :min_run and run_iov.run_num< :max_run ";
91  }
92  sql += " order by run_num ";
93  stmt->setSQL(sql);
94  stmt->setInt(1, tagID);
95  if (min_run > 0) {
96  stmt->setInt(2, my_min_run);
97  stmt->setInt(3, my_max_run);
98  }
99 
100  DateHandler dh(m_env, m_conn);
101  Tm runStart;
102  Tm runEnd;
103  Tm dbtime;
104 
105  ResultSet* rset = stmt->executeQuery();
106  int i=0;
107  while (i<nruns) {
108  rset->next();
109  int iovID = rset->getInt(1);
110  // int tagID = rset->getInt(2);
111  int runNum = rset->getInt(3);
112  Date startDate = rset->getDate(4);
113  Date endDate = rset->getDate(5);
114  Date dbDate = rset->getDate(6);
115 
116  runStart = dh.dateToTm( startDate );
117  runEnd = dh.dateToTm( endDate );
118  dbtime = dh.dateToTm( dbDate );
119 
120  RunIOV r ;
121  r.setRunNumber(runNum);
122  r.setRunStart(runStart);
123  r.setRunEnd(runEnd);
124  r.setDBInsertionTime(dbtime);
125  r.setRunTag(m_runTag);
126  r.setID(iovID);
127  m_vec_runiov.push_back(r);
128 
129  i++;
130  }
131  m_conn->terminateStatement(stmt);
132  } catch (SQLException &e) {
133  throw(std::runtime_error("RunList::fetchRuns: "+e.getMessage()));
134  }
135 }
int i
Definition: DBlmapReader.cc:9
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setRunEnd(Tm end)
Definition: RunIOV.cc:69
return((rh^lh)&mask)
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
void setDBInsertionTime(Tm dbtime)
Definition: RunIOV.h:31
void setRunTag(RunTag tag)
Definition: RunIOV.cc:86
int fetchID()
Definition: RunTag.cc:80
void setRunStart(Tm start)
Definition: RunIOV.cc:52
RunTag m_runTag
Definition: RunList.h:40
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: RunIOV.h:13
Definition: Tm.h:14
void checkConnection() const
Definition: IDBObject.h:41
void setID(int id)
Definition: RunIOV.cc:37
std::vector< RunIOV > m_vec_runiov
Definition: RunList.h:39
void RunList::fetchRunsByLocation ( int  min_run,
int  max_run,
const LocationDef  locDef 
)
throw (std::runtime_error
)

Definition at line 211 of file RunList.cc.

References getBeamSpotDB::atag, gather_cfg::cout, DateHandler::dateToTm(), i, csvReporter::r, RunIOV::setDBInsertionTime(), RunTag::setGeneralTag(), RunIOV::setID(), RunTag::setLocationDef(), RunIOV::setRunEnd(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), RunTypeDef::setRunType(), and RunTag::setRunTypeDef().

Referenced by EcalCondDBInterface::fetchRunListByLocation().

213 {
214 
215  this->checkConnection();
216  int nruns=0;
217 
218  int my_min_run=min_run-1;
219  int my_max_run=max_run+1;
220  try {
221  Statement* stmt0 = m_conn->createStatement();
222  stmt0->setSQL("SELECT count(iov_id) FROM run_iov r , run_tag t, location_def l "
223  " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id AND l.LOCATION= :1 "
224  " and r.run_num> :2 and r.run_num< :3 ");
225  stmt0->setString(1,locDef.getLocation() );
226  stmt0->setInt(2, my_min_run);
227  stmt0->setInt(3, my_max_run);
228 
229  ResultSet* rset0 = stmt0->executeQuery();
230  if (rset0->next()) {
231  nruns = rset0->getInt(1);
232  }
233  m_conn->terminateStatement(stmt0);
234 
235  cout <<"number of runs="<< nruns << endl;
236 
237  m_vec_runiov.reserve(nruns);
238 
239  Statement* stmt = m_conn->createStatement();
240  stmt->setSQL("SELECT r.iov_id, r.tag_id, r.run_num, r.run_start, r.run_end, r.DB_TIMESTAMP , "
241  " t.gen_tag, rt.RUN_TYPE "
242  " FROM run_iov r , run_tag t, location_def l, run_type_def rt "
243  " WHERE r.tag_id=t.tag_id and t.LOCATION_ID=l.def_id and t.run_type_id=rt.DEF_ID "
244  " AND l.LOCATION= :1 "
245  " and r.run_num> :2 and r.run_num< :3 "
246  " order by run_num " );
247  stmt->setString(1,locDef.getLocation() );
248  stmt->setInt(2, my_min_run);
249  stmt->setInt(3, my_max_run);
250 
251  DateHandler dh(m_env, m_conn);
252  Tm runStart;
253  Tm runEnd;
254  Tm dbtime;
255 
256  ResultSet* rset = stmt->executeQuery();
257  int i=0;
258  while (i<nruns) {
259  rset->next();
260  int iovID = rset->getInt(1);
261  // int tagID = rset->getInt(2);
262  int runNum = rset->getInt(3);
263  Date startDate = rset->getDate(4);
264  Date endDate = rset->getDate(5);
265  Date dbDate = rset->getDate(6);
266 
267  runStart = dh.dateToTm( startDate );
268  runEnd = dh.dateToTm( endDate );
269  dbtime = dh.dateToTm( dbDate );
270 
271  RunTag atag;
272  atag.setLocationDef(locDef);
273  atag.setGeneralTag(rset->getString(7));
274  RunTypeDef rundef;
275  rundef.setRunType(rset->getString(8));
276  atag.setRunTypeDef(rundef);
277 
278  RunIOV r ;
279  r.setRunNumber(runNum);
280  r.setRunStart(runStart);
281  r.setRunEnd(runEnd);
282  r.setDBInsertionTime(dbtime);
283  r.setRunTag(atag);
284  r.setID(iovID);
285  m_vec_runiov.push_back(r);
286 
287  i++;
288  }
289 
290 
291  m_conn->terminateStatement(stmt);
292 
293  } catch (SQLException &e) {
294  throw(std::runtime_error("RunList::fetchRunsByLocation: "+e.getMessage()));
295  }
296 
297 
298 }
int i
Definition: DBlmapReader.cc:9
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setLocationDef(const LocationDef locDef)
Definition: RunTag.cc:53
Definition: RunTag.h:13
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setRunEnd(Tm end)
Definition: RunIOV.cc:69
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
void setDBInsertionTime(Tm dbtime)
Definition: RunIOV.h:31
void setRunTag(RunTag tag)
Definition: RunIOV.cc:86
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
std::string getLocation() const
Definition: LocationDef.cc:26
void setRunStart(Tm start)
Definition: RunIOV.cc:52
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
Definition: RunIOV.h:13
Definition: Tm.h:14
void checkConnection() const
Definition: IDBObject.h:41
void setID(int id)
Definition: RunIOV.cc:37
std::vector< RunIOV > m_vec_runiov
Definition: RunList.h:39
std::vector< RunIOV > RunList::getRuns ( )
RunTag RunList::getRunTag ( ) const

Definition at line 30 of file RunList.cc.

31 {
32  return m_runTag;
33 }
RunTag m_runTag
Definition: RunList.h:40
void RunList::setRunTag ( RunTag  tag)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 18 of file RunList.h.

Member Data Documentation

RunTag RunList::m_runTag
private

Definition at line 40 of file RunList.h.

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

Definition at line 39 of file RunList.h.