CMS 3D CMS Logo

CSCDQM_Cache.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Cache.cc
5  *
6  * Description: MonitorObject cache implementation
7  *
8  * Version: 1.0
9  * Created: 12/01/2008 11:36:11 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #include "CSCDQM_Cache.h"
20 
21 namespace cscdqm {
22 
29  const bool Cache::get(const HistoDef& histo, MonitorObject*& mo) {
30 
31  if (typeid(histo) == EMUHistoDefT) {
32  return getEMU(histo.getId(), mo);
33  } else
34  if (typeid(histo) == FEDHistoDefT) {
35  return getFED(histo.getId(), histo.getFEDId(), mo);
36  } else
37  if (typeid(histo) == DDUHistoDefT) {
38  return getDDU(histo.getId(), histo.getDDUId(), mo);
39  } else
40  if (typeid(histo) == CSCHistoDefT) {
41  return getCSC(histo.getId(), histo.getCrateId(), histo.getDMBId(), histo.getAddId(), mo);
42  } else
43  if (typeid(histo) == ParHistoDefT) {
44  return getPar(histo.getId(), mo);
45  }
46 
47  return false;
48  }
49 
56  const bool Cache::getEMU(const HistoId& id, MonitorObject*& mo) {
57  if (data[id]) {
58  mo = data[id];
59  return true;
60  }
61  return false;
62  }
63 
71  const bool Cache::getFED(const HistoId& id, const HwId& fedId, MonitorObject*& mo) {
72 
74  if (fedPointerValue != fedId) {
75  fedPointer = fedData.find(fedId);
76  if (fedPointer == fedData.end()) {
77  fedPointerValue = 0;
78  return false;
79  }
81  }
82 
84  if (fedPointer->second[id]) {
85  mo = fedPointer->second[id];
86  return true;
87  }
88  return false;
89 
90  }
91 
92 
100  const bool Cache::getDDU(const HistoId& id, const HwId& dduId, MonitorObject*& mo) {
101 
103  if (dduPointerValue != dduId) {
104  dduPointer = dduData.find(dduId);
105  if (dduPointer == dduData.end()) {
106  dduPointerValue = 0;
107  return false;
108  }
109  dduPointerValue = dduId;
110  }
111 
113  if (dduPointer->second[id]) {
114  mo = dduPointer->second[id];
115  return true;
116  }
117  return false;
118 
119  }
120 
129  const bool Cache::getCSC(const HistoId& id, const HwId& crateId, const HwId& dmbId, const HwId& addId, MonitorObject*& mo) {
130 
132  if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
133  cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
134  }
135 
137  if (cscPointer != cscData.end()) {
138  CSCHistoMapType::const_iterator hit = cscPointer->mos.find(boost::make_tuple(id, addId));
139  if (hit != cscPointer->mos.end()) {
140  mo = const_cast<MonitorObject*>(hit->mo);
141  return true;
142  }
143  }
144  return false;
145  }
146 
153  const bool Cache::getPar(const HistoId& id, MonitorObject*& mo) {
154  if (data[id]) {
155  mo = data[id];
156  return true;
157  }
158  return false;
159  }
160 
168 
169  HistoId id = histo.getId();
170 
172  if (typeid(histo) == EMUHistoDefT) {
173  data[id] = mo;
174  } else
175 
177  if (typeid(histo) == FEDHistoDefT) {
178 
179  HwId fedId = histo.getFEDId();
180 
181  if (fedPointerValue != fedId) {
182  fedPointer = fedData.find(fedId);
183  }
184 
185  if (fedPointer == fedData.end()) {
187  for (unsigned int i = 0; i < h::namesSize; i++) mos[i] = nullptr;
188  fedPointer = fedData.insert(fedData.end(), std::make_pair(fedId, mos));
189  }
190 
191  fedPointer->second[id] = mo;
193 
194  } else
195 
197  if (typeid(histo) == DDUHistoDefT) {
198 
199  HwId dduId = histo.getDDUId();
200 
201  if (dduPointerValue != dduId) {
202  dduPointer = dduData.find(dduId);
203  }
204 
205  if (dduPointer == dduData.end()) {
207  for (unsigned int i = 0; i < h::namesSize; i++) mos[i] = nullptr;
208  dduPointer = dduData.insert(dduData.end(), std::make_pair(dduId, mos));
209  }
210 
211  dduPointer->second[id] = mo;
212  dduPointerValue = dduId;
213 
214  } else
215 
217  if (typeid(histo) == CSCHistoDefT) {
218 
219  HwId crateId = histo.getCrateId();
220  HwId dmbId = histo.getDMBId();
221  HwId addId = histo.getAddId();
222 
223  CSCHistoKeyType histoKey(id, addId, mo);
224 
225  if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
226  cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
227  }
228 
229  if (cscPointer == cscData.end()) {
230  CSCKeyType cscKey(crateId, dmbId);
231  cscPointer = cscData.insert(cscData.end(), cscKey);
232  }
233  CSCHistoMapType* mos = const_cast<CSCHistoMapType*>(&cscPointer->mos);
234  mos->insert(histoKey);
235 
236  } else
237 
239  if (typeid(histo) == ParHistoDefT) {
240  data[id] = mo;
241  }
242 
243 
245  if (mo) {
246  lookupData.insert(lookupData.end(), LookupKeyType(histo, mo));
247  }
248 
249  }
250 
258  const bool Cache::nextBookedCSC(unsigned int& n, unsigned int& crateId, unsigned int& dmbId) const {
259  if (n < cscData.size()) {
260  CSCMapType::const_iterator iter = cscData.begin();
261  for (unsigned int i = n; i > 0; i--) iter++;
262  crateId = iter->crateId;
263  dmbId = iter->dmbId;
264  n++;
265  return true;
266  }
267  return false;
268  }
269 
276  const bool Cache::nextBookedFED(unsigned int& n, unsigned int& fedId) const {
277  if (n < fedData.size()) {
278  FEDMapType::const_iterator iter = fedData.begin();
279  for (unsigned int i = n; i > 0; i--) iter++;
280  fedId = iter->first;
281  n++;
282  return true;
283  }
284  return false;
285  }
286 
287 
294  const bool Cache::nextBookedDDU(unsigned int& n, unsigned int& dduId) const {
295  if (n < dduData.size()) {
296  DDUMapType::const_iterator iter = dduData.begin();
297  for (unsigned int i = n; i > 0; i--) iter++;
298  dduId = iter->first;
299  n++;
300  return true;
301  }
302  return false;
303  }
304 
311  const bool Cache::isBookedCSC(const HwId& crateId, const HwId& dmbId) const {
312  CSCMapType::const_iterator it = cscData.find(boost::make_tuple(crateId, dmbId));
313  if (it != cscData.end()) {
314  return true;
315  }
316  return false;
317  }
318 
324  const bool Cache::isBookedFED(const HwId& fedId) const {
325  FEDMapType::const_iterator iter = fedData.find(fedId);
326  return (iter != fedData.end());
327  }
328 
334  const bool Cache::isBookedDDU(const HwId& dduId) const {
335  DDUMapType::const_iterator iter = dduData.find(dduId);
336  return (iter != dduData.end());
337  }
338 
339 }
const bool getFED(const HistoId &id, const HwId &fedId, MonitorObject *&mo)
Get FED MO on Histogram Id and FED Id.
Definition: CSCDQM_Cache.cc:71
unsigned int HwId
static const std::type_info & FEDHistoDefT
const bool isBookedDDU(const HwId &dduId) const
Check if DDU was booked on given identifier.
virtual const HwId getCrateId() const
Get CSC Crate ID.
DDUMapType dduData
Definition: CSCDQM_Cache.h:128
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:56
const bool nextBookedCSC(unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
Iterator to get booked CSC identifiers on enumerator.
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
Abstract Base Histogram Definition.
MonitorObject * data[h::namesSize]
Definition: CSCDQM_Cache.h:117
virtual const HwId getDDUId() const
Get DDU ID.
const bool nextBookedDDU(unsigned int &n, unsigned int &dduId) const
Iterator to get booked DDU identifier on enumerator.
static const unsigned int namesSize
unsigned int HistoId
const HistoId getId() const
Get Histogram ID.
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
const bool nextBookedFED(unsigned int &n, unsigned int &fedId) const
Iterator to get booked FED identifier on enumerator.
HwId dduPointerValue
Definition: CSCDQM_Cache.h:132
static const std::type_info & CSCHistoDefT
DDUMapType::const_iterator dduPointer
Definition: CSCDQM_Cache.h:130
CSCMapType::const_iterator cscPointer
Definition: CSCDQM_Cache.h:137
static const std::type_info & ParHistoDefT
MO Lookup List object definition.
Definition: CSCDQM_Cache.h:90
Chamber List object definition.
Definition: CSCDQM_Cache.h:62
FEDMapType::const_iterator fedPointer
Definition: CSCDQM_Cache.h:122
virtual const HwId getDMBId() const
Get CSC DMB ID.
FEDMapType fedData
Definition: CSCDQM_Cache.h:120
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:59
const bool getDDU(const HistoId &id, const HwId &dduId, MonitorObject *&mo)
Get DDU MO on Histogram Id and DDU Id.
static const std::type_info & DDUHistoDefT
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
Chamber MO List object definition.
Definition: CSCDQM_Cache.h:40
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
CSCMapType cscData
Definition: CSCDQM_Cache.h:135
static const std::type_info & EMUHistoDefT
const bool get(const HistoDef &histo, MonitorObject *&mo)
Get Monitoring Object on Histogram Definition.
Definition: CSCDQM_Cache.cc:29
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.
virtual const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
virtual const HwId getFEDId() const
Get FED ID.
LookupMapType lookupData
Definition: CSCDQM_Cache.h:140
HwId fedPointerValue
Definition: CSCDQM_Cache.h:124