CMS 3D CMS Logo

HGCalClusteringAlgoBase.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_HGCalRecProducers_HGCalClusteringAlgoBase_h
2 #define RecoLocalCalo_HGCalRecProducers_HGCalClusteringAlgoBase_h
3 
6 
10 
12 
13 // C/C++ headers
14 #include <vector>
15 #include <numeric>
16 
17 namespace hgcal_clustering {
18  template <typename T>
19  std::vector<size_t> sorted_indices(const std::vector<T> &v) {
20  // initialize original index locations
21  std::vector<size_t> idx(v.size());
22  std::iota(std::begin(idx), std::end(idx), 0);
23 
24  // sort indices based on comparing values in v
25  std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] > v[i2]; });
26 
27  return idx;
28  }
29 
30  template <typename T>
31  size_t max_index(const std::vector<T> &v) {
32  // initialize original index locations
33  std::vector<size_t> idx(v.size(), 0);
34  std::iota(std::begin(idx), std::end(idx), 0);
35 
36  // take the max index based on comparing values in v
37  auto maxidx = std::max_element(
38  idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1].data.rho < v[i2].data.rho; });
39 
40  return (*maxidx);
41  }
42 
43  //Density collection
44  typedef std::map<DetId, float> Density;
45 
46 }; // namespace hgcal_clustering
47 
49 public:
50  enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 };
51 
54 
55  virtual void populate(const HGCRecHitCollection &hits) = 0;
56  virtual void makeClusters() = 0;
57  virtual std::vector<reco::BasicCluster> getClusters(bool) = 0;
58  virtual void reset() = 0;
59  virtual hgcal_clustering::Density getDensity() { return {}; }; //implementation is in some child class
60  virtual void getEventSetupPerAlgorithm(const edm::EventSetup &es) {} //implementation is in some child class
61 
62  inline void getEventSetup(const edm::EventSetup &es, hgcal::RecHitTools rhtools) {
63  rhtools_ = rhtools;
70  }
71  inline void setVerbosity(VerbosityLevel the_verbosity) { verbosity_ = the_verbosity; }
72  inline void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose = false) {
73  algoId_ = algo;
74  isNose_ = isNose;
75  }
76 
77  //max number of layers
78  unsigned int maxlayer_;
79  // last layer per subdetector
80  unsigned int lastLayerEE_;
81  unsigned int lastLayerFH_;
82  unsigned int firstLayerBH_;
84  bool isNose_;
85 
86 protected:
87  // The verbosity level
89 
90  // The vector of clusters
91  std::vector<reco::BasicCluster> clusters_v_;
92 
94 
95  // The algo id
97 
99 };
100 
101 #endif
std::vector< reco::BasicCluster > clusters_v_
virtual hgcal_clustering::Density getDensity()
void setVerbosity(VerbosityLevel the_verbosity)
unsigned int firstLayerBH() const
Definition: RecHitTools.h:78
std::map< DetId, float > Density
HGCalClusteringAlgoBase(VerbosityLevel v, reco::CaloCluster::AlgoId algo)
virtual void reset()=0
unsigned int lastLayerFH() const
Definition: RecHitTools.h:77
void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose=false)
std::vector< size_t > sorted_indices(const std::vector< T > &v)
reco::CaloCluster::AlgoId algoId_
int getScintMaxIphi() const
Definition: RecHitTools.h:85
virtual void makeClusters()=0
size_t max_index(const std::vector< T > &v)
virtual std::vector< reco::BasicCluster > getClusters(bool)=0
virtual void populate(const HGCRecHitCollection &hits)=0
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76
virtual void getEventSetupPerAlgorithm(const edm::EventSetup &es)
void getEventSetup(const edm::EventSetup &es, hgcal::RecHitTools rhtools)
unsigned int lastLayer(bool nose=false) const
Definition: RecHitTools.h:80
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_