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 {
14  initialize();
15 }
16 
17 
19 }
20 
21 // copy-ctor
23  : mPItems(src.mPItems), mPItemsById(src.mPItemsById) {}
24 
25 // copy assignment operator
27  HcalFrontEndMap temp(rhs);
28  temp.swap(*this);
29  return *this;
30 }
31 
32 // public swap function
34  std::swap(mPItems, other.mPItems);
36 }
37 
38 // move constructor
40  other.swap(*this);
41 }
42 
44  PrecisionItem target (fId, 0, "");
45  return HcalObjectAddons::findByT<PrecisionItem,HcalFrontEndMapAddons::LessById>(&target,mPItemsById);
46 }
47 
49 {
50 }
51 
54  auto iter = mPItems.find(target);
55  if (iter!=mPItems.end()) {
56  edm::LogWarning("HCAL") << "HcalFrontEndMap::loadObject DetId "
57  << HcalDetId(fId) << " already exists with RM "
58  << iter->mRM << " RBX " << iter->mRBX
59  << " new values " << rm << " and " << rbx
60  << " are ignored";
61  return false;
62  } else {
63  mPItems.insert(target);
64  return true;
65  }
66 }
67 
68 const int HcalFrontEndMap::lookupRM(DetId fId) const {
69  const PrecisionItem* item = findById (fId.rawId ());
70  return (item ? item->mRM : 0);
71 }
72 
73 const int HcalFrontEndMap::lookupRMIndex(DetId fId) const {
74  const PrecisionItem* item = findById (fId.rawId ());
76  if (item) id = HcalFrontEndId(item->mRBX,item->mRM,0,1,0,1,0);
77  return id.rmIndex();
78 }
79 
81  const PrecisionItem* item = findById (fId.rawId ());
82  return (item ? item->mRBX : "");
83 }
84 
85 const int HcalFrontEndMap::lookupRBXIndex(DetId fId) const {
86  const PrecisionItem* item = findById (fId.rawId ());
88  if (item) id = HcalFrontEndId(item->mRBX,item->mRM,0,1,0,1,0);
89  return id.rbxIndex();
90 }
91 
92 std::vector <DetId> HcalFrontEndMap::allDetIds() const {
93  std::vector <DetId> result;
94  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin ();
95  item != mPItems.end (); item++)
96  if (item->mId) result.push_back(DetId(item->mId));
97  return result;
98 }
99 
100 std::vector <int> HcalFrontEndMap::allRMs () const {
101  std::vector <int> result;
102  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin ();
103  item != mPItems.end (); item++) {
104  if (std::find(result.begin(),result.end(),item->mRM) == result.end())
105  result.push_back(item->mRM);
106  }
107  return result;
108 }
109 
110 std::vector <std::string> HcalFrontEndMap::allRBXs() const {
111  std::vector <std::string> result;
112  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin ();
113  item != mPItems.end (); item++) {
114  if (std::find(result.begin(),result.end(),item->mRBX) == result.end())
115  result.push_back(item->mRBX);
116  }
117  return result;
118 }
119 
121  HcalObjectAddons::sortByT<PrecisionItem,HcalFrontEndMapAddons::LessById>(mPItems,mPItemsById);
122 }
123 
126  }
std::vector< std::string > allRBXs() const
std::vector< const PrecisionItem * > mPItemsById
Definition: helper.py:1
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
HcalFrontEndMap & operator=(const HcalFrontEndMap &rhs)
const int lookupRMIndex(DetId fId) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const int lookupRBXIndex(DetId fId) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< DetId > allDetIds() const
void swap(HcalFrontEndMap &other)
#define end
Definition: vmac.h:37
const PrecisionItem * findById(uint32_t fId) const
Definition: DetId.h:18
const int lookupRM(DetId fId) const
brief lookup the RM associated with the given logical id
#define begin
Definition: vmac.h:30
std::vector< int > allRMs() const
rm
Definition: submit.py:76
const std::string lookupRBX(DetId fId) const
brief lookup the RBX associated with the given logical id
std::vector< PrecisionItem > mPItems