CMS 3D CMS Logo

FakeCPE.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_Cluster_Parameter_Estimator_Fake_H
2 #define RecoLocalTracker_Cluster_Parameter_Estimator_Fake_H
3 
6 
8 
11 
12 #include <cstdint>
13 #include <unordered_map>
14 
16 
17 class FakeCPE {
18 public:
19  using LocalValues = std::pair<LocalPoint, LocalError>;
20 
21  // store position and error for each cluster...
22  class Map {
23  public:
24  using LocalValues = std::pair<LocalPoint, LocalError>;
25  void clear() { m_map.clear(); }
26  void error(const GeomDetUnit& gd) const {
27  edm::LogError("FakeCPE") << "hit not found in det " << gd.geographicalId().rawId();
28  }
29  template <typename Cluster>
30  void add(const Cluster& cluster, const GeomDetUnit& gd, LocalValues const& lv) {
31  m_map[encode(cluster, gd)] = lv;
32  }
33 
34  template <typename Cluster>
35  LocalValues const& get(const Cluster& cluster, const GeomDetUnit& gd) const {
36  auto p = m_map.find(encode(cluster, gd));
37  if (p != m_map.end()) {
38  return (*p).second;
39  }
40  error(gd);
41  return dummy;
42  }
43 
44  static uint64_t encode(const SiPixelCluster& cluster, const GeomDetUnit& det) {
45  uint64_t u1 = det.geographicalId().rawId();
46  uint64_t u2 = cluster.minPixelRow();
47  uint64_t u3 = cluster.minPixelCol();
48  return (u1 << 32) | (u2 << 16) | u3;
49  }
50  static uint64_t encode(const SiStripCluster& cluster, const GeomDetUnit& det) {
51  uint64_t u1 = det.geographicalId().rawId();
52  uint64_t u2 = cluster.firstStrip();
53  return (u1 << 32) | u2;
54  }
55 
56  private:
57  std::unordered_map<uint64_t, LocalValues> m_map;
59  };
60 
61  Map& map() { return m_map; }
62  Map const& map() const { return m_map; }
63 
64 private:
66 };
67 
68 #endif
LocalValues dummy
Definition: FakeCPE.h:58
int minPixelCol() const
std::pair< LocalPoint, LocalError > LocalValues
Definition: FakeCPE.h:19
void clear()
Definition: FakeCPE.h:25
static uint64_t encode(const SiStripCluster &cluster, const GeomDetUnit &det)
Definition: FakeCPE.h:50
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::unordered_map< uint64_t, LocalValues > m_map
Definition: FakeCPE.h:57
uint16_t firstStrip() const
void error(const GeomDetUnit &gd) const
Definition: FakeCPE.h:26
int minPixelRow() const
Map & map()
Definition: FakeCPE.h:61
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Map const & map() const
Definition: FakeCPE.h:62
unsigned long long uint64_t
Definition: Time.h:13
static uint64_t encode(const SiPixelCluster &cluster, const GeomDetUnit &det)
Definition: FakeCPE.h:44
std::pair< LocalPoint, LocalError > LocalValues
Definition: FakeCPE.h:24
Pixel cluster – collection of neighboring pixels above threshold.
Map m_map
Definition: FakeCPE.h:65
void add(const Cluster &cluster, const GeomDetUnit &gd, LocalValues const &lv)
Definition: FakeCPE.h:30