CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
hcaldqm::electronicsmap::ElectronicsMap Class Reference

#include <ElectronicsMap.h>

Public Member Functions

 ElectronicsMap ()
 
 ElectronicsMap (ElectronicsMapType etype)
 
void initialize (HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
 
void initialize (HcalElectronicsMap const *, ElectronicsMapType, filter::HashFilter const &)
 
uint32_t lookup (DetId const &)
 
uint32_t lookup (HcalDetId const &)
 
uint32_t lookup (HcalElectronicsId const &)
 
void print ()
 
 ~ElectronicsMap ()
 

Private Types

typedef std::unordered_map< uint32_t, uint32_t > EMapType
 

Private Attributes

const HcalElectronicsMap_emap
 
ElectronicsMapType _etype
 
EMapType _ids
 

Detailed Description

Definition at line 32 of file ElectronicsMap.h.

Member Typedef Documentation

◆ EMapType

typedef std::unordered_map<uint32_t, uint32_t> hcaldqm::electronicsmap::ElectronicsMap::EMapType
private

Definition at line 54 of file ElectronicsMap.h.

Constructor & Destructor Documentation

◆ ElectronicsMap() [1/2]

hcaldqm::electronicsmap::ElectronicsMap::ElectronicsMap ( )
inline

Definition at line 34 of file ElectronicsMap.h.

34 : _emap(nullptr) {}

◆ ElectronicsMap() [2/2]

hcaldqm::electronicsmap::ElectronicsMap::ElectronicsMap ( ElectronicsMapType  etype)
inline

Definition at line 36 of file ElectronicsMap.h.

36 : _etype(etype), _emap(nullptr) {}

◆ ~ElectronicsMap()

hcaldqm::electronicsmap::ElectronicsMap::~ElectronicsMap ( )
inline

Definition at line 37 of file ElectronicsMap.h.

37 {}

Member Function Documentation

◆ initialize() [1/2]

void hcaldqm::electronicsmap::ElectronicsMap::initialize ( HcalElectronicsMap const *  emap,
ElectronicsMapType  etype = fHcalElectronicsMap 
)

Definition at line 6 of file ElectronicsMap.cc.

6  {
7  _etype = etype;
8  _emap = emap;
9  // if we actually use a HashMap then
10  if (_etype != fHcalElectronicsMap) {
11  if (_etype == fD2EHashMap) {
12  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdPrecision();
13  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
15  EMapType::iterator dit = _ids.find(did.rawId());
16  if (dit != _ids.end())
17  continue;
18  // if (!did.isHcalDetId())
19  // continue;
20 
21  _ids.insert(std::make_pair(did.rawId(), it->rawId()));
22  }
23  } else if (_etype == fT2EHashMap) {
24  // HcalTrigTowerDetId -> HcalElectronicsId
25  std::vector<HcalTrigTowerDetId> tids = emap->allTriggerId();
26  for (std::vector<HcalTrigTowerDetId>::const_iterator it = tids.begin(); it != tids.end(); ++it) {
28  uint32_t hash = it->rawId();
29  EMapType::iterator eit = _ids.find(hash);
30  if (eit != _ids.end())
31  continue;
32 
33  _ids.insert(std::make_pair(hash, eid.rawId()));
34  }
35  } else if (_etype == fE2DHashMap) {
36  // HcalElectronicId -> HcalDetId hash map
37  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdPrecision();
38  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
40  uint32_t hash = it->rawId();
41  EMapType::iterator eit = _ids.find(hash);
42  if (eit != _ids.end())
43  continue;
44 
45  // note, we have EChannel hashing here
46  _ids.insert(std::make_pair(hash, did.rawId()));
47  }
48  } else if (_etype == fE2THashMap) {
49  // HcalElectronicId -> HcalDetId hash map
50  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdTrigger();
51  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
53  EMapType::iterator eit = _ids.find(it->rawId());
54  if (eit != _ids.end())
55  continue;
56 
57  // eid.rawId() -> tid.rawId()
58  _ids.insert(std::make_pair(it->rawId(), tid.rawId()));
59  }
60  }
61  }
62  }

References _emap, _etype, _ids, HcalElectronicsMap::allElectronicsIdPrecision(), HcalElectronicsMap::allElectronicsIdTrigger(), HcalElectronicsMap::allTriggerId(), runTauDisplay::eid, hcaldqm::electronicsmap::fD2EHashMap, hcaldqm::electronicsmap::fE2DHashMap, hcaldqm::electronicsmap::fE2THashMap, hcaldqm::electronicsmap::fHcalElectronicsMap, hcaldqm::electronicsmap::fT2EHashMap, cond::hash, HcalElectronicsMap::lookup(), HcalElectronicsMap::lookupTrigger(), and DetId::rawId().

Referenced by hcaldqm::RawRunSummary::beginRun(), hcaldqm::DigiRunSummary::beginRun(), DigiComparisonTask::bookHistograms(), TPComparisonTask::bookHistograms(), FCDTask::bookHistograms(), PedestalTask::bookHistograms(), LEDTask::bookHistograms(), QIE11Task::bookHistograms(), TPTask::bookHistograms(), QIE10Task::bookHistograms(), RawTask::bookHistograms(), LaserTask::bookHistograms(), RecHitTask::bookHistograms(), DigiTask::bookHistograms(), hcaldqm::RecoRunSummary::endJob(), and hcaldqm::TPRunSummary::endJob().

◆ initialize() [2/2]

void hcaldqm::electronicsmap::ElectronicsMap::initialize ( HcalElectronicsMap const *  emap,
ElectronicsMapType  etype,
filter::HashFilter const &  filter 
)

Definition at line 64 of file ElectronicsMap.cc.

66  {
67  _etype = etype;
68  _emap = emap;
69 
70  // note this initialization has iteration over electronics not
71  // detector.
72  // Filtering is done on Electronics id - possible to have
73  // several electronics ids to 1 detid - not vice versa
74  if (_etype != fHcalElectronicsMap) {
75  if (_etype == fD2EHashMap) {
76  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdPrecision();
77  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
79  if (filter.filter(*it))
80  continue;
81  // skip those that are not detid or calib ids
82  // if (!did.isHcalDetId())
83  // continue;
84 
85  _ids.insert(std::make_pair(did.rawId(), it->rawId()));
86  }
87  } else if (_etype == fT2EHashMap) {
88  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdTrigger();
89  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
90  if (filter.filter(*it))
91  continue;
92  HcalTrigTowerDetId tid = emap->lookupTrigger(*it);
93  _ids.insert(std::make_pair(tid.rawId(), it->rawId()));
94  }
95  } else if (_etype == fE2DHashMap) {
96  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdPrecision();
97  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
99  uint32_t hash = hashfunctions::hash_EChannel(*it);
100  if (filter.filter(*it))
101  continue;
102  // skip those that are not detid or calib ids
103  // if (!did.isHcalDetId())
104  // continue;
105 
106  // note: use EChannel hashing here!
107  _ids.insert(std::make_pair(hash, did.rawId()));
108  }
109  } else if (_etype == fE2THashMap) {
110  std::vector<HcalElectronicsId> eids = emap->allElectronicsIdTrigger();
111  for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
112  if (filter.filter(*it))
113  continue;
114  HcalTrigTowerDetId tid = emap->lookupTrigger(*it);
115  _ids.insert(std::make_pair(it->rawId(), tid.rawId()));
116  }
117  }
118  }
119  }

References _emap, _etype, _ids, HcalElectronicsMap::allElectronicsIdPrecision(), HcalElectronicsMap::allElectronicsIdTrigger(), hcaldqm::electronicsmap::fD2EHashMap, hcaldqm::electronicsmap::fE2DHashMap, hcaldqm::electronicsmap::fE2THashMap, hcaldqm::electronicsmap::fHcalElectronicsMap, ALCARECOTkAlBeamHalo_cff::filter, hcaldqm::electronicsmap::fT2EHashMap, cond::hash, hcaldqm::hashfunctions::hash_EChannel(), HcalElectronicsMap::lookup(), HcalElectronicsMap::lookupTrigger(), and DetId::rawId().

◆ lookup() [1/3]

uint32_t hcaldqm::electronicsmap::ElectronicsMap::lookup ( DetId const &  id)

◆ lookup() [2/3]

uint32_t hcaldqm::electronicsmap::ElectronicsMap::lookup ( HcalDetId const &  id)

Definition at line 133 of file ElectronicsMap.cc.

133  {
134  // Turn the HcalDetId into a HcalGenericDetId to avoid newForm
135  uint32_t hash = (id.oldFormat() ? id.otherForm() : id.rawId());
136  HcalGenericDetId gdid(hash);
138  return _emap->lookup(gdid).rawId();
139  else {
140  EMapType::iterator it = _ids.find(hash);
141  return it == _ids.end() ? 0 : it->second;
142  }
143  return 0;
144  }

References _emap, _etype, _ids, hcaldqm::electronicsmap::fHcalElectronicsMap, cond::hash, HcalElectronicsMap::lookup(), and DetId::rawId().

◆ lookup() [3/3]

uint32_t hcaldqm::electronicsmap::ElectronicsMap::lookup ( HcalElectronicsId const &  id)

Definition at line 146 of file ElectronicsMap.cc.

146  {
147  uint32_t hash = id.rawId();
149  return _emap->lookup(id).rawId();
150  else {
151  EMapType::iterator it = _ids.find(hash);
152  return it == _ids.end() ? 0 : it->second;
153  }
154  return 0;
155  }

References _emap, _etype, _ids, hcaldqm::electronicsmap::fHcalElectronicsMap, cond::hash, HcalElectronicsMap::lookup(), and DetId::rawId().

◆ print()

void hcaldqm::electronicsmap::ElectronicsMap::print ( void  )

Definition at line 157 of file ElectronicsMap.cc.

157  {
158  std::cout << "Electronics HashMap Type=" << _etype << std::endl;
159  for (auto const &v : _ids) {
160  std::cout << std::hex << v.first << " " << v.second << std::dec << std::endl;
161  }
162  }

References _etype, _ids, gather_cfg::cout, TauDecayModes::dec, and findQualityFiles::v.

Member Data Documentation

◆ _emap

const HcalElectronicsMap* hcaldqm::electronicsmap::ElectronicsMap::_emap
private

Definition at line 58 of file ElectronicsMap.h.

Referenced by initialize(), and lookup().

◆ _etype

ElectronicsMapType hcaldqm::electronicsmap::ElectronicsMap::_etype
private

Definition at line 51 of file ElectronicsMap.h.

Referenced by initialize(), lookup(), and print().

◆ _ids

EMapType hcaldqm::electronicsmap::ElectronicsMap::_ids
private

Definition at line 55 of file ElectronicsMap.h.

Referenced by initialize(), lookup(), and print().

HcalGenericDetId
Definition: HcalGenericDetId.h:15
cond::hash
Definition: Time.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
hcaldqm::electronicsmap::fHcalElectronicsMap
Definition: ElectronicsMap.h:24
findQualityFiles.v
v
Definition: findQualityFiles.py:179
hcaldqm::electronicsmap::fT2EHashMap
Definition: ElectronicsMap.h:26
hcaldqm::electronicsmap::fE2DHashMap
Definition: ElectronicsMap.h:27
HcalElectronicsMap::lookupTrigger
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
Definition: HcalElectronicsMap.cc:80
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
hcaldqm::electronicsmap::ElectronicsMap::_emap
const HcalElectronicsMap * _emap
Definition: ElectronicsMap.h:58
HcalElectronicsMap::allElectronicsIdPrecision
std::vector< HcalElectronicsId > allElectronicsIdPrecision() const
Definition: HcalElectronicsMap.cc:122
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
hcaldqm::electronicsmap::fD2EHashMap
Definition: ElectronicsMap.h:25
hcaldqm::electronicsmap::ElectronicsMap::_etype
ElectronicsMapType _etype
Definition: ElectronicsMap.h:51
hcaldqm::hashfunctions::hash_EChannel
uint32_t hash_EChannel(HcalElectronicsId const &)
Definition: HashFunctions.cc:323
hcaldqm::electronicsmap::fE2THashMap
Definition: ElectronicsMap.h:28
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14
hcaldqm::electronicsmap::ElectronicsMap::_ids
EMapType _ids
Definition: ElectronicsMap.h:55