CMS 3D CMS Logo

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

#include <FEConfigLUTGroupDat.h>

Inheritance diagram for FEConfigLUTGroupDat:
IDataItem IDBObject

Public Member Functions

 FEConfigLUTGroupDat ()
 
int getLUTGroupId () const
 
int getLUTValue (int i) const
 
std::string getTable () override
 
void setLUTGroupId (int x)
 
void setLUTValue (int i, int x)
 
 ~FEConfigLUTGroupDat () 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, FEConfigLUTGroupDat > *fillMap, FEConfigLUTInfo *iconf) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeArrayDB (const std::map< EcalLogicID, FEConfigLUTGroupDat > *data, FEConfigLUTInfo *iconf) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const FEConfigLUTGroupDat *item, FEConfigLUTInfo *iconf) noexcept(false)
 

Private Attributes

int m_group_id
 
int m_lut [1024]
 

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 11 of file FEConfigLUTGroupDat.h.

Constructor & Destructor Documentation

FEConfigLUTGroupDat::FEConfigLUTGroupDat ( )

Definition at line 11 of file FEConfigLUTGroupDat.cc.

References mps_fire::i.

12 {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17 
18  m_group_id=0;
19  for(int i=0; i<1024; i++){
20  m_lut[i] = 0;
21  }
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
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
FEConfigLUTGroupDat::~FEConfigLUTGroupDat ( )
override

Definition at line 27 of file FEConfigLUTGroupDat.cc.

28 {
29 }

Member Function Documentation

void FEConfigLUTGroupDat::fetchData ( std::map< EcalLogicID, FEConfigLUTGroupDat > *  fillMap,
FEConfigLUTInfo iconf 
)
privatenoexcept

Definition at line 124 of file FEConfigLUTGroupDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, setLUTGroupId(), setLUTValue(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getLUTValue().

126 {
127  this->checkConnection();
128  fillMap->clear();
129 
130  iconf->setConnection(m_env, m_conn);
131  int iconfID = iconf->fetchID();
132  if (!iconfID) {
133  throw(std::runtime_error("FEConfigLUTGroupDat::fetchData: ICONF not in DB"));
134  return;
135  }
136 
137  try {
138 
139  m_readStmt->setSQL("SELECT d.group_id, d.lut_id, d.lut_value "
140  "FROM fe_lut_per_group_dat d "
141  "WHERE lut_conf_id = :lut_conf_id order by d.group_id, d.lut_id ");
142  m_readStmt->setInt(1, iconfID);
143  ResultSet* rset = m_readStmt->executeQuery();
144 
146  std::pair< EcalLogicID, FEConfigLUTGroupDat > p;
147 
148 
149  int nrows=1024;
150 
151  int igold=-1;
152  int ig=igold;
153 
154  while(rset->next()) {
155  ig=rset->getInt(1);
156  int il=rset->getInt(2);
157  int ival=rset->getInt(3);
158  if(il==0){
159 
160  p.first = EcalLogicID( "Group_id", ig ); // a dummy logic_id
161  dat = FEConfigLUTGroupDat();
162  dat.setLUTGroupId( ig );
163  dat.setLUTValue( il, ival );
164  } else {
165  dat.setLUTValue( il, ival );
166  }
167 
168  if(il==(nrows-1)){
169 
170  p.second = dat;
171  fillMap->insert(p);
172  }
173  }
174  } catch (SQLException &e) {
175  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::fetchData: ")+getOraMessage(&e)));
176  }
177 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setLUTValue(int i, int x)
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
int fetchID() noexcept(false)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int FEConfigLUTGroupDat::getLUTGroupId ( ) const
inline

Definition at line 21 of file FEConfigLUTGroupDat.h.

References m_group_id.

Referenced by popcon::EcalTPGLutIdMapHandler::getNewObjects(), and writeArrayDB().

21 { return m_group_id; }
int FEConfigLUTGroupDat::getLUTValue ( int  i) const
inline
std::string FEConfigLUTGroupDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file FEConfigLUTGroupDat.h.

18 { return "FE_CONFIG_LUT_PER_GROUP_DAT"; }
void FEConfigLUTGroupDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 33 of file FEConfigLUTGroupDat.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getLUTValue().

35 {
36  this->checkConnection();
37 
38  try {
39  m_writeStmt = m_conn->createStatement();
40  m_writeStmt->setSQL("INSERT INTO fe_lut_per_group_dat (lut_conf_id, group_id, "
41  " lut_id, lut_value ) "
42  "VALUES (:lut_conf_id, :group_id, "
43  ":lut_id, :lut_value )" );
44  } catch (SQLException &e) {
45  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::prepareWrite(): ")+getOraMessage(&e)));
46  }
47 }
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 FEConfigLUTGroupDat::setLUTGroupId ( int  x)
inline

Definition at line 20 of file FEConfigLUTGroupDat.h.

References m_group_id, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigLUTGroupDat::setLUTValue ( int  i,
int  x 
)
inline

Definition at line 23 of file FEConfigLUTGroupDat.h.

References mps_fire::i, m_lut, and x.

Referenced by EcalTPGParamBuilder::analyze(), and fetchData().

void FEConfigLUTGroupDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigLUTGroupDat > *  data,
FEConfigLUTInfo iconf 
)
privatenoexcept

Definition at line 179 of file FEConfigLUTGroupDat.cc.

References KineDebug3::count(), gather_cfg::cout, data, MillePedeFileConverter_cfg::e, getLUTGroupId(), getLUTValue(), mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

Referenced by getLUTValue().

181 {
182  this->checkConnection();
183  this->checkPrepare();
184 
185  int iconfID = iconf->fetchID();
186  if (!iconfID) { throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB: ICONF not in DB")); }
187 
188 
189  int nrows=data->size()*1024;
190 
191  int* iconfid_vec= new int[nrows];
192  int* xx= new int[nrows];
193  int* yy= new int[nrows];
194  int* zz= new int[nrows];
195 
196 
197 
198  ub2* iconf_len= new ub2[nrows];
199  ub2* x_len= new ub2[nrows];
200  ub2* y_len= new ub2[nrows];
201  ub2* z_len= new ub2[nrows];
202 
203 
204  const FEConfigLUTGroupDat* dataitem;
205  int count=0;
206  typedef map< EcalLogicID, FEConfigLUTGroupDat >::const_iterator CI;
207  for (CI p = data->begin(); p != data->end(); ++p) {
208 
209 
210  dataitem = &(p->second);
211  int x=dataitem->getLUTGroupId();
212 
213 
214  for (int i=0; i<1024; i++){
215  iconfid_vec[count]=iconfID;
216  int y=i;
217  int z=dataitem->getLUTValue(i);
218 
219  xx[count]=x;
220  yy[count]=y;
221  zz[count]=z;
222 
223 
224  iconf_len[count]=sizeof(iconfid_vec[count]);
225 
226  x_len[count]=sizeof(xx[count]);
227  y_len[count]=sizeof(yy[count]);
228  z_len[count]=sizeof(zz[count]);
229 
230  count++;
231 
232  }
233  }
234 
235 
236  try {
237 
238  // for (int i=0; i<nrows; i++){
239 
240  int i=0;
241  cout << "about to insert "<< iconfid_vec[i]<<" " <<xx[i]<< " "<< yy[i]<< " "<< zz[i]<< endl;
242  i=nrows-1;
243  cout << "about to insert "<< iconfid_vec[i]<<" " <<xx[i]<< " "<< yy[i]<< " "<< zz[i]<< endl;
244  // }
245  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
246  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len );
247  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
248  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
249 
250  m_writeStmt->executeArrayUpdate(nrows);
251 
252 
253  delete [] iconfid_vec;
254  delete [] xx;
255  delete [] yy;
256  delete [] zz;
257 
258 
259 
260  delete [] iconf_len;
261  delete [] x_len;
262  delete [] y_len;
263  delete [] z_len;
264 
265 
266  } catch (SQLException &e) {
267  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::writeArrayDB(): ")+getOraMessage(&e)));
268  }
269 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLUTValue(int i) const
int fetchID() noexcept(false)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void FEConfigLUTGroupDat::writeDB ( const EcalLogicID ecid,
const FEConfigLUTGroupDat item,
FEConfigLUTInfo iconf 
)
privatenoexcept

Definition at line 49 of file FEConfigLUTGroupDat.cc.

References KineDebug3::count(), gather_cfg::cout, MillePedeFileConverter_cfg::e, AlCaHLTBitMon_QueryRunRegistry::string, x, geometryCSVtoXML::xx, y, geometryCSVtoXML::yy, z, and geometryCSVtoXML::zz.

Referenced by getLUTValue().

51 {
52  this->checkConnection();
53  this->checkPrepare();
54 
55  int iconfID = iconf->fetchID();
56 
57  cout<< "iconf="<< iconfID << endl;
58 
59  if (!iconfID) { throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB: ICONF not in DB")); }
60 
61 
62  int nrows=1024;
63  int* iconfid_vec= new int[nrows];
64  int* xx= new int[nrows];
65  int* yy= new int[nrows];
66  int* zz= new int[nrows];
67 
68 
69  ub2* iconf_len= new ub2[nrows];
70  ub2* x_len= new ub2[nrows];
71  ub2* y_len= new ub2[nrows];
72  ub2* z_len= new ub2[nrows];
73 
74 
75 
76  for(int count=0; count<nrows; count++){
77 
78  iconfid_vec[count]=iconfID;
79  int x=item->getLUTGroupId();
80  int y=count;
81  int z=m_lut[count];
82 
83  xx[count]=x;
84  yy[count]=y;
85  zz[count]=z;
86 
87  iconf_len[count]=sizeof(iconfid_vec[count]);
88 
89  x_len[count]=sizeof(xx[count]);
90  y_len[count]=sizeof(yy[count]);
91  z_len[count]=sizeof(zz[count]);
92 
93  }
94 
95 
96  try {
97  m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
98  m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len );
99  m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
100  m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
101 
102  m_writeStmt->executeArrayUpdate(nrows);
103 
104 
105  delete [] iconfid_vec;
106  delete [] xx;
107  delete [] yy;
108  delete [] zz;
109 
110 
111 
112  delete [] iconf_len;
113  delete [] x_len;
114  delete [] y_len;
115  delete [] z_len;
116 
117 
118  } catch (SQLException &e) {
119  throw(std::runtime_error(std::string("FEConfigLUTGroupDat::writeArrayDB(): ")+getOraMessage(&e)));
120  }
121 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigLUTGroupDat.h.

Member Data Documentation

int FEConfigLUTGroupDat::m_group_id
private

Definition at line 40 of file FEConfigLUTGroupDat.h.

Referenced by getLUTGroupId(), and setLUTGroupId().

int FEConfigLUTGroupDat::m_lut[1024]
private

Definition at line 41 of file FEConfigLUTGroupDat.h.

Referenced by getLUTValue(), and setLUTValue().