CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
MonCrystalConsistencyDat Class Reference

#include <MonCrystalConsistencyDat.h>

Inheritance diagram for MonCrystalConsistencyDat:
IDataItem IDBObject

Public Member Functions

int getProblematicEvents () const
 
int getProblemsGainSwitch () const
 
int getProblemsGainZero () const
 
int getProblemsID () const
 
int getProcessedEvents () const
 
std::string getTable () override
 
bool getTaskStatus () const
 
 MonCrystalConsistencyDat ()
 
void setProblematicEvents (int prob)
 
void setProblemsGainSwitch (int prob)
 
void setProblemsGainZero (int prob)
 
void setProblemsID (int id)
 
void setProcessedEvents (int proc)
 
void setTaskStatus (bool status)
 
 ~MonCrystalConsistencyDat () 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, MonCrystalConsistencyDat > *fillVec, MonRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, MonCrystalConsistencyDat > *data, MonRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MonCrystalConsistencyDat *item, MonRunIOV *iov) noexcept(false)
 

Private Attributes

int m_problematicEvents
 
int m_problemsGainSwitch
 
int m_problemsGainZero
 
int m_problemsID
 
int m_processedEvents
 
bool m_taskStatus
 

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 12 of file MonCrystalConsistencyDat.h.

Constructor & Destructor Documentation

◆ MonCrystalConsistencyDat()

MonCrystalConsistencyDat::MonCrystalConsistencyDat ( )

Definition at line 10 of file MonCrystalConsistencyDat.cc.

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15 
18  m_problemsID = 0;
21  m_taskStatus = false;
22 }
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
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24

◆ ~MonCrystalConsistencyDat()

MonCrystalConsistencyDat::~MonCrystalConsistencyDat ( )
override

Definition at line 24 of file MonCrystalConsistencyDat.cc.

24 {}

Member Function Documentation

◆ fetchData()

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

Definition at line 73 of file MonCrystalConsistencyDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setProblematicEvents(), setProblemsGainSwitch(), setProblemsGainZero(), setProblemsID(), setProcessedEvents(), and setTaskStatus().

74  {
75  this->checkConnection();
76  fillMap->clear();
77 
78  iov->setConnection(m_env, m_conn);
79  int iovID = iov->fetchID();
80  if (!iovID) {
81  // throw(std::runtime_error("MonCrystalConsistencyDat::writeDB: IOV not in DB"));
82  return;
83  }
84 
85  try {
86  m_readStmt->setSQL(
87  "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
88  "d.processed_events, d.problematic_events, d.problems_id, d.problems_gain_zero, d.problems_gain_switch, "
89  "d.task_status "
90  "FROM channelview cv JOIN mon_crystal_consistency_dat d "
91  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
92  "WHERE d.iov_id = :iov_id");
93  m_readStmt->setInt(1, iovID);
94  ResultSet* rset = m_readStmt->executeQuery();
95 
96  std::pair<EcalLogicID, MonCrystalConsistencyDat> p;
98  while (rset->next()) {
99  p.first = EcalLogicID(rset->getString(1), // name
100  rset->getInt(2), // logic_id
101  rset->getInt(3), // id1
102  rset->getInt(4), // id2
103  rset->getInt(5), // id3
104  rset->getString(6)); // maps_to
105 
106  dat.setProcessedEvents(rset->getInt(7));
107  dat.setProblematicEvents(rset->getInt(8));
108  dat.setProblemsID(rset->getInt(9));
109  dat.setProblemsGainZero(rset->getInt(10));
110  dat.setProblemsGainSwitch(rset->getInt(11));
111  dat.setTaskStatus(rset->getInt(12));
112 
113  p.second = dat;
114  fillMap->insert(p);
115  }
116 
117  } catch (SQLException& e) {
118  throw(std::runtime_error("MonCrystalConsistencyDat::fetchData(): " + e.getMessage()));
119  }
120 }
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
int fetchID() noexcept(false) override
Definition: MonRunIOV.cc:72
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ getProblematicEvents()

int MonCrystalConsistencyDat::getProblematicEvents ( ) const
inline

Definition at line 25 of file MonCrystalConsistencyDat.h.

References m_problematicEvents.

Referenced by writeArrayDB().

◆ getProblemsGainSwitch()

int MonCrystalConsistencyDat::getProblemsGainSwitch ( ) const
inline

Definition at line 34 of file MonCrystalConsistencyDat.h.

References m_problemsGainSwitch.

Referenced by writeArrayDB().

◆ getProblemsGainZero()

int MonCrystalConsistencyDat::getProblemsGainZero ( ) const
inline

◆ getProblemsID()

int MonCrystalConsistencyDat::getProblemsID ( ) const
inline

Definition at line 28 of file MonCrystalConsistencyDat.h.

References m_problemsID.

Referenced by writeArrayDB().

◆ getProcessedEvents()

int MonCrystalConsistencyDat::getProcessedEvents ( ) const
inline

Definition at line 22 of file MonCrystalConsistencyDat.h.

References m_processedEvents.

Referenced by writeArrayDB().

◆ getTable()

std::string MonCrystalConsistencyDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 19 of file MonCrystalConsistencyDat.h.

19 { return "MON_CRYSTAL_CONSISTENCY_DAT"; }

◆ getTaskStatus()

bool MonCrystalConsistencyDat::getTaskStatus ( ) const
inline

Definition at line 37 of file MonCrystalConsistencyDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

◆ prepareWrite()

void MonCrystalConsistencyDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 26 of file MonCrystalConsistencyDat.cc.

References MillePedeFileConverter_cfg::e.

26  {
27  this->checkConnection();
28 
29  try {
30  m_writeStmt = m_conn->createStatement();
31  m_writeStmt->setSQL(
32  "INSERT INTO mon_crystal_consistency_dat (iov_id, logic_id, "
33  "processed_events, problematic_events, problems_id, problems_gain_zero, problems_gain_switch, task_status) "
34  "VALUES (:iov_id, :logic_id, "
35  ":3, :4, :5, :6, :7, :8)");
36  } catch (SQLException& e) {
37  throw(std::runtime_error("MonCrystalConsistencyDat::prepareWrite(): " + e.getMessage()));
38  }
39 }
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

◆ setProblematicEvents()

void MonCrystalConsistencyDat::setProblematicEvents ( int  prob)
inline

◆ setProblemsGainSwitch()

void MonCrystalConsistencyDat::setProblemsGainSwitch ( int  prob)
inline

◆ setProblemsGainZero()

void MonCrystalConsistencyDat::setProblemsGainZero ( int  prob)
inline

◆ setProblemsID()

void MonCrystalConsistencyDat::setProblemsID ( int  id)
inline

◆ setProcessedEvents()

void MonCrystalConsistencyDat::setProcessedEvents ( int  proc)
inline

◆ setTaskStatus()

void MonCrystalConsistencyDat::setTaskStatus ( bool  status)
inline

Definition at line 36 of file MonCrystalConsistencyDat.h.

References m_taskStatus, and mps_update::status.

Referenced by fetchData().

◆ writeArrayDB()

void MonCrystalConsistencyDat::writeArrayDB ( const std::map< EcalLogicID, MonCrystalConsistencyDat > *  data,
MonRunIOV iov 
)
privatenoexcept

Definition at line 122 of file MonCrystalConsistencyDat.cc.

References submitPVResolutionJobs::count, data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getProblematicEvents(), getProblemsGainSwitch(), getProblemsGainZero(), getProblemsID(), getProcessedEvents(), getTaskStatus(), AlCaHLTBitMon_ParallelJobs::p, w(), x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

123  {
124  this->checkConnection();
125  this->checkPrepare();
126 
127  int iovID = iov->fetchID();
128  if (!iovID) {
129  throw(std::runtime_error("MonCrystalConsistencyDat::writeArrayDB: IOV not in DB"));
130  }
131 
132  int nrows = data->size();
133  int* ids = new int[nrows];
134  int* iovid_vec = new int[nrows];
135  int* xx = new int[nrows];
136  int* yy = new int[nrows];
137  int* zz = new int[nrows];
138  int* ww = new int[nrows];
139  int* uu = new int[nrows];
140  int* st = new int[nrows];
141 
142  ub2* ids_len = new ub2[nrows];
143  ub2* iov_len = new ub2[nrows];
144  ub2* x_len = new ub2[nrows];
145  ub2* y_len = new ub2[nrows];
146  ub2* z_len = new ub2[nrows];
147  ub2* w_len = new ub2[nrows];
148  ub2* u_len = new ub2[nrows];
149  ub2* st_len = new ub2[nrows];
150 
151  const EcalLogicID* channel;
152  const MonCrystalConsistencyDat* dataitem;
153  int count = 0;
154  typedef map<EcalLogicID, MonCrystalConsistencyDat>::const_iterator CI;
155  for (CI p = data->begin(); p != data->end(); ++p) {
156  channel = &(p->first);
157  int logicID = channel->getLogicID();
158  if (!logicID) {
159  throw(std::runtime_error("MonCrystalConsistencyDat::writeArrayDB: Bad EcalLogicID"));
160  }
161  ids[count] = logicID;
162  iovid_vec[count] = iovID;
163 
164  dataitem = &(p->second);
165  // dataIface.writeDB( channel, dataitem, iov);
166  int x = dataitem->getProcessedEvents();
167  int y = dataitem->getProblematicEvents();
168  int z = dataitem->getProblemsID();
169  int w = dataitem->getProblemsGainZero();
170  int u = dataitem->getProblemsGainSwitch();
171  int statu = dataitem->getTaskStatus();
172 
173  xx[count] = x;
174  yy[count] = y;
175  zz[count] = z;
176  ww[count] = w;
177  uu[count] = u;
178  st[count] = statu;
179 
180  ids_len[count] = sizeof(ids[count]);
181  iov_len[count] = sizeof(iovid_vec[count]);
182 
183  x_len[count] = sizeof(xx[count]);
184  y_len[count] = sizeof(yy[count]);
185  z_len[count] = sizeof(zz[count]);
186  w_len[count] = sizeof(ww[count]);
187  u_len[count] = sizeof(uu[count]);
188  st_len[count] = sizeof(st[count]);
189 
190  count++;
191  }
192 
193  try {
194  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]), iov_len);
195  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len);
196  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len);
197  m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT, sizeof(yy[0]), y_len);
198  m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIINT, sizeof(zz[0]), z_len);
199  m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIINT, sizeof(ww[0]), w_len);
200  m_writeStmt->setDataBuffer(7, (dvoid*)uu, OCCIINT, sizeof(uu[0]), u_len);
201  m_writeStmt->setDataBuffer(8, (dvoid*)st, OCCIINT, sizeof(st[0]), st_len);
202 
203  m_writeStmt->executeArrayUpdate(nrows);
204 
205  delete[] ids;
206  delete[] iovid_vec;
207  delete[] xx;
208  delete[] yy;
209  delete[] zz;
210  delete[] ww;
211  delete[] uu;
212  delete[] st;
213 
214  delete[] ids_len;
215  delete[] iov_len;
216  delete[] x_len;
217  delete[] y_len;
218  delete[] z_len;
219  delete[] w_len;
220  delete[] u_len;
221  delete[] st_len;
222 
223  } catch (SQLException& e) {
224  throw(std::runtime_error("MonCrystalConsistencyDat::writeArrayDB(): " + e.getMessage()));
225  }
226 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
T w() const
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
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ writeDB()

void MonCrystalConsistencyDat::writeDB ( const EcalLogicID ecid,
const MonCrystalConsistencyDat item,
MonRunIOV iov 
)
privatenoexcept

Definition at line 41 of file MonCrystalConsistencyDat.cc.

References MillePedeFileConverter_cfg::e, and B2GTnPMonitor_cfi::item.

43  {
44  this->checkConnection();
45  this->checkPrepare();
46 
47  int iovID = iov->fetchID();
48  if (!iovID) {
49  throw(std::runtime_error("MonCrystalConsistencyDat::writeDB: IOV not in DB"));
50  }
51 
52  int logicID = ecid->getLogicID();
53  if (!logicID) {
54  throw(std::runtime_error("MonCrystalConsistencyDat::writeDB: Bad EcalLogicID"));
55  }
56 
57  try {
58  m_writeStmt->setInt(1, iovID);
59  m_writeStmt->setInt(2, logicID);
60 
61  m_writeStmt->setInt(3, item->getProcessedEvents());
62  m_writeStmt->setInt(4, item->getProblematicEvents());
63  m_writeStmt->setInt(5, item->getProblemsID());
64  m_writeStmt->setInt(6, item->getProblemsGainZero());
65  m_writeStmt->setInt(7, item->getProblemsGainSwitch());
66  m_writeStmt->setInt(8, item->getTaskStatus());
67  m_writeStmt->executeUpdate();
68  } catch (SQLException& e) {
69  throw(std::runtime_error("MonCrystalConsistencyDat::writeDB(): " + e.getMessage()));
70  }
71 }
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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonCrystalConsistencyDat.h.

Member Data Documentation

◆ m_problematicEvents

int MonCrystalConsistencyDat::m_problematicEvents
private

Definition at line 50 of file MonCrystalConsistencyDat.h.

Referenced by getProblematicEvents(), and setProblematicEvents().

◆ m_problemsGainSwitch

int MonCrystalConsistencyDat::m_problemsGainSwitch
private

Definition at line 53 of file MonCrystalConsistencyDat.h.

Referenced by getProblemsGainSwitch(), and setProblemsGainSwitch().

◆ m_problemsGainZero

int MonCrystalConsistencyDat::m_problemsGainZero
private

Definition at line 52 of file MonCrystalConsistencyDat.h.

Referenced by getProblemsGainZero(), and setProblemsGainZero().

◆ m_problemsID

int MonCrystalConsistencyDat::m_problemsID
private

Definition at line 51 of file MonCrystalConsistencyDat.h.

Referenced by getProblemsID(), and setProblemsID().

◆ m_processedEvents

int MonCrystalConsistencyDat::m_processedEvents
private

Definition at line 49 of file MonCrystalConsistencyDat.h.

Referenced by getProcessedEvents(), and setProcessedEvents().

◆ m_taskStatus

bool MonCrystalConsistencyDat::m_taskStatus
private

Definition at line 54 of file MonCrystalConsistencyDat.h.

Referenced by getTaskStatus(), and setTaskStatus().