CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalCondDBInterface.cc
Go to the documentation of this file.
1 // $Id: EcalCondDBInterface.cc,v 1.35 2011/09/14 13:27:59 organtin Exp $
2 
3 #include <iostream>
4 #include <string>
5 #include <vector>
6 #include <sstream>
7 #include <stdlib.h>
8 #include <cstdlib>
9 #include <time.h>
10 #include <stdexcept>
12 
18 
25 
26 using namespace std;
27 using namespace oracle::occi;
28 
30  // retrieve the lists of logic_ids, to build the detids
31  std::vector<EcalLogicID> crystals_EB =
32  getEcalLogicIDSetOrdered( "EB_crystal_angle",
33  -85,85,1,360,
35  "EB_crystal_number", 4 );
36  std::vector<EcalLogicID> crystals_EE =
37  getEcalLogicIDSetOrdered( "EE_crystal_number",
38  -1,1,1,100,
39  1,100,
40  "EE_crystal_number", 4 );
41  // fill the barrel map
42  std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
43  std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
44  while (ieb != eeb) {
45  int iEta = ieb->getID1();
46  int iPhi = ieb->getID2();
47  EBDetId ebdetid(iEta,iPhi);
48  _logicId2DetId[ieb->getLogicID()] = ebdetid;
49  _detId2LogicId[ebdetid] = ieb->getLogicID();
50  ieb++;
51  }
52 
53  // fill the endcap map
54  std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
55  std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
56 
57  while (iee != eee) {
58  int iSide = iee->getID1();
59  int iX = iee->getID2();
60  int iY = iee->getID3();
61  EEDetId eedetidpos(iX,iY,iSide);
62  _logicId2DetId[iee->getLogicID()] = eedetidpos;
63  _detId2LogicId[eedetidpos] = iee->getLogicID();
64  iee++;
65  }
66 
67 }
68 
69 
71  throw(std::runtime_error)
72 {
73 
74  string sql = "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE logic_id = :logicID AND name=maps_to";
75 
76  int id1, id2, id3;
77  string name, mapsTo;
78 
79  try {
80  stmt->setSQL(sql);
81  stmt->setInt(1, logicID);
82  ResultSet* rset = stmt->executeQuery();
83 
84  if (rset->next()) {
85  name = rset->getString(1);
86  logicID = rset->getInt(2);
87  id1 = rset->getInt(3);
88  if (rset->isNull(3)) { id1 = EcalLogicID::NULLID; }
89  id2 = rset->getInt(4);
90  if (rset->isNull(4)) { id2 = EcalLogicID::NULLID; }
91  id3 = rset->getInt(5);
92  if (rset->isNull(5)) { id3 = EcalLogicID::NULLID; }
93  mapsTo = rset->getString(6);
94  } else {
95  stringstream msg;
96  msg << "ERROR: Cannot build EcalLogicID for logic_id " << logicID;
97  throw(std::runtime_error(msg.str()));
98  }
99 
100  } catch (SQLException &e) {
101  throw(std::runtime_error("ERROR: Failed to retrive ids: " + e.getMessage() ));
102  }
103 
104  return EcalLogicID( name, logicID, id1, id2, id3, mapsTo );
105 }
106 
108  throw(std::runtime_error)
109 {
110  std::list<ODDelaysDat> ret;
111  RunFEConfigDat d;
112  std::map<EcalLogicID, RunFEConfigDat > fillMap;
113  try {
114  d.setConnection(env, conn);
115  d.fetchData(&fillMap, iov);
116  } catch (std::runtime_error &e) {
117  throw e;
118  }
119  std::map<EcalLogicID, RunFEConfigDat >::const_iterator i = fillMap.begin();
120  std::map<EcalLogicID, RunFEConfigDat >::const_iterator e = fillMap.end();
121  while (i != e) {
122  ODFEDAQConfig feDaqConfig;
124  temp.setId(i->second.getConfigId());
125  feDaqConfig.setConnection(env, conn);
126  feDaqConfig.fetchData(&temp);
127  std::vector<ODDelaysDat> delays;
128  ODDelaysDat temp2;
129  temp2.setConnection(env, conn);
130  temp2.fetchData(&delays, temp.getDelayId());
131  std::vector<ODDelaysDat>::const_iterator di = delays.begin();
132  std::vector<ODDelaysDat>::const_iterator de = delays.end();
133  while (di != de) {
134  ret.push_back(*di++);
135  }
136  i++;
137  }
138  return ret;
139 }
140 
142  int id1,
143  int id2,
144  int id3,
145  string mapsTo )
146  throw(std::runtime_error)
147 {
148 
149  if (mapsTo == "") {
150  mapsTo = name;
151  }
152 
153  // build the sql string
154  stringstream ss;
155  ss << "SELECT logic_id FROM channelView WHERE name = :n AND";
156  int idarray[] = {id1, id2, id3};
157  for (int i=1; i<=3; i++) {
158  if (idarray[i-1] == EcalLogicID::NULLID) {
159  ss << " id"<<i<<" IS NULL AND";
160  } else {
161  ss << " id"<<i<<" = :id"<<i<<" AND";
162  }
163  }
164  ss <<" maps_to = :m";
165 
166  // cout << "SQL: " << ss.str() << endl;
167 
168  int logic_id;
169  try {
170  stmt->setSQL(ss.str());
171 
172  // bind the parameters
173  int j = 1; // parameter number counter
174  stmt->setString(j, name);
175  j++;
176  for (int i=0; i<3; i++) {
177  if (idarray[i] != EcalLogicID::NULLID) {
178  stmt->setInt(j, idarray[i]);
179  j++;
180  }
181  }
182  stmt->setString(j, mapsTo);
183 
184  // execute the statement and retrieve the logic_id
185  ResultSet* rset = stmt->executeQuery();
186  if ( rset->next() ) {
187  logic_id = rset->getInt(1);
188  } else {
189  stringstream msg;
190  msg << "ERROR: Query for EcalLogicID failed for parameters [" <<
191  "name=" << name << ",maps_to=" << mapsTo <<
192  ",id1=" << id1 << ",id2=" << id2 << ",id3=" << id3 << "]";
193  throw(std::runtime_error(msg.str()));
194  }
195  } catch (SQLException &e) {
196  throw(std::runtime_error("ERROR: Failed to retrive logic_id: " + e.getMessage() ));
197  }
198 
199  // create and return the EcalLogicID object
200  return EcalLogicID(name, logic_id, id1, id2, id3, mapsTo);
201 }
202 
203 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDSet( string name,
204  int fromId1, int toId1,
205  int fromId2, int toId2,
206  int fromId3, int toId3,
207  string mapsTo )
208  throw(std::runtime_error)
209 {
210  if (mapsTo == "") {
211  mapsTo = name;
212  }
213 
214  int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
215  int from, to;
216 
217  stringstream ss;
218  ss << "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
219 
220  // loop through the three ids
221  for (int i=1; i<=3; i++) {
222  from = idArray[2*(i-1)];
223  to = idArray[2*(i-1) + 1];
224 
225  // check the id arguments in pairs
226  if ((from == EcalLogicID::NULLID && to != EcalLogicID::NULLID) || // one is null
227  (from != EcalLogicID::NULLID && to == EcalLogicID::NULLID) || // but not the other
228  (from > to)) { // negative interval
229  throw(std::runtime_error("ERROR: Bad arguments for getEcalLogicIDSet"));
230  }
231 
232  // build the sql
233  if (from == EcalLogicID::NULLID && to == EcalLogicID::NULLID) {
234  ss << "id" << i << " IS NULL AND ";
235  } else {
236  ss << "id" << i << " >= :id" << i << "from AND " <<
237  "id" << i << " <= :id" << i << "to AND ";
238  }
239  }
240  ss << "maps_to = :maps_to ORDER BY id1, id2, id3";
241 
242  std::vector<EcalLogicID> result;
243 
244  try {
245  stmt->setSQL(ss.str());
246 
247  // bind the parameters
248  int j = 1; // parameter number counter
249  stmt->setString(j, name);
250  j++;
251 
252  for (int i=0; i<3; i++) {
253  from = idArray[2*i];
254  to = idArray[2*i + 1];
255  if (from != EcalLogicID::NULLID) {
256  stmt->setInt(j, from);
257  j++;
258  stmt->setInt(j, to);
259  j++;
260  }
261  }
262 
263  stmt->setString(j, mapsTo);
264 
265 
266  stmt->setPrefetchRowCount(IDBObject::ECALDB_NROWS);
267 
268  ResultSet* rset = stmt->executeQuery();
269 
270  int id1, id2, id3, logicId;
271 
272  while (rset->next()) {
273  name = rset->getString(1);
274  logicId = rset->getInt(2);
275  id1 = rset->getInt(3);
276  if (rset->isNull(3)) { id1 = EcalLogicID::NULLID; }
277  id2 = rset->getInt(4);
278  if (rset->isNull(4)) { id2 = EcalLogicID::NULLID; }
279  id3 = rset->getInt(5);
280  if (rset->isNull(5)) { id3 = EcalLogicID::NULLID; }
281  mapsTo = rset->getString(6);
282 
283  EcalLogicID ecid = EcalLogicID( name, logicId, id1, id2, id3, mapsTo );
284  result.push_back(ecid);
285  }
286  stmt->setPrefetchRowCount(0);
287 
288  } catch (SQLException &e) {
289  throw(std::runtime_error("ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
290  }
291 
292  return result;
293 }
294 
296  std::map<int, int> ret;
297  std::vector<EcalLogicID> crystals_EB =
298  getEcalLogicIDSetOrdered( "EB_crystal_number",
299  1,36,1,1700,
301  "EB_crystal_number", EcalLogicID::NULLID);
302  std::vector<EcalLogicID> crystals_EE =
303  getEcalLogicIDSetOrdered( "EE_crystal_number",
304  -1,1,1,100,
305  1,100,
306  "EE_crystal_number", EcalLogicID::NULLID);
307  std::vector<EcalLogicID> EB_lmr =
308  getEcalLogicIDSetOrdered( "EB_crystal_number",
309  1,36,1,1700,
311  "ECAL_LMR", EcalLogicID::NULLID);
312  std::vector<EcalLogicID> EE_lmr =
313  getEcalLogicIDSetOrdered( "EE_crystal_number",
314  -1,1,1,100,
315  1,100,
316  "ECAL_LMR", EcalLogicID::NULLID);
317  unsigned int neb = crystals_EB.size();
318  unsigned int nee = crystals_EE.size();
319  if (neb != EB_lmr.size()) {
320  throw(std::runtime_error("ERROR: EB Vectors size do not agree"));
321  }
322  if (nee != EE_lmr.size()) {
323  throw(std::runtime_error("ERROR: EE Vectors size do not agree"));
324  }
325  for (unsigned int i = 0; i < neb; i++) {
326  ret[crystals_EB[i].getLogicID()] = EB_lmr[i].getLogicID() % 100;
327  }
328  for (unsigned int i = 0; i < nee; i++) {
329  ret[crystals_EE[i].getLogicID()] = EE_lmr[i].getLogicID() % 100;
330  }
331  return ret;
332 }
333 
334 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDMappedTo(int lmr_logic_id, std::string maps_to) {
335  std::string name = "EB_crystal_angle";
336  std::string sql = "SELECT LOGIC_ID, ID1, ID2, ID3 "
337  "FROM CHANNELVIEW WHERE NAME = 'EB_crystal_angle' AND LOGIC_ID IN "
338  "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EB_crystal_number' AND "
339  "ID1*10000+ID2 IN (SELECT DISTINCT ID1*10000+ID2 FROM CHANNELVIEW "
340  "WHERE LOGIC_ID = :1 AND NAME = 'EB_crystal_number' AND MAPS_TO = :2) "
341  "AND NAME = MAPS_TO)";
342  if ((lmr_logic_id / 1000000000) == 2) {
343  name = "EE_crystal_number";
344  sql = "SELECT LOGIC_ID, ID1, ID2, ID3 "
345  "FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND LOGIC_ID IN "
346  "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND "
347  "ID1*10000000+ID2*10000+ID3 IN (SELECT DISTINCT "
348  "ID1*10000000+ID2*10000+ID3 FROM CHANNELVIEW "
349  "WHERE LOGIC_ID = :1 AND NAME = 'EE_crystal_number' AND MAPS_TO = :2) "
350  "AND NAME = MAPS_TO) AND NAME = MAPS_TO";
351  }
352  std::vector<EcalLogicID> ret;
353  try {
354  stmt->setSQL(sql.c_str());
355  stmt->setInt(1, lmr_logic_id);
356  stmt->setString(2, maps_to);
357  stmt->setPrefetchRowCount(IDBObject::ECALDB_NROWS);
358 
359  ResultSet* rset = stmt->executeQuery();
360 
361  while (rset->next()) {
362  int logic_id = rset->getInt(1);
363  int id1 = rset->getInt(2);
364  if (rset->isNull(2)) { id1 = EcalLogicID::NULLID; }
365  int id2 = rset->getInt(3);
366  if (rset->isNull(3)) { id2 = EcalLogicID::NULLID; }
367  int id3 = rset->getInt(4);
368  if (rset->isNull(4)) { id3 = EcalLogicID::NULLID; }
369 
370  EcalLogicID ecid = EcalLogicID( name, logic_id, id1, id2, id3, maps_to );
371  ret.push_back(ecid);
372  }
373  stmt->setPrefetchRowCount(0);
374  }
375  catch (SQLException &e) {
376  throw(std::runtime_error("ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
377  }
378  return ret;
379 }
380 
381 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDForLMR(int lmr) {
382  return getEcalLogicIDMappedTo(lmr, "ECAL_LMR");
383 }
384 
385 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDForLMR(const EcalLogicID &lmr) {
386  return getEcalLogicIDForLMR(lmr.getLogicID());
387 }
388 
389 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDForLMPN(int lmr) {
390  if ((lmr / 1000000000) == 2) {
391  return getEcalLogicIDMappedTo(lmr, "EE_LM_PN");
392  } else {
393  return getEcalLogicIDMappedTo(lmr, "EB_LM_PN");
394  }
395 }
396 
397 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDForLMPN(const EcalLogicID &lmr) {
398  return getEcalLogicIDForLMR(lmr.getLogicID());
399 }
400 
401 std::vector<EcalLogicID> EcalCondDBInterface::getEcalLogicIDSetOrdered( string name,
402  int fromId1, int toId1,
403  int fromId2, int toId2,
404  int fromId3, int toId3,
405  string mapsTo, int orderedBy )
406  // the orderedBy can be 1, 2, 3, 4
407  // corresponding to id1 id2 id3 or logic_id
408  throw(std::runtime_error)
409 {
410  if (mapsTo == "") {
411  mapsTo = name;
412  }
413 
414  int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
415  int from, to;
416 
417  stringstream ss;
418  ss << "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
419 
420  // loop through the three ids
421  for (int i=1; i<=3; i++) {
422  from = idArray[2*(i-1)];
423  to = idArray[2*(i-1) + 1];
424 
425  // check the id arguments in pairs
426  if ((from == EcalLogicID::NULLID && to != EcalLogicID::NULLID) || // one is null
427  (from != EcalLogicID::NULLID && to == EcalLogicID::NULLID) || // but not the other
428  (from > to)) { // negative interval
429  throw(std::runtime_error("ERROR: Bad arguments for getEcalLogicIDSet"));
430  }
431 
432  // build the sql
433  if (from == EcalLogicID::NULLID && to == EcalLogicID::NULLID) {
434  ss << "id" << i << " IS NULL AND ";
435  } else {
436  ss << "id" << i << " >= :id" << i << "from AND " <<
437  "id" << i << " <= :id" << i << "to AND ";
438  }
439  }
440  ss << "maps_to = :maps_to ";
441 
442  if(orderedBy==EcalLogicID::NULLID){
443  ss<<" ORDER BY id1, id2, id3";
444  } else if(orderedBy==1 || orderedBy==12 || orderedBy==123){
445  ss<<" ORDER BY id1, id2, id3 ";
446  } else if (orderedBy==213 || orderedBy==21 ){
447  ss<<" ORDER BY id2, id1, id3 ";
448  } else if (orderedBy==231|| orderedBy==23){
449  ss<<" ORDER BY id2, id3, id1 ";
450  } else if (orderedBy==321|| orderedBy==32){
451  ss<<" ORDER BY id3, id2, id1 ";
452  } else if (orderedBy==312|| orderedBy==31){
453  ss<<" ORDER BY id3, id1, id2 ";
454  } else if (orderedBy==132|| orderedBy==13){
455  ss<<" ORDER BY id1, id3, id2 ";
456  } else if (orderedBy==1234 ){
457  ss<<" ORDER BY id1, id2, id3, logic_id ";
458  } else if (orderedBy==4) {
459  ss<<" ORDER BY logic_id ";
460  } else {
461  ss<<" ORDER BY id1, id2, id3";
462  }
463 
464  std::vector<EcalLogicID> result;
465 
466  try {
467  stmt->setSQL(ss.str());
468 
469  // bind the parameters
470  int j = 1; // parameter number counter
471  stmt->setString(j, name);
472  j++;
473 
474  for (int i=0; i<3; i++) {
475  from = idArray[2*i];
476  to = idArray[2*i + 1];
477  if (from != EcalLogicID::NULLID) {
478  stmt->setInt(j, from);
479  j++;
480  stmt->setInt(j, to);
481  j++;
482  }
483  }
484 
485  stmt->setString(j, mapsTo);
486 
487 
488  stmt->setPrefetchRowCount(IDBObject::ECALDB_NROWS);
489 
490  ResultSet* rset = stmt->executeQuery();
491 
492  int id1, id2, id3, logicId;
493 
494  while (rset->next()) {
495  name = rset->getString(1);
496  logicId = rset->getInt(2);
497  id1 = rset->getInt(3);
498  if (rset->isNull(3)) { id1 = EcalLogicID::NULLID; }
499  id2 = rset->getInt(4);
500  if (rset->isNull(4)) { id2 = EcalLogicID::NULLID; }
501  id3 = rset->getInt(5);
502  if (rset->isNull(5)) { id3 = EcalLogicID::NULLID; }
503  mapsTo = rset->getString(6);
504 
505  EcalLogicID ecid = EcalLogicID( name, logicId, id1, id2, id3, mapsTo );
506  result.push_back(ecid);
507  }
508  stmt->setPrefetchRowCount(0);
509 
510  } catch (SQLException &e) {
511  throw(std::runtime_error("ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
512  }
513 
514  return result;
515 }
516 
517 
518 
520  throw(std::runtime_error)
521 {
522  try {
523  iov->setConnection(env, conn);
524  iov->writeDB();
525  } catch(std::runtime_error &e) {
526  conn->rollback();
527  throw(e);
528  }
529  conn->commit();
530 }
531 
533  throw(std::runtime_error)
534 {
535  try {
536  iov->setConnection(env, conn);
537  iov->writeDB();
538  } catch(std::runtime_error &e) {
539  conn->rollback();
540  throw(e);
541  }
542  conn->commit();
543 }
544 
546  throw(std::runtime_error)
547 {
548  try {
549  iov->setConnection(env, conn);
550  iov->writeDB();
551  } catch(std::runtime_error &e) {
552  conn->rollback();
553  throw(e);
554  }
555  conn->commit();
556 }
557 
559  throw(std::runtime_error)
560 {
561  try {
562  iov->setConnection(env, conn);
563  iov->writeDB();
564  } catch(std::runtime_error &e) {
565  conn->rollback();
566  throw(e);
567  }
568  conn->commit();
569 }
570 
572  throw(std::runtime_error)
573 {
574  try {
575  dat->setConnection(env, conn);
576  dat->writeDB();
577  } catch(std::runtime_error &e) {
578  conn->rollback();
579  throw(e);
580  }
581  conn->commit();
582 }
583 
584 void EcalCondDBInterface::insertLmfDat(std::list<LMFDat *> dat)
585  throw(std::runtime_error)
586 {
587  try {
588  std::list<LMFDat *>::iterator i = dat.begin();
589  std::list<LMFDat *>::iterator e = dat.end();
590  while (i != e) {
591  (*i)->setConnection(env, conn);
592  (*i)->writeDB();
593  i++;
594  }
595  } catch(std::runtime_error &e) {
596  conn->rollback();
597  throw(e);
598  }
599  conn->commit();
600 }
601 
603  throw(std::runtime_error)
604 {
605  try {
606  iov->setConnection(env, conn);
607  iov->writeDB();
608  } catch(std::runtime_error &e) {
609  conn->rollback();
610  throw(e);
611  }
612  conn->commit();
613 }
614 
616  throw(std::runtime_error)
617 {
618  try {
619  iov->setConnection(env, conn);
620  iov->updateEndTimeDB();
621  } catch(std::runtime_error &e) {
622  conn->rollback();
623  throw(e);
624  }
625  conn->commit();
626 }
627 
629  throw(std::runtime_error)
630 {
631  try {
632  iov->setConnection(env, conn);
633  iov->updateEndTimeDB();
634  } catch(std::runtime_error &e) {
635  conn->rollback();
636  throw(e);
637  }
638  conn->commit();
639 }
640 
642  throw(std::runtime_error)
643 {
644  try {
645  iov->setConnection(env, conn);
646  iov->updateStartTimeDB();
647  } catch(std::runtime_error &e) {
648  conn->rollback();
649  throw(e);
650  }
651  conn->commit();
652 }
653 
655  throw(std::runtime_error)
656 {
657  try {
658  od->setConnection(env, conn);
659  od->updateDefaultCycle();
660  } catch(std::runtime_error &e) {
661  conn->rollback();
662  throw(e);
663  }
664  conn->commit();
665 }
666 
668  throw(std::runtime_error)
669 {
670  RunIOV iov;
671  iov.setConnection(env, conn);
672  iov.setByRun(tag, run);
673  return iov;
674 }
675 
676 
677 
679  throw(std::runtime_error)
680 {
681  RunIOV iov;
682  iov.setConnection(env, conn);
683  iov.setByRun(location, run);
684  return iov;
685 }
686 
688  throw(std::runtime_error)
689 {
690  RunIOV iov;
691  iov.setConnection(env, conn);
692  iov.setByTime(location, t);
693  return iov;
694 }
695 
697  throw(std::runtime_error)
698 {
699  try {
700  iov->setConnection(env, conn);
701  iov->writeDB();
702  } catch(std::runtime_error &e) {
703  conn->rollback();
704  throw(e);
705  }
706  conn->commit();
707 }
708 
710  throw(std::runtime_error)
711 {
712  try {
713  iov->setConnection(env, conn);
714  iov->writeDB();
715  } catch(std::runtime_error &e) {
716  conn->rollback();
717  throw(e);
718  }
719  conn->commit();
720 }
721 
722 
723 
724 
726  throw(std::runtime_error)
727 {
728  RunIOV runiov = fetchRunIOV(runtag, run);
729  MonRunIOV moniov;
730  moniov.setConnection(env, conn);
731  moniov.setByRun(montag, &runiov, subrun);
732  return moniov;
733 }
734 
735 
736 
738  throw(std::runtime_error)
739 {
740  DCUIOV dcuiov;
741  dcuiov.setConnection(env, conn);
742  dcuiov.setByTm(tag, eventTm);
743  return dcuiov;
744 }
745 
747  LMFSeqDat seq(env, conn);
748  return seq.fetchLastRun();
749 }
750 
752  throw(std::runtime_error)
753 {
754  RunIOV runiov = fetchRunIOV(runtag, run);
755  LMFRunIOV lmfiov;
756  lmfiov.setConnection(env, conn);
757  // lmfiov.setByRun(lmftag, &runiov, subrun);
758  return lmfiov;
759 }
760 
762  int lmr, int type, int color ) const {
763  bool ret = false;
764  iov.setConnection(env, conn);
765  std::list<LMFRunIOV> iovlist = iov.fetchBySequence(seq, lmr, type, color);
766  int s = iovlist.size();
767  if (s > 0) {
768  iov = iovlist.front();
769  ret = true;
770  if (s > 1) {
771  // should not happen
772  std::cout << "################################" << std::endl;
773  std::cout << "################################" << std::endl;
774  std::cout << "WARNING: More than one LMFRUNIOV" << std::endl;
775  std::cout << " Found for seq " << seq.getID() << std::endl;
776  std::cout << " lmr " << lmr << " type " << type << std::endl;
777  std::cout << " and color " << color << std::endl;
778  std::cout << "################################" << std::endl;
779  std::cout << "################################" << std::endl;
780  }
781  } else {
782  // find the most recent data
783  iovlist = iov.fetchLastBeforeSequence(seq, lmr, type, color);
784  s = iovlist.size();
785  if (s == 1) {
786  iov = iovlist.front();
787  }
788  }
789  return ret;
790 }
791 
793  throw(std::runtime_error)
794 {
795  CaliIOV caliiov;
796  caliiov.setConnection(env, conn);
797  caliiov.setByTm(tag, eventTm);
798  return caliiov;
799 }
800 
802  throw(std::runtime_error)
803 {
805  r.setConnection(env, conn);
806  r.fetchValuesForECID(ecid);
807  return r;
808 }
809 
811  throw(std::runtime_error)
812 {
814  r.setConnection(env, conn);
816  return r;
817 }
818 
820  throw(std::runtime_error)
821 {
822  RunList r;
823  r.setConnection(env, conn);
824  r.setRunTag(tag);
825  r.fetchRuns();
826  return r;
827 }
828 
829 RunList EcalCondDBInterface::fetchRunList(RunTag tag, int min_run, int max_run) throw(std::runtime_error){
830  RunList r;
831  r.setConnection(env, conn);
832  r.setRunTag(tag);
833  r.fetchRuns( min_run, max_run);
834  return r;
835 }
836 
837 RunList EcalCondDBInterface::fetchNonEmptyRunList(RunTag tag, int min_run, int max_run) throw(std::runtime_error){
838  RunList r;
839  r.setConnection(env, conn);
840  r.setRunTag(tag);
841  r.fetchNonEmptyRuns( min_run, max_run);
842  return r;
843 }
844 
845 RunList EcalCondDBInterface::fetchNonEmptyGlobalRunList(RunTag tag, int min_run, int max_run) throw(std::runtime_error){
846  RunList r;
847  r.setConnection(env, conn);
848  r.setRunTag(tag);
849  r.fetchNonEmptyGlobalRuns( min_run, max_run);
850  return r;
851 }
852 
854  throw(std::runtime_error) {
855  RunList r;
856  r.setConnection(env, conn);
857  r.setRunTag(tag);
858  r.fetchRunsByLocation( min_run, max_run, locDef);
859  return r;
860 }
861 
863  throw(std::runtime_error) {
864  RunList r;
865  r.setConnection(env, conn);
866  r.setRunTag(tag);
867  r.fetchGlobalRunsByLocation( min_run, max_run, locDef);
868  return r;
869 }
870 
872  throw(std::runtime_error){
873  RunList r;
874  r.setConnection(env, conn);
875  r.setRunTag(tag);
876  r.fetchLastNRuns( max_run, n_runs);
877  return r;
878 }
879 
880 
881 
882 
883 // from here it is for the MonRunList
884 
886  throw(std::runtime_error)
887 {
888  MonRunList r;
889  r.setConnection(env, conn);
890  r.setRunTag(tag);
891  r.setMonRunTag(monrunTag);
892  r.fetchRuns();
893  return r;
894 }
895 
897  throw(std::runtime_error)
898 {
899  MonRunList r;
900  r.setConnection(env, conn);
901  r.setRunTag(tag);
902  r.setMonRunTag(monrunTag);
903  r.fetchRuns(min_run, max_run);
904  return r;
905 }
906 
908  throw(std::runtime_error)
909 {
910  MonRunList r;
911  r.setConnection(env, conn);
912  r.setRunTag(tag);
913  r.setMonRunTag(monrunTag);
914  r.fetchLastNRuns(max_run, n_runs );
915  return r;
916 }
917 
918 
919 
921 {
922 }
void setByTime(std::string location, const Tm &t)
Definition: RunIOV.cc:417
std::vector< EcalLogicID > getEcalLogicIDSet(std::string name, int fromId1=EcalLogicID::NULLID, int toId1=EcalLogicID::NULLID, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="")
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
int run_t
Definition: CaliIOV.h:11
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
int getID() const
Definition: LMFUnique.h:52
void insertRunIOV(RunIOV *iov)
std::list< LMFRunIOV > fetchBySequence(const LMFSeqDat &s)
Definition: LMFRunIOV.cc:347
std::list< ODDelaysDat > fetchFEDelaysForRun(RunIOV *iov)
void setId(int id)
Definition: ODFEDAQConfig.h:18
void setByTm(DCUTag *tag, Tm time)
Definition: DCUIOV.cc:214
void setRunTag(RunTag tag)
Definition: RunList.cc:22
void fetchRuns()
Definition: MonRunList.cc:52
Definition: RunTag.h:13
RunList fetchNonEmptyGlobalRunList(RunTag tag, int min_run, int max_run)
RunList fetchRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
int getDelayId() const
Definition: ODFEDAQConfig.h:29
DCSPTMTempList fetchDCSPTMTempList(EcalLogicID ecid)
void fetchLastNRuns(int max_run, int n_runs)
Definition: RunList.cc:191
void insertLmfDat(LMFDat *dat)
RunIOV fetchRunIOV(RunTag *tag, run_t run)
void fetchData(ODFEDAQConfig *result)
void updateRunIOVStartTime(RunIOV *iov)
void fetchRuns()
Definition: RunList.cc:64
void insertLmfSeq(LMFSeqDat *iov)
Definition: DCUIOV.h:13
std::vector< EcalLogicID > getEcalLogicIDMappedTo(int logic_id, std::string maps_to)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setRunTag(RunTag tag)
Definition: MonRunList.cc:23
DCUIOV fetchDCUIOV(DCUTag *tag, Tm evenTm)
LMFRunIOV fetchLMFRunIOV(RunTag *runtag, LMFRunTag *lmftag, run_t run, subrun_t lmfrun)
std::vector< EcalLogicID > getEcalLogicIDForLMPN(int lmr_logic_id)
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID)
CaliIOV fetchCaliIOV(CaliTag *tag, Tm evenTm)
void setByRun(RunTag *tag, run_t run)
Definition: RunIOV.cc:376
RunList fetchGlobalRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
void setByRun(MonRunTag *montag, RunIOV *runiov, subrun_t subrun)
Definition: MonRunIOV.cc:292
tuple iov
Definition: o2o.py:307
RunList fetchRunList(RunTag tag)
MonRunList fetchMonRunListLastNRuns(RunTag tag, MonRunTag monruntag, int max_run, int n_runs)
Definition: LMFDat.h:19
tuple result
Definition: query.py:137
void fetchData(std::map< EcalLogicID, RunFEConfigDat > *fillMap, RunIOV *iov)
std::map< int, int > getEcalLogicID2LmrMap()
int subrun_t
Definition: MODRunIOV.h:11
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="")
RunIOV fetchLMFLastRun() const
int j
Definition: DBlmapReader.cc:9
void insertDCUIOV(DCUIOV *iov)
#define end
Definition: vmac.h:38
void fetchValuesForECIDAndTime(EcalLogicID ecid, Tm start, Tm end)
void fetchNonEmptyRuns()
Definition: RunList.cc:40
int getLogicID() const
Definition: EcalLogicID.cc:42
void insertLmfRunIOV(LMFRunIOV *iov)
Definition: LMFIOV.h:17
void insertLmfIOV(LMFIOV *iov)
void updateRunConfig(ODRunConfigInfo *od)
void fetchGlobalRunsByLocation(int min_run, int max_run, const LocationDef locDef)
Definition: RunList.cc:354
MonRunList fetchMonRunList(RunTag tag, MonRunTag monruntag)
RunList fetchNonEmptyRunList(RunTag tag, int min_run, int max_run)
void fetchLastNRuns(int max_run, int n_runs)
Definition: MonRunList.cc:259
RunIOV fetchLastRun()
Definition: LMFSeqDat.cc:264
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun)
static int const ECALDB_NROWS
Definition: IDBObject.h:18
void fetchValuesForECID(EcalLogicID ecid)
RunList fetchRunListLastNRuns(RunTag tag, int max_run, int n_runs)
void fetchRunsByLocation(int min_run, int max_run, const LocationDef locDef)
Definition: RunList.cc:265
void insertMonRunIOV(MonRunIOV *iov)
static const int NULLID
Definition: EcalLogicID.h:43
void setMonRunTag(MonRunTag tag)
Definition: MonRunList.cc:29
tuple cout
Definition: gather_cfg.py:121
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void updateRunIOV(RunIOV *iov)
std::list< LMFRunIOV > fetchLastBeforeSequence(const LMFSeqDat &s, int lmr, int type, int color)
Definition: LMFRunIOV.cc:382
void updateRunIOVEndTime(RunIOV *iov)
void fillMap(Registry *reg, regmap_type &fillme)
Definition: Registry.cc:24
std::vector< EcalLogicID > getEcalLogicIDForLMR(int lmr_logic_id)
void fetchData(std::vector< ODDelaysDat > *fillMap, int id)
Definition: ODDelaysDat.cc:73
Definition: RunIOV.h:13
void insertLmfLmrSubIOV(LMFLmrSubIOV *iov)
Definition: Tm.h:14
void setByTm(CaliTag *tag, Tm time)
Definition: CaliIOV.cc:215
tuple conn
Definition: results_mgr.py:53
Definition: DCUTag.h:13
void fetchNonEmptyGlobalRuns()
Definition: RunList.cc:46