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(), and setLUTValue().

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 
145  FEConfigLUTGroupDat* dat(nullptr);
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=new 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  delete dat;
173  }
174  }
175  } catch (SQLException &e) {
176  throw(std::runtime_error("FEConfigLUTGroupDat::fetchData: "+e.getMessage()));
177  }
178 }
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
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.

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("FEConfigLUTGroupDat::prepareWrite(): "+e.getMessage()));
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 180 of file FEConfigLUTGroupDat.cc.

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

Referenced by getLUTValue().

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