CMS 3D CMS Logo

RunPTMTempDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
4 
7 
8 using namespace std;
9 using namespace oracle::occi;
10 
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_temperature = 0;
18 }
19 
21 
23  this->checkConnection();
24 
25  try {
26  m_writeStmt = m_conn->createStatement();
27  m_writeStmt->setSQL(
28  "INSERT INTO run_temperature_ptm_dat (iov_id, logic_id, "
29  "temperature) "
30  "VALUES (:iov_id, :logic_id, "
31  ":temperature)");
32  } catch (SQLException& e) {
33  throw(std::runtime_error("RunPTMTempDat::prepareWrite(): " + e.getMessage()));
34  }
35 }
36 
37 void RunPTMTempDat::writeDB(const EcalLogicID* ecid, const RunPTMTempDat* item, RunIOV* iov) noexcept(false) {
38  this->checkConnection();
39  this->checkPrepare();
40 
41  int iovID = iov->fetchID();
42  if (!iovID) {
43  throw(std::runtime_error("RunPTMTempDat::writeDB: IOV not in DB"));
44  }
45 
46  int logicID = ecid->getLogicID();
47  if (!logicID) {
48  throw(std::runtime_error("RunPTMTempDat::writeDB: Bad EcalLogicID"));
49  }
50 
51  try {
52  m_writeStmt->setInt(1, iovID);
53  m_writeStmt->setInt(2, logicID);
54  m_writeStmt->setFloat(3, item->getTemperature());
55 
56  m_writeStmt->executeUpdate();
57  } catch (SQLException& e) {
58  throw(std::runtime_error("RunPTMTempDat::writeDB(): " + e.getMessage()));
59  }
60 }
61 
62 void RunPTMTempDat::fetchData(map<EcalLogicID, RunPTMTempDat>* fillMap, RunIOV* iov) noexcept(false) {
63  this->checkConnection();
64  fillMap->clear();
65 
66  iov->setConnection(m_env, m_conn);
67  int iovID = iov->fetchID();
68  if (!iovID) {
69  // throw(std::runtime_error("RunPTMTempDat::writeDB: IOV not in DB"));
70  return;
71  }
72 
73  try {
74  m_readStmt->setSQL(
75  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
76  "d.temperature "
77  "FROM channelview cv JOIN RUN_TEMPERATURE_PTM_DAT d "
78  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
79  "WHERE d.iov_id = :iov_id");
80  m_readStmt->setInt(1, iovID);
81  ResultSet* rset = m_readStmt->executeQuery();
82 
83  std::pair<EcalLogicID, RunPTMTempDat> p;
84  RunPTMTempDat dat;
85  while (rset->next()) {
86  p.first = EcalLogicID(rset->getString(1), // name
87  rset->getInt(2), // logic_id
88  rset->getInt(3), // id1
89  rset->getInt(4), // id2
90  rset->getInt(5), // id3
91  rset->getString(6)); // maps_to
92 
93  dat.setTemperature(rset->getFloat(7));
94 
95  p.second = dat;
96  fillMap->insert(p);
97  }
98 
99  } catch (SQLException& e) {
100  throw(std::runtime_error("RunPTMTempDat::fetchData(): " + e.getMessage()));
101  }
102 }
RunIOV
Definition: RunIOV.h:13
funct::false
false
Definition: Factorize.h:29
RunIOV.h
RunPTMTempDat::writeDB
void writeDB(const EcalLogicID *ecid, const RunPTMTempDat *item, RunIOV *iov) noexcept(false)
Definition: RunPTMTempDat.cc:37
RunPTMTempDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: RunPTMTempDat.cc:22
oracle::occi
Definition: ConnectionManager.h:7
RunPTMTempDat::RunPTMTempDat
RunPTMTempDat()
Definition: RunPTMTempDat.cc:11
RunPTMTempDat.h
EcalLogicID
Definition: EcalLogicID.h:7
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
RunPTMTempDat::setTemperature
void setTemperature(float t)
Definition: RunPTMTempDat.h:19
RunPTMTempDat
Definition: RunPTMTempDat.h:11
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
RunPTMTempDat::~RunPTMTempDat
~RunPTMTempDat() override
Definition: RunPTMTempDat.cc:20
std
Definition: JetResolutionObject.h:76
Oracle.h
RunPTMTempDat::fetchData
void fetchData(std::map< EcalLogicID, RunPTMTempDat > *fillMap, RunIOV *iov) noexcept(false)
Definition: RunPTMTempDat.cc:62
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37