test
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 
15 
16 #include <vector>
17 #include <algorithm>
18 #include <boost/cstdint.hpp>
19 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
20 #include <atomic>
21 #endif
22 
27 //
28 class HcalDcsMap {
29  public:
30  HcalDcsMap();
31  ~HcalDcsMap();
32 
33  // swap function
34  void swap(HcalDcsMap& other);
35  // copy-ctor
36  HcalDcsMap(const HcalDcsMap& src);
37  // copy assignment operator
38  HcalDcsMap& operator=(const HcalDcsMap& rhs);
39  // move constructor
40 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
41  HcalDcsMap(HcalDcsMap&& other);
42 #endif
43 
44  // lookup the logical detid associated with the given DCS id
45  // return Null item if no such mapping.
46  //
47  // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
48  // it is not preserved in the map in order to reduce data volume.
49  // This is possible because the same HCAL channels will correspond
50  // to the DCS channels where only the type is different.
51  //
52  // For the aforementioned reason, you might use any DCS type
53  // when constructing the DetId for this lookup
54  const std::vector<HcalDetId> lookup(HcalDcsDetId fId) const;
55 
56  // brief lookup the DCS detid associated with the given logical id
57  //return Null item if no such mapping
58  //
59  // Note that type (HV, BV etc.) is a part of HcalDcsDetId but
60  // it is not preserved in the map in order to reduce data volume.
61  // This is possible because the same HCAL channels will correspond
62  // to the DCS channels where only the type is different.
63  //
64  // For this reason, you need to specify the DCS type in order
65  // to extract proper HcalDcsDetId from the map
66  const std::vector<HcalDcsDetId> lookup(HcalDetId fId, HcalDcsDetId::DcsType type) const;
67 
68  // map channels
69  // DCS type is a part of DcsDetId but it does not make sense to keep
70  // duplicate records in the map for DCS channels where only type is different.
71  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
72  // inside this method
73  bool mapGeomId2DcsId (HcalDetId fId, HcalDcsDetId fDcsId);
74 
75  // sorting
76  void sortById () const;
77  void sortByDcsId () const;
78  void sort() {}
79 
80  class Item {
81  public:
82  Item () {mId = mDcsId = 0;}
83  Item (uint32_t fId, uint32_t fDcsId)
84  : mId (fId), mDcsId (fDcsId) {}
85  uint32_t mId;
86  uint32_t mDcsId;
87 
89 };
90 
92  public:
93  friend class HcalDcsMap;
96  bool operator!=(const const_iterator & other);
99  void next(void);
101  HcalDetId getHcalDetId(void);
102  private:
103  std::vector<const Item *>::const_iterator fIter;
104  };
105 
106  // iterators
107  const_iterator beginById(void) const;
108  const_iterator beginByDcsId(void) const;
109  const_iterator endById(void) const;
110  const_iterator endByDcsId(void) const;
111 
112  protected:
113  const std::vector<const Item *> findById (unsigned long fId) const;
114  const std::vector<const Item *> findByDcsId (unsigned long fDcsId) const;
115 
116  // these are inspired by the emap. Not clear if they are needed
117  // for this DCS map at all since it's many-to-many map
118  std::vector <HcalDcsDetId> allHcalDcsDetId () const;
119  std::vector <HcalGenericDetId> allHcalDetId () const;
120 
121  std::vector<Item> mItems;
122 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
123  mutable std::atomic<std::vector<const Item*>*> mItemsById COND_TRANSIENT;
124  mutable std::atomic<std::vector<const Item*>*> mItemsByDcsId COND_TRANSIENT;
125  const std::vector<const Item*>* getItemsById(void){return mItemsById.load(std::memory_order_acquire);}
126  const std::vector<const Item*>* getItemsByDcsId(void){return mItemsByDcsId.load(std::memory_order_acquire);}
127 #else
128  mutable std::vector<const Item*> mItemsById COND_TRANSIENT;
129  mutable std::vector<const Item*> mItemsByDcsId COND_TRANSIENT;
130  const std::vector<const Item*>* getItemsById(void){return &mItemsById;}
131  const std::vector<const Item*>* getItemsByDcsId(void){return &mItemsByDcsId;}
132 #endif
133 
135 };
136 
137 #endif
std::vector< const Item * >::const_iterator fIter
Definition: HcalDcsMap.h:103
type
Definition: HCALResponse.h:21
void sortByDcsId() const
Definition: HcalDcsMap.cc:281
uint32_t mDcsId
Definition: HcalDcsMap.h:86
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:235
std::vector< HcalDcsDetId > allHcalDcsDetId() const
Definition: HcalDcsMap.cc:215
const_iterator operator++()
Definition: HcalDcsMap.cc:107
uint32_t mId
Definition: HcalDcsMap.h:85
void swap(HcalDcsMap &other)
Definition: HcalDcsMap.cc:40
const_iterator endById(void) const
Definition: HcalDcsMap.cc:87
Item(uint32_t fId, uint32_t fDcsId)
Definition: HcalDcsMap.h:83
const_iterator beginById(void) const
Definition: HcalDcsMap.cc:73
std::atomic< std::vector< const Item * > * > mItemsById
Definition: HcalDcsMap.h:123
const std::vector< HcalDetId > lookup(HcalDcsDetId fId) const
Definition: HcalDcsMap.cc:177
HcalDetId getHcalDetId(void)
Definition: HcalDcsMap.cc:126
const std::vector< const Item * > findByDcsId(unsigned long fDcsId) const
Definition: HcalDcsMap.cc:154
HcalDcsMap & operator=(const HcalDcsMap &rhs)
Definition: HcalDcsMap.cc:34
HcalDcsDetId getHcalDcsDetId(void)
Definition: HcalDcsMap.cc:122
std::atomic< std::vector< const Item * > * > mItemsByDcsId
Definition: HcalDcsMap.h:124
#define COND_TRANSIENT
Definition: Serializable.h:61
const std::vector< const Item * > findById(unsigned long fId) const
Definition: HcalDcsMap.cc:131
std::vector< HcalGenericDetId > allHcalDetId() const
Definition: HcalDcsMap.cc:223
const std::vector< const Item * > * getItemsByDcsId(void)
Definition: HcalDcsMap.h:126
void sort()
Definition: HcalDcsMap.h:78
#define COND_SERIALIZABLE
Definition: Serializable.h:38
bool operator!=(const const_iterator &other)
Definition: HcalDcsMap.cc:102
const_iterator endByDcsId(void) const
Definition: HcalDcsMap.cc:94
std::vector< Item > mItems
Definition: HcalDcsMap.h:121
const std::vector< const Item * > * getItemsById(void)
Definition: HcalDcsMap.h:125
void sortById() const
Definition: HcalDcsMap.cc:264
const_iterator beginByDcsId(void) const
Definition: HcalDcsMap.cc:80