CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
150  std::vector<std::string> _wherePars;
151 };
152 
153 #endif
std::vector< std::string > _wherePars
Definition: LMFDat.h:150
std::list< int > getLogicIds()
Definition: LMFDat.h:91
tuple ret
prodAgent to be discontinued
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
void getNeighbour(LMFDat *dat, int which) noexcept(false)
Definition: LMFDat.cc:176
def which
Definition: eostools.py:336
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int getID() const
Definition: LMFUnique.h:58
const edm::EventSetup & c
LMFDat & setLMFRunIOV(const LMFRunIOV &iov)
Definition: LMFDat.h:29
void adjustParameters(int n, std::string &sql, Statement *stmt)
Definition: LMFDat.cc:207
bool isValid() override
Definition: LMFDat.cc:287
uint16_t *__restrict__ id
void getPrevious(LMFDat *dat) noexcept(false)
Definition: LMFDat.cc:172
int writeDB() noexcept(false) override
Definition: LMFDat.cc:337
std::map< unsigned int, std::string > getReverseMap() const
Definition: LMFDat.cc:53
Tm getSubRunStart() const
Definition: LMFRunIOV.cc:141
~LMFDat() override
Definition: LMFDat.h:25
std::string buildInsertSql()
Definition: LMFDat.cc:95
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
std::vector< std::string > m_type
Definition: LMFDat.h:140
int size() const
Definition: LMFDat.h:63
bool check()
Definition: LMFDat.cc:505
void getNext(LMFDat *dat) noexcept(false)
Definition: LMFDat.cc:174
void setByID(int id) noexcept(false) override
Definition: LMFUnique.cc:267
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:187
std::map< std::string, unsigned int > getKeys()
Definition: LMFDat.h:102
LMFDat & setData(const EcalLogicID &logic_id, const std::vector< float > &data)
Definition: LMFDat.h:53
std::map< int, std::vector< float > > fetchData() noexcept(false)
Definition: LMFDat.cc:299
#define override(base_class)
int m_max
Definition: LMFDat.h:139
void fetch() noexcept(false)
Definition: LMFDat.cc:201
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
Definition: LMFDat.h:18
std::string m_Error
Definition: LMFDat.h:147
tuple key
prepare the HTCondor submission files and eventually submit them
LMFDat & setData(const EcalLogicID &logic_id, const std::string &key, float v)
Definition: LMFDat.h:57
int getLogicID() const
Definition: EcalLogicID.cc:28
Tm getSubrunStart() const
Definition: LMFDat.h:40
std::map< int, std::vector< float > > getData()
Definition: LMFDat.cc:559
LMFDat & setMaxDataToDump(int n)
Definition: LMFDat.cc:48
void dump() const override
Definition: LMFDat.cc:64
int getLMFRunIOVID()
Definition: LMFDat.cc:32
LMFDat()
Definition: LMFDat.cc:9
void setWhereClause(std::string w)
Definition: LMFDat.cc:113
std::vector< float > operator[](int id)
Definition: LMFDat.cc:540
virtual std::string getIovIdFieldName() const
Definition: LMFDat.cc:111
static std::vector< std::string > checklist dat
LMFRunIOV getLMFRunIOV() const
Definition: LMFDat.h:34
virtual std::string foreignKeyName() const
Definition: LMFDat.cc:30
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::map< std::string, unsigned int > m_keys
Definition: LMFDat.h:145
tuple conn
Definition: getInfo.py:9
std::string _where
Definition: LMFDat.h:149
oracle::occi::Statement * stmt
virtual std::string getTableName() const
Definition: LMFDat.h:45
T w() const
std::list< std::string > getKeyList()
Definition: LMFDat.h:103
std::string buildSelectSql(int logic_id=0, int direction=0)
Definition: LMFDat.cc:128
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:48
Definition: Tm.h:13
void getKeyTypes() noexcept(false)
Definition: LMFDat.cc:474
std::string m_tableName
Definition: LMFDat.h:146