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 
55 
56  virtual void populate(const HGCRecHitCollection &hits) = 0;
57  virtual void makeClusters() = 0;
58  virtual std::vector<reco::BasicCluster> getClusters(bool) = 0;
59  virtual void reset() = 0;
61  virtual void getEventSetupPerAlgorithm(const edm::EventSetup &es) {}
62 
63  inline void getEventSetup(const edm::EventSetup &es) {
72  }
73  inline void setVerbosity(VerbosityLevel the_verbosity) { verbosity_ = the_verbosity; }
74  inline void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose = false) {
75  algoId_ = algo;
76  isNose_ = isNose;
77  }
78 
79  //max number of layers
80  unsigned int maxlayer_;
81  // last layer per subdetector
82  unsigned int lastLayerEE_;
83  unsigned int lastLayerFH_;
84  unsigned int firstLayerBH_;
86  bool isNose_;
87 
88 protected:
89  // The verbosity level
91 
92  // The vector of clusters
93  std::vector<reco::BasicCluster> clusters_v_;
94 
96 
97  // The algo id
99 
101 };
102 
103 #endif
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
HGCalClusteringAlgoBase(VerbosityLevel v, reco::CaloCluster::AlgoId algo, edm::ConsumesCollector iC)
std::vector< reco::BasicCluster > clusters_v_
void setVerbosity(VerbosityLevel the_verbosity)
unsigned int firstLayerBH() const
Definition: RecHitTools.h:77
std::map< DetId, float > Density
virtual void reset()=0
unsigned int lastLayerFH() const
Definition: RecHitTools.h:76
void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose=false)
virtual hgcal_clustering::Density getDensity()=0
std::vector< size_t > sorted_indices(const std::vector< T > &v)
reco::CaloCluster::AlgoId algoId_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
int getScintMaxIphi() const
Definition: RecHitTools.h:84
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
virtual void makeClusters()=0
void getEventSetup(const edm::EventSetup &es)
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:75
virtual void getEventSetupPerAlgorithm(const edm::EventSetup &es)
unsigned int lastLayer(bool nose=false) const
Definition: RecHitTools.h:79
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_