CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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() { }
28 
29  virtual std::string foreignKeyName() const;
30 
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) throw(std::runtime_error);
47  void getNext(LMFDat *dat) throw(std::runtime_error);
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 ;
125  void dump(int n) const ;
126  virtual void dump(int n, int max) const ;
127  std::map<int, std::vector<float> > fetchData() throw(std::runtime_error);
128  void fetch() throw(std::runtime_error);
129  void fetch(int logic_id) throw(std::runtime_error);
130  void fetch(int logic_id, const Tm &tm) throw(std::runtime_error);
131  void fetch(int logic_id, const Tm *timestamp, int dir) throw(std::runtime_error);
132  void fetch(const EcalLogicID &id, const Tm &tm) throw(std::runtime_error);
133  void fetch(const EcalLogicID &id, const Tm &tm, int dir) throw(std::runtime_error);
134  void fetch(const EcalLogicID &id)
135  throw(std::runtime_error);
136 
137  virtual bool isValid();
138  void setWhereClause(std::string w);
139  void setWhereClause(std::string w, std::vector<std::string> p);
140  protected:
141  void getNeighbour(LMFDat *dat, int which) throw(std::runtime_error);
142  int writeDB() throw(std::runtime_error);
143  bool check();
144  void adjustParameters(int n, std::string &sql, Statement *stmt);
145  std::string buildInsertSql();
146  std::string buildSelectSql(int logic_id = 0, int direction = 0);
147  void getKeyTypes() throw(std::runtime_error);
148 
149  int m_max;
150  std::vector<std::string> m_type;
151  // m_data contains objects like (key, value) where key is the logic_id
152  // of a channel and value is a vector of values associated to that logic_id
153  std::map<int, std::vector<float> > m_data;
154  // m_keys contains the keys to the components of the vector of data
155  std::map<std::string, unsigned int> m_keys;
156  std::string m_tableName;
157  std::string m_Error;
158  // experts only
159  std::string _where;
160  std::vector<std::string> _wherePars;
161 };
162 
163 #endif
std::map< int, std::vector< float > > fetchData()
Definition: LMFDat.cc:352
std::vector< std::string > _wherePars
Definition: LMFDat.h:160
std::list< int > getLogicIds()
Definition: LMFDat.h:99
int i
Definition: DBlmapReader.cc:9
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
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
~LMFDat()
Definition: LMFDat.h:27
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:57
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:161
std::string buildInsertSql()
Definition: LMFDat.cc:103
std::map< int, std::vector< float > > m_data
Definition: LMFDat.h:153
LMFDat & setData(int logic_id, const std::vector< float > &data)
Definition: LMFDat.h:55
std::vector< std::string > m_type
Definition: LMFDat.h:150
int size() const
Definition: LMFDat.h:71
void getPrevious(LMFDat *dat)
Definition: LMFDat.cc:188
bool check()
Definition: LMFDat.cc:576
int writeDB()
Definition: LMFDat.cc:398
void dump() const
Definition: LMFDat.cc:68
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:203
void getKeyTypes()
Definition: LMFDat.cc:542
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
void setByID(int id)
Definition: LMFUnique.cc:286
tuple iov
Definition: o2o.py:307
virtual bool isValid()
Definition: LMFDat.cc:339
const T & max(const T &a, const T &b)
int m_max
Definition: LMFDat.h:149
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
Definition: LMFDat.h:19
std::string m_Error
Definition: LMFDat.h:157
void getNext(LMFDat *dat)
Definition: LMFDat.cc:194
LMFDat & setData(const EcalLogicID &logic_id, const std::string &key, float v)
Definition: LMFDat.h:64
int getLogicID() const
Definition: EcalLogicID.cc:42
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
string const
Definition: compareJSON.py:14
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
list key
Definition: combine.py:13
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:155
std::string _where
Definition: LMFDat.h:159
oracle::occi::Statement * stmt
virtual std::string getTableName() const
Definition: LMFDat.h:49
#define protected
Definition: FWEveView.cc:36
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:14
void getNeighbour(LMFDat *dat, int which)
Definition: LMFDat.cc:200
mathSSE::Vec4< T > v
tuple conn
Definition: results_mgr.py:53
void fetch()
Definition: LMFDat.cc:237
T w() const
std::string m_tableName
Definition: LMFDat.h:156