CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LMFDefFabric.cc
Go to the documentation of this file.
7 
8 #include <iostream>
9 
11 
12 LMFDefFabric::LMFDefFabric(oracle::occi::Environment *env, oracle::occi::Connection *conn) {
13  noDebug();
14  setConnection(env, conn);
15  initialize();
16 }
17 
19  noDebug();
20  setConnection(c->getEnv(), c->getConn());
21  initialize();
22 }
23 
25 
26 void LMFDefFabric::debug() { _debug = true; }
27 
28 void LMFDefFabric::noDebug() { _debug = false; }
29 
30 std::list<LMFColor> LMFDefFabric::getColors() const { return _lmfColors; }
31 
32 std::list<LMFTrigType> LMFDefFabric::getTriggerTypes() const { return _lmfTrigTypes; }
33 
34 std::list<LMFRunTag> LMFDefFabric::getRunTags() const { return _lmfRunTags; }
35 
37  std::list<LMFColor>::const_iterator i = _lmfColors.begin();
38  std::list<LMFColor>::const_iterator e = _lmfColors.end();
39  LMFColor ret;
40  bool loop = true;
41  while ((loop) && (i != e)) {
42  if (i->getShortName() == name) {
43  ret = *i;
44  loop = false;
45  }
46  i++;
47  }
48  return ret;
49 }
50 
52  std::list<LMFColor>::const_iterator i = _lmfColors.begin();
53  std::list<LMFColor>::const_iterator e = _lmfColors.end();
54  LMFColor ret;
55  bool loop = true;
56  while ((loop) && (i != e)) {
57  if (i->getID() == id) {
58  ret = *i;
59  loop = false;
60  }
61  i++;
62  }
63  return ret;
64 }
65 
67  std::list<LMFColor>::const_iterator i = _lmfColors.begin();
68  std::list<LMFColor>::const_iterator e = _lmfColors.end();
69  LMFColor ret;
70  bool loop = true;
71  while ((loop) && (i != e)) {
72  if (i->getColorIndex() == index) {
73  ret = *i;
74  loop = false;
75  }
76  i++;
77  }
78  return ret;
79 }
80 
81 int LMFDefFabric::getColorID(std::string sname) const { return getColor(sname).getID(); }
82 
83 int LMFDefFabric::getColorID(int index) const { return getColor(index).getID(); }
84 
85 int LMFDefFabric::getTrigTypeID(std::string sname) const { return getTrigType(sname).getID(); }
86 
88  std::list<LMFTrigType>::const_iterator i = _lmfTrigTypes.begin();
89  std::list<LMFTrigType>::const_iterator e = _lmfTrigTypes.end();
91  bool loop = true;
92  while ((loop) && (i != e)) {
93  if (i->getShortName() == sname) {
94  tt = *i;
95  loop = false;
96  }
97  i++;
98  }
99  return tt;
100 }
101 
103  std::list<LMFTrigType>::const_iterator i = _lmfTrigTypes.begin();
104  std::list<LMFTrigType>::const_iterator e = _lmfTrigTypes.end();
105  LMFTrigType tt;
106  bool loop = true;
107  while ((loop) && (i != e)) {
108  if (i->getID() == id) {
109  tt = *i;
110  loop = false;
111  }
112  i++;
113  }
114  return tt;
115 }
116 
118  std::list<LMFRunTag>::const_iterator i = _lmfRunTags.begin();
119  std::list<LMFRunTag>::const_iterator e = _lmfRunTags.end();
120  LMFRunTag rt;
121  bool loop = true;
122  while ((loop) && (i != e)) {
123  if ((i->getGeneralTag()) == tag && (i->getVersion() == version)) {
124  rt = *i;
125  }
126  i++;
127  }
128  return rt;
129 }
130 
132  std::list<LMFRunTag>::const_iterator i = _lmfRunTags.begin();
133  std::list<LMFRunTag>::const_iterator e = _lmfRunTags.end();
134  LMFRunTag rt;
135  bool loop = true;
136  while ((loop) && (i != e)) {
137  if (i->getID() == id) {
138  rt = *i;
139  }
140  i++;
141  }
142  return rt;
143 }
144 
145 int LMFDefFabric::getRunTagID(std::string tag, int version) const { return getRunTag(tag, version).getID(); }
146 
147 template <typename T, typename U>
148 inline T &unique_static_cast(U &i) {
149  return *(static_cast<T *>(i.get()));
150 }
151 
152 void LMFDefFabric::initialize() noexcept(false) {
153  _lmfColors.clear();
154  _lmfTrigTypes.clear();
155  _lmfRunTags.clear();
156  _lmfPrimVersions.clear();
157  _lmfSeqVersions.clear();
158  _lmfCorrVersions.clear();
159  if ((m_env != nullptr) && (m_conn != nullptr)) {
160  auto listOfObjects = LMFColor(m_env, m_conn).fetchAll();
161  auto i = listOfObjects.begin();
162  auto e = listOfObjects.end();
163 
164  while (i != e) {
165  const LMFColor &c = unique_static_cast<const LMFColor>(*i);
166  _lmfColors.push_back(c);
167  i++;
168  }
169  listOfObjects.clear();
170  listOfObjects = LMFTrigType(m_env, m_conn).fetchAll();
171  i = listOfObjects.begin();
172  e = listOfObjects.end();
173  while (i != e) {
174  const LMFTrigType &c = unique_static_cast<const LMFTrigType>(*i);
175  _lmfTrigTypes.push_back(c);
176  i++;
177  }
178  listOfObjects.clear();
179  listOfObjects = LMFRunTag(m_env, m_conn).fetchAll();
180  i = listOfObjects.begin();
181  e = listOfObjects.end();
182  while (i != e) {
183  const LMFRunTag &c = unique_static_cast<const LMFRunTag>(*i);
184  _lmfRunTags.push_back(c);
185  i++;
186  }
187  listOfObjects.clear();
188  listOfObjects = LMFPrimVers(m_env, m_conn).fetchAll();
189  i = listOfObjects.begin();
190  e = listOfObjects.end();
191  while (i != e) {
192  const LMFPrimVers &c = unique_static_cast<const LMFPrimVers>(*i);
193  _lmfPrimVersions.push_back(c);
194  i++;
195  }
196  listOfObjects.clear();
197  listOfObjects = LMFCorrVers(m_env, m_conn).fetchAll();
198  i = listOfObjects.begin();
199  e = listOfObjects.end();
200  while (i != e) {
201  const LMFCorrVers &c = unique_static_cast<const LMFCorrVers>(*i);
202  _lmfCorrVersions.push_back(c);
203  i++;
204  }
205  listOfObjects.clear();
206  listOfObjects = LMFSeqVers(m_env, m_conn).fetchAll();
207  i = listOfObjects.begin();
208  e = listOfObjects.end();
209  while (i != e) {
210  const LMFSeqVers &c = unique_static_cast<const LMFSeqVers>(*i);
211  _lmfSeqVersions.push_back(c);
212  i++;
213  }
214  listOfObjects.clear();
215  _lmfColors.sort();
216  _lmfTrigTypes.sort();
217  _lmfRunTags.sort();
218  _lmfPrimVersions.sort();
219  _lmfSeqVersions.sort();
220  _lmfCorrVersions.sort();
221  } else {
222  throw(
223  std::runtime_error("LMFDefFabric: cannot initialize since connection not"
224  "set"));
225  }
226 }
227 
229  std::cout << "========= Fabric dump @ address " << this << " ============" << std::endl;
230  std::list<LMFColor>::const_iterator i1 = _lmfColors.begin();
231  std::list<LMFTrigType>::const_iterator i2 = _lmfTrigTypes.begin();
232  std::list<LMFRunTag>::const_iterator i3 = _lmfRunTags.begin();
233  std::list<LMFPrimVers>::const_iterator i4 = _lmfPrimVersions.begin();
234  std::list<LMFSeqVers>::const_iterator i5 = _lmfSeqVersions.begin();
235  std::list<LMFCorrVers>::const_iterator i6 = _lmfCorrVersions.begin();
236  std::list<LMFColor>::const_iterator e1 = _lmfColors.end();
237  std::list<LMFTrigType>::const_iterator e2 = _lmfTrigTypes.end();
238  std::list<LMFRunTag>::const_iterator e3 = _lmfRunTags.end();
239  std::list<LMFPrimVers>::const_iterator e4 = _lmfPrimVersions.end();
240  std::list<LMFSeqVers>::const_iterator e5 = _lmfSeqVersions.end();
241  std::list<LMFCorrVers>::const_iterator e6 = _lmfCorrVersions.end();
242  std::cout << "=== Colors" << std::endl;
243  while (i1 != e1) {
244  i1++->dump();
245  }
246  std::cout << "=== Trigger Types" << std::endl;
247  while (i2 != e2) {
248  i2++->dump();
249  }
250  std::cout << "=== Run Tags" << std::endl;
251  while (i3 != e3) {
252  i3++->dump();
253  }
254  std::cout << "=== Prim. Vers." << std::endl;
255  while (i4 != e4) {
256  i4++->dump();
257  }
258  std::cout << "=== Seq. Vers." << std::endl;
259  while (i5 != e5) {
260  i5++->dump();
261  }
262  std::cout << "=== Corr. Vers." << std::endl;
263  while (i6 != e6) {
264  i6++->dump();
265  }
266 }
LMFRunTag getRunTag(std::string tag, int version) const
LMFColor getColorFromID(int color_id) const
Definition: LMFDefFabric.cc:51
tuple ret
prodAgent to be discontinued
std::list< LMFTrigType > getTriggerTypes() const
Definition: LMFDefFabric.cc:32
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int getID() const
Definition: LMFUnique.h:58
const edm::EventSetup & c
uint16_t *__restrict__ id
void initialize() noexcept(false)
void noDebug()
Definition: LMFDefFabric.cc:28
virtual std::list< std::unique_ptr< LMFUnique > > fetchAll() const noexcept(false)
Definition: LMFUnique.cc:61
LMFColor getColor(std::string name) const
Definition: LMFDefFabric.cc:36
int getColorID(std::string name) const
Definition: LMFDefFabric.cc:81
oracle::occi::Environment * getEnv() const
std::list< LMFPrimVers > _lmfPrimVersions
Definition: LMFDefFabric.h:60
oracle::occi::Connection * getConn() const
list rt
Definition: hcal_runs.py:76
T & unique_static_cast(U &i)
Definition: LMFColor.cc:100
std::list< LMFTrigType > _lmfTrigTypes
Definition: LMFDefFabric.h:58
LMFRunTag getRunTagFromID(int runTag_id) const
std::list< LMFSeqVers > _lmfSeqVersions
Definition: LMFDefFabric.h:61
std::list< LMFCorrVers > _lmfCorrVersions
Definition: LMFDefFabric.h:62
int getRunTagID(std::string tag, int version) const
int getTrigTypeID(std::string sname) const
Definition: LMFDefFabric.cc:85
std::list< LMFColor > _lmfColors
Definition: LMFDefFabric.h:57
std::list< LMFRunTag > getRunTags() const
Definition: LMFDefFabric.cc:34
std::list< LMFRunTag > _lmfRunTags
Definition: LMFDefFabric.h:59
LMFTrigType getTrigType(std::string sname) const
Definition: LMFDefFabric.cc:87
tuple conn
Definition: getInfo.py:9
tuple cout
Definition: gather_cfg.py:144
LMFTrigType getTrigTypeFromID(int trigType_id) const
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
long double T
std::list< LMFColor > getColors() const
Definition: LMFDefFabric.cc:30
~LMFDefFabric() override
Definition: LMFDefFabric.cc:24