CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondFormats/HcalObjects/interface/HcalDcsMap.h

Go to the documentation of this file.
00001 #ifndef HcalDcsMap_h
00002 #define HcalDcsMap_h
00003 
00014 #include <vector>
00015 #include <algorithm>
00016 #include <boost/cstdint.hpp>
00017 
00018 #include "DataFormats/DetId/interface/DetId.h"
00019 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00020 #include "DataFormats/HcalDetId/interface/HcalDcsDetId.h"
00021 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00022 // 
00023 class HcalDcsMap {
00024  public:
00025   HcalDcsMap();
00026   ~HcalDcsMap();
00027   
00028   // lookup the logical detid associated with the given DCS id
00029   // return Null item if no such mapping.
00030   //
00031   // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
00032   // it is not preserved in the map in order to reduce data volume.
00033   // This is possible because the same HCAL channels will correspond
00034   // to the DCS channels where only the type is different.
00035   //
00036   // For the aforementioned reason, you might use any DCS type
00037   // when constructing the DetId for this lookup
00038   const std::vector<HcalDetId> lookup(HcalDcsDetId fId) const;
00039   
00040   // brief lookup the DCS detid associated with the given logical id
00041   //return Null item if no such mapping
00042   //
00043   // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
00044   // it is not preserved in the map in order to reduce data volume.
00045   // This is possible because the same HCAL channels will correspond
00046   // to the DCS channels where only the type is different.
00047   //
00048   // For this reason, you need to specify  the DCS type in order
00049   // to extract proper HcalDcsDetId from the map
00050   const std::vector<HcalDcsDetId> lookup(HcalDetId fId, HcalDcsDetId::DcsType type) const;
00051 
00052   // map channels
00053   // DCS type is a part of DcsDetId but it does not make sense to keep
00054   // duplicate records in the map for DCS channels where only type is different.
00055   // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
00056   // inside this method
00057   bool mapGeomId2DcsId (HcalDetId fId, HcalDcsDetId fDcsId);
00058 
00059   // sorting
00060   void sortById () const;
00061   void sortByDcsId () const;
00062   void sort() {}
00063 
00064   class Item { 
00065   public:
00066     Item () {mId = mDcsId = 0;}
00067     Item (uint32_t fId, uint32_t fDcsId) 
00068       : mId (fId), mDcsId (fDcsId) {}
00069     uint32_t mId;
00070     uint32_t mDcsId;
00071   };
00072 
00073   class const_iterator{
00074   public:
00075     friend class HcalDcsMap;
00076     const_iterator(){}
00077     ~const_iterator(){}
00078     bool operator!=(const const_iterator & other);
00079     const_iterator operator++();
00080     const_iterator operator++(int);
00081     void next(void);
00082     HcalDcsDetId getHcalDcsDetId(void);
00083     HcalDetId getHcalDetId(void);
00084   private:
00085     std::vector<const Item *>::const_iterator fIter;
00086   };
00087 
00088   // iterators
00089   const_iterator beginById(void) const;
00090   const_iterator beginByDcsId(void) const;
00091   const_iterator endById(void) const;
00092   const_iterator endByDcsId(void) const;
00093 
00094  protected:
00095   const std::vector<const Item *> findById (unsigned long fId) const;
00096   const std::vector<const Item *> findByDcsId (unsigned long fDcsId) const;
00097   
00098   // these are inspired by the emap. Not clear if they are needed
00099   // for this DCS map at all since it's many-to-many map
00100   std::vector <HcalDcsDetId> allHcalDcsDetId () const;
00101   std::vector <HcalGenericDetId> allHcalDetId () const;
00102 
00103   std::vector<Item> mItems;
00104   mutable std::vector<const Item*> mItemsById;
00105   mutable bool sortedById;
00106   const std::vector<const Item *> * getItemsById(void){return &mItemsById;}  
00107   mutable std::vector<const Item*> mItemsByDcsId;
00108   mutable bool sortedByDcsId;
00109   const std::vector<const Item *> * getItemsByDcsId(void){return &mItemsByDcsId;}  
00110 };
00111 
00112 #endif