CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDcsMap.h
Go to the documentation of this file.
1 #ifndef HcalDcsMap_h
2 #define HcalDcsMap_h
3 
14 #include <vector>
15 #include <algorithm>
16 #include <boost/cstdint.hpp>
17 
22 //
23 class HcalDcsMap {
24  public:
25  HcalDcsMap();
26  ~HcalDcsMap();
27 
28  // lookup the logical detid associated with the given DCS id
29  // return Null item if no such mapping.
30  //
31  // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
32  // it is not preserved in the map in order to reduce data volume.
33  // This is possible because the same HCAL channels will correspond
34  // to the DCS channels where only the type is different.
35  //
36  // For the aforementioned reason, you might use any DCS type
37  // when constructing the DetId for this lookup
38  const std::vector<HcalDetId> lookup(HcalDcsDetId fId) const;
39 
40  // brief lookup the DCS detid associated with the given logical id
41  //return Null item if no such mapping
42  //
43  // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
44  // it is not preserved in the map in order to reduce data volume.
45  // This is possible because the same HCAL channels will correspond
46  // to the DCS channels where only the type is different.
47  //
48  // For this reason, you need to specify the DCS type in order
49  // to extract proper HcalDcsDetId from the map
50  const std::vector<HcalDcsDetId> lookup(HcalDetId fId, HcalDcsDetId::DcsType type) const;
51 
52  // map channels
53  // DCS type is a part of DcsDetId but it does not make sense to keep
54  // duplicate records in the map for DCS channels where only type is different.
55  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
56  // inside this method
57  bool mapGeomId2DcsId (HcalDetId fId, HcalDcsDetId fDcsId);
58 
59  // sorting
60  void sortById () const;
61  void sortByDcsId () const;
62  void sort() {}
63 
64  class Item {
65  public:
66  Item () {mId = mDcsId = 0;}
67  Item (uint32_t fId, uint32_t fDcsId)
68  : mId (fId), mDcsId (fDcsId) {}
69  uint32_t mId;
70  uint32_t mDcsId;
71  };
72 
74  public:
75  friend class HcalDcsMap;
78  bool operator!=(const const_iterator & other);
81  void next(void);
83  HcalDetId getHcalDetId(void);
84  private:
85  std::vector<const Item *>::const_iterator fIter;
86  };
87 
88  // iterators
89  const_iterator beginById(void) const;
90  const_iterator beginByDcsId(void) const;
91  const_iterator endById(void) const;
92  const_iterator endByDcsId(void) const;
93 
94  protected:
95  const std::vector<const Item *> findById (unsigned long fId) const;
96  const std::vector<const Item *> findByDcsId (unsigned long fDcsId) const;
97 
98  // these are inspired by the emap. Not clear if they are needed
99  // for this DCS map at all since it's many-to-many map
100  std::vector <HcalDcsDetId> allHcalDcsDetId () const;
101  std::vector <HcalGenericDetId> allHcalDetId () const;
102 
103  std::vector<Item> mItems;
104  mutable std::vector<const Item*> mItemsById;
105  mutable bool sortedById;
106  const std::vector<const Item *> * getItemsById(void){return &mItemsById;}
107  mutable std::vector<const Item*> mItemsByDcsId;
108  mutable bool sortedByDcsId;
109  const std::vector<const Item *> * getItemsByDcsId(void){return &mItemsByDcsId;}
110 };
111 
112 #endif
std::vector< const Item * >::const_iterator fIter
Definition: HcalDcsMap.h:85
type
Definition: HCALResponse.h:22
void sortByDcsId() const
Definition: HcalDcsMap.cc:243
bool sortedById
Definition: HcalDcsMap.h:105
uint32_t mDcsId
Definition: HcalDcsMap.h:70
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:205
std::vector< HcalDcsDetId > allHcalDcsDetId() const
Definition: HcalDcsMap.cc:185
const_iterator operator++()
Definition: HcalDcsMap.cc:79
uint32_t mId
Definition: HcalDcsMap.h:69
bool sortedByDcsId
Definition: HcalDcsMap.h:108
const std::vector< const Item * > * getItemsById(void)
Definition: HcalDcsMap.h:106
const_iterator endById(void) const
Definition: HcalDcsMap.cc:59
Item(uint32_t fId, uint32_t fDcsId)
Definition: HcalDcsMap.h:67
const_iterator beginById(void) const
Definition: HcalDcsMap.cc:45
const std::vector< HcalDetId > lookup(HcalDcsDetId fId) const
Definition: HcalDcsMap.cc:147
HcalDetId getHcalDetId(void)
Definition: HcalDcsMap.cc:98
const std::vector< const Item * > findByDcsId(unsigned long fDcsId) const
Definition: HcalDcsMap.cc:125
HcalDcsDetId getHcalDcsDetId(void)
Definition: HcalDcsMap.cc:94
const std::vector< const Item * > * getItemsByDcsId(void)
Definition: HcalDcsMap.h:109
const std::vector< const Item * > findById(unsigned long fId) const
Definition: HcalDcsMap.cc:103
std::vector< HcalGenericDetId > allHcalDetId() const
Definition: HcalDcsMap.cc:193
void sort()
Definition: HcalDcsMap.h:62
bool operator!=(const const_iterator &other)
Definition: HcalDcsMap.cc:74
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:107
const_iterator endByDcsId(void) const
Definition: HcalDcsMap.cc:66
std::vector< Item > mItems
Definition: HcalDcsMap.h:103
void sortById() const
Definition: HcalDcsMap.cc:232
const_iterator beginByDcsId(void) const
Definition: HcalDcsMap.cc:52
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:104