CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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) == DDUHistoDefT) {
35  return getDDU(histo.getId(), histo.getDDUId(), mo);
36  } else
37  if (typeid(histo) == CSCHistoDefT) {
38  return getCSC(histo.getId(), histo.getCrateId(), histo.getDMBId(), histo.getAddId(), mo);
39  } else
40  if (typeid(histo) == ParHistoDefT) {
41  return getPar(histo.getId(), mo);
42  }
43 
44  return false;
45  }
46 
53  const bool Cache::getEMU(const HistoId& id, MonitorObject*& mo) {
54  if (data[id]) {
55  mo = data[id];
56  return true;
57  }
58  return false;
59  }
60 
68  const bool Cache::getDDU(const HistoId& id, const HwId& dduId, MonitorObject*& mo) {
69 
71  if (dduPointerValue != dduId) {
72  dduPointer = dduData.find(dduId);
73  if (dduPointer == dduData.end()) {
74  dduPointerValue = 0;
75  return false;
76  }
77  dduPointerValue = dduId;
78  }
79 
81  if (dduPointer->second[id]) {
82  mo = dduPointer->second[id];
83  return true;
84  }
85  return false;
86 
87  }
88 
97  const bool Cache::getCSC(const HistoId& id, const HwId& crateId, const HwId& dmbId, const HwId& addId, MonitorObject*& mo) {
98 
100  if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
101  cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
102  }
103 
105  if (cscPointer != cscData.end()) {
106  CSCHistoMapType::const_iterator hit = cscPointer->mos.find(boost::make_tuple(id, addId));
107  if (hit != cscPointer->mos.end()) {
108  mo = const_cast<MonitorObject*>(hit->mo);
109  return true;
110  }
111  }
112  return false;
113  }
114 
121  const bool Cache::getPar(const HistoId& id, MonitorObject*& mo) {
122  if (data[id]) {
123  mo = data[id];
124  return true;
125  }
126  return false;
127  }
128 
136 
137  HistoId id = histo.getId();
138 
140  if (typeid(histo) == EMUHistoDefT) {
141  data[id] = mo;
142  } else
143 
145  if (typeid(histo) == DDUHistoDefT) {
146 
147  HwId dduId = histo.getDDUId();
148 
149  if (dduPointerValue != dduId) {
150  dduPointer = dduData.find(dduId);
151  }
152 
153  if (dduPointer == dduData.end()) {
155  for (unsigned int i = 0; i < h::namesSize; i++) mos[i] = 0;
156  dduPointer = dduData.insert(dduData.end(), std::make_pair(dduId, mos));
157  }
158 
159  dduPointer->second[id] = mo;
160  dduPointerValue = dduId;
161 
162  } else
163 
165  if (typeid(histo) == CSCHistoDefT) {
166 
167  HwId crateId = histo.getCrateId();
168  HwId dmbId = histo.getDMBId();
169  HwId addId = histo.getAddId();
170 
171  CSCHistoKeyType histoKey(id, addId, mo);
172 
173  if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
174  cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
175  }
176 
177  if (cscPointer == cscData.end()) {
178  CSCKeyType cscKey(crateId, dmbId);
179  cscPointer = cscData.insert(cscData.end(), cscKey);
180  }
181  CSCHistoMapType* mos = const_cast<CSCHistoMapType*>(&cscPointer->mos);
182  mos->insert(histoKey);
183 
184  } else
185 
187  if (typeid(histo) == ParHistoDefT) {
188  data[id] = mo;
189  }
190 
191 
193  if (mo) {
194  lookupData.insert(lookupData.end(), LookupKeyType(histo, mo));
195  }
196 
197  }
198 
206  const bool Cache::nextBookedCSC(unsigned int& n, unsigned int& crateId, unsigned int& dmbId) const {
207  if (n < cscData.size()) {
208  CSCMapType::const_iterator iter = cscData.begin();
209  for (unsigned int i = n; i > 0; i--) iter++;
210  crateId = iter->crateId;
211  dmbId = iter->dmbId;
212  n++;
213  return true;
214  }
215  return false;
216  }
217 
224  const bool Cache::nextBookedDDU(unsigned int& n, unsigned int& dduId) const {
225  if (n < dduData.size()) {
226  DDUMapType::const_iterator iter = dduData.begin();
227  for (unsigned int i = n; i > 0; i--) iter++;
228  dduId = iter->first;
229  n++;
230  return true;
231  }
232  return false;
233  }
234 
241  const bool Cache::isBookedCSC(const HwId& crateId, const HwId& dmbId) const {
242  CSCMapType::const_iterator it = cscData.find(boost::make_tuple(crateId, dmbId));
243  if (it != cscData.end()) {
244  return true;
245  }
246  return false;
247  }
248 
254  const bool Cache::isBookedDDU(const HwId& dduId) const {
255  DDUMapType::const_iterator iter = dduData.find(dduId);
256  return (iter != dduData.end());
257  }
258 
259 }
int i
Definition: DBlmapReader.cc:9
unsigned int HwId
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:117
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:53
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:114
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.
tuple histo
Definition: trackerHits.py:12
unsigned int HistoId
const HistoId getId() const
Get Histogram ID.
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
HwId dduPointerValue
Definition: CSCDQM_Cache.h:121
static const std::type_info & CSCHistoDefT
DDUMapType::const_iterator dduPointer
Definition: CSCDQM_Cache.h:119
CSCMapType::const_iterator cscPointer
Definition: CSCDQM_Cache.h:126
static const std::type_info & ParHistoDefT
MO Lookup List object definition.
Definition: CSCDQM_Cache.h:87
Chamber List object definition.
Definition: CSCDQM_Cache.h:62
virtual const HwId getDMBId() const
Get CSC DMB ID.
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.
Definition: CSCDQM_Cache.cc:68
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:124
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
static const unsigned int namesSize
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:97
virtual const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
LookupMapType lookupData
Definition: CSCDQM_Cache.h:129