HerdSoftware  0.4.0
CaloDBSCANClustering.h
Go to the documentation of this file.
1 /*
2  * CaloDBSCANClustering.h
3  *
4  * Created on: 24 Apr 2019
5  * Author: Valerio Formato
6  */
7 
8 #ifndef HERD_CaloDBSCANClustering_H_
9 #define HERD_CaloDBSCANClustering_H_
10 
11 // HerdSoftware headers
14 
15 // EventAnalysis headers
16 #include "algorithm/Algorithm.h"
17 
18 namespace Herd {
19 
20 //clang-format off
49 //clang-format on
50 
51 class CaloDBSCANClustering : public EA::Algorithm {
52 public:
57  CaloDBSCANClustering(const std::string &name);
58 
63  bool Initialize() override;
64 
69  bool Process() override;
70 
79  std::vector<std::string> FreeObjects(const std::vector<std::string> &objs, EA::Memory::Status memStatus) override;
80 
81 private:
82  // Algorithm parameters
83  float m_threshold;
84  float m_maxDist;
85  unsigned int m_minHits;
86  unsigned int m_minShowerHits;
87  std::string m_caloHitsName;
88 
89  // Class members
91  EA::observer_ptr<CaloGeoParams> m_caloGeoParams;
92  EA::EventStorePtr m_evStore;
93  EA::GlobalStorePtr m_globStore;
94 
96  std::map<unsigned int, int> m_labels; // key: volumeID, value: shower number (label)
97  void FindShowers(CaloHits &caloHits);
98 
99  using HitIt = std::vector<Hit>::const_iterator;
100  void BuildShowerFromSeed(HitIt seedIt, const CaloHits &hits);
101  std::vector<unsigned int> FindNeighborsHitID(HitIt hitIt, const CaloHits &hits);
102  unsigned int CountHitNeighbors(HitIt hitIt, const CaloHits &hits);
103  std::vector<unsigned int> NeighboringCubesID(unsigned int volID, CaloGeoParams &caloGeoParams);
104 
105  // value: all neighboring cubes ID to volumeID
106  std::vector<std::vector<unsigned int>> m_neighborCubes;
107  void BuildNeighborsMap(CaloGeoParams &caloGeoParams);
108  const std::vector<unsigned int> &NeighboringCubesID(unsigned int volID) { return m_neighborCubes[volID]; };
109 };
110 
111 } // namespace Herd
112 
113 #endif /* HERD_CaloDBSCANClustering_H_ */
Herd::CaloDBSCANClustering::BuildShowerFromSeed
void BuildShowerFromSeed(HitIt seedIt, const CaloHits &hits)
Definition: CaloDBSCANClustering.cpp:168
Herd::CaloDBSCANClustering::m_threshold
float m_threshold
Definition: CaloDBSCANClustering.h:83
Herd::CaloDBSCANClustering::m_nShowers
int m_nShowers
Definition: CaloDBSCANClustering.h:95
Herd::CaloDBSCANClustering::CaloDBSCANClustering
CaloDBSCANClustering(const std::string &name)
Constructor.
Definition: CaloDBSCANClustering.cpp:22
Herd::CaloDBSCANClustering::m_neighborCubes
std::vector< std::vector< unsigned int > > m_neighborCubes
Definition: CaloDBSCANClustering.h:106
Herd::CaloDBSCANClustering::m_caloHitsName
std::string m_caloHitsName
Definition: CaloDBSCANClustering.h:87
Herd::CaloDBSCANClustering::FreeObjects
std::vector< std::string > FreeObjects(const std::vector< std::string > &objs, EA::Memory::Status memStatus) override
Free the memory of unneeded objects.
Definition: CaloDBSCANClustering.cpp:263
Herd::CaloDBSCANClustering::m_labels
std::map< unsigned int, int > m_labels
Definition: CaloDBSCANClustering.h:96
CaloClusters
Container for a group of hits of the calorimeter.
Herd::CaloDBSCANClustering
Algorithm that clusters calorimeter hits into showers.
Definition: CaloDBSCANClustering.h:51
Herd::CaloDBSCANClustering::m_evStore
EA::EventStorePtr m_evStore
Definition: CaloDBSCANClustering.h:92
CaloClusters.h
Herd::CaloDBSCANClustering::CountHitNeighbors
unsigned int CountHitNeighbors(HitIt hitIt, const CaloHits &hits)
Definition: CaloDBSCANClustering.cpp:115
Herd::CaloDBSCANClustering::Process
bool Process() override
Process a single event.
Definition: CaloDBSCANClustering.cpp:57
Herd::CaloDBSCANClustering::Initialize
bool Initialize() override
Initialization of the algorithm.
Definition: CaloDBSCANClustering.cpp:38
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::CaloDBSCANClustering::m_maxDist
float m_maxDist
Definition: CaloDBSCANClustering.h:84
Herd::CaloDBSCANClustering::m_minShowerHits
unsigned int m_minShowerHits
Definition: CaloDBSCANClustering.h:86
CaloHits
Container for the hits of a single CALO detector.
Herd::CaloDBSCANClustering::m_globStore
EA::GlobalStorePtr m_globStore
Definition: CaloDBSCANClustering.h:93
Herd::CaloDBSCANClustering::NeighboringCubesID
const std::vector< unsigned int > & NeighboringCubesID(unsigned int volID)
Definition: CaloDBSCANClustering.h:108
Herd::CaloDBSCANClustering::HitIt
std::vector< Hit >::const_iterator HitIt
Definition: CaloDBSCANClustering.h:99
Herd::CaloGeoParams
Data structure for the Calo geometry parameters.
Definition: CaloGeoParams.h:35
CaloGeoParams.h
Herd::CaloDBSCANClustering::BuildNeighborsMap
void BuildNeighborsMap(CaloGeoParams &caloGeoParams)
Definition: CaloDBSCANClustering.cpp:257
Herd::CaloDBSCANClustering::m_showers
CaloClusters m_showers
Definition: CaloDBSCANClustering.h:90
Herd::CaloDBSCANClustering::m_caloGeoParams
EA::observer_ptr< CaloGeoParams > m_caloGeoParams
Definition: CaloDBSCANClustering.h:91
Herd::CaloDBSCANClustering::FindShowers
void FindShowers(CaloHits &caloHits)
Definition: CaloDBSCANClustering.cpp:119
Herd::CaloDBSCANClustering::FindNeighborsHitID
std::vector< unsigned int > FindNeighborsHitID(HitIt hitIt, const CaloHits &hits)
Definition: CaloDBSCANClustering.cpp:78
Herd::CaloDBSCANClustering::m_minHits
unsigned int m_minHits
Definition: CaloDBSCANClustering.h:85
Herd::CaloDBSCANClustering::NeighboringCubesID
std::vector< unsigned int > NeighboringCubesID(unsigned int volID, CaloGeoParams &caloGeoParams)
Definition: CaloDBSCANClustering.cpp:225