CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MonPulseShapeDat Class Reference

#include <MonPulseShapeDat.h>

Inheritance diagram for MonPulseShapeDat:
IDataItem IDBObject

Public Member Functions

std::vector< float > getSamples (int gain) const noexcept(false)
 
std::string getTable () override
 
 MonPulseShapeDat ()
 
void setSamples (std::vector< float > &samples, int gain) noexcept(false)
 
 ~MonPulseShapeDat () override
 
- Public Member Functions inherited from IDataItem
 IDataItem ()
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void fetchData (std::map< EcalLogicID, MonPulseShapeDat > *fillVec, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB (const EcalLogicID *ecid, const MonPulseShapeDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

std::vector< float > m_samplesG1
 
std::vector< float > m_samplesG12
 
std::vector< float > m_samplesG6
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IDataItem
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IDataItem
oracle::occi::Statement * m_readStmt
 
oracle::occi::Statement * m_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 13 of file MonPulseShapeDat.h.

Constructor & Destructor Documentation

MonPulseShapeDat::MonPulseShapeDat ( )

Definition at line 12 of file MonPulseShapeDat.cc.

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_samplesG1.assign(10, 0);
19  m_samplesG6.assign(10, 0);
20  m_samplesG12.assign(10, 0);
21 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::vector< float > m_samplesG1
std::vector< float > m_samplesG6
std::vector< float > m_samplesG12
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
MonPulseShapeDat::~MonPulseShapeDat ( )
override

Definition at line 23 of file MonPulseShapeDat.cc.

23 {}

Member Function Documentation

void MonPulseShapeDat::fetchData ( std::map< EcalLogicID, MonPulseShapeDat > *  fillVec,
MonRunIOV iov 
)
privatenoexcept

Definition at line 86 of file MonPulseShapeDat.cc.

References dat, alignCSCRings::e, mps_fire::i, dqmiolumiharvest::j, AlCaHLTBitMon_ParallelJobs::p, and setSamples().

86  {
87  this->checkConnection();
88  fillMap->clear();
89 
90  iov->setConnection(m_env, m_conn);
91  int iovID = iov->fetchID();
92  if (!iovID) {
93  // throw(std::runtime_error("MonPulseShapeDat::writeDB: IOV not in DB"));
94  return;
95  }
96 
97  try {
98  m_readStmt->setSQL(
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();
111 
112  std::pair<EcalLogicID, MonPulseShapeDat> p;
114  while (rset->next()) {
115  p.first = EcalLogicID(rset->getString(1), // name
116  rset->getInt(2), // logic_id
117  rset->getInt(3), // id1
118  rset->getInt(4), // id2
119  rset->getInt(5), // id3
120  rset->getString(6)); // maps_to
121 
122  int gain[] = {1, 6, 12};
123  std::vector<float> samples(10);
124  for (int i = 0; i < 3; i++) {
125  samples.clear();
126  for (int j = 0; j < 10; j++) {
127  samples.push_back(rset->getFloat(7 + (10 * i) + j));
128  }
129  dat.setSamples(samples, gain[i]);
130  }
131 
132  p.second = dat;
133  fillMap->insert(p);
134  }
135  } catch (SQLException& e) {
136  throw(std::runtime_error("MonPulseShapeDat::fetchData: " + e.getMessage()));
137  }
138 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setSamples(std::vector< float > &samples, int gain) noexcept(false)
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
static std::vector< std::string > checklist dat
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
std::vector<float> MonPulseShapeDat::getSamples ( int  gain) const
inlinenoexcept

Definition at line 38 of file MonPulseShapeDat.h.

References m_samplesG1, m_samplesG12, and m_samplesG6.

38  {
39  if (gain == 1) {
40  return m_samplesG1;
41  } else if (gain == 6) {
42  return m_samplesG6;
43  } else if (gain == 12) {
44  return m_samplesG12;
45  } else {
46  throw(std::runtime_error("MonPulseShapeDat::getSamples: Gain should be 1, 6 or 12"));
47  }
48  }
std::vector< float > m_samplesG1
std::vector< float > m_samplesG6
std::vector< float > m_samplesG12
std::string MonPulseShapeDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 20 of file MonPulseShapeDat.h.

20 { return "MON_PULSE_SHAPE_DAT"; }
void MonPulseShapeDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file MonPulseShapeDat.cc.

References alignCSCRings::e.

25  {
26  this->checkConnection();
27 
28  try {
29  m_writeStmt = m_conn->createStatement();
30  m_writeStmt->setSQL(
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)");
45 
46  } catch (SQLException& e) {
47  throw(std::runtime_error("MonPulseShapeDat::prepareWrite(): " + e.getMessage()));
48  }
49 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void MonPulseShapeDat::setSamples ( std::vector< float > &  samples,
int  gain 
)
inlinenoexcept

Definition at line 22 of file MonPulseShapeDat.h.

References m_samplesG1, m_samplesG12, and m_samplesG6.

Referenced by fetchData(), and ecaldqm::TestPulseWriter::run().

22  {
23  if (samples.size() != 10) {
24  throw(std::runtime_error("MonPulseShapeDat::setSamples: There should be 10 samples."));
25  }
26 
27  if (gain == 1) {
28  m_samplesG1 = samples;
29  } else if (gain == 6) {
30  m_samplesG6 = samples;
31  } else if (gain == 12) {
32  m_samplesG12 = samples;
33  } else {
34  throw(std::runtime_error("MonPulseShapeDat::setSamples: Gain should be 1, 6 or 12"));
35  }
36  }
std::vector< float > m_samplesG1
std::vector< float > m_samplesG6
std::vector< float > m_samplesG12
void MonPulseShapeDat::writeDB ( const EcalLogicID ecid,
const MonPulseShapeDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 51 of file MonPulseShapeDat.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, mps_fire::i, B2GTnPMonitor_cfi::item, and dqmiolumiharvest::j.

51  {
52  this->checkConnection();
53  this->checkPrepare();
54 
55  int iovID = iov->fetchID();
56  if (!iovID) {
57  throw(std::runtime_error("MonPulseShapeDat::writeDB: IOV not in DB"));
58  }
59 
60  int logicID = ecid->getLogicID();
61  if (!logicID) {
62  throw(std::runtime_error("MonPulseShapeDat::writeDB: Bad EcalLogicID"));
63  }
64 
65  try {
66  m_writeStmt->setInt(1, iovID);
67  m_writeStmt->setInt(2, logicID);
68 
69  int gain[] = {1, 6, 12};
70  std::vector<float> samples;
71  for (int i = 0; i < 3; i++) {
72  samples = item->getSamples(gain[i]);
73  for (int j = 0; j < 10; j++) {
74  m_writeStmt->setFloat(3 + (10 * i) + j, samples.at(j));
75  }
76  }
77 
78  m_writeStmt->executeUpdate();
79  } catch (SQLException& e) {
80  throw(std::runtime_error("MonPulseShapeDat::writeDB: " + e.getMessage()));
81  } catch (exception& e) {
82  throw(std::runtime_error("MonPulseShapeDat::writeDB: " + string(e.what())));
83  }
84 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
int getLogicID() const
Definition: EcalLogicID.cc:28
std::vector< float > getSamples(int gain) const noexcept(false)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 15 of file MonPulseShapeDat.h.

Member Data Documentation

std::vector<float> MonPulseShapeDat::m_samplesG1
private

Definition at line 58 of file MonPulseShapeDat.h.

Referenced by getSamples(), and setSamples().

std::vector<float> MonPulseShapeDat::m_samplesG12
private

Definition at line 60 of file MonPulseShapeDat.h.

Referenced by getSamples(), and setSamples().

std::vector<float> MonPulseShapeDat::m_samplesG6
private

Definition at line 59 of file MonPulseShapeDat.h.

Referenced by getSamples(), and setSamples().