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) {
71  }
72  inline void setVerbosity(VerbosityLevel the_verbosity) { verbosity_ = the_verbosity; }
73  inline void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose = false) {
74  algoId_ = algo;
75  isNose_ = isNose;
76  }
77 
78  //max number of layers
79  unsigned int maxlayer_;
80  // last layer per subdetector
81  unsigned int lastLayerEE_;
82  unsigned int lastLayerFH_;
83  unsigned int firstLayerBH_;
85  bool isNose_;
86 
87 protected:
88  // The verbosity level
90 
91  // The vector of clusters
92  std::vector<reco::BasicCluster> clusters_v_;
93 
95 
96  // The algo id
98 };
99 
100 #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:23
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:89
BasicCluster.h
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
edm::SortedCollection
Definition: SortedCollection.h:49
findQualityFiles.v
v
Definition: findQualityFiles.py:179
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
cmsdt::algo
algo
Definition: constants.h:164
hgcal::RecHitTools::lastLayerFH
unsigned int lastLayerFH() const
Definition: RecHitTools.h:65
HGCalClusteringAlgoBase::lastLayerFH_
unsigned int lastLayerFH_
Definition: HGCalClusteringAlgoBase.h:82
HGCalClusteringAlgoBase::reset
virtual void reset()=0
HGCalClusteringAlgoBase::clusters_v_
std::vector< reco::BasicCluster > clusters_v_
Definition: HGCalClusteringAlgoBase.h:92
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
HGCalClusteringAlgoBase::lastLayerEE_
unsigned int lastLayerEE_
Definition: HGCalClusteringAlgoBase.h:81
HGCalClusteringAlgoBase::firstLayerBH_
unsigned int firstLayerBH_
Definition: HGCalClusteringAlgoBase.h:83
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
mps_fire.end
end
Definition: mps_fire.py:242
edm::ESHandle< CaloGeometry >
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
reco::CaloCluster::AlgoId
AlgoId
Definition: CaloCluster.h:33
hgcal_clustering
Definition: HGCalClusteringAlgoBase.h:16
HGCalClusteringAlgoBase::setVerbosity
void setVerbosity(VerbosityLevel the_verbosity)
Definition: HGCalClusteringAlgoBase.h:72
HGCalClusteringAlgoBase::algoId_
reco::CaloCluster::AlgoId algoId_
Definition: HGCalClusteringAlgoBase.h:97
HGCalClusteringAlgoBase::setAlgoId
void setAlgoId(reco::CaloCluster::AlgoId algo, bool isNose=false)
Definition: HGCalClusteringAlgoBase.h:73
HGCRecHitCollections.h
HGCalClusteringAlgoBase::rhtools_
hgcal::RecHitTools rhtools_
Definition: HGCalClusteringAlgoBase.h:94
hgcal::RecHitTools::lastLayerEE
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:64
HGCalClusteringAlgoBase::maxlayer_
unsigned int maxlayer_
Definition: HGCalClusteringAlgoBase.h:79
HGCalClusteringAlgoBase::getDensity
virtual hgcal_clustering::Density getDensity()=0
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
hgcal::RecHitTools::lastLayer
unsigned int lastLayer(bool nose=false) const
Definition: RecHitTools.h:68
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:66
hgcal::RecHitTools::setGeometry
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
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:84
HGCalClusteringAlgoBase::makeClusters
virtual void makeClusters()=0
HGCalClusteringAlgoBase::VerbosityLevel
VerbosityLevel
Definition: HGCalClusteringAlgoBase.h:49
HGCalClusteringAlgoBase
Definition: HGCalClusteringAlgoBase.h:47
RecHitTools.h
hgcal::RecHitTools::getScintMaxIphi
int getScintMaxIphi() const
Definition: RecHitTools.h:72
HGCalClusteringAlgoBase::isNose_
bool isNose_
Definition: HGCalClusteringAlgoBase.h:85
HGCalClusteringAlgoBase::getEventSetup
void getEventSetup(const edm::EventSetup &es)
Definition: HGCalClusteringAlgoBase.h:61