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