CMS 3D CMS Logo

MonLaserStatusDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
4 
6 
7 using namespace std;
8 using namespace oracle::occi;
9 
11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16 
17  m_laserPower = 0;
18  m_laserFilter = 0;
19  m_laserWavelength = 0;
20  m_laserFanout = 0;
21 }
22 
23 
24 
26 {
27 }
28 
29 
30 
33 {
34  this->checkConnection();
35 
36  try {
37  m_writeStmt = m_conn->createStatement();
38  m_writeStmt->setSQL("INSERT INTO mon_laser_status_dat (iov_id, logic_id, "
39  "laser_power, laser_filter, laser_wavelength, laser_fanout) "
40  "VALUES (:iov_id, :logic_id, "
41  ":3, :4, :5, :6)");
42  } catch (SQLException &e) {
43  throw(std::runtime_error("MonLaserStatusDat::prepareWrite(): "+e.getMessage()));
44  }
45 }
46 
47 
48 
50  noexcept(false)
51 {
52  this->checkConnection();
53  this->checkPrepare();
54 
55  int iovID = iov->fetchID();
56  if (!iovID) { throw(std::runtime_error("MonLaserStatusDat::writeDB: IOV not in DB")); }
57 
58  int logicID = ecid->getLogicID();
59  if (!logicID) { throw(std::runtime_error("MonLaserStatusDat::writeDB: Bad EcalLogicID")); }
60 
61  try {
62  m_writeStmt->setInt(1, iovID);
63  m_writeStmt->setInt(2, logicID);
64 
65  m_writeStmt->setFloat(3, item->getLaserPower() );
66  m_writeStmt->setFloat(4, item->getLaserFilter() );
67  m_writeStmt->setFloat(5, item->getLaserWavelength() );
68  m_writeStmt->setFloat(6, item->getLaserFanout() );
69 
70  m_writeStmt->executeUpdate();
71  } catch (SQLException &e) {
72  throw(std::runtime_error("MonLaserStatusDat::writeDB(): "+e.getMessage()));
73  }
74 }
75 
76 
77 
78 void MonLaserStatusDat::fetchData(std::map< EcalLogicID, MonLaserStatusDat >* fillMap, MonRunIOV* iov)
79  noexcept(false)
80 {
81  this->checkConnection();
82  fillMap->clear();
83 
84  iov->setConnection(m_env, m_conn);
85  int iovID = iov->fetchID();
86  if (!iovID) {
87  // throw(std::runtime_error("MonLaserStatusDat::writeDB: IOV not in DB"));
88  return;
89  }
90 
91  try {
92 
93  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
94  "d.laser_power, d.laser_filter, d.laser_wavelength, d.laser_fanout "
95  "FROM channelview cv JOIN mon_laser_status_dat d "
96  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
97  "WHERE d.iov_id = :iov_id");
98  m_readStmt->setInt(1, iovID);
99  ResultSet* rset = m_readStmt->executeQuery();
100 
101  std::pair< EcalLogicID, MonLaserStatusDat > p;
102  MonLaserStatusDat dat;
103  while(rset->next()) {
104  p.first = EcalLogicID( rset->getString(1), // name
105  rset->getInt(2), // logic_id
106  rset->getInt(3), // id1
107  rset->getInt(4), // id2
108  rset->getInt(5), // id3
109  rset->getString(6)); // maps_to
110 
111  dat.setLaserPower( rset->getFloat(7) );
112  dat.setLaserFilter( rset->getFloat(8) );
113  dat.setLaserWavelength( rset->getFloat(9) );
114  dat.setLaserFanout( rset->getFloat(10) );
115 
116  p.second = dat;
117  fillMap->insert(p);
118  }
119  } catch (SQLException &e) {
120  throw(std::runtime_error("MonLaserStatusDat::fetchData(): "+e.getMessage()));
121  }
122 }
void setLaserFanout(float p)
void setLaserFilter(float p)
void setLaserPower(float p)
#define noexcept
#define NULL
Definition: scimark2.h:8
void setLaserWavelength(float p)
void prepareWrite() noexcept(false)
void fetchData(std::map< EcalLogicID, MonLaserStatusDat > *fillMap, MonRunIOV *iov) noexcept(false)
void writeDB(const EcalLogicID *ecid, const MonLaserStatusDat *item, MonRunIOV *iov) noexcept(false)