CMS 3D CMS Logo

CSCDQM_Cache.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Cache.h
5  *
6  * Description: Efficiently manages lists of MonitorObject's for internal
7  * MO cache.
8  *
9  * Version: 1.0
10  * Created: 11/27/2008 10:05:00 AM
11  * Revision: none
12  * Compiler: gcc
13  *
14  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
15  * Company: CERN, CH
16  *
17  * =====================================================================================
18  */
19 
20 #ifndef CSCDQM_Cache_H
21 #define CSCDQM_Cache_H
22 
23 #include <map>
24 #include <boost/multi_index_container.hpp>
25 #include <boost/multi_index/member.hpp>
26 #include <boost/multi_index/composite_key.hpp>
27 #include <boost/multi_index/ordered_index.hpp>
28 #include "boost/tuple/tuple.hpp"
29 
30 #include "CSCDQM_Logger.h"
31 #include "CSCDQM_HistoDef.h"
32 #include "CSCDQM_MonitorObject.h"
33 #include "CSCDQM_Utility.h"
34 
35 namespace cscdqm {
36 
38  struct CSCHistoKeyType {
41  const MonitorObject* mo;
42  CSCHistoKeyType(const HistoId& id_, const HwId& addId_, const MonitorObject* mo_)
43  : id(id_), addId(addId_), mo(mo_) {}
44  };
45 
47  typedef boost::multi_index_container<
48  CSCHistoKeyType,
49  boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<
50  CSCHistoKeyType,
51  boost::multi_index::member<CSCHistoKeyType, HistoId, &CSCHistoKeyType::id>,
52  boost::multi_index::member<CSCHistoKeyType, HwId, &CSCHistoKeyType::addId> > > > >
54 
56  struct CSCKeyType {
60  CSCKeyType(const HwId& crateId_, const HwId& dmbId_) : crateId(crateId_), dmbId(dmbId_) {}
61  };
62 
64  typedef boost::multi_index_container<
65  CSCKeyType,
66  boost::multi_index::indexed_by<boost::multi_index::ordered_unique<
67  boost::multi_index::composite_key<CSCKeyType,
68  boost::multi_index::member<CSCKeyType, HwId, &CSCKeyType::crateId>,
69  boost::multi_index::member<CSCKeyType, HwId, &CSCKeyType::dmbId> > > > >
71 
73  typedef std::map<HwId, MonitorObject**> FEDMapType;
74 
76  typedef std::map<HwId, MonitorObject**> DDUMapType;
77 
79  struct LookupKeyType {
83  LookupKeyType(const HistoDef& histo_, MonitorObject*& mo_) : histo(histo_), mo(mo_) { path = histo.getPath(); }
84  };
85 
87  typedef boost::multi_index_container<
88  LookupKeyType,
89  boost::multi_index::indexed_by<
90  boost::multi_index::ordered_unique<boost::multi_index::member<LookupKeyType, HistoDef, &LookupKeyType::histo> >,
91  boost::multi_index::ordered_non_unique<
92  boost::multi_index::member<LookupKeyType, std::string, &LookupKeyType::path> > > >
94 
99  class Cache {
100  private:
103 
107  FEDMapType::const_iterator fedPointer;
110 
114  DDUMapType::const_iterator dduPointer;
117 
121  CSCMapType::const_iterator cscPointer;
122 
125 
126  public:
128  Cache() {
130  for (unsigned int i = 0; i < h::namesSize; i++)
131  data[i] = nullptr;
132 
134  fedPointer = fedData.end();
135  fedPointerValue = 0;
136 
138  dduPointer = dduData.end();
139  dduPointerValue = 0;
140  cscPointer = cscData.end();
141  }
142 
144  ~Cache() {
146  while (fedData.begin() != fedData.end()) {
147  if (fedData.begin()->second) {
148  delete[] fedData.begin()->second;
149  }
150  fedData.erase(fedData.begin());
151  }
152 
154  while (dduData.begin() != dduData.end()) {
155  if (dduData.begin()->second) {
156  delete[] dduData.begin()->second;
157  }
158  dduData.erase(dduData.begin());
159  }
160  }
161 
164  const bool get(const HistoDef& histo, MonitorObject*& mo);
165  const bool getEMU(const HistoId& id, MonitorObject*& mo);
166  const bool getFED(const HistoId& id, const HwId& fedId, MonitorObject*& mo);
167  const bool getDDU(const HistoId& id, const HwId& dduId, MonitorObject*& mo);
168  const bool getCSC(const HistoId& id, const HwId& crateId, const HwId& dmbId, const HwId& addId, MonitorObject*& mo);
169  const bool getPar(const HistoId& id, MonitorObject*& mo);
170  void put(const HistoDef& histo, MonitorObject* mo);
171 
174  const bool nextBookedFED(unsigned int& n, unsigned int& fedId) const;
175  const bool nextBookedDDU(unsigned int& n, unsigned int& dduId) const;
176  const bool nextBookedCSC(unsigned int& n, unsigned int& crateId, unsigned int& dmbId) const;
177  const bool isBookedCSC(const HwId& crateId, const HwId& dmbId) const;
178  const bool isBookedDDU(const HwId& dduId) const;
179  const bool isBookedFED(const HwId& fedId) const;
180  };
181 
182 } // namespace cscdqm
183 
184 #endif
const bool getFED(const HistoId &id, const HwId &fedId, MonitorObject *&mo)
Get FED MO on Histogram Id and FED Id.
Definition: CSCDQM_Cache.cc:66
unsigned int HwId
DDUMapType dduData
Definition: CSCDQM_Cache.h:112
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:51
LookupKeyType(const HistoDef &histo_, MonitorObject *&mo_)
Definition: CSCDQM_Cache.h:83
CSCHistoKeyType(const HistoId &id_, const HwId &addId_, const MonitorObject *mo_)
Definition: CSCDQM_Cache.h:42
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
Abstract Base Histogram Definition.
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
const bool nextBookedFED(unsigned int &n, unsigned int &fedId) const
Iterator to get booked FED identifier on enumerator.
CSCKeyType(const HwId &crateId_, const HwId &dmbId_)
Definition: CSCDQM_Cache.h:60
MonitorObject * data[h::namesSize]
Definition: CSCDQM_Cache.h:102
const bool nextBookedCSC(unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
Iterator to get booked CSC identifiers on enumerator.
std::map< HwId, MonitorObject ** > DDUMapType
Definition: CSCDQM_Cache.h:76
boost::multi_index_container< CSCHistoKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::composite_key< CSCHistoKeyType, boost::multi_index::member< CSCHistoKeyType, HistoId, &CSCHistoKeyType::id >, boost::multi_index::member< CSCHistoKeyType, HwId, &CSCHistoKeyType::addId > > > > > CSCHistoMapType
Definition: CSCDQM_Cache.h:53
static const unsigned int namesSize
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
unsigned int HistoId
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
HwId dduPointerValue
Definition: CSCDQM_Cache.h:116
MonitorObject * mo
Definition: CSCDQM_Cache.h:82
MonitorObject cache - list objects and routines to manage cache.
Definition: CSCDQM_Cache.h:99
const bool nextBookedDDU(unsigned int &n, unsigned int &dduId) const
Iterator to get booked DDU identifier on enumerator.
boost::multi_index_container< CSCKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::composite_key< CSCKeyType, boost::multi_index::member< CSCKeyType, HwId, &CSCKeyType::crateId >, boost::multi_index::member< CSCKeyType, HwId, &CSCKeyType::dmbId > > > > > CSCMapType
Definition: CSCDQM_Cache.h:70
DDUMapType::const_iterator dduPointer
Definition: CSCDQM_Cache.h:114
CSCMapType::const_iterator cscPointer
Definition: CSCDQM_Cache.h:121
boost::multi_index_container< LookupKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::member< LookupKeyType, HistoDef, &LookupKeyType::histo > >, boost::multi_index::ordered_non_unique< boost::multi_index::member< LookupKeyType, std::string, &LookupKeyType::path > > > > LookupMapType
Definition: CSCDQM_Cache.h:93
MO Lookup List object definition.
Definition: CSCDQM_Cache.h:79
const bool isBookedDDU(const HwId &dduId) const
Check if DDU was booked on given identifier.
virtual const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
Chamber List object definition.
Definition: CSCDQM_Cache.h:56
FEDMapType::const_iterator fedPointer
Definition: CSCDQM_Cache.h:107
FEDMapType fedData
Definition: CSCDQM_Cache.h:105
const bool getDDU(const HistoId &id, const HwId &dduId, MonitorObject *&mo)
Get DDU MO on Histogram Id and DDU Id.
Definition: CSCDQM_Cache.cc:92
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
Chamber MO List object definition.
Definition: CSCDQM_Cache.h:38
CSCMapType cscData
Definition: CSCDQM_Cache.h:119
std::map< HwId, MonitorObject ** > FEDMapType
Definition: CSCDQM_Cache.h:73
const bool getCSC(const HistoId &id, const HwId &crateId, const HwId &dmbId, const HwId &addId, MonitorObject *&mo)
Get CSC MO on Histogram Id and CSC Crate and DMB Ids.
const MonitorObject * mo
Definition: CSCDQM_Cache.h:41
CSCHistoMapType mos
Definition: CSCDQM_Cache.h:59
LookupMapType lookupData
Definition: CSCDQM_Cache.h:124
HwId fedPointerValue
Definition: CSCDQM_Cache.h:109