CMS 3D CMS Logo

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 override
 
void dump (int n) const override
 
virtual void dump (int n, int max) const
 
void fetch () noexcept(false)
 
void fetch (int logic_id) noexcept(false)
 
void fetch (int logic_id, const Tm &tm) noexcept(false)
 
void fetch (int logic_id, const Tm *timestamp, int dir) noexcept(false)
 
void fetch (const EcalLogicID &id, const Tm &tm) noexcept(false)
 
void fetch (const EcalLogicID &id, const Tm &tm, int dir) noexcept(false)
 
void fetch (const EcalLogicID &id) noexcept(false)
 
std::map< int, std::vector< float > > fetchData () noexcept(false)
 
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) noexcept(false)
 
void getPrevious (LMFDat *dat) noexcept(false)
 
std::map< unsigned int, std::string > getReverseMap () const
 
Tm getSubrunStart () const
 
virtual std::string getTableName () const
 
bool isValid () override
 
 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)
 
void setWhereClause (std::string w)
 
void setWhereClause (std::string w, const std::vector< std::string > &p)
 
int size () const
 
 ~LMFDat () override
 
- Public Member Functions inherited from LMFUnique
void attach (std::string name, LMFUnique *u)
 
void debug ()
 
virtual bool exists ()
 
virtual std::list< std::unique_ptr< LMFUnique > > fetchAll () const noexcept(false)
 
int fetchID () noexcept(false) override
 
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 (const Tm &t)
 
void setByID (int id) noexcept(false) override
 
LMFUniquesetInt (std::string key, int value)
 
LMFUniquesetString (std::string key, std::string value)
 
void startProfiling ()
 
void stopProfiling ()
 
 ~LMFUnique () override
 
- 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

void adjustParameters (int n, std::string &sql, Statement *stmt)
 
std::string buildInsertSql ()
 
std::string buildSelectSql (int logic_id=0, int direction=0)
 
bool check ()
 
void getKeyTypes () noexcept(false)
 
void getNeighbour (LMFDat *dat, int which) noexcept(false)
 
int writeDB () noexcept(false) override
 
- Protected Member Functions inherited from LMFUnique
virtual void getParameters (ResultSet *rset)
 
virtual void setClassName (std::string s)
 
virtual int writeForeignKeys () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

std::string _where
 
std::vector< std::string > _wherePars
 
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 18 of file LMFDat.h.

Constructor & Destructor Documentation

◆ LMFDat() [1/3]

LMFDat::LMFDat ( )

Definition at line 9 of file LMFDat.cc.

References _where, _wherePars, m_max, and m_tableName.

9  : LMFUnique() {
10  m_tableName = "";
11  m_max = -1;
12  _where = "";
13  _wherePars.clear();
14 }
std::vector< std::string > _wherePars
Definition: LMFDat.h:150
LMFUnique()
Definition: LMFUnique.h:27
int m_max
Definition: LMFDat.h:139
std::string _where
Definition: LMFDat.h:149
std::string m_tableName
Definition: LMFDat.h:146

◆ LMFDat() [2/3]

LMFDat::LMFDat ( EcalDBConnection c)

Definition at line 16 of file LMFDat.cc.

References _where, _wherePars, m_max, and m_tableName.

16  : LMFUnique(c) {
17  m_tableName = "";
18  m_max = -1;
19  _where = "";
20  _wherePars.clear();
21 }
std::vector< std::string > _wherePars
Definition: LMFDat.h:150
LMFUnique()
Definition: LMFUnique.h:27
int m_max
Definition: LMFDat.h:139
std::string _where
Definition: LMFDat.h:149
std::string m_tableName
Definition: LMFDat.h:146

◆ LMFDat() [3/3]

LMFDat::LMFDat ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 23 of file LMFDat.cc.

References _where, _wherePars, m_max, and m_tableName.

23  : LMFUnique(env, conn) {
24  m_tableName = "";
25  m_max = -1;
26  _where = "";
27  _wherePars.clear();
28 }
std::vector< std::string > _wherePars
Definition: LMFDat.h:150
LMFUnique()
Definition: LMFUnique.h:27
int m_max
Definition: LMFDat.h:139
conn
Definition: getInfo.py:9
std::string _where
Definition: LMFDat.h:149
std::string m_tableName
Definition: LMFDat.h:146

◆ ~LMFDat()

LMFDat::~LMFDat ( )
inlineoverride

Definition at line 25 of file LMFDat.h.

25 {}

Member Function Documentation

◆ adjustParameters()

void LMFDat::adjustParameters ( int  n,
std::string &  sql,
Statement stmt 
)
protected

Definition at line 207 of file LMFDat.cc.

References _wherePars, submitPVResolutionJobs::count, fileCollector::done, and dqmiodumpmetadata::n.

207  {
208  // adjust positional parameters and change them according to their
209  // decalred type
210  std::size_t nw = 0;
211  std::size_t n = sql.find(':');
212  for (int done = 1; done < count; done++) {
213  // skip already bound variables
214  n = sql.find(':', n + 1);
215  }
216  while (n != std::string::npos) {
217  char type = sql.at(n + 1);
218  if (type == 'S') {
219  stmt->setString(nw + count, _wherePars[nw]);
220  nw++;
221  } else if (type == 'F') {
222  stmt->setFloat(nw + count, atof(_wherePars[nw].c_str()));
223  nw++;
224  } else if (type == 'I') {
225  stmt->setInt(nw + count, atoi(_wherePars[nw].c_str()));
226  nw++;
227  }
228  n = sql.find(':', n + 1);
229  }
230 }
std::vector< std::string > _wherePars
Definition: LMFDat.h:150

◆ buildInsertSql()

std::string LMFDat::buildInsertSql ( )
protected

Definition at line 95 of file LMFDat.cc.

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

Referenced by writeDB().

95  {
96  // create the insert statement
97  std::stringstream sql;
98  sql << "INSERT INTO " + getTableName() + " VALUES (";
99  unsigned int nParameters = m_keys.size() + 2;
100  for (unsigned int i = 0; i < nParameters - 1; i++) {
101  sql << ":" << i + 1 << ", ";
102  }
103  sql << ":" << nParameters << ")";
104  std::string sqls = sql.str();
105  if (m_debug) {
106  cout << m_className << "::writeDB: " << sqls << endl;
107  }
108  return sqls;
109 }
std::string m_className
Definition: LMFUnique.h:99
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145
char m_debug
Definition: LMFUnique.h:100
virtual std::string getTableName() const
Definition: LMFDat.h:45

◆ buildSelectSql()

std::string LMFDat::buildSelectSql ( int  logic_id = 0,
int  direction = 0 
)
protected

Definition at line 128 of file LMFDat.cc.

References _where, submitPVResolutionJobs::count, gather_cfg::cout, getIovIdFieldName(), getLMFRunIOVID(), getTableName(), LMFUnique::m_className, LMFUnique::m_debug, findAndChange::op, eventshapeDQM_cfi::order, and AlCaHLTBitMon_QueryRunRegistry::string.

128  {
129  // create the insert statement
130  // if logic_id = 0 select all channels for a given iov_id
131  std::stringstream sql;
132  int count = 1;
133  if (getLMFRunIOVID() > 0) {
134  if (_where.length() > 0) {
135  // check if this is an expert query. If so, add a WHERE clause
136  _where = " AND " + _where;
137  }
138  // in this case we are looking for all data collected during the same
139  // IOV. There can be many logic_ids per IOV.
140  sql << "SELECT * FROM CMS_ECAL_LASER_COND." << getTableName() << " WHERE " << getIovIdFieldName() << " = "
141  << getLMFRunIOVID() << _where;
142  // the expert query must be specified each time the expert makes the query
143  // then empty it
144  _where = "";
145  } else {
146  // in this case we are looking for a specific logic_id whose
147  // data have been collected at a given time. There is only
148  // one record in this case.
149  std::string op = ">";
150  std::string order = "ASC";
151  if (direction < 0) {
152  op = "<";
153  order = "DESC";
154  }
155  sql << "SELECT * FROM (SELECT CMS_ECAL_LASER_COND." << getTableName() << ".* FROM CMS_ECAL_LASER_COND."
156  << getTableName() << " JOIN LMF_RUN_IOV ON "
157  << "LMF_RUN_IOV.LMF_IOV_ID = " << getTableName() << "." << getIovIdFieldName() << " "
158  << "WHERE SUBRUN_START " << op << "= TO_DATE(:" << count;
159  count++;
160  sql << ", 'YYYY-MM-DD HH24:MI:SS') ORDER BY SUBRUN_START " << order << ") WHERE ROWNUM <= 1";
161  }
162  if (logic_id > 0) {
163  sql << " AND LOGIC_ID = :" << count;
164  }
165  std::string sqls = sql.str();
166  if (m_debug) {
167  cout << m_className << "::buildSelectSqlDB: " << sqls << endl;
168  }
169  return sqls;
170 }
std::string m_className
Definition: LMFUnique.h:99
int getLMFRunIOVID()
Definition: LMFDat.cc:32
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:111
std::string _where
Definition: LMFDat.h:149
char m_debug
Definition: LMFUnique.h:100
virtual std::string getTableName() const
Definition: LMFDat.h:45

◆ check()

bool LMFDat::check ( void  )
protected

Definition at line 505 of file LMFDat.cc.

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

Referenced by writeDB().

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

◆ dump() [1/3]

void LMFDat::dump ( void  ) const
overridevirtual

Reimplemented from LMFUnique.

Definition at line 64 of file LMFDat.cc.

References m_max.

Referenced by dump(), and writeDB().

64 { dump(0, m_max); }
int m_max
Definition: LMFDat.h:139
void dump() const override
Definition: LMFDat.cc:64

◆ dump() [2/3]

void LMFDat::dump ( int  n) const
overridevirtual

Reimplemented from LMFUnique.

Definition at line 66 of file LMFDat.cc.

References dump(), m_max, and dqmiodumpmetadata::n.

66 { dump(n, m_max); }
int m_max
Definition: LMFDat.h:139
void dump() const override
Definition: LMFDat.cc:64

◆ dump() [3/3]

void LMFDat::dump ( int  n,
int  max 
) const
virtual

Definition at line 68 of file LMFDat.cc.

References HltBtagPostValidation_cff::c, gather_cfg::cout, LMFUnique::dump(), mps_fire::end, getReverseMap(), dqmiolumiharvest::j, m_data, SiStripPI::max, dqmiodumpmetadata::n, AlCaHLTBitMon_ParallelJobs::p, eostools::rm(), alignCSCRings::s, and x.

68  {
70  int s = m_data.size();
71  cout << "Stored data: " << s << endl;
72  if (max >= 0) {
73  std::map<int, std::vector<float> >::const_iterator p = m_data.begin();
74  std::map<int, std::vector<float> >::const_iterator end = m_data.end();
75  int c = 0;
76  std::map<unsigned int, std::string> rm = getReverseMap();
77  while ((p != end) && (c < max)) {
78  int id = p->first;
79  std::vector<float> x = p->second;
80  cout << c << " -------------------------------------------" << endl;
81  cout << " ID: " << id << endl;
82  for (unsigned int j = 0; j < x.size(); j++) {
83  if (j % 4 == 0) {
84  cout << endl << " ";
85  }
86  cout << rm[j] << ":" << x[j] << "\t";
87  }
88  cout << endl;
89  p++;
90  c++;
91  }
92  }
93 }
def rm(path, rec=False)
Definition: eostools.py:363
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
virtual void dump() const
Definition: LMFUnique.cc:104
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:53

◆ fetch() [1/7]

void LMFDat::fetch ( )
noexcept

Definition at line 201 of file LMFDat.cc.

201 { fetch(0); }
void fetch() noexcept(false)
Definition: LMFDat.cc:201

◆ fetch() [2/7]

void LMFDat::fetch ( int  logic_id)
noexcept

Definition at line 203 of file LMFDat.cc.

References cond::persistency::fetch().

203 { fetch(logic_id, nullptr, 0); }
void fetch() noexcept(false)
Definition: LMFDat.cc:201

◆ fetch() [3/7]

void LMFDat::fetch ( int  logic_id,
const Tm tm 
)
noexcept

Definition at line 205 of file LMFDat.cc.

References cond::persistency::fetch().

205 { fetch(logic_id, &tm, 1); }
void fetch() noexcept(false)
Definition: LMFDat.cc:201

◆ fetch() [4/7]

void LMFDat::fetch ( int  logic_id,
const Tm timestamp,
int  dir 
)
noexcept

Definition at line 232 of file LMFDat.cc.

References RPCNoise_example::check, submitPVResolutionJobs::count, gather_cfg::cout, MillePedeFileConverter_cfg::e, mps_fire::i, sistrip::SpyUtilities::isValid(), convertSQLiteXML::ok, AlCaHLTBitMon_QueryRunRegistry::string, cond::timestamp, and x.

232  {
233  bool ok = check();
234  if ((timestamp == nullptr) && (getLMFRunIOVID() == 0)) {
235  throw(std::runtime_error(m_className + "::fetch: Cannot fetch data with "
236  "timestamp = 0 and LMFRunIOV = 0"));
237  }
238  if (ok && isValid()) {
239  if (m_debug) {
240  std::cout << "[LMFDat] This object is valid..." << std::endl;
241  }
242  try {
243  Statement *stmt = m_conn->createStatement();
244  std::string sql = buildSelectSql(logic_id, direction);
245  if (m_debug) {
246  std::cout << "[LMFDat] Executing query " << std::endl;
247  std::cout << " " << sql << std::endl << std::flush;
248  }
249  if (logic_id == 0) {
250  // get data for all crystals with a given timestamp
251  stmt->setPrefetchRowCount(10000);
252  }
253  stmt->setSQL(sql);
254  int count = 1;
255  if (logic_id > 0) {
256  if (timestamp != nullptr) {
257  stmt->setString(count, timestamp->str());
258  count++;
259  }
260  stmt->setInt(count++, logic_id);
261  }
262  adjustParameters(count, sql, stmt);
263  ResultSet *rset = stmt->executeQuery();
264  std::vector<float> x;
265  int nData = m_keys.size();
266  x.reserve(nData);
267  while (rset->next() != 0) {
268  for (int i = 0; i < nData; i++) {
269  x.push_back(rset->getFloat(i + 3));
270  }
271  int id = rset->getInt(2);
272  if (timestamp != nullptr) {
273  setInt(foreignKeyName(), rset->getInt(1));
274  }
275  this->setData(id, x);
276  x.clear();
277  }
278  stmt->setPrefetchRowCount(0);
279  m_conn->terminateStatement(stmt);
280  } catch (oracle::occi::SQLException &e) {
281  throw(std::runtime_error(m_className + "::fetch: " + e.getMessage()));
282  }
283  m_ID = m_data.size();
284  }
285 }
std::string m_className
Definition: LMFUnique.h:99
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void adjustParameters(int n, std::string &sql, Statement *stmt)
Definition: LMFDat.cc:207
bool isValid() override
Definition: LMFDat.cc:287
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
LMFDat & setData(int logic_id, const std::vector< float > &data)
Definition: LMFDat.h:49
bool check()
Definition: LMFDat.cc:505
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
int getLMFRunIOVID()
Definition: LMFDat.cc:32
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145
char m_debug
Definition: LMFUnique.h:100
std::string buildSelectSql(int logic_id=0, int direction=0)
Definition: LMFDat.cc:128

◆ fetch() [5/7]

void LMFDat::fetch ( const EcalLogicID id,
const Tm tm 
)
noexcept

Definition at line 194 of file LMFDat.cc.

References cond::persistency::fetch().

194 { fetch(id.getLogicID(), &tm, 1); }
void fetch() noexcept(false)
Definition: LMFDat.cc:201

◆ fetch() [6/7]

void LMFDat::fetch ( const EcalLogicID id,
const Tm tm,
int  dir 
)
noexcept

Definition at line 196 of file LMFDat.cc.

References cond::persistency::fetch().

196  {
197  setInt(foreignKeyName(), 0); /* set the LMF_IOV_ID to undefined */
198  fetch(id.getLogicID(), &tm, direction);
199 }
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
void fetch() noexcept(false)
Definition: LMFDat.cc:201
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30

◆ fetch() [7/7]

void LMFDat::fetch ( const EcalLogicID id)
noexcept

Definition at line 192 of file LMFDat.cc.

References cond::persistency::fetch().

192 { fetch(id.getLogicID()); }
void fetch() noexcept(false)
Definition: LMFDat.cc:201

◆ fetchData()

std::map< int, std::vector< float > > LMFDat::fetchData ( )
noexcept

Definition at line 299 of file LMFDat.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, getIovIdFieldName(), getLMFRunIOVID(), getTableName(), mps_fire::i, LMFUnique::m_className, IDBObject::m_conn, m_data, LMFUnique::m_debug, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by writeDB().

299  {
300  // see if any of the data is already in the database
301  std::map<int, std::vector<float> > s = m_data;
302  std::string sql =
303  "SELECT LOGIC_ID FROM CMS_ECAL_LASER_COND." + getTableName() + " WHERE " + getIovIdFieldName() + " = :1";
304  if (m_debug) {
305  cout << m_className << ":: candidate data items to be written = " << s.size() << endl;
306  cout << m_className << " Executing " << sql;
307  cout << " where " << getIovIdFieldName() << " = " << getLMFRunIOVID() << endl;
308  }
309  try {
310  Statement *stmt = m_conn->createStatement();
311  stmt->setSQL(sql);
312  stmt->setInt(1, getLMFRunIOVID());
313  stmt->setPrefetchRowCount(10000);
314  ResultSet *rset = stmt->executeQuery();
315  std::map<int, std::vector<float> >::iterator i = s.end();
316  std::map<int, std::vector<float> >::iterator e = s.end();
317  while (rset->next() != 0) {
318  if (m_debug) {
319  cout << m_className << ":: checking " << rset->getInt(1) << endl << 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  } catch (oracle::occi::SQLException &e) {
329  throw(std::runtime_error(m_className + "::fetchData: " + e.getMessage()));
330  }
331  if (m_debug) {
332  cout << m_className << ":: data items to write = " << s.size() << endl;
333  }
334  return s;
335 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
int getLMFRunIOVID()
Definition: LMFDat.cc:32
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:111
char m_debug
Definition: LMFUnique.h:100
virtual std::string getTableName() const
Definition: LMFDat.h:45

◆ foreignKeyName()

std::string LMFDat::foreignKeyName ( ) const
virtual

Reimplemented in LMFCorrCoefDatComponent.

Definition at line 30 of file LMFDat.cc.

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

30 { return "lmfRunIOV"; }

◆ getData() [1/13]

std::vector< float > LMFDat::getData ( int  id)

Definition at line 532 of file LMFDat.cc.

References l1ctLayer2EG_cff::id, m_data, and runTheMatrix::ret.

532  {
533  std::vector<float> ret;
534  if (m_data.find(id) != m_data.end()) {
535  ret = m_data[id];
536  }
537  return ret;
538 }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143

◆ getData() [2/13]

std::vector< float > LMFDat::getData ( const EcalLogicID id)

Definition at line 542 of file LMFDat.cc.

References getData().

542 { return getData(id.getLogicID()); }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ getData() [3/13]

bool LMFDat::getData ( int  id,
std::vector< float > &  ret 
)

Definition at line 546 of file LMFDat.cc.

References l1ctLayer2EG_cff::id, m_data, and runTheMatrix::ret.

546  {
547  bool retval = false;
548  if (m_data.find(id) != m_data.end()) {
549  ret = m_data[id];
550  retval = true;
551  }
552  return retval;
553 }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143

◆ getData() [4/13]

bool LMFDat::getData ( const EcalLogicID id,
std::vector< float > &  ret 
)

Definition at line 555 of file LMFDat.cc.

References getData(), and runTheMatrix::ret.

555 { return getData(id.getLogicID(), ret); }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ getData() [5/13]

std::map< int, std::vector< float > > LMFDat::getData ( void  )

Definition at line 559 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::getENorm(), LMFRunDat::getEvents(), LMFLaserPulseDat::getFitMethod(), LMFCorrCoefDatComponent::getFlag(), LMFClsDat::getFlag(), LMFPrimDat::getFlag(), LMFPnPrimDat::getFlag(), LMFClsDat::getFlagNorm(), LMFClsDat::getLMFRefRunIOVID(), LMFLaserConfigDat::getLSRAttenuator(), LMFLaserConfigDat::getLSRCurrent(), LMFLaserConfigDat::getLSRDelay1(), LMFLaserConfigDat::getLSRDelay2(), LMFLaserConfigDat::getLSRPower(), LMFPrimDat::getM3(), LMFPnPrimDat::getM3(), LMFClsDat::getMean(), LMFPrimDat::getMean(), LMFPnPrimDat::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(), LMFClsDat::getRMS(), LMFPrimDat::getRMS(), LMFPnPrimDat::getRMS(), LMFCorrCoefDatComponent::getSeqID(), LMFCorrCoefDatComponent::getSequence(), LMFPnPrimDat::getShapeCor(), LMFPrimDat::getShapeCorr(), LMFTestPulseConfigDat::getVFEGain(), LMFLaserConfigDat::getVFEGain(), LMFColoredTable::getVmax(), LMFColoredTable::getVmin(), LMFLaserConfigDat::getWavelength(), and operator[]().

559 { return m_data; }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143

◆ getData() [6/13]

float LMFDat::getData ( int  id,
unsigned int  k 
)

Definition at line 563 of file LMFDat.cc.

References l1ctLayer2EG_cff::id, dqmdumpme::k, and m_data.

563 { return m_data[id][k]; }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143

◆ getData() [7/13]

float LMFDat::getData ( const EcalLogicID id,
unsigned int  k 
)

Definition at line 565 of file LMFDat.cc.

References getData(), and dqmdumpme::k.

565 { return getData(id.getLogicID(), k); }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ getData() [8/13]

float LMFDat::getData ( const EcalLogicID id,
const std::string &  key 
)

Definition at line 567 of file LMFDat.cc.

References getData(), crabWrapper::key, and m_keys.

567 { return getData(id.getLogicID(), m_keys[key]); }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ getData() [9/13]

float LMFDat::getData ( int  id,
const std::string &  key 
)

Definition at line 569 of file LMFDat.cc.

References getData(), crabWrapper::key, and m_keys.

569 { return getData(id, m_keys[key]); }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ getData() [10/13]

bool LMFDat::getData ( int  id,
unsigned int  k,
float &  ret 
)

Definition at line 573 of file LMFDat.cc.

References getData(), dqmdumpme::k, runTheMatrix::ret, and findQualityFiles::v.

573  {
574  bool retval = false;
575  std::vector<float> v;
576  retval = getData(id, v);
577  if ((retval) && (v.size() > k)) {
578  ret = v[k];
579  retval = true;
580  } else {
581  retval = false;
582  }
583  return retval;
584 }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ getData() [11/13]

bool LMFDat::getData ( const EcalLogicID id,
unsigned int  k,
float &  ret 
)

Definition at line 586 of file LMFDat.cc.

References getData(), dqmdumpme::k, and runTheMatrix::ret.

586 { return getData(id.getLogicID(), k, ret); }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ getData() [12/13]

bool LMFDat::getData ( int  id,
const std::string &  key,
float &  ret 
)

Definition at line 588 of file LMFDat.cc.

References getData(), crabWrapper::key, m_keys, and runTheMatrix::ret.

588  {
589  bool retval = false;
590  if (m_keys.find(key) != m_keys.end()) {
591  retval = getData(id, m_keys[key], ret);
592  }
593  return retval;
594 }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ getData() [13/13]

bool LMFDat::getData ( const EcalLogicID id,
const std::string &  key,
float &  ret 
)

Definition at line 596 of file LMFDat.cc.

References getData(), crabWrapper::key, and runTheMatrix::ret.

596  {
597  return getData(id.getLogicID(), key, ret);
598 }
ret
prodAgent to be discontinued
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ getIovIdFieldName()

std::string LMFDat::getIovIdFieldName ( ) const
virtual

Reimplemented in LMFCorrCoefDatComponent.

Definition at line 111 of file LMFDat.cc.

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

111 { return "LMF_IOV_ID"; }

◆ getKeyList()

std::list<std::string> LMFDat::getKeyList ( )
inline

Definition at line 103 of file LMFDat.h.

References MillePedeFileConverter_cfg::e, mps_fire::i, MainPageGenerator::l, and m_keys.

103  {
104  std::list<std::string> l;
105  std::map<std::string, unsigned int>::const_iterator i = m_keys.begin();
106  std::map<std::string, unsigned int>::const_iterator e = m_keys.end();
107  while (i != e) {
108  l.push_back(i->first);
109  i++;
110  }
111  return l;
112  }
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ getKeys()

std::map<std::string, unsigned int> LMFDat::getKeys ( )
inline

Definition at line 102 of file LMFDat.h.

References m_keys.

102 { return m_keys; }
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ getKeyTypes()

void LMFDat::getKeyTypes ( )
protectednoexcept

Definition at line 474 of file LMFDat.cc.

References MillePedeFileConverter_cfg::e, getIovIdFieldName(), getTableName(), mps_fire::i, LMFUnique::m_className, IDBObject::m_conn, m_keys, m_type, Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by check().

474  {
475  m_type.reserve(m_keys.size());
476  for (unsigned int i = 0; i < m_keys.size(); i++) {
477  m_type.push_back("");
478  }
479  // get the description of the table
480  std::string sql = "";
481  try {
482  Statement *stmt = m_conn->createStatement();
483  sql = "SELECT * FROM TABLE(CMS_ECAL_LASER_COND.LMF_TAB_COLS(:1, :2))";
484  /*
485  sql = "SELECT COLUMN_NAME, DATA_TYPE FROM "
486  "USER_TAB_COLS WHERE TABLE_NAME = '" + getTableName() + "' "
487  "AND COLUMN_NAME != '" + getIovIdFieldName() + "' AND COLUMN_NAME != "
488  "'LOGIC_ID'";
489  */
490  stmt->setSQL(sql);
491  stmt->setString(1, getTableName());
492  stmt->setString(2, getIovIdFieldName());
493  ResultSet *rset = stmt->executeQuery();
494  while (rset->next() != 0) {
495  std::string name = rset->getString(1);
496  std::string t = rset->getString(2);
497  m_type[m_keys[name]] = t;
498  }
499  m_conn->terminateStatement(stmt);
500  } catch (oracle::occi::SQLException &e) {
501  throw(std::runtime_error(m_className + "::getKeyTypes: " + e.getMessage() + " [" + sql + "]"));
502  }
503 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
std::vector< std::string > m_type
Definition: LMFDat.h:140
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:111
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145
virtual std::string getTableName() const
Definition: LMFDat.h:45

◆ getLMFRunIOV()

LMFRunIOV LMFDat::getLMFRunIOV ( ) const
inline

Definition at line 34 of file LMFDat.h.

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

Referenced by getSubrunStart().

34  {
35  LMFRunIOV runiov(m_env, m_conn);
36  runiov.setByID(getInt(foreignKeyName()));
37  return runiov;
38  }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:187

◆ getLMFRunIOVID()

int LMFDat::getLMFRunIOVID ( )

Definition at line 32 of file LMFDat.cc.

References LMFUnique::fetchID(), foreignKeyName(), LMFUnique::getInt(), mps_fire::i, l1ctLayer2EG_cff::id, LMFUnique::m_foreignKeys, and LMFUnique::setInt().

Referenced by buildSelectSql(), and fetchData().

32  {
33  int id = getInt(foreignKeyName());
34  if (id == 0) {
35  // try to get it from the list of foreign keys
36  std::map<std::string, LMFUnique *>::iterator i = m_foreignKeys.find(foreignKeyName());
37  if (i != m_foreignKeys.end()) {
38  LMFRunIOV *iov = (LMFRunIOV *)(i->second);
39  if (iov != nullptr) {
40  id = iov->fetchID();
41  setInt(foreignKeyName(), id);
42  }
43  }
44  }
45  return id;
46 }
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:187
int fetchID() noexcept(false) override
Definition: LMFUnique.cc:197

◆ getLogicIds()

std::list<int> LMFDat::getLogicIds ( )
inline

Definition at line 91 of file LMFDat.h.

References MillePedeFileConverter_cfg::e, mps_fire::i, MainPageGenerator::l, and m_data.

91  {
92  std::list<int> l;
93  std::map<int, std::vector<float> >::const_iterator i = m_data.begin();
94  std::map<int, std::vector<float> >::const_iterator e = m_data.end();
95  while (i != e) {
96  l.push_back(i->first);
97  i++;
98  }
99  return l;
100  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143

◆ getNeighbour()

void LMFDat::getNeighbour ( LMFDat dat,
int  which 
)
protectednoexcept

Definition at line 176 of file LMFDat.cc.

References GCP_Ntuples_cfg::dump, and eostools::which().

176  {
177  // there should be just one record in this case
178  if (m_data.size() == 1) {
179  dat->setConnection(this->getEnv(), this->getConn());
180  int logic_id = m_data.begin()->first;
181  Tm lastMeasuredOn = getSubrunStart();
182  lastMeasuredOn += which;
183  dat->fetch(logic_id, &lastMeasuredOn, which);
184  dat->setMaxDataToDump(m_max);
185  } else {
186  dump();
187  throw(std::runtime_error(m_className + "::getPrevious: Too many LOGIC_IDs in "
188  "this object"));
189  }
190 }
std::string m_className
Definition: LMFUnique.h:99
Tm getSubrunStart() const
Definition: LMFDat.h:40
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
oracle::occi::Connection * getConn() const
Definition: IDBObject.h:29
int m_max
Definition: LMFDat.h:139
void fetch() noexcept(false)
Definition: LMFDat.cc:201
oracle::occi::Environment * getEnv() const
Definition: IDBObject.h:28
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:48
void dump() const override
Definition: LMFDat.cc:64
def which(cmd)
Definition: eostools.py:336
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: Tm.h:13

◆ getNext()

void LMFDat::getNext ( LMFDat dat)
noexcept

Definition at line 174 of file LMFDat.cc.

174 { getNeighbour(dat, +1); }
void getNeighbour(LMFDat *dat, int which) noexcept(false)
Definition: LMFDat.cc:176

◆ getPrevious()

void LMFDat::getPrevious ( LMFDat dat)
noexcept

Definition at line 172 of file LMFDat.cc.

172 { getNeighbour(dat, -1); }
void getNeighbour(LMFDat *dat, int which) noexcept(false)
Definition: LMFDat.cc:176

◆ getReverseMap()

std::map< unsigned int, std::string > LMFDat::getReverseMap ( ) const

Definition at line 53 of file LMFDat.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, visualization-live-secondInstance_cfg::m, and m_keys.

Referenced by dump().

53  {
54  std::map<unsigned int, std::string> m;
55  std::map<std::string, unsigned int>::const_iterator i = m_keys.begin();
56  std::map<std::string, unsigned int>::const_iterator e = m_keys.end();
57  while (i != e) {
58  m[i->second] = i->first;
59  i++;
60  }
61  return m;
62 }
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ getSubrunStart()

Tm LMFDat::getSubrunStart ( ) const
inline

Definition at line 40 of file LMFDat.h.

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

40 { return getLMFRunIOV().getSubRunStart(); }
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:141
LMFRunIOV getLMFRunIOV() const
Definition: LMFDat.h:34

◆ getTableName()

virtual std::string LMFDat::getTableName ( ) const
inlinevirtual

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

Definition at line 45 of file LMFDat.h.

References m_tableName.

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

45 { return m_tableName; }
std::string m_tableName
Definition: LMFDat.h:146

◆ isValid()

bool LMFDat::isValid ( void  )
overridevirtual

Reimplemented from LMFUnique.

Reimplemented in LMFPrimDat, LMFPnPrimDat, and LMFLaserPulseDat.

Definition at line 287 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 ntupleDataFormat._Object::_checkIsValid(), LMFLaserPulseDat::isValid(), core.AutoHandle.AutoHandle::ReallyLoad(), and writeDB().

287  {
288  bool ret = true;
289  if (m_foreignKeys.find(foreignKeyName()) == m_foreignKeys.end()) {
290  ret = false;
291  m_Error += " Can't find lmfRunIOV within foreign keys.";
292  if (m_debug) {
293  cout << m_className << ": Foreign keys map size: " << m_foreignKeys.size() << endl;
294  }
295  }
296  return ret;
297 }
std::string m_className
Definition: LMFUnique.h:99
ret
prodAgent to be discontinued
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106
std::string m_Error
Definition: LMFDat.h:147
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
char m_debug
Definition: LMFUnique.h:100

◆ operator[]()

std::vector< float > LMFDat::operator[] ( int  id)

Definition at line 540 of file LMFDat.cc.

References getData().

540 { return getData(id); }
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559

◆ setData() [1/3]

LMFDat& LMFDat::setData ( int  logic_id,
const std::vector< float > &  data 
)
inline

Definition at line 49 of file LMFDat.h.

References 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::setENorm(), LMFRunDat::setEvents(), LMFLaserPulseDat::setFitMethod(), LMFCorrCoefDatComponent::setFlag(), LMFPrimDat::setFlag(), LMFPnPrimDat::setFlag(), LMFClsDat::setFlag(), LMFClsDat::setFlagNorm(), 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(), LMFPrimDat::setRMS(), LMFPnPrimDat::setRMS(), LMFClsDat::setRMS(), LMFCorrCoefDatComponent::setSequence(), LMFPnPrimDat::setShapeCorr(), LMFPrimDat::setShapeCorr(), LMFColoredTable::setVersions(), LMFTestPulseConfigDat::setVFEGain(), LMFLaserConfigDat::setVFEGain(), LMFColoredTable::setVmax(), LMFColoredTable::setVmin(), and LMFLaserConfigDat::setWavelength().

49  {
50  m_data[logic_id] = data;
51  return *this;
52  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ setData() [2/3]

LMFDat& LMFDat::setData ( const EcalLogicID logic_id,
const std::vector< float > &  data 
)
inline

Definition at line 53 of file LMFDat.h.

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

53  {
54  m_data[logic_id.getLogicID()] = data;
55  return *this;
56  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
int getLogicID() const
Definition: EcalLogicID.cc:28
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ setData() [3/3]

LMFDat& LMFDat::setData ( const EcalLogicID logic_id,
const std::string &  key,
float  v 
)
inline

Definition at line 57 of file LMFDat.h.

References EcalLogicID::getLogicID(), l1ctLayer2EG_cff::id, crabWrapper::key, m_data, m_keys, and findQualityFiles::v.

57  {
58  int id = logic_id.getLogicID();
59  m_data[id].resize(m_keys.size());
60  m_data[id][m_keys[key]] = v;
61  return *this;
62  }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
int getLogicID() const
Definition: EcalLogicID.cc:28
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145

◆ setLMFRunIOV()

LMFDat& LMFDat::setLMFRunIOV ( const LMFRunIOV iov)
inline

Definition at line 29 of file LMFDat.h.

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

29  {
30  setInt(foreignKeyName(), iov.getID());
31  attach(foreignKeyName(), (LMFUnique *)&iov);
32  return *this;
33  }
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
int getID() const
Definition: LMFUnique.h:58
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:48

◆ setMaxDataToDump()

LMFDat & LMFDat::setMaxDataToDump ( int  n)

Definition at line 48 of file LMFDat.cc.

References m_max, and dqmiodumpmetadata::n.

Referenced by writeDB().

48  {
49  m_max = n;
50  return *this;
51 }
int m_max
Definition: LMFDat.h:139

◆ setWhereClause() [1/2]

void LMFDat::setWhereClause ( std::string  w)

Definition at line 113 of file LMFDat.cc.

References _where.

113  {
114  // to be used by experts to restrict the results of a query
115  _where = where;
116 }
std::string _where
Definition: LMFDat.h:149

◆ setWhereClause() [2/2]

void LMFDat::setWhereClause ( std::string  w,
const std::vector< std::string > &  p 
)

Definition at line 118 of file LMFDat.cc.

References _where, and _wherePars.

118  {
119  // to be used by experts to restrict the results of a query
120  // in this case the where clause can contains positional parameter,
121  // identified as :/I, :/S, :/F for, respectively, integer, string or
122  // float parameters. The parameters are all passed as strings
123  // in parameters
125  _where = where;
126 }
std::vector< std::string > _wherePars
Definition: LMFDat.h:150
std::string _where
Definition: LMFDat.h:149

◆ size()

int LMFDat::size ( void  ) const
inline

Definition at line 63 of file LMFDat.h.

References m_data.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and writeDB().

63 { return m_data.size(); }
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143

◆ writeDB()

int LMFDat::writeDB ( )
overrideprotectedvirtualnoexcept

Reimplemented from LMFUnique.

Definition at line 337 of file LMFDat.cc.

References b, cms::cuda::be, edmScanValgrind::buffer, buildInsertSql(), HltBtagPostValidation_cff::c, check(), IDBObject::checkConnection(), gather_cfg::cout, LMFUnique::debug(), dump(), MillePedeFileConverter_cfg::e, fetchData(), nano_mu_digi_cff::float, foreignKeyName(), free(), LMFUnique::getID(), mps_fire::i, l1ctLayer2EG_cff::id, createfilelist::int, isValid(), dqmdumpme::k, LMFUnique::m_className, IDBObject::m_conn, LMFUnique::m_debug, m_Error, LMFUnique::m_foreignKeys, m_keys, m_max, m_type, malloc(), convertSQLiteXML::ok, runTheMatrix::ret, setMaxDataToDump(), size(), AlCaHLTBitMon_QueryRunRegistry::string, LMFUnique::writeForeignKeys(), and x.

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

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 20 of file LMFDat.h.

Member Data Documentation

◆ _where

std::string LMFDat::_where
protected

Definition at line 149 of file LMFDat.h.

Referenced by buildSelectSql(), LMFDat(), and setWhereClause().

◆ _wherePars

std::vector<std::string> LMFDat::_wherePars
protected

Definition at line 150 of file LMFDat.h.

Referenced by adjustParameters(), LMFDat(), and setWhereClause().

◆ m_data

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

◆ m_Error

std::string LMFDat::m_Error
protected

◆ m_keys

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

◆ m_max

int LMFDat::m_max
protected

Definition at line 139 of file LMFDat.h.

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

◆ m_tableName

std::string LMFDat::m_tableName
protected

◆ m_type

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