CMS 3D CMS Logo

HGCal3DClustering.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_HGCalRecAlgos_HGCal3DClustering
2 #define RecoLocalCalo_HGCalRecAlgos_HGCal3DClustering
3 
7 
8 #include <vector>
9 #include <array>
10 
13 
15 
17 public:
18  HGCal3DClustering() : radii({0., 0., 0.}), minClusters(0), clusterTools(nullptr) {}
19 
22  const std::vector<double>& radii_in,
23  uint32_t min_clusters)
24  : radii(radii_in),
25  minClusters(min_clusters),
26  es(0),
27  clusterTools(std::make_unique<hgcal::ClusterTools>(conf, sumes)),
29 
31  : HGCal3DClustering(conf,
32  sumes,
33  conf.getParameter<std::vector<double>>("multiclusterRadii"),
34  conf.getParameter<unsigned>("minClusters")) {}
35 
36  void getEvent(const edm::Event& ev) { clusterTools->getEvent(ev); }
38  clusterTools->getEventSetup(es);
39  const CaloGeometry& geom = es.getData(caloGeomToken_);
42  points.clear();
43  minpos.clear();
44  maxpos.clear();
45  zees.clear();
46  points.resize(2 * (maxlayer + 1));
47  minpos.resize(2 * (maxlayer + 1), {{0.0f, 0.0f}});
48  maxpos.resize(2 * (maxlayer + 1), {{0.0f, 0.0f}});
49  zees.resize(2 * (maxlayer + 1), 0.);
50  }
51 
52  typedef std::vector<reco::BasicCluster> ClusterCollection;
53 
54  std::vector<reco::HGCalMultiCluster> makeClusters(const reco::HGCalMultiCluster::ClusterCollection&);
55 
56 private:
58  void reset() {
59  for (auto& it : points) {
60  it.clear();
61  std::vector<KDNode>().swap(it);
62  }
63  std::fill(zees.begin(), zees.end(), 0.);
64  for (unsigned int i = 0; i < minpos.size(); i++) {
65  minpos[i][0] = 0.;
66  minpos[i][1] = 0.;
67  maxpos[i][0] = 0.;
68  maxpos[i][1] = 0.;
69  }
70  }
71  void layerIntersection(std::array<double, 3>& to, const std::array<double, 3>& from) const;
72 
73  //max number of layers
74  unsigned int maxlayer;
75 
76  std::vector<double> radii;
77  uint32_t minClusters;
78  struct ClusterRef {
79  int ind;
80  float z;
81  ClusterRef(int ind_i, float z_i) : ind(ind_i), z(z_i) {}
82  ClusterRef() : ind(-1), z(0.) {}
83  };
84 
87  std::vector<std::vector<KDNode>> points;
88  std::vector<std::array<float, 2>> minpos;
89  std::vector<std::array<float, 2>> maxpos;
90  std::vector<size_t> es;
91  std::vector<float> zees;
92  std::unique_ptr<hgcal::ClusterTools> clusterTools;
95 };
96 
97 #endif
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< std::vector< KDNode > > points
ClusterRef(int ind_i, float z_i)
KDTreeNodeInfo< ClusterRef > KDNode
void getEventSetup(const edm::EventSetup &es)
HGCal3DClustering(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
std::vector< reco::BasicCluster > ClusterCollection
std::vector< double > radii
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
void organizeByLayer(const reco::HGCalMultiCluster::ClusterCollection &)
KDTreeLinkerAlgo< ClusterRef > KDTree
std::vector< float > zees
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
std::vector< std::array< float, 2 > > maxpos
std::vector< std::array< float, 2 > > minpos
void layerIntersection(std::array< double, 3 > &to, const std::array< double, 3 > &from) const
void getEvent(const edm::Event &ev)
unsigned int lastLayerBH() const
Definition: RecHitTools.h:78
HGCal3DClustering(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes, const std::vector< double > &radii_in, uint32_t min_clusters)
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
std::unique_ptr< hgcal::ClusterTools > clusterTools
hgcal::RecHitTools rhtools_
unsigned int maxlayer
std::vector< size_t > es
std::vector< reco::HGCalMultiCluster > makeClusters(const reco::HGCalMultiCluster::ClusterCollection &)