CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  if (typeid(histo) == EMUHistoDefT) {
31  return getEMU(histo.getId(), mo);
32  } else if (typeid(histo) == FEDHistoDefT) {
33  return getFED(histo.getId(), histo.getFEDId(), mo);
34  } else if (typeid(histo) == DDUHistoDefT) {
35  return getDDU(histo.getId(), histo.getDDUId(), mo);
36  } else if (typeid(histo) == CSCHistoDefT) {
37  return getCSC(histo.getId(), histo.getCrateId(), histo.getDMBId(), histo.getAddId(), mo);
38  } else if (typeid(histo) == ParHistoDefT) {
39  return getPar(histo.getId(), mo);
40  }
41 
42  return false;
43  }
44 
51  const bool Cache::getEMU(const HistoId& id, MonitorObject*& mo) {
52  if (data[id]) {
53  mo = data[id];
54  return true;
55  }
56  return false;
57  }
58 
66  const bool Cache::getFED(const HistoId& id, const HwId& fedId, MonitorObject*& mo) {
68  if (fedPointerValue != fedId) {
69  fedPointer = fedData.find(fedId);
70  if (fedPointer == fedData.end()) {
71  fedPointerValue = 0;
72  return false;
73  }
75  }
76 
78  if (fedPointer->second[id]) {
79  mo = fedPointer->second[id];
80  return true;
81  }
82  return false;
83  }
84 
92  const bool Cache::getDDU(const HistoId& id, const HwId& dduId, MonitorObject*& mo) {
94  if (dduPointerValue != dduId) {
95  dduPointer = dduData.find(dduId);
96  if (dduPointer == dduData.end()) {
97  dduPointerValue = 0;
98  return false;
99  }
100  dduPointerValue = dduId;
101  }
102 
104  if (dduPointer->second[id]) {
105  mo = dduPointer->second[id];
106  return true;
107  }
108  return false;
109  }
110 
119  const bool Cache::getCSC(
120  const HistoId& id, const HwId& crateId, const HwId& dmbId, const HwId& addId, MonitorObject*& mo) {
122  if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
123  cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
124  }
125 
127  if (cscPointer != cscData.end()) {
128  CSCHistoMapType::const_iterator hit = cscPointer->mos.find(boost::make_tuple(id, addId));
129  if (hit != cscPointer->mos.end()) {
130  mo = const_cast<MonitorObject*>(hit->mo);
131  return true;
132  }
133  }
134  return false;
135  }
136 
143  const bool Cache::getPar(const HistoId& id, MonitorObject*& mo) {
144  if (data[id]) {
145  mo = data[id];
146  return true;
147  }
148  return false;
149  }
150 
158  HistoId id = histo.getId();
159 
161  if (typeid(histo) == EMUHistoDefT) {
162  data[id] = mo;
163  } else
164 
166  if (typeid(histo) == FEDHistoDefT) {
167  HwId fedId = histo.getFEDId();
168 
169  if (fedPointerValue != fedId) {
170  fedPointer = fedData.find(fedId);
171  }
172 
173  if (fedPointer == fedData.end()) {
175  for (unsigned int i = 0; i < h::namesSize; i++)
176  mos[i] = nullptr;
177  fedPointer = fedData.insert(fedData.end(), std::make_pair(fedId, mos));
178  }
179 
180  fedPointer->second[id] = mo;
182 
183  } else
184 
186  if (typeid(histo) == DDUHistoDefT) {
187  HwId dduId = histo.getDDUId();
188 
189  if (dduPointerValue != dduId) {
190  dduPointer = dduData.find(dduId);
191  }
192 
193  if (dduPointer == dduData.end()) {
195  for (unsigned int i = 0; i < h::namesSize; i++)
196  mos[i] = nullptr;
197  dduPointer = dduData.insert(dduData.end(), std::make_pair(dduId, mos));
198  }
199 
200  dduPointer->second[id] = mo;
201  dduPointerValue = dduId;
202 
203  } else
204 
206  if (typeid(histo) == CSCHistoDefT) {
207  HwId crateId = histo.getCrateId();
208  HwId dmbId = histo.getDMBId();
209  HwId addId = histo.getAddId();
210 
211  CSCHistoKeyType histoKey(id, addId, mo);
212 
213  if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
214  cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
215  }
216 
217  if (cscPointer == cscData.end()) {
218  CSCKeyType cscKey(crateId, dmbId);
219  cscPointer = cscData.insert(cscData.end(), cscKey);
220  }
221  CSCHistoMapType* mos = const_cast<CSCHistoMapType*>(&cscPointer->mos);
222  mos->insert(histoKey);
223 
224  } else
225 
227  if (typeid(histo) == ParHistoDefT) {
228  data[id] = mo;
229  }
230 
232  if (mo) {
233  lookupData.insert(lookupData.end(), LookupKeyType(histo, mo));
234  }
235  }
236 
244  const bool Cache::nextBookedCSC(unsigned int& n, unsigned int& crateId, unsigned int& dmbId) const {
245  if (n < cscData.size()) {
246  CSCMapType::const_iterator iter = cscData.begin();
247  for (unsigned int i = n; i > 0; i--)
248  iter++;
249  crateId = iter->crateId;
250  dmbId = iter->dmbId;
251  n++;
252  return true;
253  }
254  return false;
255  }
256 
263  const bool Cache::nextBookedFED(unsigned int& n, unsigned int& fedId) const {
264  if (n < fedData.size()) {
265  FEDMapType::const_iterator iter = fedData.begin();
266  for (unsigned int i = n; i > 0; i--)
267  iter++;
268  fedId = iter->first;
269  n++;
270  return true;
271  }
272  return false;
273  }
274 
281  const bool Cache::nextBookedDDU(unsigned int& n, unsigned int& dduId) const {
282  if (n < dduData.size()) {
283  DDUMapType::const_iterator iter = dduData.begin();
284  for (unsigned int i = n; i > 0; i--)
285  iter++;
286  dduId = iter->first;
287  n++;
288  return true;
289  }
290  return false;
291  }
292 
299  const bool Cache::isBookedCSC(const HwId& crateId, const HwId& dmbId) const {
300  CSCMapType::const_iterator it = cscData.find(boost::make_tuple(crateId, dmbId));
301  if (it != cscData.end()) {
302  return true;
303  }
304  return false;
305  }
306 
312  const bool Cache::isBookedFED(const HwId& fedId) const {
313  FEDMapType::const_iterator iter = fedData.find(fedId);
314  return (iter != fedData.end());
315  }
316 
322  const bool Cache::isBookedDDU(const HwId& dduId) const {
323  DDUMapType::const_iterator iter = dduData.find(dduId);
324  return (iter != dduData.end());
325  }
326 
327 } // namespace cscdqm
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
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:112
uint16_t *__restrict__ id
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:51
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:102
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.
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
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:116
static const std::type_info & CSCHistoDefT
DDUMapType::const_iterator dduPointer
Definition: CSCDQM_Cache.h:114
CSCMapType::const_iterator cscPointer
Definition: CSCDQM_Cache.h:121
static const std::type_info & ParHistoDefT
MO Lookup List object definition.
Definition: CSCDQM_Cache.h:79
Chamber List object definition.
Definition: CSCDQM_Cache.h:56
FEDMapType::const_iterator fedPointer
Definition: CSCDQM_Cache.h:107
virtual const HwId getDMBId() const
Get CSC DMB ID.
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
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:38
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
CSCMapType cscData
Definition: CSCDQM_Cache.h:119
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:124
HwId fedPointerValue
Definition: CSCDQM_Cache.h:109