CMS 3D CMS Logo

LMFDat.h
Go to the documentation of this file.
1 #ifndef LMFDAT_H
2 #define LMFDAT_H
3 
4 /*
5  Last updated by Giovanni.Organtini@roma1.infn.it 2010
6  */
7 
12 
13 #include <map>
14 
18 class LMFDat : public LMFUnique {
19 public:
20  friend class EcalCondDBInterface;
21 
22  LMFDat();
24  LMFDat(oracle::occi::Environment *env, oracle::occi::Connection *conn);
25  ~LMFDat() override {}
26 
27  virtual std::string foreignKeyName() const;
28 
29  LMFDat &setLMFRunIOV(const LMFRunIOV &iov) {
30  setInt(foreignKeyName(), iov.getID());
31  attach(foreignKeyName(), (LMFUnique *)&iov);
32  return *this;
33  }
35  LMFRunIOV runiov(m_env, m_conn);
36  runiov.setByID(getInt(foreignKeyName()));
37  return runiov;
38  }
39 
40  Tm getSubrunStart() const { return getLMFRunIOV().getSubRunStart(); }
41 
42  void getPrevious(LMFDat *dat) noexcept(false);
43  void getNext(LMFDat *dat) noexcept(false);
44 
45  virtual std::string getTableName() const { return m_tableName; }
46  virtual std::string getIovIdFieldName() const;
47  int getLMFRunIOVID();
48 
49  LMFDat &setData(int logic_id, const std::vector<float> &data) {
50  m_data[logic_id] = data;
51  return *this;
52  }
53  LMFDat &setData(const EcalLogicID &logic_id, const std::vector<float> &data) {
54  m_data[logic_id.getLogicID()] = data;
55  return *this;
56  }
57  LMFDat &setData(const EcalLogicID &logic_id, const std::string &key, float v) {
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  }
63  int size() const { return m_data.size(); }
64 
65  std::map<unsigned int, std::string> getReverseMap() const;
66 
67  /* UNSAFE methods returning data for a given logic_id */
68  std::vector<float> getData(int id);
69  std::vector<float> operator[](int id);
70  std::vector<float> getData(const EcalLogicID &id);
71 
72  /* SAFE methods returning data for a given logic_id */
73  bool getData(int id, std::vector<float> &ret);
74  bool getData(const EcalLogicID &id, std::vector<float> &ret);
75 
76  /* methods returning the whole map between logic_id and data */
77  std::map<int, std::vector<float> > getData();
78 
79  /* UNSAFE methods returning a field of a given logic_id */
80  float getData(int id, unsigned int k);
81  float getData(const EcalLogicID &id, unsigned int k);
82  float getData(const EcalLogicID &id, const std::string &key);
83  float getData(int id, const std::string &key);
84 
85  /* SAFE methods returning a field of a given logic_id */
86  bool getData(int id, unsigned int k, float &ret);
87  bool getData(const EcalLogicID &id, unsigned int k, float &ret);
88  bool getData(int id, const std::string &key, float &ret);
89  bool getData(const EcalLogicID &id, const std::string &key, float &ret);
90 
91  std::list<int> getLogicIds() {
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  }
101 
102  std::map<std::string, unsigned int> getKeys() { return m_keys; }
103  std::list<std::string> getKeyList() {
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  }
113  LMFDat &setMaxDataToDump(int n);
114  void dump() const override;
115  void dump(int n) const override;
116  virtual void dump(int n, int max) const;
117  std::map<int, std::vector<float> > fetchData() noexcept(false);
118  void fetch() noexcept(false);
119  void fetch(int logic_id) noexcept(false);
120  void fetch(int logic_id, const Tm &tm) noexcept(false);
121  void fetch(int logic_id, const Tm *timestamp, int dir) noexcept(false);
122  void fetch(const EcalLogicID &id, const Tm &tm) noexcept(false);
123  void fetch(const EcalLogicID &id, const Tm &tm, int dir) noexcept(false);
124  void fetch(const EcalLogicID &id) noexcept(false);
125 
126  bool isValid() override;
127  void setWhereClause(std::string w);
128  void setWhereClause(std::string w, const std::vector<std::string> &p);
129 
130 protected:
131  void getNeighbour(LMFDat *dat, int which) noexcept(false);
132  int writeDB() noexcept(false) override;
133  bool check();
134  void adjustParameters(int n, std::string &sql, Statement *stmt);
135  std::string buildInsertSql();
136  std::string buildSelectSql(int logic_id = 0, int direction = 0);
137  void getKeyTypes() noexcept(false);
138 
139  int m_max;
140  std::vector<std::string> m_type;
141  // m_data contains objects like (key, value) where key is the logic_id
142  // of a channel and value is a vector of values associated to that logic_id
143  std::map<int, std::vector<float> > m_data;
144  // m_keys contains the keys to the components of the vector of data
145  std::map<std::string, unsigned int> m_keys;
146  std::string m_tableName;
147  std::string m_Error;
148  // experts only
149  std::string _where;
151 };
152 
153 #endif
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
EcalCondDBInterface
Definition: EcalCondDBInterface.h:37
LMFDat::dump
void dump() const override
Definition: LMFDat.cc:64
LMFDat::getData
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559
LMFDat::getTableName
virtual std::string getTableName() const
Definition: LMFDat.h:45
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
LMFUnique::setByID
void setByID(int id) noexcept(false) override
Definition: LMFUnique.cc:267
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
LMFDat::getKeyTypes
void getKeyTypes() noexcept(false)
Definition: LMFDat.cc:474
LMFDat::getSubrunStart
Tm getSubrunStart() const
Definition: LMFDat.h:40
LMFDat::getNeighbour
void getNeighbour(LMFDat *dat, int which) noexcept(false)
Definition: LMFDat.cc:176
LMFDat::getKeyList
std::list< std::string > getKeyList()
Definition: LMFDat.h:103
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
LMFDat::m_max
int m_max
Definition: LMFDat.h:139
LMFDat::setData
LMFDat & setData(const EcalLogicID &logic_id, const std::vector< float > &data)
Definition: LMFDat.h:53
LMFDat::getPrevious
void getPrevious(LMFDat *dat) noexcept(false)
Definition: LMFDat.cc:172
LMFDat::adjustParameters
void adjustParameters(int n, std::string &sql, Statement *stmt)
Definition: LMFDat.cc:207
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
LMFUnique::setInt
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
findQualityFiles.v
v
Definition: findQualityFiles.py:179
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
LMFUnique::getInt
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:187
watchdog.const
const
Definition: watchdog.py:83
LMFDat::fetch
void fetch() noexcept(false)
Definition: LMFDat.cc:201
EcalDBConnection::stmt
oracle::occi::Statement * stmt
Definition: EcalDBConnection.h:73
LMFDat::foreignKeyName
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
cond::timestamp
Definition: Time.h:19
LMFDat::_where
std::string _where
Definition: LMFDat.h:149
LMFDat
Definition: LMFDat.h:18
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
LMFRunIOV
Definition: LMFRunIOV.h:18
LMFDat::m_data
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:143
w
const double w
Definition: UKUtility.cc:23
LMFDat::getIovIdFieldName
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:111
LMFDat::isValid
bool isValid() override
Definition: LMFDat.cc:287
LMFDat::getKeys
std::map< std::string, unsigned int > getKeys()
Definition: LMFDat.h:102
LMFDat::writeDB
int writeDB() noexcept(false) override
Definition: LMFDat.cc:337
LMFUnique.h
EcalLogicID
Definition: EcalLogicID.h:7
dqmdumpme.k
k
Definition: dqmdumpme.py:60
LMFDat::setData
LMFDat & setData(int logic_id, const std::vector< float > &data)
Definition: LMFDat.h:49
Tm
Definition: Tm.h:13
LMFDat::getLMFRunIOV
LMFRunIOV getLMFRunIOV() const
Definition: LMFDat.h:34
LMFDat::setMaxDataToDump
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
web.browse_db.env
env
Definition: browse_db.py:18
LMFDat::check
bool check()
Definition: LMFDat.cc:505
LMFDat::_wherePars
std::vector< std::string > _wherePars
Definition: LMFDat.h:150
LMFDat::m_tableName
std::string m_tableName
Definition: LMFDat.h:146
LMFDat::m_keys
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145
LMFDat::buildSelectSql
std::string buildSelectSql(int logic_id=0, int direction=0)
Definition: LMFDat.cc:128
LMFDat::getLogicIds
std::list< int > getLogicIds()
Definition: LMFDat.h:91
LMFUnique::attach
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:48
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LMFDat::fetchData
std::map< int, std::vector< float > > fetchData() noexcept(false)
Definition: LMFDat.cc:299
EcalDBConnection.h
LMFDat::~LMFDat
~LMFDat() override
Definition: LMFDat.h:25
LMFDat::getLMFRunIOVID
int getLMFRunIOVID()
Definition: LMFDat.cc:32
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
LMFDat::buildInsertSql
std::string buildInsertSql()
Definition: LMFDat.cc:95
LMFRunIOV.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
LMFDat::setLMFRunIOV
LMFDat & setLMFRunIOV(const LMFRunIOV &iov)
Definition: LMFDat.h:29
EcalLogicID.h
LMFDat::getReverseMap
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:53
std
Definition: JetResolutionObject.h:76
LMFUnique::getID
int getID() const
Definition: LMFUnique.h:58
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
LMFUnique::Statement
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
LMFRunIOV::getSubRunStart
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:141
LMFDat::operator[]
std::vector< float > operator[](int id)
Definition: LMFDat.cc:540
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
LMFDat::getNext
void getNext(LMFDat *dat) noexcept(false)
Definition: LMFDat.cc:174
LMFDat::setData
LMFDat & setData(const EcalLogicID &logic_id, const std::string &key, float v)
Definition: LMFDat.h:57
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LMFDat::size
int size() const
Definition: LMFDat.h:63
LMFDat::LMFDat
LMFDat()
Definition: LMFDat.cc:9
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
LMFUnique
Definition: LMFUnique.h:21
crabWrapper.key
key
Definition: crabWrapper.py:19
eostools.which
def which(cmd)
Definition: eostools.py:336
LMFDat::setWhereClause
void setWhereClause(std::string w)
Definition: LMFDat.cc:113
LMFDat::m_type
std::vector< std::string > m_type
Definition: LMFDat.h:140
LMFDat::m_Error
std::string m_Error
Definition: LMFDat.h:147
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
EcalDBConnection
Definition: EcalDBConnection.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37