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 
HcalFrontEndMap::allRMs
std::vector< int > allRMs() const
Definition: HcalFrontEndMap.cc:92
HcalFrontEndMap::operator=
HcalFrontEndMap & operator=(const HcalFrontEndMap &rhs)
Definition: HcalFrontEndMap.cc:22
MessageLogger.h
HcalFrontEndMap::initialize
void initialize()
Definition: HcalFrontEndMap.cc:114
HcalFrontEndMap::lookupRMIndex
const int lookupRMIndex(DetId fId) const
Definition: HcalFrontEndMap.cc:63
HcalFrontEndMap::sortById
void sortById()
Definition: HcalFrontEndMap.cc:110
HcalFrontEndMap::~HcalFrontEndMap
~HcalFrontEndMap()
Definition: HcalFrontEndMap.cc:16
HcalFrontEndMapAddons::Helper::loadObject
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
Definition: HcalFrontEndMap.cc:44
HcalFrontEndMapAddons::Helper::Helper
Helper()
Definition: HcalFrontEndMap.cc:42
HcalObjectAddons.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
end
#define end
Definition: vmac.h:39
HcalFrontEndMap::mPItems
std::vector< PrecisionItem > mPItems
Definition: HcalFrontEndMap.h:76
DetId
Definition: DetId.h:17
HcalFrontEndId.h
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
HcalFrontEndMap::allRBXs
std::vector< std::string > allRBXs() const
Definition: HcalFrontEndMap.cc:101
HcalFrontEndMap::allDetIds
std::vector< DetId > allDetIds() const
Definition: HcalFrontEndMap.cc:84
HcalFrontEndId
Definition: HcalFrontEndId.h:8
trackingPlots.other
other
Definition: trackingPlots.py:1465
submit.rm
rm
Definition: submit.py:77
HcalFrontEndMap::lookupRBXIndex
const int lookupRBXIndex(DetId fId) const
Definition: HcalFrontEndMap.cc:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
HcalFrontEndMap::lookupRBX
const std::string lookupRBX(DetId fId) const
brief lookup the RBX associated with the given logical id
Definition: HcalFrontEndMap.cc:71
HcalFrontEndMap.h
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
HcalDetId.h
helper
Definition: helper.py:1
HcalDetId
Definition: HcalDetId.h:12
HcalFrontEndMap::HcalFrontEndMap
HcalFrontEndMap()
Definition: HcalFrontEndMap.h:39
HcalFrontEndMap::mPItemsById
std::vector< const PrecisionItem * > mPItemsById
Definition: HcalFrontEndMap.h:77
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HcalFrontEndMap::PrecisionItem
Definition: HcalFrontEndMap.h:25
HcalFrontEndMapAddons::Helper
Definition: HcalFrontEndMap.h:96
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
HcalFrontEndMap::lookupRM
const int lookupRM(DetId fId) const
brief lookup the RM associated with the given logical id
Definition: HcalFrontEndMap.cc:58
HcalFrontEndMap
Definition: HcalFrontEndMap.h:23
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
mps_fire.result
result
Definition: mps_fire.py:303
HcalFrontEndMap::swap
void swap(HcalFrontEndMap &other)
Definition: HcalFrontEndMap.cc:29
HcalFrontEndMap::findById
const PrecisionItem * findById(uint32_t fId) const
Definition: HcalFrontEndMap.cc:37
begin
#define begin
Definition: vmac.h:32