CMS 3D CMS Logo

cscdqm::Cache Class Reference

MonitorObject cache - lists and routines to manage cache. More...

#include <DQM/CSCMonitorModule/interface/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)
const bool getDDU (const HistoId &id, const HwId &dduId, MonitorObject *&mo)
const bool getEMU (const HistoId &id, MonitorObject *&mo)
const bool getPar (const HistoId &id, MonitorObject *&mo)
const bool isBookedCSC (const HwId &crateId, const HwId &dmbId) const
const bool isBookedDDU (const HwId &dduId) const
const bool nextBookedCSC (unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
const bool nextBookedDDU (unsigned int &n, unsigned int &dduId) const
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


Detailed Description

MonitorObject cache - lists and routines to manage cache.

Definition at line 84 of file CSCDQM_Cache.h.


Constructor & Destructor Documentation

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

Definition at line 99 of file CSCDQM_Cache.h.

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

00099               {
00100         for (unsigned int i = 0; i < h::namesSize; i++) data[i] = 0;
00101         dduPointer = dduData.end();
00102         dduPointerValue = 0;
00103         cscPointer = cscData.end();
00104       }

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

Definition at line 106 of file CSCDQM_Cache.h.

References dduData, and it.

00106                {
00107         DDUMapType::iterator it;
00108         while (dduData.size() > 0) {
00109           it = dduData.begin();
00110           if (it->second) delete [] it->second;
00111           dduData.erase(it);
00112         }
00113       }


Member Function Documentation

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

Get Monitoring Object on Histogram Definition.

Parameters:
histo Histogram definition
mo Monitoring 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().

00029                                                                  {
00030 
00031     if (typeid(histo) == EMUHistoDefT) {
00032       return getEMU(histo.getId(), mo);
00033     } else
00034     if (typeid(histo) == DDUHistoDefT) {
00035       return getDDU(histo.getId(), histo.getDDUId(), mo);
00036     } else
00037     if (typeid(histo) == CSCHistoDefT) {
00038       return getCSC(histo.getId(), histo.getCrateId(), histo.getDMBId(), histo.getAddId(), mo);
00039     } else
00040     if (typeid(histo) == ParHistoDefT) {
00041       return getPar(histo.getId(), mo);
00042     }
00043 
00044     /*
00045     if (found) {
00046         LOG_DEBUG << "CACHE: histo " << histo << " key " << key << " found in cache: " << mo;
00047     } else {
00048         LOG_DEBUG << "CACHE: histo " << histo << " key " << key << " NOT found in cache.";
00049     }
00050     */
00051     
00052     return false;
00053   }

const bool cscdqm::Cache::getCSC ( const HistoId id,
const HwId crateId,
const HwId dmbId,
const HwId addId,
MonitorObject *&  mo 
)

Definition at line 82 of file CSCDQM_Cache.cc.

References cscData, and cscPointer.

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

00082                                                                                                                            {
00083 
00084     if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
00085       cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
00086     }
00087 
00088     if (cscPointer != cscData.end()) {
00089       CSCHistoMapType::const_iterator hit = cscPointer->mos.find(boost::make_tuple(id, addId));
00090       if (hit != cscPointer->mos.end()) {
00091         mo = const_cast<MonitorObject*>(hit->mo);
00092         return true;
00093       }
00094     }
00095     return false;
00096   }

const bool cscdqm::Cache::getDDU ( const HistoId id,
const HwId dduId,
MonitorObject *&  mo 
)

Definition at line 63 of file CSCDQM_Cache.cc.

References dduData, dduPointer, and dduPointerValue.

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

00063                                                                                    {
00064 
00065     if (dduPointerValue != dduId) {
00066       dduPointer = dduData.find(dduId);
00067       if (dduPointer == dduData.end()) {
00068         dduPointerValue = 0;
00069         return false;
00070       }
00071       dduPointerValue  = dduId;
00072     } 
00073 
00074     if (dduPointer->second[id]) {
00075       mo = dduPointer->second[id];
00076       return true;
00077     }
00078     return false;
00079 
00080   }

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

Definition at line 55 of file CSCDQM_Cache.cc.

References data.

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

00055                                                                 {
00056     if (data[id]) {
00057       mo = data[id];
00058       return true;
00059     }
00060     return false;
00061   }

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

Definition at line 98 of file CSCDQM_Cache.cc.

References data.

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

00098                                                                 {
00099     if (data[id]) {
00100       mo = data[id];
00101       return true;
00102     }
00103     return false;
00104   }

const bool cscdqm::Cache::isBookedCSC ( const HwId crateId,
const HwId dmbId 
) const

Definition at line 189 of file CSCDQM_Cache.cc.

References cscData, and it.

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

00189                                                                             {
00190     CSCMapType::const_iterator it = cscData.find(boost::make_tuple(crateId, dmbId));
00191     if (it != cscData.end()) {
00192       return true;
00193     }
00194     return false;
00195   }

const bool cscdqm::Cache::isBookedDDU ( const HwId dduId  )  const

Definition at line 197 of file CSCDQM_Cache.cc.

References dduData, and iter.

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

00197                                                        {
00198     DDUMapType::const_iterator iter = dduData.find(dduId);
00199     return (iter != dduData.end());
00200   }

const bool cscdqm::Cache::nextBookedCSC ( unsigned int n,
unsigned int crateId,
unsigned int dmbId 
) const

Definition at line 166 of file CSCDQM_Cache.cc.

References cscData, i, and iter.

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

00166                                                                                                    {
00167     if (n < cscData.size()) {
00168       CSCMapType::const_iterator iter = cscData.begin();
00169       for (unsigned int i = n; i > 0; i--) iter++;
00170       crateId = iter->crateId;
00171       dmbId   = iter->dmbId;
00172       n++;
00173       return true;
00174     }
00175     return false;
00176   }

const bool cscdqm::Cache::nextBookedDDU ( unsigned int n,
unsigned int dduId 
) const

Definition at line 178 of file CSCDQM_Cache.cc.

References dduData, i, and iter.

00178                                                                             {
00179     if (n < dduData.size()) {
00180       DDUMapType::const_iterator iter = dduData.begin();
00181       for (unsigned int i = n; i > 0; i--) iter++;
00182       dduId = iter->first;
00183       n++;
00184       return true;
00185     }
00186     return false;
00187   }

void cscdqm::Cache::put ( const HistoDef histo,
MonitorObject mo 
)

Put Monitoring Object into cache.

Parameters:
histo Histogram Definition (to be used to generate cache key)
mo Monitoring Object to put
Returns:

Definition at line 112 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, h::namesSize, and cscdqm::ParHistoDefT.

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

00112                                                           {
00113 
00114     HistoId id = histo.getId();
00115 
00116     if (typeid(histo) == EMUHistoDefT) {
00117       data[id] = mo;
00118     } else
00119 
00120     if (typeid(histo) == DDUHistoDefT) {
00121 
00122       HwId dduId = histo.getDDUId();
00123 
00124       if (dduPointerValue != dduId) {
00125         dduPointer = dduData.find(dduId);
00126       } 
00127 
00128       if (dduPointer == dduData.end()) {
00129         MonitorObject** mos = new MonitorObject*[h::namesSize];
00130         for (unsigned int i = 0; i < h::namesSize; i++) mos[i] = 0;
00131         dduPointer = dduData.insert(dduData.end(), std::make_pair(dduId, mos));
00132       }
00133 
00134       dduPointer->second[id] = mo;
00135       dduPointerValue = dduId;
00136 
00137     } else
00138 
00139     if (typeid(histo) == CSCHistoDefT) {
00140 
00141       HwId crateId = histo.getCrateId();
00142       HwId dmbId = histo.getDMBId();
00143       HwId addId = histo.getAddId();
00144 
00145       CSCHistoKeyType histoKey(id, addId, mo);
00146 
00147       if (cscPointer == cscData.end() || cscPointer->crateId != crateId || cscPointer->dmbId != dmbId) {
00148         cscPointer = cscData.find(boost::make_tuple(crateId, dmbId));
00149       } 
00150 
00151       if (cscPointer == cscData.end()) {
00152         CSCKeyType cscKey(crateId, dmbId);
00153         cscPointer = cscData.insert(cscData.end(), cscKey);
00154       }
00155       CSCHistoMapType* mos = const_cast<CSCHistoMapType*>(&cscPointer->mos);
00156       mos->insert(histoKey);
00157 
00158     } else
00159 
00160     if (typeid(histo) == ParHistoDefT) {
00161       data[id] = mo;
00162     }
00163 
00164   }


Member Data Documentation

CSCMapType cscdqm::Cache::cscData [private]

Definition at line 94 of file CSCDQM_Cache.h.

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

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

Definition at line 95 of file CSCDQM_Cache.h.

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

MonitorObject* cscdqm::Cache::data[h::namesSize] [private]

Definition at line 88 of file CSCDQM_Cache.h.

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

DDUMapType cscdqm::Cache::dduData [private]

Definition at line 90 of file CSCDQM_Cache.h.

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

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

Definition at line 91 of file CSCDQM_Cache.h.

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

HwId cscdqm::Cache::dduPointerValue [private]

Definition at line 92 of file CSCDQM_Cache.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:36:55 2009 for CMSSW by  doxygen 1.5.4