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