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:
102  MonitorObject* data[h::namesSize];
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
cscdqm::Cache::nextBookedDDU
const bool nextBookedDDU(unsigned int &n, unsigned int &dduId) const
Iterator to get booked DDU identifier on enumerator.
Definition: CSCDQM_Cache.cc:281
CSCDQM_Logger.h
mps_fire.i
i
Definition: mps_fire.py:428
cscdqm::HistoDef
Abstract Base Histogram Definition.
Definition: CSCDQM_HistoDef.h:62
cscdqm::DDUMapType
std::map< HwId, MonitorObject ** > DDUMapType
Definition: CSCDQM_Cache.h:76
cscdqm::HistoId
unsigned int HistoId
Definition: CSCDQM_HistoDef.h:35
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cscdqm::Cache::getFED
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
cscdqm::Cache::fedPointerValue
HwId fedPointerValue
Definition: CSCDQM_Cache.h:109
cscdqm::LookupKeyType
MO Lookup List object definition.
Definition: CSCDQM_Cache.h:79
cscdqm::CSCKeyType::mos
CSCHistoMapType mos
Definition: CSCDQM_Cache.h:59
cscdqm::CSCHistoKeyType
Chamber MO List object definition.
Definition: CSCDQM_Cache.h:38
cscdqm::Cache::data
MonitorObject * data[h::namesSize]
Definition: CSCDQM_Cache.h:102
CSCDQM_Utility.h
cscdqm::LookupKeyType::path
std::string path
Definition: CSCDQM_Cache.h:81
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
cscdqm::Cache::nextBookedCSC
const bool nextBookedCSC(unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
Iterator to get booked CSC identifiers on enumerator.
Definition: CSCDQM_Cache.cc:244
cscdqm::CSCHistoMapType
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
cscdqm::Cache::isBookedDDU
const bool isBookedDDU(const HwId &dduId) const
Check if DDU was booked on given identifier.
Definition: CSCDQM_Cache.cc:322
cscdqm::Cache::isBookedCSC
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
Definition: CSCDQM_Cache.cc:299
CSCDQM_HistoDef.h
cscdqm::CSCKeyType
Chamber List object definition.
Definition: CSCDQM_Cache.h:56
cscdqm::LookupKeyType::mo
MonitorObject * mo
Definition: CSCDQM_Cache.h:82
cscdqm::CSCHistoKeyType::CSCHistoKeyType
CSCHistoKeyType(const HistoId &id_, const HwId &addId_, const MonitorObject *mo_)
Definition: CSCDQM_Cache.h:42
cscdqm::Cache::~Cache
~Cache()
Definition: CSCDQM_Cache.h:144
cscdqm::Cache::dduPointerValue
HwId dduPointerValue
Definition: CSCDQM_Cache.h:116
cscdqm::Cache::get
const bool get(const HistoDef &histo, MonitorObject *&mo)
Get Monitoring Object on Histogram Definition.
Definition: CSCDQM_Cache.cc:29
cscdqm::HwId
unsigned int HwId
Definition: CSCDQM_HistoDef.h:38
cscdqm::CSCHistoKeyType::id
HistoId id
Definition: CSCDQM_Cache.h:39
cscdqm::LookupMapType
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
cscdqm::Cache::cscData
CSCMapType cscData
Definition: CSCDQM_Cache.h:119
cscdqm::FEDMapType
std::map< HwId, MonitorObject ** > FEDMapType
Definition: CSCDQM_Cache.h:73
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cscdqm::Cache::getPar
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
Definition: CSCDQM_Cache.cc:143
cscdqm::Cache::lookupData
LookupMapType lookupData
Definition: CSCDQM_Cache.h:124
cscdqm::Cache::dduData
DDUMapType dduData
Definition: CSCDQM_Cache.h:112
cscdqm::Cache
MonitorObject cache - list objects and routines to manage cache.
Definition: CSCDQM_Cache.h:99
cscdqm
Definition: CSCDQM_DCSBase.h:29
cscdqm::Cache::fedPointer
FEDMapType::const_iterator fedPointer
Definition: CSCDQM_Cache.h:107
cscdqm::Cache::getDDU
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
cscdqm::Cache::dduPointer
DDUMapType::const_iterator dduPointer
Definition: CSCDQM_Cache.h:114
cscdqm::LookupKeyType::histo
HistoDef histo
Definition: CSCDQM_Cache.h:80
cscdqm::CSCMapType
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
cscdqm::CSCHistoKeyType::mo
const MonitorObject * mo
Definition: CSCDQM_Cache.h:41
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
cscdqm::CSCHistoKeyType::addId
HwId addId
Definition: CSCDQM_Cache.h:40
cscdqm::Cache::isBookedFED
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
Definition: CSCDQM_Cache.cc:312
cscdqm::HistoDef::getPath
virtual const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
Definition: CSCDQM_HistoDef.h:177
cscdqm::Cache::fedData
FEDMapType fedData
Definition: CSCDQM_Cache.h:105
cscdqm::Cache::nextBookedFED
const bool nextBookedFED(unsigned int &n, unsigned int &fedId) const
Iterator to get booked FED identifier on enumerator.
Definition: CSCDQM_Cache.cc:263
CSCDQM_MonitorObject.h
cscdqm::Cache::put
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
Definition: CSCDQM_Cache.cc:157
cscdqm::CSCKeyType::CSCKeyType
CSCKeyType(const HwId &crateId_, const HwId &dmbId_)
Definition: CSCDQM_Cache.h:60
cscdqm::CSCKeyType::dmbId
HwId dmbId
Definition: CSCDQM_Cache.h:58
cscdqm::Cache::getEMU
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:51
cscdqm::CSCKeyType::crateId
HwId crateId
Definition: CSCDQM_Cache.h:57
cscdqm::MonitorObject
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
Definition: CSCDQM_MonitorObject.h:35
cscdqm::Cache::cscPointer
CSCMapType::const_iterator cscPointer
Definition: CSCDQM_Cache.h:121
cscdqm::Cache::Cache
Cache()
Definition: CSCDQM_Cache.h:128
cscdqm::LookupKeyType::LookupKeyType
LookupKeyType(const HistoDef &histo_, MonitorObject *&mo_)
Definition: CSCDQM_Cache.h:83
cscdqm::Cache::getCSC
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.
Definition: CSCDQM_Cache.cc:119