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 
5 
9 
11 
12 // C/C++ headers
13 #include <vector>
14 #include <numeric>
15 
16 namespace hgcal_clustering {
17 template <typename T>
18 std::vector<size_t> sorted_indices(const std::vector<T> &v) {
19 
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(),
26  [&v](size_t i1, size_t i2) {
27  return v[i1] > v[i2];
28  });
29 
30  return idx;
31 }
32 
33 template <typename T>
34 size_t max_index(const std::vector<T> &v) {
35 
36  // initialize original index locations
37  std::vector<size_t> idx(v.size(),0);
38  std::iota (std::begin(idx), std::end(idx), 0);
39 
40  // take the max index based on comparing values in v
41  auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1].data.rho < v[i2].data.rho;});
42 
43  return (*maxidx);
44 }
45 
46 //Density collection
47 typedef std::map< DetId, float > Density;
48 
49 };
50 
52 {
53 
54 public:
55 
56 enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 };
57 
60  : verbosity_(v), algoId_(algo) {};
62 
63  virtual void populate(const HGCRecHitCollection &hits) = 0;
64  virtual void makeClusters() = 0;
65  virtual std::vector<reco::BasicCluster> getClusters(bool) = 0;
66  virtual void reset() = 0;
67  virtual hgcal_clustering::Density getDensity() = 0;
68 
69  inline void getEventSetup(const edm::EventSetup& es){
70  rhtools_.getEventSetup(es);
71  }
72  inline void setVerbosity(VerbosityLevel the_verbosity) {
73  verbosity_ = the_verbosity;
74  }
75  inline void setAlgoId(reco::CaloCluster::AlgoId algo) {algoId_ = algo;}
76 
77  //max number of layers
78  static const unsigned int maxlayer = 52;
79  // last layer per subdetector
80  static const unsigned int lastLayerEE = 28;
81  static const unsigned int lastLayerFH = 40;
82 
83 protected:
84  // The verbosity level
86 
87  // The vector of clusters
88  std::vector<reco::BasicCluster> clusters_v_;
89 
91 
92  // The algo id
94 
95 };
96 
97 #endif
std::map< DetId, float > Density
std::vector< reco::BasicCluster > clusters_v_
void setVerbosity(VerbosityLevel the_verbosity)
HGCalClusteringAlgoBase(VerbosityLevel v, reco::CaloCluster::AlgoId algo)
std::vector< size_t > sorted_indices(const std::vector< T > &v)
#define end
Definition: vmac.h:39
reco::CaloCluster::AlgoId algoId_
#define begin
Definition: vmac.h:32
void getEventSetup(const edm::EventSetup &es)
size_t max_index(const std::vector< T > &v)
void setAlgoId(reco::CaloCluster::AlgoId algo)
void reset(double vett[256])
Definition: TPedValues.cc:11