CMS 3D CMS Logo

HcalDcsMap.h
Go to the documentation of this file.
1 #ifndef HcalDcsMap_h
2 #define HcalDcsMap_h
3 
15 
16 #include <set>
17 #include <vector>
18 #include <algorithm>
19 #include <boost/cstdint.hpp>
20 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
21 #include <atomic>
22 #endif
23 
28 
29 //forward declaration
30 namespace HcalDcsMapAddons {
31  class Helper;
32 }
33 
34 class HcalDcsMap {
35  public:
36 
37  class Item {
38  public:
39  Item () {mId = mDcsId = 0;}
40  Item (uint32_t fId, uint32_t fDcsId)
41  : mId (fId), mDcsId (fDcsId) {}
42  uint32_t mId;
43  uint32_t mDcsId;
44 
46  };
47 
50  ~HcalDcsMap();
51 
52  // swap function
53  void swap(HcalDcsMap& other);
54  // copy-ctor
55  HcalDcsMap(const HcalDcsMap& src);
56  // copy assignment operator
57  HcalDcsMap& operator=(const HcalDcsMap& rhs);
58  // move constructor
59 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
60  HcalDcsMap(HcalDcsMap&& other);
61 #endif
62 
63  // lookup the logical detid associated with the given DCS id
64  // return Null item if no such mapping.
65  //
66  // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
67  // it is not preserved in the map in order to reduce data volume.
68  // This is possible because the same HCAL channels will correspond
69  // to the DCS channels where only the type is different.
70  //
71  // For the aforementioned reason, you might use any DCS type
72  // when constructing the DetId for this lookup
73  HcalDetId lookup(HcalDcsDetId fId) const;
74 
75  // brief lookup the DCS detid associated with the given logical id
76  //return Null item if no such mapping
77  //
78  // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
79  // it is not preserved in the map in order to reduce data volume.
80  // This is possible because the same HCAL channels will correspond
81  // to the DCS channels where only the type is different.
82  //
83  // For this reason, you need to specify the DCS type in order
84  // to extract proper HcalDcsDetId from the map
86 
88  public:
89  friend class HcalDcsMap;
92  bool operator!=(const const_iterator & other);
93  const_iterator operator++();
94  const_iterator operator++(int);
95  void next(void);
96  HcalDcsDetId getHcalDcsDetId(void);
97  HcalDetId getHcalDetId(void);
98  private:
99  std::vector<const Item *>::const_iterator fIter;
100  };
101 
102  // iterators
103  const_iterator beginById(void) const;
104  const_iterator beginByDcsId(void) const;
105  const_iterator endById(void) const;
106  const_iterator endByDcsId(void) const;
107 
108  void initialize();
109 
110  const Item * findById (unsigned long fId) const;
111  const Item * findByDcsId (unsigned long fDcsId) const;
112 
113  //sorting
114  void sortById();
115  void sortByDcsId();
116 
117  protected:
118  // these are inspired by the emap. Not clear if they are needed
119  // for this DCS map at all since it's many-to-many map
120  std::vector <HcalDcsDetId> allHcalDcsDetId () const;
121  std::vector <HcalGenericDetId> allHcalDetId () const;
122 
123  std::vector<Item> mItems;
124  std::vector<const Item*> mItemsById COND_TRANSIENT;
125  std::vector<const Item*> mItemsByDcsId COND_TRANSIENT;
126 
128 };
129 
130 namespace HcalDcsMapAddons {
131  class LessById {
132  public:
133  bool operator () (const HcalDcsMap::Item* a, const HcalDcsMap::Item* b) const {
134  return a->mId < b->mId;
135  }
136  bool operator () (const HcalDcsMap::Item& a, const HcalDcsMap::Item& b) const {
137  return a.mId < b.mId;
138  }
139  bool equal (const HcalDcsMap::Item* a, const HcalDcsMap::Item* b) const {
140  return a->mId == b->mId;
141  }
142  bool good (const HcalDcsMap::Item& a) const {
143  return a.mDcsId;
144  }
145  };
146  class LessByDcsId {
147  public:
148  bool operator () (const HcalDcsMap::Item* a, const HcalDcsMap::Item* b) const {
149  return a->mDcsId < b->mDcsId;
150  }
151  bool operator () (const HcalDcsMap::Item& a, const HcalDcsMap::Item& b) const {
152  return a.mDcsId < b.mDcsId;
153  }
154  bool equal (const HcalDcsMap::Item* a, const HcalDcsMap::Item* b) const {
155  return a->mDcsId == b->mDcsId;
156  }
157  bool good (const HcalDcsMap::Item& a) const {
158  return a.mDcsId;
159  }
160  };
161  class Helper {
162  public:
163  Helper();
164  // map channels
165  // DCS type is a part of DcsDetId but it does not make sense to keep
166  // duplicate records in the map for DCS channels where only type is different.
167  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
168  // inside this method
169  bool mapGeomId2DcsId (HcalDetId fId, HcalDcsDetId fDcsId);
170 
171  std::set<HcalDcsMap::Item,LessByDcsId> mItems;
172  };
173 }
174 
175 #endif
std::vector< const Item * >::const_iterator fIter
Definition: HcalDcsMap.h:99
type
Definition: HCALResponse.h:21
static AlgebraicMatrix initialize()
uint32_t mDcsId
Definition: HcalDcsMap.h:43
Definition: helper.py:1
bool equal(const HcalDcsMap::Item *a, const HcalDcsMap::Item *b) const
Definition: HcalDcsMap.h:139
std::vector< HcalDcsDetId > allHcalDcsDetId() const
Definition: HcalDcsMap.cc:137
uint32_t mId
Definition: HcalDcsMap.h:42
bool good(const HcalDcsMap::Item &a) const
Definition: HcalDcsMap.h:142
bool good(const HcalDcsMap::Item &a) const
Definition: HcalDcsMap.h:157
const Item * findById(unsigned long fId) const
Definition: HcalDcsMap.cc:102
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
const_iterator endById(void) const
Definition: HcalDcsMap.cc:61
Item(uint32_t fId, uint32_t fDcsId)
Definition: HcalDcsMap.h:40
const_iterator beginById(void) const
Definition: HcalDcsMap.cc:49
void sortById()
Definition: HcalDcsMap.cc:181
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
#define COND_TRANSIENT
Definition: Serializable.h:61
bool equal(const HcalDcsMap::Item *a, const HcalDcsMap::Item *b) const
Definition: HcalDcsMap.h:154
std::vector< HcalGenericDetId > allHcalDetId() const
Definition: HcalDcsMap.cc:145
double b
Definition: hdecay.h:120
#define COND_SERIALIZABLE
Definition: Serializable.h:38
const Item * findByDcsId(unsigned long fDcsId) const
Definition: HcalDcsMap.cc:107
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:125
const_iterator endByDcsId(void) const
Definition: HcalDcsMap.cc:67
double a
Definition: hdecay.h:121
std::vector< Item > mItems
Definition: HcalDcsMap.h:123
void sortByDcsId()
Definition: HcalDcsMap.cc:184
const_iterator beginByDcsId(void) const
Definition: HcalDcsMap.cc:55
std::set< HcalDcsMap::Item, LessByDcsId > mItems
Definition: HcalDcsMap.h:171
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:124