test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronicsMap.cc
Go to the documentation of this file.
2 #include <iomanip>
3 
4 namespace hcaldqm
5 {
6  namespace electronicsmap
7  {
9  ElectronicsMapType etype/*=fHcalElectronicsMap*/)
10  {
11  _etype=etype;
12  _emap = emap;
13  // if we actually use a HashMap then
15  {
16  if (_etype==fD2EHashMap)
17  {
18  std::vector<HcalElectronicsId> eids =
20  for (std::vector<HcalElectronicsId>::const_iterator it=
21  eids.begin(); it!=eids.end(); ++it)
22  {
24  _emap->lookup(*it));
25  if (!did.isHcalDetId())
26  continue;
27 
28  _ids.insert(std::make_pair(did.rawId(), it->rawId()));
29  }
30  }
31  else if (_etype==fT2EHashMap)
32  {
33  // HcalTrigTowerDetId -> HcalElectronicsId
34  std::vector<HcalTrigTowerDetId> tids =
35  emap->allTriggerId();
36  for (std::vector<HcalTrigTowerDetId>::const_iterator it=
37  tids.begin(); it!=tids.end(); ++it)
38  {
40  uint32_t hash = it->rawId();
41  EMapType::iterator eit = _ids.find(hash);
42  if (eit!=_ids.end())
43  continue;
44 
45  _ids.insert(std::make_pair(hash, eid.rawId()));
46  }
47  }
48  else if (_etype==fE2DHashMap)
49  {
50  // HcalElectronicId -> HcalDetId hash map
51  std::vector<HcalElectronicsId> eids =
53  for (std::vector<HcalElectronicsId>::const_iterator
54  it=eids.begin(); it!=eids.end(); ++it)
55  {
56  HcalDetId did = HcalDetId(_emap->lookup(*it));
58  *it);
59  EMapType::iterator eit = _ids.find(hash);
60  if (eit!=_ids.end())
61  continue;
62 
63  // note, we have EChannel hashing here
64  _ids.insert(std::make_pair(hash, did.rawId()));
65  }
66  }
67  else if (_etype==fE2THashMap)
68  {
69  // HcalElectronicId -> HcalDetId hash map
70  std::vector<HcalElectronicsId> eids =
72  for (std::vector<HcalElectronicsId>::const_iterator
73  it=eids.begin(); it!=eids.end(); ++it)
74  {
75  HcalTrigTowerDetId tid =
77  EMapType::iterator eit = _ids.find(it->rawId());
78  if (eit!=_ids.end())
79  continue;
80 
81  // eid.rawId() -> tid.rawId()
82  _ids.insert(std::make_pair(it->rawId(),
83  tid.rawId()));
84  }
85  }
86  }
87  }
88 
91  {
92  _etype=etype;
93  _emap = emap;
94 
95  // note this initialization has iteration over electronics not
96  // detector.
97  // Filtering is done on Electronics id - possible to have
98  // several electronics ids to 1 detid - not vice versa
100  {
101  if (_etype==fD2EHashMap)
102  {
103  std::vector<HcalElectronicsId> eids =
105  for (std::vector<HcalElectronicsId>::const_iterator it=
106  eids.begin(); it!=eids.end(); ++it)
107  {
109  _emap->lookup(*it));
110  if (filter.filter(*it))
111  continue;
112  // skip those that are not detid or calib ids
113  if (!did.isHcalDetId())
114  continue;
115 
116  _ids.insert(std::make_pair(did.rawId(), it->rawId()));
117  }
118  }
119  else if (_etype==fT2EHashMap)
120  {
121  std::vector<HcalElectronicsId> eids=
122  emap->allElectronicsIdTrigger();
123  for (std::vector<HcalElectronicsId>::const_iterator it=
124  eids.begin(); it!=eids.end(); ++it)
125  {
126  if (filter.filter(*it))
127  continue;
128  HcalTrigTowerDetId tid = emap->lookupTrigger(*it);
129  _ids.insert(std::make_pair(tid.rawId(), it->rawId()));
130  }
131  }
132  else if (_etype==fE2DHashMap)
133  {
134  std::vector<HcalElectronicsId> eids =
136  for (std::vector<HcalElectronicsId>::const_iterator it=
137  eids.begin(); it!=eids.end(); ++it)
138  {
140  _emap->lookup(*it));
142  *it);
143  if (filter.filter(*it))
144  continue;
145  // skip those that are not detid or calib ids
146  if (!did.isHcalDetId())
147  continue;
148 
149  // note: use EChannel hashing here!
150  _ids.insert(std::make_pair(hash,did.rawId()));
151  }
152  }
153  else if (_etype==fE2THashMap)
154  {
155  std::vector<HcalElectronicsId> eids=
156  emap->allElectronicsIdTrigger();
157  for (std::vector<HcalElectronicsId>::const_iterator it=
158  eids.begin(); it!=eids.end(); ++it)
159  {
160  if (filter.filter(*it))
161  continue;
162  HcalTrigTowerDetId tid = emap->lookupTrigger(*it);
163  _ids.insert(std::make_pair(it->rawId(), tid.rawId()));
164  }
165  }
166  }
167  }
168 
169  // 2 funcs below are only for 1->1 mappings
170  uint32_t ElectronicsMap::lookup(DetId const &id)
171  {
172  uint32_t hash = id.rawId();
173  return _etype==fHcalElectronicsMap? _emap->lookup(id).rawId():
174  _ids[hash];
175  }
176 
178  {
179  uint32_t hash = id.rawId();
180  return _etype==fHcalElectronicsMap? _emap->lookup(id).rawId():
181  _ids[hash];
182  }
183 
185  {
186  std::cout << "Electronics HashMap Type=" << _etype << std::endl;
187  BOOST_FOREACH(EMapType::value_type &v, _ids)
188  {
189  std::cout << std::hex << v.first
190  << " "<< v.second << std::dec << std::endl;
191  }
192  }
193  }
194 }
std::vector< HcalElectronicsId > allElectronicsIdPrecision() const
uint32_t rawId() const
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< HcalElectronicsId > allElectronicsIdTrigger() const
bool isHcalDetId() const
HcalElectronicsMap const * _emap
Definition: DetId.h:18
virtual bool filter(HcalDetId const &) const
Definition: HashFilter.cc:36
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
tuple cout
Definition: gather_cfg.py:145
uint32_t hash_EChannel(HcalElectronicsId const &)
Readout chain identification for Hcal.
std::vector< HcalTrigTowerDetId > allTriggerId() const
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id