CMS 3D CMS Logo

HcalDcsMap.cc
Go to the documentation of this file.
1 
11 #include <iostream>
12 #include <set>
13 
17 
19  mItems(helper.mItems.begin(),helper.mItems.end())
20 {
21  initialize();
22 }
23 
25 }
26 // copy-ctor
28  : mItems(src.mItems),
30 // copy assignment operator
33  HcalDcsMap temp(rhs);
34  temp.swap(*this);
35  return *this;
36 }
37 // public swap function
39  std::swap(mItems, other.mItems);
42 }
43 // move constructor
45  : HcalDcsMap() {
46  other.swap(*this);
47 }
48 
50  const_iterator _iter;
51  _iter.fIter = mItemsById.begin();
52  return _iter;
53 }
54 
56  const_iterator _iter;
57  _iter.fIter = mItemsByDcsId.begin();
58  return _iter;
59 }
60 
62  const_iterator _iter;
63  _iter.fIter = mItemsById.end();
64  return _iter;
65 }
66 
68  const_iterator _iter;
69  _iter.fIter = mItemsByDcsId.end();
70  return _iter;
71 }
72 
73 // iterator methods
75  if (fIter != other.fIter) return true;
76  else return false;
77 }
78 
80  ++fIter;
81  return *this;
82 }
83 
85  const_iterator i = *this;
86  ++fIter;
87  return i;
88 }
89 
91  ++fIter;
92 }
93 
95  return (*fIter)->mDcsId;
96 }
97 
99  return (*fIter)->mId;
100 }
101 
102 const HcalDcsMap::Item * HcalDcsMap::findById (unsigned long fId) const {
103  Item target(fId,0);
104  return HcalObjectAddons::findByT<Item,HcalDcsMapAddons::LessById>(&target,mItemsById);
105 }
106 
107 const HcalDcsMap::Item * HcalDcsMap::findByDcsId (unsigned long fDcsId) const {
108  Item target(0,fDcsId);
109  return HcalObjectAddons::findByT<Item,HcalDcsMapAddons::LessByDcsId>(&target,mItemsByDcsId);
110 }
111 
113  // DCS type is a part of DcsDetId but it does not make sense to keep
114  // duplicate records in the map for DCS channels where only type is different.
115  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
116  HcalDcsDetId fDcsId_notype(fId.subdet(),
117  fId.ring(), // side is already included
118  fId.slice(),
120  fId.subchannel());
121  auto item = HcalDcsMap::findByDcsId (fDcsId_notype.rawId ());
122  return item ? item->mId : 0;
123 }
124 
126  auto item = HcalDcsMap::findById (fId.rawId ());
127  HcalDcsDetId _id(item ? item->mId : 0);
128  return HcalDcsDetId(_id.subdet(),
129  _id.zside()*_id.ring(),
130  _id.slice(),
131  type,
132  _id.subchannel()
133  );
134 }
135 
136 //FIXME: remove duplicates
137 std::vector <HcalDcsDetId> HcalDcsMap::allHcalDcsDetId () const {
138  std::vector <HcalDcsDetId> result;
139  for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++)
140  if (item->mDcsId) result.push_back(HcalDcsDetId(item->mDcsId));
141  return result;
142 }
143 
144 // FIXME: remove duplicates
145 std::vector <HcalGenericDetId> HcalDcsMap::allHcalDetId () const {
146  std::vector <HcalGenericDetId> result;
147  std::set <unsigned long> allIds;
148  for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++)
149  if (item->mId) allIds.insert (item->mId);
150  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) {
151  result.push_back (HcalGenericDetId (*channel));
152  }
153  return result;
154 }
155 
157 {
158 }
159 
161  // DCS type is a part of DcsDetId but it does not make sense to keep
162  // duplicate records in the map for DCS channels where only type is different.
163  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
164  HcalDcsDetId fDcsId_notype(fDcsId.subdet(),
165  fDcsId.ring(), // side is included
166  fDcsId.slice(),
168  fDcsId.subchannel());
169  HcalDcsMap::Item target(fId, fDcsId_notype);
170  auto iter = mItems.find(target);
171  if(iter != mItems.end() and iter->mId == fId){
172  edm::LogWarning("HCAL") << "HcalDcsMap::mapGeomId2DcsId-> Geom channel " << fId
173  << " already mapped to DCS channel " << fDcsId_notype;
174  return false; // element already exists
175  }
176  mItems.insert(target);
177 
178  return true;
179 }
180 
182  HcalObjectAddons::sortByT<Item,HcalDcsMapAddons::LessById>(mItems,mItemsById);
183 }
185  HcalObjectAddons::sortByT<Item,HcalDcsMapAddons::LessByDcsId>(mItems,mItemsByDcsId);
186 }
187 
189  sortById();
190  sortByDcsId();
191 }
std::vector< const Item * >::const_iterator fIter
Definition: HcalDcsMap.h:99
type
Definition: HCALResponse.h:21
Definition: helper.py:1
int subchannel() const
Definition: HcalDcsDetId.h:49
std::vector< HcalDcsDetId > allHcalDcsDetId() const
Definition: HcalDcsMap.cc:137
void initialize()
Definition: HcalDcsMap.cc:188
const_iterator operator++()
Definition: HcalDcsMap.cc:79
uint32_t mId
Definition: HcalDcsMap.h:42
const Item * findById(unsigned long fId) const
Definition: HcalDcsMap.cc:102
void swap(HcalDcsMap &other)
Definition: HcalDcsMap.cc:38
HcalDetId lookup(HcalDcsDetId fId) const
Definition: HcalDcsMap.cc:112
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
const_iterator endById(void) const
Definition: HcalDcsMap.cc:61
const_iterator beginById(void) const
Definition: HcalDcsMap.cc:49
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
HcalDetId getHcalDetId(void)
Definition: HcalDcsMap.cc:98
HcalDcsMap & operator=(const HcalDcsMap &rhs)
Definition: HcalDcsMap.cc:32
HcalDcsDetId getHcalDcsDetId(void)
Definition: HcalDcsMap.cc:94
void sortById()
Definition: HcalDcsMap.cc:181
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:160
#define end
Definition: vmac.h:39
HcalOtherSubdetector subdet() const
get the category
std::vector< HcalGenericDetId > allHcalDetId() const
Definition: HcalDcsMap.cc:145
int slice() const
Definition: HcalDcsDetId.h:47
bool operator!=(const const_iterator &other)
Definition: HcalDcsMap.cc:74
const Item * findByDcsId(unsigned long fDcsId) const
Definition: HcalDcsMap.cc:107
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:125
#define begin
Definition: vmac.h:32
const_iterator endByDcsId(void) const
Definition: HcalDcsMap.cc:67
std::vector< Item > mItems
Definition: HcalDcsMap.h:123
void sortByDcsId()
Definition: HcalDcsMap.cc:184
int ring() const
Definition: HcalDcsDetId.h:46
const_iterator beginByDcsId(void) const
Definition: HcalDcsMap.cc:55
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:124