CMS 3D CMS Logo

HcalElectronicsMap.cc
Go to the documentation of this file.
1 
10 #include <iostream>
11 #include <set>
12 
16 
18  : mPItems(helper.mPItems), mTItems(helper.mTItems) {
19  initialize();
20 }
21 
23 // copy-ctor
25  : mPItems(src.mPItems), mTItems(src.mTItems), mPItemsById(src.mPItemsById), mTItemsByTrigId(src.mTItemsByTrigId) {}
26 // copy assignment operator
29  temp.swap(*this);
30  return *this;
31 }
32 // public swap function
34  std::swap(mPItems, other.mPItems);
35  std::swap(mTItems, other.mTItems);
36  std::swap(mPItemsById, other.mPItemsById);
37  std::swap(mTItemsByTrigId, other.mTItemsByTrigId);
38 }
39 // move constructor
41 
43  PrecisionItem target(fId, 0);
44  return HcalObjectAddons::findByT<PrecisionItem, HcalElectronicsMapAddons::LessById>(&target, mPItemsById);
45 }
46 
48  HcalElectronicsId eid(fElId);
49  const PrecisionItem* i = &(mPItems[eid.linearIndex()]);
50 
51  if (i != nullptr && i->mElId != fElId)
52  i = nullptr;
53  return i;
54 }
55 
57  HcalElectronicsId eid(fElId);
58  const TriggerItem* i = &(mTItems[eid.linearIndex()]);
59 
60  if (i != nullptr && i->mElId != fElId)
61  i = nullptr;
62  return i;
63 }
64 
66  TriggerItem target(fTrigId, 0);
67  return HcalObjectAddons::findByT<TriggerItem, HcalElectronicsMapAddons::LessByTrigId>(&target, mTItemsByTrigId);
68 }
69 
71  const PrecisionItem* item = findPByElId(fId.rawId());
72  return DetId(item ? item->mId : 0);
73 }
74 
76  const PrecisionItem* item = findById(fId.rawId());
77  return HcalElectronicsId(item ? item->mElId : 0);
78 }
79 
81  const TriggerItem* item = findTByElId(fId.rawId());
82  return DetId(item ? item->mTrigId : 0);
83 }
84 
86  const TriggerItem* item = findByTrigId(fId.rawId());
87  return HcalElectronicsId(item ? item->mElId : 0);
88 }
89 
91  const PrecisionItem* i = &(mPItems[pid.linearIndex()]);
92  if (i != nullptr && i->mId != 0) {
93  eid = HcalElectronicsId(i->mElId);
94  did = HcalGenericDetId(i->mId);
95  return true;
96  } else
97  return false;
98 }
99 
101  const TriggerItem* i = &(mTItems[pid.linearIndex()]);
102  if (i != nullptr && i->mTrigId != 0) {
103  eid = HcalElectronicsId(i->mElId);
104  did = HcalGenericDetId(i->mTrigId);
105  return true;
106  } else
107  return false;
108 }
109 
110 std::vector<HcalElectronicsId> HcalElectronicsMap::allElectronicsId() const {
111  std::vector<HcalElectronicsId> result;
112  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
113  if (item->mElId)
114  result.push_back(HcalElectronicsId(item->mElId));
115  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin(); item != mTItems.end(); item++)
116  if (item->mElId)
117  result.push_back(HcalElectronicsId(item->mElId));
118 
119  return result;
120 }
121 
122 std::vector<HcalElectronicsId> HcalElectronicsMap::allElectronicsIdPrecision() const {
123  std::vector<HcalElectronicsId> result;
124  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
125  if (item->mElId)
126  result.push_back(HcalElectronicsId(item->mElId));
127  return result;
128 }
129 
130 std::vector<HcalElectronicsId> HcalElectronicsMap::allElectronicsIdTrigger() const {
131  std::vector<HcalElectronicsId> result;
132  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin(); item != mTItems.end(); item++)
133  if (item->mElId)
134  result.push_back(HcalElectronicsId(item->mElId));
135 
136  return result;
137 }
138 
139 std::vector<HcalGenericDetId> HcalElectronicsMap::allPrecisionId() const {
140  std::vector<HcalGenericDetId> result;
141  std::set<unsigned long> allIds;
142  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
143  if (item->mId)
144  allIds.insert(item->mId);
145  for (std::set<unsigned long>::const_iterator channel = allIds.begin(); channel != allIds.end(); channel++) {
146  result.push_back(HcalGenericDetId(*channel));
147  }
148  return result;
149 }
150 
151 std::vector<HcalTrigTowerDetId> HcalElectronicsMap::allTriggerId() const {
152  std::vector<HcalTrigTowerDetId> result;
153  std::set<unsigned long> allIds;
154  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin(); item != mTItems.end(); item++)
155  if (item->mTrigId)
156  allIds.insert(item->mTrigId);
157  for (std::set<unsigned long>::const_iterator channel = allIds.begin(); channel != allIds.end(); channel++)
158  result.push_back(HcalTrigTowerDetId(*channel));
159  return result;
160 }
161 
162 //use helper to do mapping
164  : mPItems(HcalElectronicsId::maxLinearIndex + 1), mTItems(HcalElectronicsId::maxLinearIndex + 1) {}
165 
167  HcalElectronicsMap::TriggerItem& item = mTItems[fElectronicsId.linearIndex()];
168 
169  if (item.mElId == 0)
170  item.mElId = fElectronicsId.rawId();
171  if (item.mTrigId == 0) {
172  item.mTrigId = fTriggerId.rawId(); // just cast avoiding long machinery
173  } else if (item.mTrigId != fTriggerId.rawId()) {
174  edm::LogWarning("HCAL") << "HcalElectronicsMap::Helper::mapEId2tId-> Electronics channel " << fElectronicsId
175  << " already mapped to trigger channel " << (HcalTrigTowerDetId(item.mTrigId))
176  << ". New value " << fTriggerId << " is ignored";
177  return false;
178  }
179  return true;
180 }
181 
183  HcalElectronicsMap::PrecisionItem& item = mPItems[fElectronicsId.linearIndex()];
184 
185  if (item.mElId == 0)
186  item.mElId = fElectronicsId.rawId();
187  if (item.mId == 0) {
188  item.mId = fId.rawId();
189  } else if (item.mId != fId.rawId()) {
190  edm::LogWarning("HCAL") << "HcalElectronicsMap::Helper::mapEId2tId-> Electronics channel " << fElectronicsId
191  << " already mapped to channel " << HcalGenericDetId(item.mId) << ". New value "
192  << HcalGenericDetId(fId) << " is ignored";
193  return false;
194  }
195  return true;
196 }
197 
199  HcalObjectAddons::sortByT<PrecisionItem, HcalElectronicsMapAddons::LessById>(mPItems, mPItemsById);
200 }
201 
203  HcalObjectAddons::sortByT<TriggerItem, HcalElectronicsMapAddons::LessByTrigId>(mTItems, mTItemsByTrigId);
204 }
205 
207  sortById();
208  sortByTriggerId();
209 }
HcalElectronicsMap.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
HcalElectronicsMap::allElectronicsId
std::vector< HcalElectronicsId > allElectronicsId() const
Definition: HcalElectronicsMap.cc:110
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalElectronicsMap::findById
const PrecisionItem * findById(unsigned long fId) const
Definition: HcalElectronicsMap.cc:42
HcalElectronicsMap::findByTrigId
const TriggerItem * findByTrigId(unsigned long fTrigId) const
Definition: HcalElectronicsMap.cc:65
HcalElectronicsMap::mTItemsByTrigId
std::vector< const TriggerItem * > mTItemsByTrigId
Definition: HcalElectronicsMap.h:106
HcalElectronicsMap::HcalElectronicsMap
HcalElectronicsMap()
Definition: HcalElectronicsMap.h:53
HcalObjectAddons.h
HcalElectronicsMapAddons::Helper::mapEId2tId
bool mapEId2tId(HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
Definition: HcalElectronicsMap.cc:166
HcalElectronicsMap::findTByElId
const TriggerItem * findTByElId(unsigned long fElId) const
Definition: HcalElectronicsMap.cc:56
HcalElectronicsMap::~HcalElectronicsMap
~HcalElectronicsMap()
Definition: HcalElectronicsMap.cc:22
HcalElectronicsMap::operator=
HcalElectronicsMap & operator=(const HcalElectronicsMap &rhs)
Definition: HcalElectronicsMap.cc:27
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HcalElectronicsMap::lookupTrigger
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
Definition: HcalElectronicsMap.cc:80
HcalElectronicsMap::findPByElId
const PrecisionItem * findPByElId(unsigned long fElId) const
Definition: HcalElectronicsMap.cc:47
HcalElectronicsMap::allPrecisionId
std::vector< HcalGenericDetId > allPrecisionId() const
Definition: HcalElectronicsMap.cc:139
DetId
Definition: DetId.h:17
HcalElectronicsMap::allTriggerId
std::vector< HcalTrigTowerDetId > allTriggerId() const
Definition: HcalElectronicsMap.cc:151
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
HcalElectronicsMapAddons::Helper::Helper
Helper()
Definition: HcalElectronicsMap.cc:163
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
trackingPlots.other
other
Definition: trackingPlots.py:1467
HcalElectronicsMap::allElectronicsIdTrigger
std::vector< HcalElectronicsId > allElectronicsIdTrigger() const
Definition: HcalElectronicsMap.cc:130
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
helper
Definition: helper.py:1
HcalElectronicsMap::sortByTriggerId
void sortByTriggerId()
Definition: HcalElectronicsMap.cc:202
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
HcalElectronicsMap::TriggerItem
Definition: HcalElectronicsMap.h:43
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HcalElectronicsMap::mTItems
std::vector< TriggerItem > mTItems
Definition: HcalElectronicsMap.h:104
HcalElectronicsMap::allElectronicsIdPrecision
std::vector< HcalElectronicsId > allElectronicsIdPrecision() const
Definition: HcalElectronicsMap.cc:122
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalElectronicsMap::lookup
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
Definition: HcalElectronicsMap.cc:70
HcalElectronicsMap::swap
void swap(HcalElectronicsMap &other)
Definition: HcalElectronicsMap.cc:33
HcalElectronicsId::linearIndex
constexpr int linearIndex() const
get a fast, compact, unique index for linear lookups
Definition: HcalElectronicsId.h:111
HcalElectronicsMap::sortById
void sortById()
Definition: HcalElectronicsMap.cc:198
HcalElectronicsMapAddons::Helper
Definition: HcalElectronicsMap.h:137
HcalElectronicsId::rawId
constexpr uint32_t rawId() const
Definition: HcalElectronicsId.h:59
HcalElectronicsMapAddons::Helper::mapEId2chId
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
Definition: HcalElectronicsMap.cc:182
HcalElectronicsMap::mPItemsById
std::vector< const PrecisionItem * > mPItemsById
Definition: HcalElectronicsMap.h:105
HcalElectronicsMap::initialize
void initialize()
Definition: HcalElectronicsMap.cc:206
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
mps_fire.result
result
Definition: mps_fire.py:311
HcalElectronicsMap::PrecisionItem
Definition: HcalElectronicsMap.h:33
HcalElectronicsMap::mPItems
std::vector< PrecisionItem > mPItems
Definition: HcalElectronicsMap.h:103
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14