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