CMS 3D CMS Logo

LMFDat.h
Go to the documentation of this file.
1 #ifndef LMFDAT_H
2 #define LMFDAT_H
3 
4 
5 /*
6  Last updated by Giovanni.Organtini@roma1.infn.it 2010
7  */
8 
13 
14 #include <map>
15 
19 class LMFDat : public LMFUnique {
20  public:
21  friend class EcalCondDBInterface;
22 
23  LMFDat();
25  LMFDat(oracle::occi::Environment* env,
26  oracle::occi::Connection* conn);
27  ~LMFDat() override { }
28 
29  virtual std::string foreignKeyName() const;
30 
31  LMFDat& setLMFRunIOV(const LMFRunIOV &iov) {
32  setInt(foreignKeyName(), iov.getID());
33  attach(foreignKeyName(), (LMFUnique*)&iov);
34  return *this;
35  }
37  LMFRunIOV runiov(m_env, m_conn);
38  runiov.setByID(getInt(foreignKeyName()));
39  return runiov;
40  }
41 
42  Tm getSubrunStart() const {
43  return getLMFRunIOV().getSubRunStart();
44  }
45 
46  void getPrevious(LMFDat *dat) noexcept(false);
47  void getNext(LMFDat *dat) noexcept(false);
48 
49  virtual std::string getTableName() const {
50  return m_tableName;
51  }
52  virtual std::string getIovIdFieldName() const ;
53  int getLMFRunIOVID();
54 
55  LMFDat& setData(int logic_id, const std::vector<float> &data) {
56  m_data[logic_id] = data;
57  return *this;
58  }
59  LMFDat& setData(const EcalLogicID &logic_id,
60  const std::vector<float> &data) {
61  m_data[logic_id.getLogicID()] = data;
62  return *this;
63  }
64  LMFDat& setData(const EcalLogicID &logic_id, const std::string &key,
65  float v) {
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  }
71  int size() const { return m_data.size(); }
72 
73  std::map<unsigned int, std::string> getReverseMap() const;
74 
75  /* UNSAFE methods returning data for a given logic_id */
76  std::vector<float> getData(int id);
77  std::vector<float> operator[](int id);
78  std::vector<float> getData(const EcalLogicID &id);
79 
80  /* SAFE methods returning data for a given logic_id */
81  bool getData(int id, std::vector<float> &ret);
82  bool getData(const EcalLogicID &id, std::vector<float> &ret);
83 
84  /* methods returning the whole map between logic_id and data */
85  std::map<int, std::vector<float> > getData();
86 
87  /* UNSAFE methods returning a field of a given logic_id */
88  float getData(int id, unsigned int k);
89  float getData(const EcalLogicID &id, unsigned int k);
90  float getData(const EcalLogicID &id, const std::string &key);
91  float getData(int id, const std::string &key);
92 
93  /* SAFE methods returning a field of a given logic_id */
94  bool getData(int id, unsigned int k, float &ret);
95  bool getData(const EcalLogicID &id, unsigned int k, float &ret);
96  bool getData(int id, const std::string &key, float &ret);
97  bool getData(const EcalLogicID &id, const std::string &key, float &ret);
98 
99  std::list<int> getLogicIds() {
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  }
109 
110  std::map<std::string, unsigned int> getKeys() {
111  return m_keys;
112  }
113  std::list<std::string> getKeyList() {
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  }
123  LMFDat& setMaxDataToDump(int n);
124  void dump() const override ;
125  void dump(int n) const override ;
126  virtual void dump(int n, int max) const ;
127  std::map<int, std::vector<float> > fetchData() noexcept(false);
128  void fetch() noexcept(false);
129  void fetch(int logic_id) noexcept(false);
130  void fetch(int logic_id, const Tm &tm) noexcept(false);
131  void fetch(int logic_id, const Tm *timestamp, int dir) noexcept(false);
132  void fetch(const EcalLogicID &id, const Tm &tm) noexcept(false);
133  void fetch(const EcalLogicID &id, const Tm &tm, int dir) noexcept(false);
134  void fetch(const EcalLogicID &id) noexcept(false);
135 
136  bool isValid() override;
138  void setWhereClause(std::string w, const std::vector<std::string>& p);
139  protected:
140  void getNeighbour(LMFDat *dat, int which) noexcept(false);
141  int writeDB() noexcept(false) override;
142  bool check();
143  void adjustParameters(int n, std::string &sql, Statement *stmt);
145  std::string buildSelectSql(int logic_id = 0, int direction = 0);
146  void getKeyTypes() noexcept(false);
147 
148  int m_max;
149  std::vector<std::string> m_type;
150  // m_data contains objects like (key, value) where key is the logic_id
151  // of a channel and value is a vector of values associated to that logic_id
152  std::map<int, std::vector<float> > m_data;
153  // m_keys contains the keys to the components of the vector of data
154  std::map<std::string, unsigned int> m_keys;
157  // experts only
159  std::vector<std::string> _wherePars;
160 };
161 
162 #endif
std::vector< std::string > _wherePars
Definition: LMFDat.h:159
std::list< int > getLogicIds()
Definition: LMFDat.h:99
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
void getNeighbour(LMFDat *dat, int which) noexcept(false)
Definition: LMFDat.cc:200
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getID() const
Definition: LMFUnique.h:52
LMFDat & setLMFRunIOV(const LMFRunIOV &iov)
Definition: LMFDat.h:31
void adjustParameters(int n, std::string &sql, Statement *stmt)
Definition: LMFDat.cc:255
bool isValid() override
Definition: LMFDat.cc:339
const double w
Definition: UKUtility.cc:23
void getPrevious(LMFDat *dat) noexcept(false)
Definition: LMFDat.cc:188
int writeDB() noexcept(false) override
Definition: LMFDat.cc:398
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:57
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:163
~LMFDat() override
Definition: LMFDat.h:27
std::string buildInsertSql()
Definition: LMFDat.cc:103
#define noexcept
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:152
void dump() const override
Definition: LMFDat.cc:68
LMFDat & setData(int logic_id, const std::vector< float > &data)
Definition: LMFDat.h:55
std::vector< std::string > m_type
Definition: LMFDat.h:149
int size() const
Definition: LMFDat.h:71
bool check()
Definition: LMFDat.cc:576
void getNext(LMFDat *dat) noexcept(false)
Definition: LMFDat.cc:194
void setByID(int id) noexcept(false) override
Definition: LMFUnique.cc:286
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:203
std::map< std::string, unsigned int > getKeys()
Definition: LMFDat.h:110
LMFDat & setData(const EcalLogicID &logic_id, const std::vector< float > &data)
Definition: LMFDat.h:59
std::map< int, std::vector< float > > fetchData() noexcept(false)
Definition: LMFDat.cc:352
oracle::occi::Connection * conn
int m_max
Definition: LMFDat.h:148
void fetch() noexcept(false)
Definition: LMFDat.cc:237
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
Definition: LMFDat.h:19
std::string m_Error
Definition: LMFDat.h:156
LMFDat & setData(const EcalLogicID &logic_id, const std::string &key, float v)
Definition: LMFDat.h:64
int getLogicID() const
Definition: EcalLogicID.cc:41
Tm getSubrunStart() const
Definition: LMFDat.h:42
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:636
int k[5][pyjets_maxn]
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:52
int getLMFRunIOVID()
Definition: LMFDat.cc:35
LMFDat()
Definition: LMFDat.cc:9
void setWhereClause(std::string w)
Definition: LMFDat.cc:123
std::vector< float > operator[](int id)
Definition: LMFDat.cc:611
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:119
LMFRunIOV getLMFRunIOV() const
Definition: LMFDat.h:36
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:31
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:154
std::string _where
Definition: LMFDat.h:158
oracle::occi::Statement * stmt
def which(cmd)
Definition: eostools.py:335
virtual std::string getTableName() const
Definition: LMFDat.h:49
std::list< std::string > getKeyList()
Definition: LMFDat.h:113
std::string buildSelectSql(int logic_id=0, int direction=0)
Definition: LMFDat.cc:139
dbl *** dir
Definition: mlp_gen.cc:35
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:50
Definition: Tm.h:13
void getKeyTypes() noexcept(false)
Definition: LMFDat.cc:542
std::string m_tableName
Definition: LMFDat.h:155