CMS 3D CMS Logo

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 ()
 
 MonPulseShapeDat ()
 
void setSamples (std::vector< float > &samples, int gain) noexcept(false)
 
 ~MonPulseShapeDat ()
 
- 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)
 
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.

References NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
18 
19  m_samplesG1.assign(10, 0);
20  m_samplesG6.assign(10, 0);
21  m_samplesG12.assign(10, 0);
22 
23 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::vector< float > m_samplesG1
#define NULL
Definition: scimark2.h:8
std::vector< float > m_samplesG6
std::vector< float > m_samplesG12
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
MonPulseShapeDat::~MonPulseShapeDat ( )

Definition at line 27 of file MonPulseShapeDat.cc.

28 {
29 }

Member Function Documentation

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

Definition at line 92 of file MonPulseShapeDat.cc.

References MillePedeFileConverter_cfg::e, muonCSCDigis_cfi::gain, mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, hcalTTPDigis_cfi::samples, and setSamples().

Referenced by getSamples().

94 {
95  this->checkConnection();
96  fillMap->clear();
97 
98  iov->setConnection(m_env, m_conn);
99  int iovID = iov->fetchID();
100  if (!iovID) {
101  // throw(std::runtime_error("MonPulseShapeDat::writeDB: IOV not in DB"));
102  return;
103  }
104 
105  try {
106 
107  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
108  "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, 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, "
109  "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, 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, "
110  "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, 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 "
111  "FROM channelview cv JOIN mon_pulse_shape_dat d "
112  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
113  "WHERE d.iov_id = :iov_id");
114  m_readStmt->setInt(1, iovID);
115  ResultSet* rset = m_readStmt->executeQuery();
116 
117  std::pair< EcalLogicID, MonPulseShapeDat > p;
118  MonPulseShapeDat dat;
119  while(rset->next()) {
120  p.first = EcalLogicID( rset->getString(1), // name
121  rset->getInt(2), // logic_id
122  rset->getInt(3), // id1
123  rset->getInt(4), // id2
124  rset->getInt(5), // id3
125  rset->getString(6)); // maps_to
126 
127  int gain[] = {1, 6, 12};
128  std::vector<float> samples(10);
129  for (int i=0; i<3; i++) {
130  samples.clear();
131  for (int j=0; j<10; j++) {
132  samples.push_back( rset->getFloat(7+(10*i)+j) );
133  }
134  dat.setSamples(samples, gain[i]);
135  }
136 
137  p.second = dat;
138  fillMap->insert(p);
139  }
140  } catch (SQLException &e) {
141  throw(std::runtime_error("MonPulseShapeDat::fetchData: "+e.getMessage()));
142  }
143 }
int fetchID() noexcept(false)
Definition: MonRunIOV.cc:118
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setSamples(std::vector< float > &samples, int gain) noexcept(false)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
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 40 of file MonPulseShapeDat.h.

References fetchData(), muonCSCDigis_cfi::gain, m_samplesG1, m_samplesG12, m_samplesG6, noexcept, prepareWrite(), and writeDB().

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

Implements IDataItem.

Definition at line 20 of file MonPulseShapeDat.h.

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

Implements IDataItem.

Definition at line 33 of file MonPulseShapeDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getSamples().

35 {
36  this->checkConnection();
37 
38  try {
39  m_writeStmt = m_conn->createStatement();
40  m_writeStmt->setSQL("INSERT INTO mon_pulse_shape_dat (iov_id, logic_id, "
41  "g1_avg_sample_01, g1_avg_sample_02, g1_avg_sample_03, g1_avg_sample_04, g1_avg_sample_05, g1_avg_sample_06, g1_avg_sample_07, g1_avg_sample_08, g1_avg_sample_09, g1_avg_sample_10, "
42  "g6_avg_sample_01, g6_avg_sample_02, g6_avg_sample_03, g6_avg_sample_04, g6_avg_sample_05, 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, g12_avg_sample_06, g12_avg_sample_07, g12_avg_sample_08, g12_avg_sample_09, g12_avg_sample_10) "
44  "VALUES (:iov_id, :logic_id, "
45  ":g1_avg_sample_01, :g1_avg_sample_02, :g1_avg_sample_03, :g1_avg_sample_04, :g1_avg_sample_05, :g1_avg_sample_06, :g1_avg_sample_07, :g1_avg_sample_08, :g1_avg_sample_09, :g1_avg_sample_10,"
46  ":g6_avg_sample_01, :g6_avg_sample_02, :g6_avg_sample_03, :g6_avg_sample_04, :g6_avg_sample_05, :g6_avg_sample_06, :g6_avg_sample_07, :g6_avg_sample_08, :g6_avg_sample_09, :g6_avg_sample_10,"
47  ":g12_avg_sample_01, :g12_avg_sample_02, :g12_avg_sample_03, :g12_avg_sample_04, :g12_avg_sample_05, :g12_avg_sample_06, :g12_avg_sample_07, :g12_avg_sample_08, :g12_avg_sample_09, :g12_avg_sample_10)"
48  );
49 
50  } catch (SQLException &e) {
51  throw(std::runtime_error("MonPulseShapeDat::prepareWrite(): "+e.getMessage()));
52  }
53 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void MonPulseShapeDat::setSamples ( std::vector< float > &  samples,
int  gain 
)
inlinenoexcept

Definition at line 22 of file MonPulseShapeDat.h.

References muonCSCDigis_cfi::gain, m_samplesG1, m_samplesG12, m_samplesG6, and hcalTTPDigis_cfi::samples.

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

24  {
25  if (samples.size() != 10) {
26  throw(std::runtime_error("MonPulseShapeDat::setSamples: There should be 10 samples."));
27  }
28 
29  if (gain == 1) {
31  } else if (gain == 6) {
33  } else if (gain == 12) {
35  } else {
36  throw(std::runtime_error("MonPulseShapeDat::setSamples: Gain should be 1, 6 or 12"));
37  }
38  }
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 57 of file MonPulseShapeDat.cc.

References MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, muonCSCDigis_cfi::gain, mps_fire::i, and hcalTTPDigis_cfi::samples.

Referenced by getSamples().

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

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 65 of file MonPulseShapeDat.h.

Referenced by getSamples(), and setSamples().

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

Definition at line 67 of file MonPulseShapeDat.h.

Referenced by getSamples(), and setSamples().

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

Definition at line 66 of file MonPulseShapeDat.h.

Referenced by getSamples(), and setSamples().