CMS 3D CMS Logo

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

#include <LMFDat.h>

Inheritance diagram for LMFDat:
LMFUnique IUniqueDBObject IDBObject LMFColoredTable LMFCorrCoefDatComponent LMFLaserConfigDat LMFRunDat LMFTestPulseConfigDat LMFClsDat LMFLaserPulseDat LMFPnPrimDat LMFPrimDat

Public Member Functions

void dump () const
 
void dump (int n) const
 
virtual void dump (int n, int max) const
 
void fetch () throw (std::runtime_error)
 
void fetch (int logic_id) throw (std::runtime_error)
 
void fetch (int logic_id, const Tm &tm) throw (std::runtime_error)
 
void fetch (int logic_id, const Tm *timestamp, int dir) throw (std::runtime_error)
 
void fetch (const EcalLogicID &id, const Tm &tm) throw (std::runtime_error)
 
void fetch (const EcalLogicID &id, const Tm &tm, int dir) throw (std::runtime_error)
 
void fetch (const EcalLogicID &id) throw (std::runtime_error)
 
std::map< int, std::vector
< float > > 
fetchData () throw (std::runtime_error)
 
virtual std::string foreignKeyName () const
 
std::vector< float > getData (int id)
 
std::vector< float > getData (const EcalLogicID &id)
 
bool getData (int id, std::vector< float > &ret)
 
bool getData (const EcalLogicID &id, std::vector< float > &ret)
 
std::map< int, std::vector
< float > > 
getData ()
 
float getData (int id, unsigned int k)
 
float getData (const EcalLogicID &id, unsigned int k)
 
float getData (const EcalLogicID &id, const std::string &key)
 
float getData (int id, const std::string &key)
 
bool getData (int id, unsigned int k, float &ret)
 
bool getData (const EcalLogicID &id, unsigned int k, float &ret)
 
bool getData (int id, const std::string &key, float &ret)
 
bool getData (const EcalLogicID &id, const std::string &key, float &ret)
 
virtual std::string getIovIdFieldName () const
 
std::list< std::string > getKeyList ()
 
std::map< std::string,
unsigned int > 
getKeys ()
 
LMFRunIOV getLMFRunIOV () const
 
int getLMFRunIOVID ()
 
std::list< int > getLogicIds ()
 
void getNext (LMFDat *dat) throw (std::runtime_error)
 
void getPrevious (LMFDat *dat) throw (std::runtime_error)
 
std::map< unsigned int,
std::string > 
getReverseMap () const
 
Tm getSubrunStart () const
 
virtual std::string getTableName () const
 
virtual bool isValid ()
 
 LMFDat ()
 
 LMFDat (EcalDBConnection *c)
 
 LMFDat (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
std::vector< float > operator[] (int id)
 
LMFDatsetData (int logic_id, const std::vector< float > &data)
 
LMFDatsetData (const EcalLogicID &logic_id, const std::vector< float > &data)
 
LMFDatsetData (const EcalLogicID &logic_id, const std::string &key, float v)
 
LMFDatsetLMFRunIOV (const LMFRunIOV &iov)
 
LMFDatsetMaxDataToDump (int n)
 
int size () const
 
 ~LMFDat ()
 
- Public Member Functions inherited from LMFUnique
void attach (std::string name, LMFUnique *u)
 
void debug ()
 
virtual bool exists ()
 
virtual boost::ptr_list
< LMFUnique
fetchAll () const throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
std::string getClassName ()
 
std::string getClassName () const
 
int getID () const
 
int getInt (std::string fieldname) const
 
std::string getString (std::string fieldname) const
 
virtual bool isValid () const
 
 LMFUnique ()
 
 LMFUnique (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
 LMFUnique (EcalDBConnection *c)
 
void nodebug ()
 
virtual bool operator< (const LMFUnique &r)
 
virtual bool operator<= (const LMFUnique &r)
 
std::string sequencePostfix (Tm t)
 
void setByID (int id) throw (std::runtime_error)
 
LMFUniquesetInt (std::string key, int value)
 
LMFUniquesetString (std::string key, std::string value)
 
void startProfiling ()
 
void stopProfiling ()
 
virtual ~LMFUnique ()
 
- 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 ()
 

Protected Member Functions

std::string buildInsertSql ()
 
std::string buildSelectSql (int logic_id=0, int direction=0)
 
bool check ()
 
void getKeyTypes () throw (std::runtime_error)
 
void getNeighbour (LMFDat *dat, int which) throw (std::runtime_error)
 
int writeDB () throw (std::runtime_error)
 
- Protected Member Functions inherited from LMFUnique
virtual void setClassName (std::string s)
 
virtual int writeForeignKeys () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 

Protected Attributes

std::map< int, std::vector
< float > > 
m_data
 
std::string m_Error
 
std::map< std::string,
unsigned int > 
m_keys
 
int m_max
 
std::string m_tableName
 
std::vector< std::string > m_type
 
- Protected Attributes inherited from LMFUnique
bool _profiling
 
std::string m_className
 
char m_debug
 
std::map< std::string,
LMFUnique * > 
m_foreignKeys
 
std::map< std::string, int > m_intFields
 
std::map< std::string,
std::string > 
m_stringFields
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Public Types inherited from LMFUnique
typedef oracle::occi::ResultSet ResultSet
 
typedef oracle::occi::Statement Statement
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 

Detailed Description

Data Tables for LMF Runs

Definition at line 19 of file LMFDat.h.

Constructor & Destructor Documentation

LMFDat::LMFDat ( )

Definition at line 9 of file LMFDat.cc.

References m_max, and m_tableName.

9  : LMFUnique() {
10  m_tableName = "";
11  m_max = -1;
12 }
LMFUnique()
Definition: LMFUnique.h:23
int m_max
Definition: LMFDat.h:146
std::string m_tableName
Definition: LMFDat.h:153
LMFDat::LMFDat ( EcalDBConnection c)

Definition at line 14 of file LMFDat.cc.

References m_max, and m_tableName.

14  : LMFUnique(c) {
15  m_tableName = "";
16  m_max = -1;
17 }
LMFUnique()
Definition: LMFUnique.h:23
int m_max
Definition: LMFDat.h:146
std::string m_tableName
Definition: LMFDat.h:153
LMFDat::LMFDat ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 19 of file LMFDat.cc.

References m_max, and m_tableName.

20  : LMFUnique(env, conn) {
21  m_tableName = "";
22  m_max = -1;
23 }
LMFUnique()
Definition: LMFUnique.h:23
int m_max
Definition: LMFDat.h:146
std::string m_tableName
Definition: LMFDat.h:153
LMFDat::~LMFDat ( )
inline

Definition at line 27 of file LMFDat.h.

27 { }

Member Function Documentation

std::string LMFDat::buildInsertSql ( )
protected

Definition at line 97 of file LMFDat.cc.

References gather_cfg::cout, getTableName(), i, LMFUnique::m_className, LMFUnique::m_debug, and m_keys.

Referenced by writeDB().

97  {
98  // create the insert statement
99  std::stringstream sql;
100  sql << "INSERT INTO " + getTableName() + " VALUES (";
101  unsigned int nParameters = m_keys.size() + 2;
102  for (unsigned int i = 0; i < nParameters - 1; i++) {
103  sql << ":" << i + 1 << ", ";
104  }
105  sql << ":" << nParameters << ")";
106  std::string sqls = sql.str();
107  if (m_debug) {
108  cout << m_className << "::writeDB: " << sqls << endl;
109  }
110  return sqls;
111 }
std::string m_className
Definition: LMFUnique.h:98
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
tuple cout
Definition: gather_cfg.py:41
virtual std::string getTableName() const
Definition: LMFDat.h:49
char m_debug
Definition: LMFUnique.h:99
std::string LMFDat::buildSelectSql ( int  logic_id = 0,
int  direction = 0 
)
protected

Definition at line 117 of file LMFDat.cc.

References prof2calltree::count, gather_cfg::cout, getIovIdFieldName(), getLMFRunIOVID(), getTableName(), LMFUnique::m_className, and LMFUnique::m_debug.

117  {
118  // create the insert statement
119  // if logic_id = 0 select all channels for a given iov_id
120  std::stringstream sql;
121  int count = 1;
122  if (getLMFRunIOVID() > 0) {
123  // in this case we are looking for all data collected during the same
124  // IOV. There can be many logic_ids per IOV.
125  sql << "SELECT * FROM " << getTableName() << " WHERE "
126  << getIovIdFieldName() << " = " << getLMFRunIOVID();
127  } else {
128  // in this case we are looking for a specific logic_id whose
129  // data have been collected at a given time. There is only
130  // one record in this case.
131  std::string op = ">";
132  std::string order = "ASC";
133  if (direction < 0) {
134  op = "<";
135  order = "DESC";
136  }
137  sql << "SELECT * FROM (SELECT " << getTableName() << ".* FROM "
138  << getTableName()
139  << " JOIN LMF_RUN_IOV ON "
140  << "LMF_RUN_IOV.LMF_IOV_ID = "
141  << getTableName() << "." << getIovIdFieldName() << " "
142  << "WHERE SUBRUN_START " << op << "= TO_DATE(:" << count;
143  count++;
144  sql << ", 'YYYY-MM-DD HH24:MI:SS') ORDER BY SUBRUN_START "
145  << order << ") WHERE ROWNUM <= 1";
146  }
147  if (logic_id > 0) {
148  sql << " AND LOGIC_ID = :" << count;
149  }
150  std::string sqls = sql.str();
151  if (m_debug) {
152  cout << m_className << "::buildSelectSqlDB: " << sqls << endl;
153  }
154  return sqls;
155 }
std::string m_className
Definition: LMFUnique.h:98
int getLMFRunIOVID()
Definition: LMFDat.cc:29
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:113
tuple cout
Definition: gather_cfg.py:41
virtual std::string getTableName() const
Definition: LMFDat.h:49
char m_debug
Definition: LMFUnique.h:99
bool LMFDat::check ( void  )
protected

Definition at line 508 of file LMFDat.cc.

References getKeyTypes(), getTableName(), LMFUnique::m_className, m_Error, m_keys, m_type, and runTheMatrix::ret.

Referenced by writeDB().

508  {
509  // check that everything has been correctly setup
510  bool ret = true;
511  m_Error = "";
512  // first of all we need to check that the class name has been set
513  if (m_className == "LMFUnique") {
514  m_Error = "class name not set ";
515  ret = false;
516  }
517  //then check that the table name has been set
518  if (getTableName() == "") {
519  m_Error += "table name not set ";
520  ret = false;
521  }
522  // fill key types if not yet done
523  if (m_type.size() != m_keys.size()) {
524  getKeyTypes();
525  if (m_type.size() != m_keys.size()) {
526  m_Error += "key size does not correspond to table definition";
527  ret = false;
528  }
529  }
530  return ret;
531 }
std::string m_className
Definition: LMFUnique.h:98
std::vector< std::string > m_type
Definition: LMFDat.h:147
void getKeyTypes()
Definition: LMFDat.cc:479
std::string m_Error
Definition: LMFDat.h:154
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
virtual std::string getTableName() const
Definition: LMFDat.h:49
void LMFDat::dump ( void  ) const
virtual

Reimplemented from LMFUnique.

Definition at line 62 of file LMFDat.cc.

References m_max.

Referenced by dump(), LMFCorrCoefDat::fetch(), and writeDB().

62  {
63  dump(0, m_max);
64 }
void dump() const
Definition: LMFDat.cc:62
int m_max
Definition: LMFDat.h:146
void LMFDat::dump ( int  n) const
virtual

Reimplemented from LMFUnique.

Definition at line 66 of file LMFDat.cc.

References dump(), and m_max.

66  {
67  dump(n, m_max);
68 }
void dump() const
Definition: LMFDat.cc:62
int m_max
Definition: LMFDat.h:146
void LMFDat::dump ( int  n,
int  max 
) const
virtual

Definition at line 70 of file LMFDat.cc.

References trackerHits::c, gather_cfg::cout, LMFUnique::dump(), end, getReverseMap(), j, m_data, L1TEmulatorMonitor_cff::p, submit::rm, asciidump::s, and x.

70  {
72  int s = m_data.size();
73  cout << "Stored data: " << s << endl;
74  if (max >= 0) {
75  std::map<int, std::vector<float> >::const_iterator p = m_data.begin();
76  std::map<int, std::vector<float> >::const_iterator end = m_data.end();
77  int c = 0;
78  std::map<unsigned int, std::string> rm = getReverseMap();
79  while ((p != end) && (c < max)) {
80  int id = p->first;
81  std::vector<float> x = p->second;
82  cout << c << " -------------------------------------------" << endl;
83  cout << " ID: " << id << endl;
84  for (unsigned int j = 0; j < x.size(); j++) {
85  if (j % 4 == 0) {
86  cout << endl << " ";
87  }
88  cout << rm[j] << ":" << x[j] << "\t";
89  }
90  cout << endl;
91  p++;
92  c++;
93  }
94  }
95 }
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:51
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
virtual void dump() const
Definition: LMFUnique.cc:106
const T & max(const T &a, const T &b)
string rm
Definition: submit.py:76
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
Definition: DDAxes.h:10
void LMFDat::fetch ( )
throw (std::runtime_error
)

Definition at line 206 of file LMFDat.cc.

Referenced by LMFCorrCoefDat::fetch().

208 {
209  fetch(0);
210 }
void fetch()
Definition: LMFDat.cc:206
void LMFDat::fetch ( int  logic_id)
throw (std::runtime_error
)

Definition at line 212 of file LMFDat.cc.

References NULL.

214 {
215  fetch(logic_id, NULL, 0);
216 }
#define NULL
Definition: scimark2.h:8
void fetch()
Definition: LMFDat.cc:206
void LMFDat::fetch ( int  logic_id,
const Tm tm 
)
throw (std::runtime_error
)

Definition at line 218 of file LMFDat.cc.

220 {
221  fetch(logic_id, &tm, 1);
222 }
void fetch()
Definition: LMFDat.cc:206
void LMFDat::fetch ( int  logic_id,
const Tm timestamp,
int  dir 
)
throw (std::runtime_error
)

Definition at line 224 of file LMFDat.cc.

References CastorDataFrameFilter_impl::check(), prof2calltree::count, gather_cfg::cout, i, NULL, convertSQLiteXML::ok, cond::timestamp, and x.

226 {
227  bool ok = check();
228  if ((timestamp == NULL) && (getLMFRunIOVID() == 0)) {
229  throw(std::runtime_error(m_className + "::fetch: Cannot fetch data with "
230  "timestamp = 0 and LMFRunIOV = 0"));
231  }
232  if (ok && isValid()) {
233  if (m_debug) {
234  std::cout << "[LMFDat] This object is valid..." << std::endl;
235  }
236  try {
237  Statement * stmt = m_conn->createStatement();
238  std::string sql = buildSelectSql(logic_id, direction);
239  if (m_debug) {
240  std::cout << "[LMFDat] Executing query " << std::endl;
241  std::cout << " " << sql << std::endl << std::flush;
242  }
243  if (logic_id == 0) {
244  // get data for all crystals with a given timestamp
245  stmt->setPrefetchRowCount(131072);
246  }
247  stmt->setSQL(sql);
248  int count = 1;
249  if (logic_id > 0) {
250  if (timestamp != NULL) {
251  stmt->setString(count, timestamp->str());
252  count++;
253  }
254  stmt->setInt(count, logic_id);
255  }
256  ResultSet *rset = stmt->executeQuery();
257  std::vector<float> x;
258  int nData = m_keys.size();
259  x.reserve(nData);
260  while (rset->next()) {
261  for (int i = 0; i < nData; i++) {
262  x.push_back(rset->getFloat(i + 3));
263  }
264  int id = rset->getInt(2);
265  if (timestamp != NULL) {
266  setInt(foreignKeyName(), rset->getInt(1));
267  }
268  this->setData(id, x);
269  x.clear();
270  }
271  stmt->setPrefetchRowCount(0);
272  m_conn->terminateStatement(stmt);
273  }
274  catch (oracle::occi::SQLException &e) {
275  throw(std::runtime_error(m_className + "::fetch: " + e.getMessage()));
276  }
277  m_ID = m_data.size();
278  }
279 }
std::string m_className
Definition: LMFUnique.h:98
int i
Definition: DBlmapReader.cc:9
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
LMFDat & setData(int logic_id, const std::vector< float > &data)
Definition: LMFDat.h:55
bool check()
Definition: LMFDat.cc:508
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
virtual bool isValid()
Definition: LMFDat.cc:281
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
int getLMFRunIOVID()
Definition: LMFDat.cc:29
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
std::string str() const
Definition: Tm.cc:82
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
tuple cout
Definition: gather_cfg.py:41
char m_debug
Definition: LMFUnique.h:99
std::string buildSelectSql(int logic_id=0, int direction=0)
Definition: LMFDat.cc:117
Definition: DDAxes.h:10
void LMFDat::fetch ( const EcalLogicID id,
const Tm tm 
)
throw (std::runtime_error
)

Definition at line 193 of file LMFDat.cc.

195 {
196  fetch(id.getLogicID(), &tm, 1);
197 }
void fetch()
Definition: LMFDat.cc:206
void LMFDat::fetch ( const EcalLogicID id,
const Tm tm,
int  dir 
)
throw (std::runtime_error
)

Definition at line 199 of file LMFDat.cc.

201 {
202  setInt(foreignKeyName(), 0); /* set the LMF_IOV_ID to undefined */
203  fetch(id.getLogicID(), &tm, direction);
204 }
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
void fetch()
Definition: LMFDat.cc:206
void LMFDat::fetch ( const EcalLogicID id)
throw (std::runtime_error
)

Definition at line 187 of file LMFDat.cc.

189 {
190  fetch(id.getLogicID());
191 }
void fetch()
Definition: LMFDat.cc:206
std::map< int, std::vector< float > > LMFDat::fetchData ( )
throw (std::runtime_error
)

Definition at line 294 of file LMFDat.cc.

References gather_cfg::cout, getIovIdFieldName(), getLMFRunIOVID(), getTableName(), i, LMFUnique::m_className, IDBObject::m_conn, m_data, LMFUnique::m_debug, and asciidump::s.

Referenced by writeDB().

296 {
297  // see if any of the data is already in the database
298  std::map<int, std::vector<float> > s = m_data;
299  std::string sql = "SELECT LOGIC_ID FROM " + getTableName() + " WHERE "
300  + getIovIdFieldName() + " = :1";
301  if (m_debug) {
302  cout << m_className << ":: candidate data items to be written = "
303  << s.size() << endl;
304  cout << m_className << " Executing " << sql;
305  cout << " where " << getIovIdFieldName() << " = "
306  << getLMFRunIOVID() << endl;
307  }
308  try {
309  Statement* stmt = m_conn->createStatement();
310  stmt->setSQL(sql);
311  stmt->setInt(1, getLMFRunIOVID());
312  stmt->setPrefetchRowCount(131072);
313  ResultSet* rset = stmt->executeQuery();
314  std::map<int, std::vector<float> >::iterator i = s.end();
315  std::map<int, std::vector<float> >::iterator e = s.end();
316  while (rset->next()) {
317  if (m_debug) {
318  cout << m_className << ":: checking " << rset->getInt(1) << endl
319  << std::flush;
320  }
321  i = s.find(rset->getInt(1));
322  if (i != e) {
323  s.erase(i);
324  }
325  }
326  stmt->setPrefetchRowCount(0);
327  m_conn->terminateStatement(stmt);
328  }
329  catch (oracle::occi::SQLException &e) {
330  throw(std::runtime_error(m_className + "::fetchData: "+e.getMessage()));
331  }
332  if (m_debug) {
333  cout << m_className << ":: data items to write = "
334  << s.size() << endl;
335  }
336  return s;
337 }
std::string m_className
Definition: LMFUnique.h:98
int i
Definition: DBlmapReader.cc:9
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
int getLMFRunIOVID()
Definition: LMFDat.cc:29
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:113
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41
virtual std::string getTableName() const
Definition: LMFDat.h:49
char m_debug
Definition: LMFUnique.h:99
string s
Definition: asciidump.py:422
std::string LMFDat::foreignKeyName ( ) const
virtual

Reimplemented in LMFCorrCoefDatComponent.

Definition at line 25 of file LMFDat.cc.

Referenced by getLMFRunIOV(), getLMFRunIOVID(), isValid(), setLMFRunIOV(), and writeDB().

25  {
26  return "lmfRunIOV";
27 }
std::vector< float > LMFDat::getData ( int  id)

Definition at line 535 of file LMFDat.cc.

References m_data, and runTheMatrix::ret.

535  {
536  std::vector<float> ret;
537  if (m_data.find(id) != m_data.end()) {
538  ret = m_data[id];
539  }
540  return ret;
541 }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
std::vector< float > LMFDat::getData ( const EcalLogicID id)

Definition at line 547 of file LMFDat.cc.

References getData().

547  {
548  return getData(id.getLogicID());
549 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
bool LMFDat::getData ( int  id,
std::vector< float > &  ret 
)

Definition at line 553 of file LMFDat.cc.

References m_data.

553  {
554  bool retval = false;
555  if (m_data.find(id) != m_data.end()) {
556  ret= m_data[id];
557  retval = true;
558  }
559  return retval;
560 }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
bool LMFDat::getData ( const EcalLogicID id,
std::vector< float > &  ret 
)

Definition at line 562 of file LMFDat.cc.

References getData().

562  {
563  return getData(id.getLogicID(), ret);
564 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
std::map< int, std::vector< float > > LMFDat::getData ( void  )

Definition at line 568 of file LMFDat.cc.

References m_data.

Referenced by LMFPrimDat::getAlpha(), LMFPrimDat::getAPDoverAM3(), LMFPrimDat::getAPDoverAMean(), LMFPrimDat::getAPDoverARMS(), LMFPrimDat::getAPDoverBM3(), LMFPrimDat::getAPDoverBMean(), LMFPrimDat::getAPDoverBRMS(), LMFPrimDat::getAPDoverPnM3(), LMFPrimDat::getAPDoverPnMean(), LMFPrimDat::getAPDoverPnRMS(), LMFPrimDat::getBeta(), LMFTestPulseConfigDat::getDACMGPA(), getData(), LMFClsDat::getEFlag(), LMFClsDat::getENorm(), LMFRunDat::getEvents(), LMFLaserPulseDat::getFitMethod(), LMFCorrCoefDatComponent::getFlag(), LMFClsDat::getFlag(), LMFPnPrimDat::getFlag(), LMFPrimDat::getFlag(), LMFClsDat::getLMFRefRunIOVID(), LMFLaserConfigDat::getLSRAttenuator(), LMFLaserConfigDat::getLSRCURRENT(), LMFLaserConfigDat::getLSRDelay1(), LMFLaserConfigDat::getLSRDelay2(), LMFLaserConfigDat::getLSRPower(), LMFPnPrimDat::getM3(), LMFPrimDat::getM3(), LMFPnPrimDat::getMean(), LMFClsDat::getMean(), LMFPrimDat::getMean(), LMFLaserPulseDat::getMTQAmplification(), LMFLaserPulseDat::getMTQFW20(), LMFLaserPulseDat::getMTQFW80(), LMFLaserPulseDat::getMTQFWHM(), LMFLaserPulseDat::getMTQRise(), LMFLaserPulseDat::getMTQSliding(), LMFLaserPulseDat::getMTQTime(), LMFClsDat::getNevt(), LMFClsDat::getNorm(), LMFCorrCoefDatComponent::getParameterErrors(), LMFCorrCoefDatComponent::getParameters(), LMFPnPrimDat::getPNAoverBM3(), LMFPnPrimDat::getPNAoverBMean(), LMFPnPrimDat::getPNAoverBRMS(), LMFTestPulseConfigDat::getPNGain(), LMFLaserConfigDat::getPNGain(), LMFTestPulseConfigDat::getPNVinj(), LMFRunDat::getQualityFlag(), LMFPnPrimDat::getRMS(), LMFClsDat::getRMS(), LMFPrimDat::getRMS(), LMFCorrCoefDatComponent::getSeqID(), LMFCorrCoefDatComponent::getSequence(), LMFPnPrimDat::getShapeCor(), LMFPrimDat::getShapeCorr(), LMFTestPulseConfigDat::getVFEGain(), LMFLaserConfigDat::getVFEGain(), LMFColoredTable::getVmax(), LMFColoredTable::getVmin(), LMFLaserConfigDat::getWavelength(), and operator[]().

568  {
569  return m_data;
570 }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
float LMFDat::getData ( int  id,
unsigned int  k 
)

Definition at line 574 of file LMFDat.cc.

References gen::k, and m_data.

574  {
575  return m_data[id][k];
576 }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
int k[5][pyjets_maxn]
float LMFDat::getData ( const EcalLogicID id,
unsigned int  k 
)

Definition at line 578 of file LMFDat.cc.

References getData().

578  {
579  return getData(id.getLogicID(), k);
580 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
int k[5][pyjets_maxn]
float LMFDat::getData ( const EcalLogicID id,
const std::string &  key 
)

Definition at line 582 of file LMFDat.cc.

References getData(), and m_keys.

582  {
583  return getData(id.getLogicID(), m_keys[key]);
584 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
list key
Definition: combine.py:13
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
float LMFDat::getData ( int  id,
const std::string &  key 
)

Definition at line 586 of file LMFDat.cc.

References getData(), and m_keys.

586  {
587  return getData(id, m_keys[key]);
588 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
list key
Definition: combine.py:13
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
bool LMFDat::getData ( int  id,
unsigned int  k,
float &  ret 
)

Definition at line 592 of file LMFDat.cc.

References getData(), gen::k, and v.

592  {
593  bool retval = false;
594  std::vector<float> v;
595  retval = getData(id, v);
596  if ((retval) && (v.size() > k)) {
597  ret= v[k];
598  retval = true;
599  } else {
600  retval = false;
601  }
602  return retval;
603 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
int k[5][pyjets_maxn]
mathSSE::Vec4< T > v
bool LMFDat::getData ( const EcalLogicID id,
unsigned int  k,
float &  ret 
)

Definition at line 605 of file LMFDat.cc.

References getData().

605  {
606  return getData(id.getLogicID(), k, ret);
607 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
int k[5][pyjets_maxn]
bool LMFDat::getData ( int  id,
const std::string &  key,
float &  ret 
)

Definition at line 609 of file LMFDat.cc.

References getData(), and m_keys.

609  {
610  bool retval = false;
611  if (m_keys.find(key) != m_keys.end()) {
612  retval = getData(id, m_keys[key], ret);
613  }
614  return retval;
615 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
list key
Definition: combine.py:13
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
bool LMFDat::getData ( const EcalLogicID id,
const std::string &  key,
float &  ret 
)

Definition at line 617 of file LMFDat.cc.

References getData().

618 {
619  return getData(id.getLogicID(), key, ret);
620 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
list key
Definition: combine.py:13
std::string LMFDat::getIovIdFieldName ( ) const
virtual

Reimplemented in LMFCorrCoefDatComponent.

Definition at line 113 of file LMFDat.cc.

Referenced by buildSelectSql(), fetchData(), and getKeyTypes().

113  {
114  return "LMF_IOV_ID";
115 }
std::list<std::string> LMFDat::getKeyList ( )
inline

Definition at line 113 of file LMFDat.h.

References i, prof2calltree::l, and m_keys.

113  {
114  std::list<std::string> l;
115  std::map<std::string, unsigned int>::const_iterator i = m_keys.begin();
116  std::map<std::string, unsigned int>::const_iterator e = m_keys.end();
117  while (i != e) {
118  l.push_back(i->first);
119  i++;
120  }
121  return l;
122  }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
std::map<std::string, unsigned int> LMFDat::getKeys ( )
inline

Definition at line 110 of file LMFDat.h.

References m_keys.

110  {
111  return m_keys;
112  }
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
void LMFDat::getKeyTypes ( )
throw (std::runtime_error
)
protected

Definition at line 479 of file LMFDat.cc.

References getIovIdFieldName(), getTableName(), i, LMFUnique::m_className, IDBObject::m_conn, m_keys, m_type, mergeVDriftHistosByStation::name, and matplotRender::t.

Referenced by check().

481 {
482  m_type.reserve(m_keys.size());
483  for (unsigned int i = 0; i < m_keys.size(); i++) {
484  m_type.push_back("");
485  }
486  // get the description of the table
487  std::string sql = "";
488  try {
489  Statement *stmt = m_conn->createStatement();
490  sql = "SELECT COLUMN_NAME, DATA_TYPE FROM "
491  "USER_TAB_COLS WHERE TABLE_NAME = '" + getTableName() + "' "
492  "AND COLUMN_NAME != '" + getIovIdFieldName() + "' AND COLUMN_NAME != "
493  "'LOGIC_ID'";
494  stmt->setSQL(sql);
495  ResultSet *rset = stmt->executeQuery();
496  while (rset->next()) {
497  std::string name = rset->getString(1);
498  std::string t = rset->getString(2);
499  m_type[m_keys[name]] = t;
500  }
501  m_conn->terminateStatement(stmt);
502  } catch (oracle::occi::SQLException &e) {
503  throw(std::runtime_error(m_className + "::getKeyTypes: " + e.getMessage() +
504  " [" + sql + "]"));
505  }
506 }
std::string m_className
Definition: LMFUnique.h:98
int i
Definition: DBlmapReader.cc:9
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::vector< std::string > m_type
Definition: LMFDat.h:147
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:113
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
virtual std::string getTableName() const
Definition: LMFDat.h:49
LMFRunIOV LMFDat::getLMFRunIOV ( ) const
inline

Definition at line 36 of file LMFDat.h.

References foreignKeyName(), LMFUnique::getInt(), IDBObject::m_conn, IDBObject::m_env, and LMFUnique::setByID().

Referenced by getSubrunStart().

36  {
37  LMFRunIOV runiov(m_env, m_conn);
38  runiov.setByID(getInt(foreignKeyName()));
39  return runiov;
40  }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:197
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
int LMFDat::getLMFRunIOVID ( )

Definition at line 29 of file LMFDat.cc.

References LMFUnique::fetchID(), foreignKeyName(), LMFUnique::getInt(), i, o2o::iov, LMFUnique::m_foreignKeys, NULL, and LMFUnique::setInt().

Referenced by buildSelectSql(), and fetchData().

29  {
30  int id = getInt(foreignKeyName());
31  if (id == 0) {
32  // try to get it from the list of foreign keys
33  std::map<std::string, LMFUnique*>::iterator i =
35  if (i != m_foreignKeys.end()) {
36  LMFRunIOV *iov = (LMFRunIOV*)(i->second);
37  if (iov != NULL) {
38  id = iov->fetchID();
39  setInt(foreignKeyName(), id);
40  }
41  }
42  }
43  return id;
44 }
int i
Definition: DBlmapReader.cc:9
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
#define NULL
Definition: scimark2.h:8
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:197
int fetchID()
Definition: LMFUnique.cc:207
tuple iov
Definition: o2o.py:307
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:105
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
std::list<int> LMFDat::getLogicIds ( )
inline

Definition at line 99 of file LMFDat.h.

References i, prof2calltree::l, and m_data.

99  {
100  std::list<int> l;
101  std::map<int, std::vector<float> >::const_iterator i = m_data.begin();
102  std::map<int, std::vector<float> >::const_iterator e = m_data.end();
103  while (i != e) {
104  l.push_back(i->first);
105  i++;
106  }
107  return l;
108  }
int i
Definition: DBlmapReader.cc:9
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
void LMFDat::getNeighbour ( LMFDat dat,
int  which 
)
throw (std::runtime_error
)
protected

Definition at line 169 of file LMFDat.cc.

References hcal_timing_source_file_cfg::dump.

171 {
172  // there should be just one record in this case
173  if (m_data.size() == 1) {
174  dat->setConnection(this->getEnv(), this->getConn());
175  int logic_id = m_data.begin()->first;
176  Tm lastMeasuredOn = getSubrunStart();
177  lastMeasuredOn += which;
178  dat->fetch(logic_id, &lastMeasuredOn, which);
179  dat->setMaxDataToDump(m_max);
180  } else {
181  dump();
182  throw(std::runtime_error(m_className + "::getPrevious: Too many LOGIC_IDs in "
183  "this object"));
184  }
185 }
std::string m_className
Definition: LMFUnique.h:98
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
void dump() const
Definition: LMFDat.cc:62
int m_max
Definition: LMFDat.h:146
Tm getSubrunStart() const
Definition: LMFDat.h:42
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:46
oracle::occi::Connection * getConn() const
Definition: IDBObject.h:32
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
oracle::occi::Environment * getEnv() const
Definition: IDBObject.h:29
Definition: Tm.h:14
void fetch()
Definition: LMFDat.cc:206
void LMFDat::getNext ( LMFDat dat)
throw (std::runtime_error
)

Definition at line 163 of file LMFDat.cc.

165 {
166  getNeighbour(dat, +1);
167 }
void getNeighbour(LMFDat *dat, int which)
Definition: LMFDat.cc:169
void LMFDat::getPrevious ( LMFDat dat)
throw (std::runtime_error
)

Definition at line 157 of file LMFDat.cc.

159 {
160  getNeighbour(dat, -1);
161 }
void getNeighbour(LMFDat *dat, int which)
Definition: LMFDat.cc:169
std::map< unsigned int, std::string > LMFDat::getReverseMap ( ) const

Definition at line 51 of file LMFDat.cc.

References i, m, and m_keys.

Referenced by dump().

51  {
52  std::map<unsigned int, std::string> m;
53  std::map<std::string, unsigned int>::const_iterator i = m_keys.begin();
54  std::map<std::string, unsigned int>::const_iterator e = m_keys.end();
55  while (i != e) {
56  m[i->second] = i->first;
57  i++;
58  }
59  return m;
60 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
Tm LMFDat::getSubrunStart ( ) const
inline

Definition at line 42 of file LMFDat.h.

References getLMFRunIOV(), and LMFRunIOV::getSubRunStart().

42  {
43  return getLMFRunIOV().getSubRunStart();
44  }
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:161
LMFRunIOV getLMFRunIOV() const
Definition: LMFDat.h:36
virtual std::string LMFDat::getTableName ( ) const
inlinevirtual

Reimplemented in LMFCorrCoefDatComponent, LMFClsDat, LMFPnPrimDat, LMFPrimDat, LMFLaserPulseDat, and LMFColoredTable.

Definition at line 49 of file LMFDat.h.

References m_tableName.

Referenced by buildInsertSql(), buildSelectSql(), check(), fetchData(), and getKeyTypes().

49  {
50  return m_tableName;
51  }
std::string m_tableName
Definition: LMFDat.h:153
bool LMFDat::isValid ( void  )
virtual

Reimplemented in LMFPrimDat, LMFClsDat, LMFPnPrimDat, and LMFLaserPulseDat.

Definition at line 281 of file LMFDat.cc.

References gather_cfg::cout, foreignKeyName(), LMFUnique::m_className, LMFUnique::m_debug, m_Error, LMFUnique::m_foreignKeys, and runTheMatrix::ret.

Referenced by LMFLaserPulseDat::isValid(), and writeDB().

281  {
282  bool ret = true;
283  if (m_foreignKeys.find(foreignKeyName()) == m_foreignKeys.end()) {
284  ret = false;
285  m_Error += " Can't find lmfRunIOV within foreign keys.";
286  if (m_debug) {
287  cout << m_className << ": Foreign keys map size: " << m_foreignKeys.size()
288  << endl;
289  }
290  }
291  return ret;
292 }
std::string m_className
Definition: LMFUnique.h:98
std::string m_Error
Definition: LMFDat.h:154
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:105
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
tuple cout
Definition: gather_cfg.py:41
char m_debug
Definition: LMFUnique.h:99
std::vector< float > LMFDat::operator[] ( int  id)

Definition at line 543 of file LMFDat.cc.

References getData().

543  {
544  return getData(id);
545 }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:568
LMFDat& LMFDat::setData ( int  logic_id,
const std::vector< float > &  data 
)
inline

Definition at line 55 of file LMFDat.h.

References runTheMatrix::data, and m_data.

Referenced by LMFRunDat::Data(), LMFPrimDat::setAlpha(), LMFPrimDat::setAPDoverAM3(), LMFPrimDat::setAPDoverAMean(), LMFPrimDat::setAPDoverARMS(), LMFPrimDat::setAPDoverBM3(), LMFPrimDat::setAPDoverBMean(), LMFPrimDat::setAPDoverBRMS(), LMFPrimDat::setAPDoverPnM3(), LMFPrimDat::setAPDoverPnMean(), LMFPrimDat::setAPDoverPnRMS(), LMFPrimDat::setBeta(), LMFTestPulseConfigDat::setDACMGPA(), LMFRunDat::setData(), LMFTestPulseConfigDat::setData(), LMFLaserConfigDat::setData(), LMFClsDat::setEFlag(), LMFClsDat::setENorm(), LMFRunDat::setEvents(), LMFLaserPulseDat::setFitMethod(), LMFCorrCoefDatComponent::setFlag(), LMFPrimDat::setFlag(), LMFPnPrimDat::setFlag(), LMFClsDat::setFlag(), LMFClsDat::setLMFRefRunIOVID(), LMFLaserConfigDat::setLSRAttenuator(), LMFLaserConfigDat::setLSRCurrent(), LMFLaserConfigDat::setLSRDelay1(), LMFLaserConfigDat::setLSRDelay2(), LMFLaserConfigDat::setLSRPower(), LMFPnPrimDat::setM3(), LMFPrimDat::setM3(), LMFPnPrimDat::setMean(), LMFPrimDat::setMean(), LMFClsDat::setMean(), LMFLaserPulseDat::setMTQAmplification(), LMFLaserPulseDat::setMTQFW20(), LMFLaserPulseDat::setMTQFW80(), LMFLaserPulseDat::setMTQFWHM(), LMFLaserPulseDat::setMTQRise(), LMFLaserPulseDat::setMTQSliding(), LMFLaserPulseDat::setMTQTime(), LMFClsDat::setNevt(), LMFClsDat::setNorm(), LMFCorrCoefDatComponent::setP123(), LMFCorrCoefDatComponent::setP123Errors(), LMFPnPrimDat::setPNAoverBM3(), LMFPnPrimDat::setPNAoverBMean(), LMFPnPrimDat::setPNAoverBRMS(), LMFTestPulseConfigDat::setPNGain(), LMFLaserConfigDat::setPNGain(), LMFTestPulseConfigDat::setPNVinj(), LMFRunDat::setQualityFlag(), LMFPnPrimDat::setRMS(), LMFPrimDat::setRMS(), LMFClsDat::setRMS(), LMFCorrCoefDatComponent::setSequence(), LMFPnPrimDat::setShapeCorr(), LMFPrimDat::setShapeCorr(), LMFColoredTable::setVersions(), LMFTestPulseConfigDat::setVFEGain(), LMFLaserConfigDat::setVFEGain(), LMFColoredTable::setVmax(), LMFColoredTable::setVmin(), and LMFLaserConfigDat::setWavelength().

55  {
56  m_data[logic_id] = data;
57  return *this;
58  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
LMFDat& LMFDat::setData ( const EcalLogicID logic_id,
const std::vector< float > &  data 
)
inline

Definition at line 59 of file LMFDat.h.

References runTheMatrix::data, EcalLogicID::getLogicID(), and m_data.

60  {
61  m_data[logic_id.getLogicID()] = data;
62  return *this;
63  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
int getLogicID() const
Definition: EcalLogicID.cc:42
LMFDat& LMFDat::setData ( const EcalLogicID logic_id,
const std::string &  key,
float  v 
)
inline

Definition at line 64 of file LMFDat.h.

References EcalLogicID::getLogicID(), combine::key, m_data, m_keys, and v.

65  {
66  int id = logic_id.getLogicID();
67  m_data[id].resize(m_keys.size());
68  m_data[id][m_keys[key]] = v;
69  return *this;
70  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
int getLogicID() const
Definition: EcalLogicID.cc:42
list key
Definition: combine.py:13
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
mathSSE::Vec4< T > v
LMFDat& LMFDat::setLMFRunIOV ( const LMFRunIOV iov)
inline

Definition at line 31 of file LMFDat.h.

References LMFUnique::attach(), foreignKeyName(), LMFUnique::getID(), and LMFUnique::setInt().

31  {
32  setInt(foreignKeyName(), iov.getID());
33  attach(foreignKeyName(), (LMFUnique*)&iov);
34  return *this;
35  }
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
int getID() const
Definition: LMFUnique.h:51
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:50
LMFDat & LMFDat::setMaxDataToDump ( int  n)

Definition at line 46 of file LMFDat.cc.

References m_max, and n.

Referenced by writeDB().

46  {
47  m_max = n;
48  return *this;
49 }
int m_max
Definition: LMFDat.h:146
int LMFDat::size ( void  ) const
inline

Definition at line 71 of file LMFDat.h.

References m_data.

Referenced by writeDB().

71 { return m_data.size(); }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:150
int LMFDat::writeDB ( )
throw (std::runtime_error
)
protectedvirtual

Reimplemented from LMFUnique.

Definition at line 339 of file LMFDat.cc.

References b, buildInsertSql(), trackerHits::c, check(), IDBObject::checkConnection(), gather_cfg::cout, LMFUnique::debug(), dump(), fetchData(), foreignKeyName(), LMFUnique::getID(), i, isValid(), gen::k, LMFUnique::m_className, IDBObject::m_conn, LMFUnique::m_debug, m_Error, LMFUnique::m_foreignKeys, m_keys, m_max, m_type, convertSQLiteXML::ok, runTheMatrix::ret, setMaxDataToDump(), size(), LMFUnique::writeForeignKeys(), and x.

Referenced by LMFCorrCoefDatComponent::writeDB(), and LMFColoredTable::writeDB().

341 {
342  // first of all check if data already present
343  if (m_debug) {
344  cout << m_className << ": Writing foreign keys" << endl;
345  }
347  if (m_debug) {
348  cout << m_className << ": Foreign keys written" << endl;
349  }
350  // write data on the database
351  int ret = 0;
352  std::map<int, std::vector<float> > data2write = fetchData();
353  if (data2write.size() > 0) {
354  this->checkConnection();
355  bool ok = check();
356  // write
357  if (ok && isValid()) {
358  std::list<dvoid *> bufPointers;
359  int nParameters = m_keys.size();
360  int nData = data2write.size();
361  if (m_debug) {
362  cout << m_className << ": # data items = " << nData << endl;
363  cout << m_className << ": # parameters = " << nParameters << endl;
364  }
365  int * iovid_vec = new int[nData];
366  int * logicid_vec = new int[nData];
367  int *intArray = new int[nData];
368  float *floatArray = new float[nData];
369  ub2 * intSize = new ub2[nData];
370  ub2 * floatSize = new ub2[nData];
371  size_t intTotalSize = sizeof(int)*nData;
372  size_t floatTotalSize = sizeof(float)*nData;
373  try {
374  Statement * stmt = m_conn->createStatement();
375  std::string sql = buildInsertSql();
376  stmt->setSQL(sql);
377  // build the array of the size of each column
378  for (int i = 0; i < nData; i++) {
379  intSize[i] = sizeof(int);
380  floatSize[i] = sizeof(int);
381  }
382  // build the data array for first column: the same run iov id
384  int iov_id = runiov->getID();
385  std::map<int, std::vector<float> >::const_iterator b = data2write.begin();
386  std::map<int, std::vector<float> >::const_iterator e = data2write.end();
387  for (int i = 0; i < nData; i++) {
388  iovid_vec[i] = iov_id;
389  }
390  stmt->setDataBuffer(1, (dvoid*)iovid_vec, oracle::occi::OCCIINT,
391  sizeof(iovid_vec[0]), intSize);
392  // build the data array for second column: the logic ids
393  int c = 0;
394  while (b != e) {
395  int id = b->first;
396  logicid_vec[c++] = id;
397  b++;
398  }
399  stmt->setDataBuffer(2, (dvoid*)logicid_vec, oracle::occi::OCCIINT,
400  sizeof(logicid_vec[0]), intSize);
401  // for each column build the data array
402  oracle::occi::Type type = oracle::occi::OCCIFLOAT;
403  for (int i = 0; i < nParameters; i++) {
404  b = data2write.begin();
405  // loop on all logic ids
406  c = 0;
407  while (b != e) {
408  std::vector<float> x = b->second;
409  if (m_type[i] == "INT") {
410  intArray[c] = (int)rint(x[i]);
411  } else if ((m_type[i] == "FLOAT") || (m_type[i] == "NUMBER")) {
412  floatArray[c] = x[i];
413  } else {
414  throw(std::runtime_error("ERROR: LMFDat::writeDB: unsupported type"));
415  }
416  c++;
417  b++;
418  }
419  // copy data into a "permanent" buffer
420  dvoid * buffer;
421  type = oracle::occi::OCCIINT;
422  ub2 *sizeArray = intSize;
423  int size = sizeof(intArray[0]);
424  if ((m_type[i] == "FLOAT") || (m_type[i] == "NUMBER")) {
425  buffer = (dvoid *)malloc(sizeof(float)*nData);
426  memcpy(buffer, floatArray, floatTotalSize);
427  type = oracle::occi::OCCIFLOAT;
428  sizeArray = floatSize;
429  size = sizeof(floatArray[0]);
430  } else {
431  buffer = (dvoid *)malloc(sizeof(int)*nData);
432  memcpy(buffer, intArray, intTotalSize);
433  }
434  bufPointers.push_back(buffer);
435  if (m_debug) {
436  for (int k = 0; ((k < nData) && (k < m_max)); k++) {
437  cout << m_className << ": === Index=== " << k << endl;
438  cout << m_className << ": RUN_IOV_ID = " << iovid_vec[k] << endl;
439  cout << m_className << ": LOGIC_ID = " << logicid_vec[k] << endl;
440  cout << m_className << ": FIELD " << i << ": "
441  << ((float *)(buffer))[k] << endl;
442  }
443  }
444  stmt->setDataBuffer(i + 3, buffer, type, size, sizeArray);
445  }
446  stmt->executeArrayUpdate(nData);
447  delete [] intArray;
448  delete [] floatArray;
449  delete [] intSize;
450  delete [] floatSize;
451  delete [] logicid_vec;
452  delete [] iovid_vec;
453  std::list<dvoid *>::const_iterator bi = bufPointers.begin();
454  std::list<dvoid *>::const_iterator be = bufPointers.end();
455  while (bi != be) {
456  free(*bi);
457  bi++;
458  }
459  m_conn->commit();
460  m_conn->terminateStatement(stmt);
461  ret = nData;
462  } catch (oracle::occi::SQLException &e) {
463  debug();
464  setMaxDataToDump(nData);
465  dump();
466  m_conn->rollback();
467  throw(std::runtime_error(m_className + "::writeDB: " +
468  e.getMessage()));
469  }
470  } else {
471  cout << m_className << "::writeDB: Cannot write because " <<
472  m_Error << endl;
473  dump();
474  }
475  }
476  return ret;
477 }
std::map< int, std::vector< float > > fetchData()
Definition: LMFDat.cc:294
std::string m_className
Definition: LMFUnique.h:98
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getID() const
Definition: LMFUnique.h:51
std::string buildInsertSql()
Definition: LMFDat.cc:97
std::vector< std::string > m_type
Definition: LMFDat.h:147
int size() const
Definition: LMFDat.h:71
bool check()
Definition: LMFDat.cc:508
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
virtual int writeForeignKeys()
Definition: LMFUnique.cc:317
void dump() const
Definition: LMFDat.cc:62
virtual bool isValid()
Definition: LMFDat.cc:281
int m_max
Definition: LMFDat.h:146
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
std::string m_Error
Definition: LMFDat.h:154
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:105
int k[5][pyjets_maxn]
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:46
double b
Definition: hdecay.h:120
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
tuple cout
Definition: gather_cfg.py:41
char m_debug
Definition: LMFUnique.h:99
Definition: DDAxes.h:10
void debug()
Definition: LMFUnique.h:67
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 21 of file LMFDat.h.

Member Data Documentation

std::map<int, std::vector<float> > LMFDat::m_data
protected

Definition at line 150 of file LMFDat.h.

Referenced by dump(), fetchData(), getData(), getLogicIds(), setData(), size(), and LMFColoredTable::writeDB().

std::string LMFDat::m_Error
protected
std::map<std::string, unsigned int> LMFDat::m_keys
protected
int LMFDat::m_max
protected

Definition at line 146 of file LMFDat.h.

Referenced by dump(), LMFDat(), setMaxDataToDump(), and writeDB().

std::string LMFDat::m_tableName
protected
std::vector<std::string> LMFDat::m_type
protected