CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RunLaserRunDat.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_laserSeqType = "";
16  m_laserSeqCond = "";
17 }
18 
20 
22  this->checkConnection();
23 
24  try {
25  m_writeStmt = m_conn->createStatement();
26  m_writeStmt->setSQL(
27  "INSERT INTO run_laserrun_config_dat (iov_id, logic_id, "
28  "laser_sequence_type, laser_sequence_cond) "
29  "VALUES (:1, :2, "
30  ":3, :4 )");
31  } catch (SQLException& e) {
32  throw(std::runtime_error("RunLaserRunDat::prepareWrite(): " + e.getMessage()));
33  }
34 }
35 
36 void RunLaserRunDat::writeDB(const EcalLogicID* ecid, const RunLaserRunDat* item, RunIOV* iov) noexcept(false) {
37  this->checkConnection();
38  this->checkPrepare();
39 
40  int iovID = iov->fetchID();
41  if (!iovID) {
42  throw(std::runtime_error("RunLaserRunDat::writeDB: IOV not in DB"));
43  }
44 
45  int logicID = ecid->getLogicID();
46  if (!logicID) {
47  throw(std::runtime_error("RunLaserRunDat::writeDB: Bad EcalLogicID"));
48  }
49 
50  try {
51  m_writeStmt->setInt(1, iovID);
52  m_writeStmt->setInt(2, logicID);
53  m_writeStmt->setString(3, item->getLaserSequenceType());
54  m_writeStmt->setString(4, item->getLaserSequenceCond());
55 
56  m_writeStmt->executeUpdate();
57  } catch (SQLException& e) {
58  throw(std::runtime_error("RunLaserRunDat::writeDB(): " + e.getMessage()));
59  }
60 }
61 
62 void RunLaserRunDat::fetchData(map<EcalLogicID, RunLaserRunDat>* 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("RunLaserRunDat::writeDB: IOV not in DB"));
70  return;
71  }
72 
73  try {
74  Statement* stmt = m_conn->createStatement();
75  stmt->setSQL(
76  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
77  "d.laser_sequence_type, d.laser_sequence_cond "
78  "FROM channelview cv JOIN run_laserrun_config_dat d "
79  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
80  "WHERE d.iov_id = :iov_id");
81  stmt->setInt(1, iovID);
82  ResultSet* rset = stmt->executeQuery();
83 
84  std::pair<EcalLogicID, RunLaserRunDat> p;
85  RunLaserRunDat dat;
86  while (rset->next()) {
87  p.first = EcalLogicID(rset->getString(1), // name
88  rset->getInt(2), // logic_id
89  rset->getInt(3), // id1
90  rset->getInt(4), // id2
91  rset->getInt(5), // id3
92  rset->getString(6)); // maps_to
93 
94  dat.setLaserSequenceType(rset->getString(7)); // maps_to
95  dat.setLaserSequenceCond(rset->getString(8)); // maps_to
96 
97  p.second = dat;
98  fillMap->insert(p);
99  }
100  m_conn->terminateStatement(stmt);
101  } catch (SQLException& e) {
102  throw(std::runtime_error("RunLaserRunDat::fetchData(): " + e.getMessage()));
103  }
104 }
RunIOV
Definition: RunIOV.h:13
funct::false
false
Definition: Factorize.h:29
RunIOV.h
RunLaserRunDat::fetchData
void fetchData(std::map< EcalLogicID, RunLaserRunDat > *fillMap, RunIOV *iov) noexcept(false)
Definition: RunLaserRunDat.cc:62
RunLaserRunDat::~RunLaserRunDat
~RunLaserRunDat() override
Definition: RunLaserRunDat.cc:19
oracle::occi
Definition: ConnectionManager.h:7
RunLaserRunDat
Definition: RunLaserRunDat.h:11
EcalLogicID
Definition: EcalLogicID.h:7
RunLaserRunDat::RunLaserRunDat
RunLaserRunDat()
Definition: RunLaserRunDat.cc:11
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
RunLaserRunDat::writeDB
void writeDB(const EcalLogicID *ecid, const RunLaserRunDat *item, RunIOV *iov) noexcept(false)
Definition: RunLaserRunDat.cc:36
RunLaserRunDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: RunLaserRunDat.cc:21
RunLaserRunDat::setLaserSequenceType
void setLaserSequenceType(std::string x)
Definition: RunLaserRunDat.h:20
std
Definition: JetResolutionObject.h:76
RunLaserRunDat.h
Oracle.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
RunLaserRunDat::setLaserSequenceCond
void setLaserSequenceCond(std::string x)
Definition: RunLaserRunDat.h:23