CMS 3D CMS Logo

Public Member Functions | Private Attributes

cscdqm::Cache Class Reference

MonitorObject cache - list objects and routines to manage cache. More...

#include <CSCDQM_Cache.h>

List of all members.

Public Member Functions

 Cache ()
const bool get (const HistoDef &histo, MonitorObject *&mo)
 Get Monitoring Object on Histogram Definition.
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.
const bool getDDU (const HistoId &id, const HwId &dduId, MonitorObject *&mo)
 Get DDU MO on Histogram Id and DDU Id.
const bool getEMU (const HistoId &id, MonitorObject *&mo)
 Get EMU MO on Histogram Id.
const bool getPar (const HistoId &id, MonitorObject *&mo)
 Get Parameter MO on Histogram Id.
const bool isBookedCSC (const HwId &crateId, const HwId &dmbId) const
 Check if CSC was booked on given identifiers.
const bool isBookedDDU (const HwId &dduId) const
 Check if DDU was booked on given identifier.
const bool nextBookedCSC (unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
 Iterator to get booked CSC identifiers on enumerator.
const bool nextBookedDDU (unsigned int &n, unsigned int &dduId) const
 Iterator to get booked DDU identifier on enumerator.
void put (const HistoDef &histo, MonitorObject *mo)
 Put Monitoring Object into cache.
 ~Cache ()

Private Attributes

CSCMapType cscData
CSCMapType::const_iterator cscPointer
MonitorObjectdata [h::namesSize]
DDUMapType dduData
DDUMapType::const_iterator dduPointer
HwId dduPointerValue
LookupMapType lookupData

Detailed Description

MonitorObject cache - list objects and routines to manage cache.

Definition at line 109 of file CSCDQM_Cache.h.


Constructor & Destructor Documentation

cscdqm::Cache::Cache ( ) [inline]

Cache Constructor

Initialize EMU and PAR static array with zero's

Initialize DDU and CSC cached pointers

Definition at line 134 of file CSCDQM_Cache.h.

References cscData, cscPointer, data, dduData, dduPointer, dduPointerValue, i, and h::namesSize.

              {
        
        for (unsigned int i = 0; i < h::namesSize; i++) data[i] = 0;

        dduPointer = dduData.end();
        dduPointerValue = 0;
        cscPointer = cscData.end();
      }
cscdqm::Cache::~Cache ( ) [inline]

Destructor

Clear DDU MO static arrays

Definition at line 146 of file CSCDQM_Cache.h.

References dduData.

               {
        while (dduData.begin() != dduData.end()) {
          if (dduData.begin()->second) {
            delete [] dduData.begin()->second;
          }
          dduData.erase(dduData.begin());
        }
      }

Member Function Documentation

const bool cscdqm::Cache::get ( const HistoDef histo,
MonitorObject *&  mo 
)

Get Monitoring Object on Histogram Definition.

Native Cache methods

Parameters:
histoHistogram definition
moMonitoring Object to return
Returns:
true if MO was found in cache and false otherwise

Definition at line 29 of file CSCDQM_Cache.cc.

References cscdqm::CSCHistoDefT, cscdqm::DDUHistoDefT, cscdqm::EMUHistoDefT, cscdqm::HistoDef::getAddId(), cscdqm::HistoDef::getCrateId(), getCSC(), getDDU(), cscdqm::HistoDef::getDDUId(), cscdqm::HistoDef::getDMBId(), getEMU(), cscdqm::HistoDef::getId(), getPar(), and cscdqm::ParHistoDefT.

Referenced by cscdqm::Dispatcher::getHisto().

                                                                 {

    if (typeid(histo) == EMUHistoDefT) {
      return getEMU(histo.getId(), mo);
    } else
    if (typeid(histo) == DDUHistoDefT) {
      return getDDU(histo.getId(), histo.getDDUId(), mo);
    } else
    if (typeid(histo) == CSCHistoDefT) {
      return getCSC(histo.getId(), histo.getCrateId(), histo.getDMBId(), histo.getAddId(), mo);
    } else
    if (typeid(histo) == ParHistoDefT) {
      return getPar(histo.getId(), mo);
    }

    return false;
  }
const bool cscdqm::Cache::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.

Parameters:
idHistogram identifier
crateIdCSC Crate identifier
dmbIdCSC DMB identifier
moMonitoring Object to return
Returns:
true if MO was found in cache and false otherwise

If not cached (last CSC) - find CSC

Get Monitor object from multi_index List

Definition at line 97 of file CSCDQM_Cache.cc.

References cscData, and cscPointer.

Referenced by cscdqm::Dispatcher::Dispatcher(), and get().

                                                                                                                           {

    if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
      cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
    }

    if (cscPointer != cscData.end()) {
      CSCHistoMapType::const_iterator hit = cscPointer->mos.find(boost::make_tuple(id, addId));
      if (hit != cscPointer->mos.end()) {
        mo = const_cast<MonitorObject*>(hit->mo);
        return true;
      }
    }
    return false;
  }
const bool cscdqm::Cache::getDDU ( const HistoId id,
const HwId dduId,
MonitorObject *&  mo 
)

Get DDU MO on Histogram Id and DDU Id.

Parameters:
idHistogram identifier
dduIdDDU identifier
moMonitoring Object to return
Returns:
true if MO was found in cache and false otherwise

If not cached (last DDU) - find DDU

Get MO from static array

Definition at line 68 of file CSCDQM_Cache.cc.

References dduData, dduPointer, dduPointerValue, and ExpressReco_HICollisions_FallBack::id.

Referenced by cscdqm::Dispatcher::Dispatcher(), and get().

                                                                                   {

    if (dduPointerValue != dduId) {
      dduPointer = dduData.find(dduId);
      if (dduPointer == dduData.end()) {
        dduPointerValue = 0;
        return false;
      }
      dduPointerValue  = dduId;
    } 

    if (dduPointer->second[id]) {
      mo = dduPointer->second[id];
      return true;
    }
    return false;

  }
const bool cscdqm::Cache::getEMU ( const HistoId id,
MonitorObject *&  mo 
)

Get EMU MO on Histogram Id.

Parameters:
idHistogram identifier
moMonitoring Object to return
Returns:
true if MO was found in cache and false otherwise

Definition at line 53 of file CSCDQM_Cache.cc.

References data, and ExpressReco_HICollisions_FallBack::id.

Referenced by cscdqm::Dispatcher::Dispatcher(), and get().

                                                                {
    if (data[id]) {
      mo = data[id];
      return true;
    }
    return false;
  }
const bool cscdqm::Cache::getPar ( const HistoId id,
MonitorObject *&  mo 
)

Get Parameter MO on Histogram Id.

Parameters:
idHistogram identifier
moMonitoring Object to return
Returns:
true if MO was found in cache and false otherwise

Definition at line 121 of file CSCDQM_Cache.cc.

References data, and ExpressReco_HICollisions_FallBack::id.

Referenced by cscdqm::Dispatcher::Dispatcher(), and get().

                                                                {
    if (data[id]) {
      mo = data[id];
      return true;
    }
    return false;
  }
const bool cscdqm::Cache::isBookedCSC ( const HwId crateId,
const HwId dmbId 
) const

Check if CSC was booked on given identifiers.

Parameters:
crateIdCSC Crate Id
dmbIdCSC DMB Id
Returns:
true if CSC was booked, false - otherwise

Definition at line 241 of file CSCDQM_Cache.cc.

References cscData.

Referenced by cscdqm::Dispatcher::Dispatcher(), and cscdqm::Dispatcher::getHisto().

                                                                            {
    CSCMapType::const_iterator it = cscData.find(boost::make_tuple(crateId, dmbId));
    if (it != cscData.end()) {
      return true;
    }
    return false;
  }
const bool cscdqm::Cache::isBookedDDU ( const HwId dduId) const

Check if DDU was booked on given identifier.

Parameters:
dduIdDDU Id
Returns:
true if DDU was booked, false - otherwise

Definition at line 254 of file CSCDQM_Cache.cc.

References dduData.

Referenced by cscdqm::Dispatcher::Dispatcher(), and cscdqm::Dispatcher::getHisto().

                                                       {
    DDUMapType::const_iterator iter = dduData.find(dduId);
    return (iter != dduData.end());
  }
const bool cscdqm::Cache::nextBookedCSC ( unsigned int &  n,
unsigned int &  crateId,
unsigned int &  dmbId 
) const

Iterator to get booked CSC identifiers on enumerator.

Parameters:
niterator (0 and up)
crateIdCSC Crate Id returned
dmbIdCSC DMB Id returned
Returns:
true if CSC on n found, false - otherwise

Definition at line 206 of file CSCDQM_Cache.cc.

References cscData, and i.

Referenced by cscdqm::Dispatcher::Dispatcher().

                                                                                                   {
    if (n < cscData.size()) {
      CSCMapType::const_iterator iter = cscData.begin();
      for (unsigned int i = n; i > 0; i--) iter++;
      crateId = iter->crateId;
      dmbId   = iter->dmbId;
      n++;
      return true;
    }
    return false;
  }
const bool cscdqm::Cache::nextBookedDDU ( unsigned int &  n,
unsigned int &  dduId 
) const

Iterator to get booked DDU identifier on enumerator.

Utility methods

Parameters:
niterator (0 and up)
dduIdDDU Id returned
Returns:
true if DDU on n found, false - otherwise

Definition at line 224 of file CSCDQM_Cache.cc.

References dduData, and i.

                                                                            {
    if (n < dduData.size()) {
      DDUMapType::const_iterator iter = dduData.begin();
      for (unsigned int i = n; i > 0; i--) iter++;
      dduId = iter->first;
      n++;
      return true;
    }
    return false;
  }
void cscdqm::Cache::put ( const HistoDef histo,
MonitorObject mo 
)

Put Monitoring Object into cache.

Parameters:
histoHistogram Definition
moMonitoring Object to put
Returns:

EMU MO

DDU MO

CSC MO

Parameter MO

Add histo (if mo is not null!) into lookup list

Definition at line 135 of file CSCDQM_Cache.cc.

References cscData, cscdqm::CSCHistoDefT, cscPointer, data, dduData, cscdqm::DDUHistoDefT, dduPointer, dduPointerValue, cscdqm::EMUHistoDefT, cscdqm::HistoDef::getAddId(), cscdqm::HistoDef::getCrateId(), cscdqm::HistoDef::getDDUId(), cscdqm::HistoDef::getDMBId(), cscdqm::HistoDef::getId(), i, ExpressReco_HICollisions_FallBack::id, lookupData, h::namesSize, and cscdqm::ParHistoDefT.

Referenced by cscdqm::Dispatcher::Dispatcher(), and cscdqm::Dispatcher::getHisto().

                                                          {

    HistoId id = histo.getId();

    if (typeid(histo) == EMUHistoDefT) {
      data[id] = mo;
    } else

    if (typeid(histo) == DDUHistoDefT) {

      HwId dduId = histo.getDDUId();

      if (dduPointerValue != dduId) {
        dduPointer = dduData.find(dduId);
      } 

      if (dduPointer == dduData.end()) {
        MonitorObject** mos = new MonitorObject*[h::namesSize];
        for (unsigned int i = 0; i < h::namesSize; i++) mos[i] = 0;
        dduPointer = dduData.insert(dduData.end(), std::make_pair(dduId, mos));
      }

      dduPointer->second[id] = mo;
      dduPointerValue = dduId;

    } else

    if (typeid(histo) == CSCHistoDefT) {

      HwId crateId = histo.getCrateId();
      HwId dmbId = histo.getDMBId();
      HwId addId = histo.getAddId();

      CSCHistoKeyType histoKey(id, addId, mo);

      if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
        cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
      } 

      if (cscPointer == cscData.end()) {
        CSCKeyType cscKey(crateId, dmbId);
        cscPointer = cscData.insert(cscData.end(), cscKey);
      }
      CSCHistoMapType* mos = const_cast<CSCHistoMapType*>(&cscPointer->mos);
      mos->insert(histoKey);

    } else

    if (typeid(histo) == ParHistoDefT) {
      data[id] = mo;
    }


    if (mo) {
      lookupData.insert(lookupData.end(), LookupKeyType(histo, mo));
    }

  }

Member Data Documentation

Chamber MO List

Definition at line 124 of file CSCDQM_Cache.h.

Referenced by Cache(), getCSC(), isBookedCSC(), nextBookedCSC(), and put().

CSCMapType::const_iterator cscdqm::Cache::cscPointer [private]

Pointer to the Last Chamber object used (cached)

Definition at line 126 of file CSCDQM_Cache.h.

Referenced by Cache(), getCSC(), and put().

EMU and PAR MO static List

Definition at line 114 of file CSCDQM_Cache.h.

Referenced by Cache(), getEMU(), getPar(), and put().

DDU MO List

Definition at line 117 of file CSCDQM_Cache.h.

Referenced by Cache(), getDDU(), isBookedDDU(), nextBookedDDU(), put(), and ~Cache().

DDUMapType::const_iterator cscdqm::Cache::dduPointer [private]

Pointer to the Last DDU object used (cached)

Definition at line 119 of file CSCDQM_Cache.h.

Referenced by Cache(), getDDU(), and put().

Last DDU id used (cached)

Definition at line 121 of file CSCDQM_Cache.h.

Referenced by Cache(), getDDU(), and put().

MO Lookup List

Definition at line 129 of file CSCDQM_Cache.h.

Referenced by put().