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
MonRunList Class Reference

#include <MonRunList.h>

Inheritance diagram for MonRunList:
IDBObject

Public Member Functions

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)
 
MonRunTag getMonRunTag () const
 
std::vector< MonRunIOVgetRuns ()
 
RunTag getRunTag () const
 
 MonRunList ()
 
void setMonRunTag (const MonRunTag &tag)
 
void setRunTag (const RunTag &tag)
 
 ~MonRunList ()
 
- 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

MonRunTag m_monrunTag
 
RunTag m_runTag
 
std::vector< MonRunIOVm_vec_monruniov
 

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

Constructor & Destructor Documentation

MonRunList::MonRunList ( )

Definition at line 14 of file MonRunList.cc.

References NULL.

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

Definition at line 19 of file MonRunList.cc.

20 {
21 }

Member Function Documentation

void MonRunList::fetchLastNRuns ( int  max_run,
int  n_runs 
)
throw (std::runtime_error
)

Definition at line 259 of file MonRunList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, reco::return(), MonRunIOV::setID(), RunIOV::setID(), MonRunIOV::setMonRunTag(), RunIOV::setRunEnd(), MonRunIOV::setRunIOV(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), and MonRunIOV::setSubRunStart().

Referenced by EcalCondDBInterface::fetchMonRunListLastNRuns().

261 {
262 
263  // fetch the last n_runs that come just before max_run (including max_run)
264 
265  this->checkConnection();
266 
267 
269  int tagID = m_runTag.fetchID();
270  cout <<"tag id="<< tagID << endl;
271  if (!tagID) {
272  return ;
273  }
275  int montagID = m_monrunTag.fetchID();
276  cout <<"mon tag id="<< montagID << endl;
277  if (!montagID) {
278  return ;
279  }
280 
281  int my_max_run=max_run+1;
282  try {
283 
284  int nruns=n_runs;
285  m_vec_monruniov.reserve(nruns);
286 
287  Statement* stmt = m_conn->createStatement();
288  stmt->setSQL("select run_num, run_start, run_end, tag_id, run_iov_id, subrun_num, subrun_start, subrun_end, mon_iov_id from (SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id as mon_iov_id FROM run_iov, mon_run_iov "
289  "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id "
290  " and mon_run_iov.tag_id=:montag_id "
291  " and run_iov.run_num< :max_run "
292  " order by run_iov.run_num DESC ) where rownum< :n_runs order by run_num DESC " );
293  stmt->setInt(1, tagID);
294  stmt->setInt(2, montagID);
295  stmt->setInt(3, my_max_run);
296  stmt->setInt(4, n_runs);
297 
299  Tm runStart;
300  Tm runEnd;
301  Tm lrunStart;
302  Tm lrunEnd;
303 
304  ResultSet* rset = stmt->executeQuery();
305  int i=0;
306  while (i<nruns) {
307  rset->next();
308  int runNum = rset->getInt(1);
309  Date startDate = rset->getDate(2);
310  Date endDate = rset->getDate(3);
311  // int ltag = rset->getInt(4);
312  int lid=rset->getInt(5);
313  int subrun=rset->getInt(6);
314  Date monstartDate = rset->getDate(7);
315  Date monendDate = rset->getDate(8);
316  int liov_id=rset->getInt(9);
317 
318  runStart = dh.dateToTm( startDate );
319  runEnd = dh.dateToTm( endDate );
320  lrunStart = dh.dateToTm( monstartDate );
321  lrunEnd = dh.dateToTm( monendDate );
322 
323  RunIOV r ;
324  r.setRunNumber(runNum);
325  r.setRunStart(runStart);
326  r.setRunEnd(runEnd);
327  r.setRunTag(m_runTag);
328  r.setID(lid);
329 
330  MonRunIOV lr ;
331  // da correggere qui
332  lr.setRunIOV(r);
333  lr.setSubRunNumber(subrun);
334  lr.setSubRunStart(lrunStart);
335  lr.setSubRunEnd(lrunEnd);
337  lr.setID(liov_id);
338  m_vec_monruniov.push_back(lr);
339 
340  i++;
341  }
342 
343 
344  m_conn->terminateStatement(stmt);
345  } catch (SQLException &e) {
346  throw(std::runtime_error("MonRunList::fetchLastNRuns: "+e.getMessage()));
347  }
348 
349 
350 }
int i
Definition: DBlmapReader.cc:9
RunTag m_runTag
Definition: MonRunList.h:39
int fetchID()
Definition: MonRunTag.cc:59
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
void setRunStart(const Tm &start)
Definition: RunIOV.cc:52
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setRunIOV(const RunIOV &iov)
Definition: MonRunIOV.cc:53
void setRunTag(const RunTag &tag)
Definition: RunIOV.cc:86
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
int fetchID()
Definition: RunTag.cc:80
void setSubRunEnd(const Tm &end)
Definition: MonRunIOV.cc:101
void setSubRunNumber(subrun_t subrun)
Definition: MonRunIOV.cc:67
void setSubRunStart(const Tm &start)
Definition: MonRunIOV.cc:84
std::vector< MonRunIOV > m_vec_monruniov
Definition: MonRunList.h:38
MonRunTag m_monrunTag
Definition: MonRunList.h:40
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunIOV.cc:36
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setRunEnd(const Tm &end)
Definition: RunIOV.cc:69
return(e1-e2)*(e1-e2)+dp *dp
tuple cout
Definition: gather_cfg.py:145
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: RunIOV.h:13
Definition: Tm.h:13
void checkConnection() const
Definition: IDBObject.h:41
void setID(int id)
Definition: RunIOV.cc:37
tuple dh
Definition: cuy.py:353
void setID(int id)
Definition: MonRunIOV.cc:31
void MonRunList::fetchRuns ( )
throw (std::runtime_error
)

Definition at line 52 of file MonRunList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, reco::return(), MonRunIOV::setID(), RunIOV::setID(), MonRunIOV::setMonRunTag(), RunIOV::setRunEnd(), MonRunIOV::setRunIOV(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), and MonRunIOV::setSubRunStart().

Referenced by EcalCondDBInterface::fetchMonRunList().

54 {
55 
56 
57  this->checkConnection();
58  int nruns=0;
59 
61  int tagID = m_runTag.fetchID();
62  cout <<"tag id="<< tagID << endl;
63  if (!tagID) {
64  return ;
65  }
67  int montagID = m_monrunTag.fetchID();
68  cout <<"mon tag id="<< montagID << endl;
69  if (!montagID) {
70  return ;
71  }
72 
73  try {
74  Statement* stmt0 = m_conn->createStatement();
75  stmt0->setSQL("SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov "
76  "WHERE mon_run_iov.run_iov_id= run_iov.iov_id and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id " );
77  stmt0->setInt(1, tagID);
78  stmt0->setInt(2, montagID);
79 
80  ResultSet* rset0 = stmt0->executeQuery();
81  if (rset0->next()) {
82  nruns = rset0->getInt(1);
83  }
84  m_conn->terminateStatement(stmt0);
85 
86  cout <<"nruns="<< nruns << endl;
87 
88  m_vec_monruniov.reserve(nruns);
89 
90  Statement* stmt = m_conn->createStatement();
91  stmt->setSQL("SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, mon_run_iov "
92  "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id order by run_iov.run_num, mon_run_iov.subrun_num ASC " );
93  stmt->setInt(1, tagID);
94 
96  Tm runStart;
97  Tm runEnd;
98  Tm lrunStart;
99  Tm lrunEnd;
100 
101  ResultSet* rset = stmt->executeQuery();
102  int i=0;
103  while (i<nruns) {
104  rset->next();
105  int runNum = rset->getInt(1);
106  Date startDate = rset->getDate(2);
107  Date endDate = rset->getDate(3);
108  //int ltag = rset->getInt(4);
109  int lid=rset->getInt(5);
110  int subrun=rset->getInt(6);
111  Date monstartDate = rset->getDate(7);
112  Date monendDate = rset->getDate(8);
113  int liov_id=rset->getInt(9);
114 
115  runStart = dh.dateToTm( startDate );
116  runEnd = dh.dateToTm( endDate );
117  lrunStart = dh.dateToTm( monstartDate );
118  lrunEnd = dh.dateToTm( monendDate );
119 
120  RunIOV r ;
121  r.setRunNumber(runNum);
122  r.setRunStart(runStart);
123  r.setRunEnd(runEnd);
124  r.setRunTag(m_runTag);
125  r.setID(lid);
126 
127  MonRunIOV lr ;
128  // da correggere qui
129  lr.setRunIOV(r);
130  lr.setSubRunNumber(subrun);
131  lr.setSubRunStart(lrunStart);
132  lr.setSubRunEnd(lrunEnd);
134  lr.setID(liov_id);
135  m_vec_monruniov.push_back(lr);
136 
137  i++;
138  }
139 
140 
141  m_conn->terminateStatement(stmt);
142  } catch (SQLException &e) {
143  throw(std::runtime_error("RunIOV::fetchID: "+e.getMessage()));
144  }
145 
146 
147 }
int i
Definition: DBlmapReader.cc:9
RunTag m_runTag
Definition: MonRunList.h:39
int fetchID()
Definition: MonRunTag.cc:59
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
void setRunStart(const Tm &start)
Definition: RunIOV.cc:52
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setRunIOV(const RunIOV &iov)
Definition: MonRunIOV.cc:53
void setRunTag(const RunTag &tag)
Definition: RunIOV.cc:86
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
int fetchID()
Definition: RunTag.cc:80
void setSubRunEnd(const Tm &end)
Definition: MonRunIOV.cc:101
void setSubRunNumber(subrun_t subrun)
Definition: MonRunIOV.cc:67
void setSubRunStart(const Tm &start)
Definition: MonRunIOV.cc:84
std::vector< MonRunIOV > m_vec_monruniov
Definition: MonRunList.h:38
MonRunTag m_monrunTag
Definition: MonRunList.h:40
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunIOV.cc:36
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setRunEnd(const Tm &end)
Definition: RunIOV.cc:69
return(e1-e2)*(e1-e2)+dp *dp
tuple cout
Definition: gather_cfg.py:145
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: RunIOV.h:13
Definition: Tm.h:13
void checkConnection() const
Definition: IDBObject.h:41
void setID(int id)
Definition: RunIOV.cc:37
tuple dh
Definition: cuy.py:353
void setID(int id)
Definition: MonRunIOV.cc:31
void MonRunList::fetchRuns ( int  min_run,
int  max_run 
)
throw (std::runtime_error
)

Definition at line 149 of file MonRunList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, alignCSCRings::r, reco::return(), MonRunIOV::setID(), RunIOV::setID(), MonRunIOV::setMonRunTag(), RunIOV::setRunEnd(), MonRunIOV::setRunIOV(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), and MonRunIOV::setSubRunStart().

151 {
152 
153 
154  this->checkConnection();
155  int nruns=0;
156 
158  int tagID = m_runTag.fetchID();
159  cout <<"tag id="<< tagID << endl;
160  if (!tagID) {
161  return ;
162  }
164  int montagID = m_monrunTag.fetchID();
165  cout <<"mon tag id="<< montagID << endl;
166  if (!montagID) {
167  return ;
168  }
169 
170  int my_min_run=min_run-1;
171  int my_max_run=max_run+1;
172  try {
173  Statement* stmt0 = m_conn->createStatement();
174  stmt0->setSQL("SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov "
175  "WHERE mon_run_iov.run_iov_id= run_iov.iov_id "
176  "and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id "
177  " and run_iov.run_num> :min_run and run_iov.run_num< :max_run "
178  );
179  stmt0->setInt(1, tagID);
180  stmt0->setInt(2, montagID);
181  stmt0->setInt(3, my_min_run);
182  stmt0->setInt(4, my_max_run);
183 
184  ResultSet* rset0 = stmt0->executeQuery();
185  if (rset0->next()) {
186  nruns = rset0->getInt(1);
187  }
188  m_conn->terminateStatement(stmt0);
189 
190  cout <<"nruns="<< nruns << endl;
191 
192  m_vec_monruniov.reserve(nruns);
193 
194  Statement* stmt = m_conn->createStatement();
195  stmt->setSQL("SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, mon_run_iov "
196  "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id "
197  " and mon_run_iov.tag_id=:montag_id "
198  " and run_iov.run_num> :min_run and run_iov.run_num< :max_run "
199  " order by run_iov.run_num, mon_run_iov.subrun_num ASC " );
200  stmt->setInt(1, tagID);
201  stmt->setInt(2, montagID);
202  stmt->setInt(3, my_min_run);
203  stmt->setInt(4, my_max_run);
204 
206  Tm runStart;
207  Tm runEnd;
208  Tm lrunStart;
209  Tm lrunEnd;
210 
211  ResultSet* rset = stmt->executeQuery();
212  int i=0;
213  while (i<nruns) {
214  rset->next();
215  int runNum = rset->getInt(1);
216  Date startDate = rset->getDate(2);
217  Date endDate = rset->getDate(3);
218  // int ltag = rset->getInt(4);
219  int lid=rset->getInt(5);
220  int subrun=rset->getInt(6);
221  Date monstartDate = rset->getDate(7);
222  Date monendDate = rset->getDate(8);
223  int liov_id=rset->getInt(9);
224 
225  runStart = dh.dateToTm( startDate );
226  runEnd = dh.dateToTm( endDate );
227  lrunStart = dh.dateToTm( monstartDate );
228  lrunEnd = dh.dateToTm( monendDate );
229 
230  RunIOV r ;
231  r.setRunNumber(runNum);
232  r.setRunStart(runStart);
233  r.setRunEnd(runEnd);
234  r.setRunTag(m_runTag);
235  r.setID(lid);
236 
237  MonRunIOV lr ;
238  // da correggere qui
239  lr.setRunIOV(r);
240  lr.setSubRunNumber(subrun);
241  lr.setSubRunStart(lrunStart);
242  lr.setSubRunEnd(lrunEnd);
244  lr.setID(liov_id);
245  m_vec_monruniov.push_back(lr);
246 
247  i++;
248  }
249 
250 
251  m_conn->terminateStatement(stmt);
252  } catch (SQLException &e) {
253  throw(std::runtime_error("RunIOV::fetchID: "+e.getMessage()));
254  }
255 
256 
257 }
int i
Definition: DBlmapReader.cc:9
RunTag m_runTag
Definition: MonRunList.h:39
int fetchID()
Definition: MonRunTag.cc:59
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
void setRunStart(const Tm &start)
Definition: RunIOV.cc:52
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setRunIOV(const RunIOV &iov)
Definition: MonRunIOV.cc:53
void setRunTag(const RunTag &tag)
Definition: RunIOV.cc:86
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
int fetchID()
Definition: RunTag.cc:80
void setSubRunEnd(const Tm &end)
Definition: MonRunIOV.cc:101
void setSubRunNumber(subrun_t subrun)
Definition: MonRunIOV.cc:67
void setSubRunStart(const Tm &start)
Definition: MonRunIOV.cc:84
std::vector< MonRunIOV > m_vec_monruniov
Definition: MonRunList.h:38
MonRunTag m_monrunTag
Definition: MonRunList.h:40
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunIOV.cc:36
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setRunEnd(const Tm &end)
Definition: RunIOV.cc:69
return(e1-e2)*(e1-e2)+dp *dp
tuple cout
Definition: gather_cfg.py:145
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: RunIOV.h:13
Definition: Tm.h:13
void checkConnection() const
Definition: IDBObject.h:41
void setID(int id)
Definition: RunIOV.cc:37
tuple dh
Definition: cuy.py:353
void setID(int id)
Definition: MonRunIOV.cc:31
MonRunTag MonRunList::getMonRunTag ( ) const

Definition at line 41 of file MonRunList.cc.

42 {
43  return m_monrunTag;
44 }
MonRunTag m_monrunTag
Definition: MonRunList.h:40
std::vector< MonRunIOV > MonRunList::getRuns ( )
RunTag MonRunList::getRunTag ( ) const

Definition at line 37 of file MonRunList.cc.

38 {
39  return m_runTag;
40 }
RunTag m_runTag
Definition: MonRunList.h:39
void MonRunList::setMonRunTag ( const MonRunTag tag)
void MonRunList::setRunTag ( const RunTag tag)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 18 of file MonRunList.h.

Member Data Documentation

MonRunTag MonRunList::m_monrunTag
private

Definition at line 40 of file MonRunList.h.

RunTag MonRunList::m_runTag
private

Definition at line 39 of file MonRunList.h.

std::vector<MonRunIOV> MonRunList::m_vec_monruniov
private

Definition at line 38 of file MonRunList.h.