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  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()) {
174  MonitorObject** mos = new MonitorObject*[h::namesSize];
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()) {
194  MonitorObject** mos = new MonitorObject*[h::namesSize];
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
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
mps_fire.i
i
Definition: mps_fire.py:428
cscdqm::HistoDef
Abstract Base Histogram Definition.
Definition: CSCDQM_HistoDef.h:62
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::CSCHistoKeyType
Chamber MO List object definition.
Definition: CSCDQM_Cache.h:38
cscdqm::Cache::data
MonitorObject * data[h::namesSize]
Definition: CSCDQM_Cache.h:102
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::CSCHistoDefT
static const std::type_info & CSCHistoDefT
Definition: CSCDQM_HistoDef.h:453
CSCDQM_Cache.h
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::CSCKeyType
Chamber List object definition.
Definition: CSCDQM_Cache.h:56
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::DDUHistoDefT
static const std::type_info & DDUHistoDefT
Definition: CSCDQM_HistoDef.h:452
cscdqm::Cache::cscData
CSCMapType cscData
Definition: CSCDQM_Cache.h:119
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
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
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
cscdqm::ParHistoDefT
static const std::type_info & ParHistoDefT
Definition: CSCDQM_HistoDef.h:454
cscdqm::FEDHistoDefT
static const std::type_info & FEDHistoDefT
Definition: CSCDQM_HistoDef.h:451
cscdqm::Cache::isBookedFED
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
Definition: CSCDQM_Cache.cc:312
cscdqm::Cache::fedData
FEDMapType fedData
Definition: CSCDQM_Cache.h:105
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
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::Cache::put
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
Definition: CSCDQM_Cache.cc:157
cscdqm::Cache::getEMU
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:51
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::EMUHistoDefT
static const std::type_info & EMUHistoDefT
Definition: CSCDQM_HistoDef.h:450
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
hit
Definition: SiStripHitEffFromCalibTree.cc:88