Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:59

0001 #ifndef RecoLocalTracker_Cluster_Parameter_Estimator_Fake_H
0002 #define RecoLocalTracker_Cluster_Parameter_Estimator_Fake_H
0003 
0004 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0005 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0006 
0007 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0008 
0009 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0010 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0011 
0012 #include <cstdint>
0013 #include <unordered_map>
0014 
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 
0017 class FakeCPE {
0018 public:
0019   using LocalValues = std::pair<LocalPoint, LocalError>;
0020 
0021   // store position and error for each cluster...
0022   class Map {
0023   public:
0024     using LocalValues = std::pair<LocalPoint, LocalError>;
0025     void clear() { m_map.clear(); }
0026     void error(const GeomDetUnit& gd) const {
0027       edm::LogError("FakeCPE") << "hit not found in det " << gd.geographicalId().rawId();
0028     }
0029     template <typename Cluster>
0030     void add(const Cluster& cluster, const GeomDetUnit& gd, LocalValues const& lv) {
0031       m_map[encode(cluster, gd)] = lv;
0032     }
0033 
0034     template <typename Cluster>
0035     LocalValues const& get(const Cluster& cluster, const GeomDetUnit& gd) const {
0036       auto p = m_map.find(encode(cluster, gd));
0037       if (p != m_map.end()) {
0038         return (*p).second;
0039       }
0040       error(gd);
0041       return dummy;
0042     }
0043 
0044     static uint64_t encode(const SiPixelCluster& cluster, const GeomDetUnit& det) {
0045       uint64_t u1 = det.geographicalId().rawId();
0046       uint64_t u2 = cluster.minPixelRow();
0047       uint64_t u3 = cluster.minPixelCol();
0048       return (u1 << 32) | (u2 << 16) | u3;
0049     }
0050     static uint64_t encode(const SiStripCluster& cluster, const GeomDetUnit& det) {
0051       uint64_t u1 = det.geographicalId().rawId();
0052       uint64_t u2 = cluster.firstStrip();
0053       return (u1 << 32) | u2;
0054     }
0055 
0056   private:
0057     std::unordered_map<uint64_t, LocalValues> m_map;
0058     LocalValues dummy;
0059   };
0060 
0061   Map& map() { return m_map; }
0062   Map const& map() const { return m_map; }
0063 
0064 private:
0065   Map m_map;
0066 };
0067 
0068 #endif