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