CMS 3D CMS Logo

HcalDcsMap.cc
Go to the documentation of this file.
1 
11 #include <iostream>
12 #include <set>
13 
17 
18 HcalDcsMap::HcalDcsMap(const HcalDcsMapAddons::Helper& helper) : mItems(helper.mItems.begin(), helper.mItems.end()) {
19  initialize();
20 }
21 
23 // copy-ctor
25  : mItems(src.mItems), mItemsById(src.mItemsById), mItemsByDcsId(src.mItemsByDcsId) {}
26 // copy assignment operator
28  HcalDcsMap temp(rhs);
29  temp.swap(*this);
30  return *this;
31 }
32 // public swap function
34  std::swap(mItems, other.mItems);
35  std::swap(mItemsById, other.mItemsById);
36  std::swap(mItemsByDcsId, other.mItemsByDcsId);
37 }
38 // move constructor
40 
42  const_iterator _iter;
43  _iter.fIter = mItemsById.begin();
44  return _iter;
45 }
46 
48  const_iterator _iter;
49  _iter.fIter = mItemsByDcsId.begin();
50  return _iter;
51 }
52 
54  const_iterator _iter;
55  _iter.fIter = mItemsById.end();
56  return _iter;
57 }
58 
60  const_iterator _iter;
61  _iter.fIter = mItemsByDcsId.end();
62  return _iter;
63 }
64 
65 // iterator methods
67  if (fIter != other.fIter)
68  return true;
69  else
70  return false;
71 }
72 
74  ++fIter;
75  return *this;
76 }
77 
79  const_iterator i = *this;
80  ++fIter;
81  return i;
82 }
83 
84 void HcalDcsMap::const_iterator::next(void) { ++fIter; }
85 
87 
88 HcalDetId HcalDcsMap::const_iterator::getHcalDetId(void) { return (*fIter)->mId; }
89 
90 const HcalDcsMap::Item* HcalDcsMap::findById(unsigned long fId) const {
91  Item target(fId, 0);
92  return HcalObjectAddons::findByT<Item, HcalDcsMapAddons::LessById>(&target, mItemsById);
93 }
94 
95 const HcalDcsMap::Item* HcalDcsMap::findByDcsId(unsigned long fDcsId) const {
96  Item target(0, fDcsId);
97  return HcalObjectAddons::findByT<Item, HcalDcsMapAddons::LessByDcsId>(&target, mItemsByDcsId);
98 }
99 
101  // DCS type is a part of DcsDetId but it does not make sense to keep
102  // duplicate records in the map for DCS channels where only type is different.
103  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
104  HcalDcsDetId fDcsId_notype(fId.subdet(),
105  fId.ring(), // side is already included
106  fId.slice(),
108  fId.subchannel());
109  auto item = HcalDcsMap::findByDcsId(fDcsId_notype.rawId());
110  return item ? item->mId : 0;
111 }
112 
114  auto item = HcalDcsMap::findById(fId.rawId());
115  HcalDcsDetId _id(item ? item->mId : 0);
116  return HcalDcsDetId(_id.subdet(), _id.zside() * _id.ring(), _id.slice(), type, _id.subchannel());
117 }
118 
119 //FIXME: remove duplicates
120 std::vector<HcalDcsDetId> HcalDcsMap::allHcalDcsDetId() const {
121  std::vector<HcalDcsDetId> result;
122  for (std::vector<Item>::const_iterator item = mItems.begin(); item != mItems.end(); item++)
123  if (item->mDcsId)
124  result.push_back(HcalDcsDetId(item->mDcsId));
125  return result;
126 }
127 
128 // FIXME: remove duplicates
129 std::vector<HcalGenericDetId> HcalDcsMap::allHcalDetId() const {
130  std::vector<HcalGenericDetId> result;
131  std::set<unsigned long> allIds;
132  for (std::vector<Item>::const_iterator item = mItems.begin(); item != mItems.end(); item++)
133  if (item->mId)
134  allIds.insert(item->mId);
135  for (std::set<unsigned long>::const_iterator channel = allIds.begin(); channel != allIds.end(); channel++) {
136  result.push_back(HcalGenericDetId(*channel));
137  }
138  return result;
139 }
140 
142 
144  // DCS type is a part of DcsDetId but it does not make sense to keep
145  // duplicate records in the map for DCS channels where only type is different.
146  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
147  HcalDcsDetId fDcsId_notype(fDcsId.subdet(),
148  fDcsId.ring(), // side is included
149  fDcsId.slice(),
151  fDcsId.subchannel());
152  HcalDcsMap::Item target(fId, fDcsId_notype);
153  auto iter = mItems.find(target);
154  if (iter != mItems.end() and iter->mId == fId) {
155  edm::LogWarning("HCAL") << "HcalDcsMap::mapGeomId2DcsId-> Geom channel " << fId << " already mapped to DCS channel "
156  << fDcsId_notype;
157  return false; // element already exists
158  }
159  mItems.insert(target);
160 
161  return true;
162 }
163 
164 void HcalDcsMap::sortById() { HcalObjectAddons::sortByT<Item, HcalDcsMapAddons::LessById>(mItems, mItemsById); }
166  HcalObjectAddons::sortByT<Item, HcalDcsMapAddons::LessByDcsId>(mItems, mItemsByDcsId);
167 }
168 
170  sortById();
171  sortByDcsId();
172 }
HcalDcsDetId::DCSUNKNOWN
Definition: HcalDcsDetId.h:42
mps_fire.i
i
Definition: mps_fire.py:428
HcalDcsMap::const_iterator::operator++
const_iterator operator++()
Definition: HcalDcsMap.cc:73
MessageLogger.h
HcalDcsMap::mItemsById
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:123
HcalDcsDetId
Definition: HcalDcsDetId.h:27
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalDcsMapAddons::Helper::mapGeomId2DcsId
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:143
HcalDcsMapAddons::Helper::Helper
Helper()
Definition: HcalDcsMap.cc:141
HcalDcsDetId::ring
int ring() const
Definition: HcalDcsDetId.h:55
HcalObjectAddons.h
HcalDcsMap
Definition: HcalDcsMap.h:34
HcalDcsMap::const_iterator
Definition: HcalDcsMap.h:85
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
HcalDcsMap::allHcalDetId
std::vector< HcalGenericDetId > allHcalDetId() const
Definition: HcalDcsMap.cc:129
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
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
HcalDcsMap::beginByDcsId
const_iterator beginByDcsId(void) const
Definition: HcalDcsMap.cc:47
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
HcalDcsMap::endByDcsId
const_iterator endByDcsId(void) const
Definition: HcalDcsMap.cc:59
mps_fire.end
end
Definition: mps_fire.py:242
HcalDcsMap::sortById
void sortById()
Definition: HcalDcsMap.cc:164
trackingPlots.other
other
Definition: trackingPlots.py:1460
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
HcalDcsMap::~HcalDcsMap
~HcalDcsMap()
Definition: HcalDcsMap.cc:22
HcalDcsMap::operator=
HcalDcsMap & operator=(const HcalDcsMap &rhs)
Definition: HcalDcsMap.cc:27
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
HcalDcsMap.h
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
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
helper
Definition: helper.py:1
HcalDetId
Definition: HcalDetId.h:12
HcalDcsMap::findById
const Item * findById(unsigned long fId) const
Definition: HcalDcsMap.cc:90
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HcalDcsMapAddons::Helper
Definition: HcalDcsMap.h:144
HcalDcsMap::const_iterator::fIter
std::vector< const Item * >::const_iterator fIter
Definition: HcalDcsMap.h:98
HcalDcsDetId::subchannel
int subchannel() const
Definition: HcalDcsDetId.h:58
HcalDcsDetId::slice
int slice() const
Definition: HcalDcsDetId.h:56
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalDcsMap::mItems
std::vector< Item > mItems
Definition: HcalDcsMap.h:122
HcalDcsMap::sortByDcsId
void sortByDcsId()
Definition: HcalDcsMap.cc:165
HcalDcsMap::mItemsByDcsId
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:124
HcalDcsMap::const_iterator::operator!=
bool operator!=(const const_iterator &other)
Definition: HcalDcsMap.cc:66
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
mps_fire.result
result
Definition: mps_fire.py:311
HcalOtherDetId::subdet
HcalOtherSubdetector subdet() const
get the category
Definition: HcalOtherDetId.h:30
HcalDcsMap::Item
Definition: HcalDcsMap.h:36
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