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  // initialize original index locations
20  std::vector<size_t> idx(v.size());
21  std::iota(std::begin(idx), std::end(idx), 0);
22 
23  // sort indices based on comparing values in v
24  std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] > v[i2]; });
25 
26  return idx;
27  }
28 
29  template <typename T>
30  size_t max_index(const std::vector<T> &v) {
31  // initialize original index locations
32  std::vector<size_t> idx(v.size(), 0);
33  std::iota(std::begin(idx), std::end(idx), 0);
34 
35  // take the max index based on comparing values in v
36  auto maxidx = std::max_element(
37  idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1].data.rho < v[i2].data.rho; });
38 
39  return (*maxidx);
40  }
41 
42  //Density collection
43  typedef std::map<DetId, float> Density;
44 
45 }; // namespace hgcal_clustering
46 
48 public:
49  enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 };
50 
53 
54  virtual void populate(const HGCRecHitCollection &hits) = 0;
55  virtual void makeClusters() = 0;
56  virtual std::vector<reco::BasicCluster> getClusters(bool) = 0;
57  virtual void reset() = 0;
59  virtual void getEventSetupPerAlgorithm(const edm::EventSetup &es) {}
60 
61  inline void getEventSetup(const edm::EventSetup &es) {
69  }
70  inline void setVerbosity(VerbosityLevel the_verbosity) { verbosity_ = the_verbosity; }
71  inline void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose = false) {
72  algoId_ = algo;
73  isNose_ = isNose;
74  }
75 
76  //max number of layers
77  unsigned int maxlayer_;
78  // last layer per subdetector
79  unsigned int lastLayerEE_;
80  unsigned int lastLayerFH_;
81  unsigned int firstLayerBH_;
83  bool isNose_;
84 
85 protected:
86  // The verbosity level
88 
89  // The vector of clusters
90  std::vector<reco::BasicCluster> clusters_v_;
91 
93 
94  // The algo id
96 };
97 
98 #endif
HGCalClusteringAlgoBase::getClusters
virtual std::vector< reco::BasicCluster > getClusters(bool)=0
HGCalClusteringAlgoBase::~HGCalClusteringAlgoBase
virtual ~HGCalClusteringAlgoBase()
Definition: HGCalClusteringAlgoBase.h:52
HGCalClusteringAlgoBase::populate
virtual void populate(const HGCRecHitCollection &hits)=0
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
hgcal::RecHitTools
Definition: RecHitTools.h:21
HGCalClusteringAlgoBase::pINFO
Definition: HGCalClusteringAlgoBase.h:49
hgcal_clustering::sorted_indices
std::vector< size_t > sorted_indices(const std::vector< T > &v)
Definition: HGCalClusteringAlgoBase.h:18
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HGCalClusteringAlgoBase::verbosity_
VerbosityLevel verbosity_
Definition: HGCalClusteringAlgoBase.h:87
BasicCluster.h
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
edm::SortedCollection
Definition: SortedCollection.h:49
findQualityFiles.v
v
Definition: findQualityFiles.py:179
training_settings.idx
idx
Definition: training_settings.py:16
end
#define end
Definition: vmac.h:39
cmsdt::algo
algo
Definition: constants.h:164
hgcal::RecHitTools::lastLayerFH
unsigned int lastLayerFH() const
Definition: RecHitTools.h:64
HGCalClusteringAlgoBase::lastLayerFH_
unsigned int lastLayerFH_
Definition: HGCalClusteringAlgoBase.h:80
HGCalClusteringAlgoBase::reset
virtual void reset()=0
HGCalClusteringAlgoBase::clusters_v_
std::vector< reco::BasicCluster > clusters_v_
Definition: HGCalClusteringAlgoBase.h:90
HGCalClusteringAlgoBase::lastLayerEE_
unsigned int lastLayerEE_
Definition: HGCalClusteringAlgoBase.h:79
HGCalClusteringAlgoBase::firstLayerBH_
unsigned int firstLayerBH_
Definition: HGCalClusteringAlgoBase.h:81
HGCalClusteringAlgoBase::HGCalClusteringAlgoBase
HGCalClusteringAlgoBase(VerbosityLevel v, reco::CaloCluster::AlgoId algo)
Definition: HGCalClusteringAlgoBase.h:51
hgcal_clustering::Density
std::map< DetId, float > Density
Definition: HGCalClusteringAlgoBase.h:43
reco::CaloCluster::AlgoId
AlgoId
Definition: CaloCluster.h:33
hgcal_clustering
Definition: HGCalClusteringAlgoBase.h:16
HGCalClusteringAlgoBase::setVerbosity
void setVerbosity(VerbosityLevel the_verbosity)
Definition: HGCalClusteringAlgoBase.h:70
HGCalClusteringAlgoBase::algoId_
reco::CaloCluster::AlgoId algoId_
Definition: HGCalClusteringAlgoBase.h:95
HGCalClusteringAlgoBase::setAlgoId
void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose=false)
Definition: HGCalClusteringAlgoBase.h:71
HGCRecHitCollections.h
HGCalClusteringAlgoBase::rhtools_
hgcal::RecHitTools rhtools_
Definition: HGCalClusteringAlgoBase.h:92
hgcal::RecHitTools::lastLayerEE
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:63
HGCalClusteringAlgoBase::maxlayer_
unsigned int maxlayer_
Definition: HGCalClusteringAlgoBase.h:77
HGCalClusteringAlgoBase::getDensity
virtual hgcal_clustering::Density getDensity()=0
edm::EventSetup
Definition: EventSetup.h:57
hgcal::RecHitTools::getEventSetup
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:70
hgcal::RecHitTools::lastLayer
unsigned int lastLayer(bool nose=false) const
Definition: RecHitTools.h:67
hgcal_clustering::max_index
size_t max_index(const std::vector< T > &v)
Definition: HGCalClusteringAlgoBase.h:30
HGCalClusteringAlgoBase::pERROR
Definition: HGCalClusteringAlgoBase.h:49
hgcal::RecHitTools::firstLayerBH
unsigned int firstLayerBH() const
Definition: RecHitTools.h:65
HGCalClusteringAlgoBase::getEventSetupPerAlgorithm
virtual void getEventSetupPerAlgorithm(const edm::EventSetup &es)
Definition: HGCalClusteringAlgoBase.h:59
HGCalClusteringAlgoBase::pWARNING
Definition: HGCalClusteringAlgoBase.h:49
Point3D.h
EventSetup.h
HGCalClusteringAlgoBase::pDEBUG
Definition: HGCalClusteringAlgoBase.h:49
HGCalClusteringAlgoBase::scintMaxIphi_
int scintMaxIphi_
Definition: HGCalClusteringAlgoBase.h:82
HGCalClusteringAlgoBase::makeClusters
virtual void makeClusters()=0
HGCalClusteringAlgoBase::VerbosityLevel
VerbosityLevel
Definition: HGCalClusteringAlgoBase.h:49
HGCalClusteringAlgoBase
Definition: HGCalClusteringAlgoBase.h:47
begin
#define begin
Definition: vmac.h:32
RecHitTools.h
hgcal::RecHitTools::getScintMaxIphi
int getScintMaxIphi() const
Definition: RecHitTools.h:71
HGCalClusteringAlgoBase::isNose_
bool isNose_
Definition: HGCalClusteringAlgoBase.h:83
HGCalClusteringAlgoBase::getEventSetup
void getEventSetup(const edm::EventSetup &es)
Definition: HGCalClusteringAlgoBase.h:61