15 m_writeStmt =
nullptr;
18 m_samplesG1.assign(10, 0);
19 m_samplesG6.assign(10, 0);
20 m_samplesG12.assign(10, 0);
26 this->checkConnection();
29 m_writeStmt = m_conn->createStatement();
31 "INSERT INTO mon_pulse_shape_dat (iov_id, logic_id, " 32 "g1_avg_sample_01, g1_avg_sample_02, g1_avg_sample_03, g1_avg_sample_04, g1_avg_sample_05, g1_avg_sample_06, " 33 "g1_avg_sample_07, g1_avg_sample_08, g1_avg_sample_09, g1_avg_sample_10, " 34 "g6_avg_sample_01, g6_avg_sample_02, g6_avg_sample_03, g6_avg_sample_04, g6_avg_sample_05, g6_avg_sample_06, " 35 "g6_avg_sample_07, g6_avg_sample_08, g6_avg_sample_09, g6_avg_sample_10, " 36 "g12_avg_sample_01, g12_avg_sample_02, g12_avg_sample_03, g12_avg_sample_04, g12_avg_sample_05, " 37 "g12_avg_sample_06, g12_avg_sample_07, g12_avg_sample_08, g12_avg_sample_09, g12_avg_sample_10) " 38 "VALUES (:iov_id, :logic_id, " 39 ":g1_avg_sample_01, :g1_avg_sample_02, :g1_avg_sample_03, :g1_avg_sample_04, :g1_avg_sample_05, " 40 ":g1_avg_sample_06, :g1_avg_sample_07, :g1_avg_sample_08, :g1_avg_sample_09, :g1_avg_sample_10," 41 ":g6_avg_sample_01, :g6_avg_sample_02, :g6_avg_sample_03, :g6_avg_sample_04, :g6_avg_sample_05, " 42 ":g6_avg_sample_06, :g6_avg_sample_07, :g6_avg_sample_08, :g6_avg_sample_09, :g6_avg_sample_10," 43 ":g12_avg_sample_01, :g12_avg_sample_02, :g12_avg_sample_03, :g12_avg_sample_04, :g12_avg_sample_05, " 44 ":g12_avg_sample_06, :g12_avg_sample_07, :g12_avg_sample_08, :g12_avg_sample_09, :g12_avg_sample_10)");
46 }
catch (SQLException&
e) {
47 throw(std::runtime_error(
"MonPulseShapeDat::prepareWrite(): " +
e.getMessage()));
52 this->checkConnection();
55 int iovID = iov->fetchID();
57 throw(std::runtime_error(
"MonPulseShapeDat::writeDB: IOV not in DB"));
60 int logicID = ecid->getLogicID();
62 throw(std::runtime_error(
"MonPulseShapeDat::writeDB: Bad EcalLogicID"));
66 m_writeStmt->setInt(1, iovID);
67 m_writeStmt->setInt(2, logicID);
69 int gain[] = {1, 6, 12};
71 for (
int i = 0;
i < 3;
i++) {
73 for (
int j = 0;
j < 10;
j++) {
74 m_writeStmt->setFloat(3 + (10 *
i) +
j,
samples.at(
j));
78 m_writeStmt->executeUpdate();
79 }
catch (SQLException&
e) {
80 throw(std::runtime_error(
"MonPulseShapeDat::writeDB: " +
e.getMessage()));
82 throw(std::runtime_error(
"MonPulseShapeDat::writeDB: " +
string(
e.what())));
87 this->checkConnection();
90 iov->setConnection(m_env, m_conn);
91 int iovID = iov->fetchID();
99 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 100 "d.g1_avg_sample_01, d.g1_avg_sample_02, d.g1_avg_sample_03, d.g1_avg_sample_04, d.g1_avg_sample_05, " 101 "d.g1_avg_sample_06, d.g1_avg_sample_07, d.g1_avg_sample_08, d.g1_avg_sample_09, d.g1_avg_sample_10, " 102 "d.g6_avg_sample_01, d.g6_avg_sample_02, d.g6_avg_sample_03, d.g6_avg_sample_04, d.g6_avg_sample_05, " 103 "d.g6_avg_sample_06, d.g6_avg_sample_07, d.g6_avg_sample_08, d.g6_avg_sample_09, d.g6_avg_sample_10, " 104 "d.g12_avg_sample_01, d.g12_avg_sample_02, d.g12_avg_sample_03, d.g12_avg_sample_04, d.g12_avg_sample_05, " 105 "d.g12_avg_sample_06, d.g12_avg_sample_07, d.g12_avg_sample_08, d.g12_avg_sample_09, d.g12_avg_sample_10 " 106 "FROM channelview cv JOIN mon_pulse_shape_dat d " 107 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 108 "WHERE d.iov_id = :iov_id");
109 m_readStmt->setInt(1, iovID);
110 ResultSet* rset = m_readStmt->executeQuery();
112 std::pair<EcalLogicID, MonPulseShapeDat>
p;
114 while (rset->next()) {
122 int gain[] = {1, 6, 12};
123 std::vector<float>
samples(10);
124 for (
int i = 0;
i < 3;
i++) {
126 for (
int j = 0;
j < 10;
j++) {
127 samples.push_back(rset->getFloat(7 + (10 *
i) +
j));
135 }
catch (SQLException&
e) {
136 throw(std::runtime_error(
"MonPulseShapeDat::fetchData: " +
e.getMessage()));
void setSamples(std::vector< float > &samples, int gain) noexcept(false)
void prepareWrite() noexcept(false) override
void fetchData(std::map< EcalLogicID, MonPulseShapeDat > *fillVec, MonRunIOV *iov) noexcept(false)
void writeDB(const EcalLogicID *ecid, const MonPulseShapeDat *item, MonRunIOV *iov) noexcept(false)
~MonPulseShapeDat() override