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  Copyright (c) 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  protected:
139  void getNeighbour(LMFDat *dat, int which) throw(std::runtime_error);
140  int writeDB() throw(std::runtime_error);
141  bool check();
142  std::string buildInsertSql();
143  std::string buildSelectSql(int logic_id = 0, int direction = 0);
144  void getKeyTypes() throw(std::runtime_error);
145 
146  int m_max;
147  std::vector<std::string> m_type;
148  // m_data contains objects like (key, value) where key is the logic_id
149  // of a channel and value is a vector of values associated to that logic_id
150  std::map<int, std::vector<float> > m_data;
151  // m_keys contains the keys to the components of the vector of data
152  std::map<std::string, unsigned int> m_keys;
153  std::string m_tableName;
154  std::string m_Error;
155 };
156 
157 #endif
std::map< int, std::vector< float > > fetchData()
Definition: LMFDat.cc:294
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:51
LMFDat & setLMFRunIOV(const LMFRunIOV &iov)
Definition: LMFDat.h:31
~LMFDat()
Definition: LMFDat.h:27
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:51
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:161
std::string buildInsertSql()
Definition: LMFDat.cc:97
oracle::occi::Environment * env
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
std::vector< std::string > m_type
Definition: LMFDat.h:147
int size() const
Definition: LMFDat.h:71
void getPrevious(LMFDat *dat)
Definition: LMFDat.cc:157
bool check()
Definition: LMFDat.cc:508
int writeDB()
Definition: LMFDat.cc:339
void dump() const
Definition: LMFDat.cc:62
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:197
void getKeyTypes()
Definition: LMFDat.cc:479
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:280
oracle::occi::Connection * conn
tuple iov
Definition: o2o.py:307
virtual bool isValid()
Definition: LMFDat.cc:281
const T & max(const T &a, const T &b)
int m_max
Definition: LMFDat.h:146
Definition: LMFDat.h:19
std::string m_Error
Definition: LMFDat.h:154
void getNext(LMFDat *dat)
Definition: LMFDat.cc:163
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:568
int k[5][pyjets_maxn]
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:46
int getLMFRunIOVID()
Definition: LMFDat.cc:29
LMFDat()
Definition: LMFDat.cc:9
std::vector< float > operator[](int id)
Definition: LMFDat.cc:543
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:113
string const
Definition: compareJSON.py:14
LMFRunIOV getLMFRunIOV() const
Definition: LMFDat.h:36
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:25
list key
Definition: combine.py:13
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:152
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:117
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:169
mathSSE::Vec4< T > v
void fetch()
Definition: LMFDat.cc:206
std::string m_tableName
Definition: LMFDat.h:153