CMS 3D CMS Logo

HcalFrontEndMap.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <set>
4 
10 
12  : mPItems(helper.mPItems.begin(), helper.mPItems.end()) {
13  initialize();
14 }
15 
17 
18 // copy-ctor
19 HcalFrontEndMap::HcalFrontEndMap(const HcalFrontEndMap& src) : mPItems(src.mPItems), mPItemsById(src.mPItemsById) {}
20 
21 // copy assignment operator
23  HcalFrontEndMap temp(rhs);
24  temp.swap(*this);
25  return *this;
26 }
27 
28 // public swap function
30  std::swap(mPItems, other.mPItems);
31  std::swap(mPItemsById, other.mPItemsById);
32 }
33 
34 // move constructor
36 
38  PrecisionItem target(fId, 0, "");
39  return HcalObjectAddons::findByT<PrecisionItem, HcalFrontEndMapAddons::LessById>(&target, mPItemsById);
40 }
41 
43 
46  auto iter = mPItems.find(target);
47  if (iter != mPItems.end()) {
48  edm::LogWarning("HCAL") << "HcalFrontEndMap::loadObject DetId " << HcalDetId(fId) << " already exists with RM "
49  << iter->mRM << " RBX " << iter->mRBX << " new values " << rm << " and " << rbx
50  << " are ignored";
51  return false;
52  } else {
53  mPItems.insert(target);
54  return true;
55  }
56 }
57 
58 const int HcalFrontEndMap::lookupRM(DetId fId) const {
59  const PrecisionItem* item = findById(fId.rawId());
60  return (item ? item->mRM : 0);
61 }
62 
63 const int HcalFrontEndMap::lookupRMIndex(DetId fId) const {
64  const PrecisionItem* item = findById(fId.rawId());
66  if (item)
67  id = HcalFrontEndId(item->mRBX, item->mRM, 0, 1, 0, 1, 0);
68  return id.rmIndex();
69 }
70 
72  const PrecisionItem* item = findById(fId.rawId());
73  return (item ? item->mRBX : "");
74 }
75 
76 const int HcalFrontEndMap::lookupRBXIndex(DetId fId) const {
77  const PrecisionItem* item = findById(fId.rawId());
79  if (item)
80  id = HcalFrontEndId(item->mRBX, item->mRM, 0, 1, 0, 1, 0);
81  return id.rbxIndex();
82 }
83 
84 std::vector<DetId> HcalFrontEndMap::allDetIds() const {
85  std::vector<DetId> result;
86  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
87  if (item->mId)
88  result.push_back(DetId(item->mId));
89  return result;
90 }
91 
92 std::vector<int> HcalFrontEndMap::allRMs() const {
93  std::vector<int> result;
94  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++) {
95  if (std::find(result.begin(), result.end(), item->mRM) == result.end())
96  result.push_back(item->mRM);
97  }
98  return result;
99 }
100 
101 std::vector<std::string> HcalFrontEndMap::allRBXs() const {
102  std::vector<std::string> result;
103  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++) {
104  if (std::find(result.begin(), result.end(), item->mRBX) == result.end())
105  result.push_back(item->mRBX);
106  }
107  return result;
108 }
109 
111  HcalObjectAddons::sortByT<PrecisionItem, HcalFrontEndMapAddons::LessById>(mPItems, mPItemsById);
112 }
113 
const int lookupRBXIndex(DetId fId) const
def rm(path, rec=False)
Definition: eostools.py:363
std::vector< const PrecisionItem * > mPItemsById
Definition: helper.py:1
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
const PrecisionItem * findById(uint32_t fId) const
HcalFrontEndMap & operator=(const HcalFrontEndMap &rhs)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
const int lookupRMIndex(DetId fId) const
const int lookupRM(DetId fId) const
brief lookup the RM associated with the given logical id
void swap(HcalFrontEndMap &other)
std::vector< std::string > allRBXs() const
std::vector< int > allRMs() const
std::vector< DetId > allDetIds() const
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Log< level::Warning, false > LogWarning
const std::string lookupRBX(DetId fId) const
brief lookup the RBX associated with the given logical id
std::vector< PrecisionItem > mPItems