Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::rec::alg::KNNClusterAlg Class Reference

#include <KNNClusterAlg.h>

Public Member Functions

 KNNClusterAlg (fhicl::ParameterSet const &pset)
 
virtual ~KNNClusterAlg ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
bool usesTracks ()
 
void PrepareAlgo (const std::vector< art::Ptr< gar::rec::Track > > &trkVector, const std::vector< art::Ptr< gar::rec::CaloHit > > &hitVector, std::unordered_map< const gar::rec::Track *, art::Ptr< gar::rec::Track > > &trkMaptoArtPtr, std::unordered_map< const gar::rec::CaloHit *, art::Ptr< gar::rec::CaloHit > > &hitMaptoArtPtr)
 
void DoClustering ()
 
ClusterVec GetFoundClusters () const
 

Private Member Functions

void ClearLists ()
 

Private Attributes

gar::geo::GeometryCore const * fGeo
 geometry information More...
 
std::string fClusterAlgName
 
float m_EnergyCut
 
float m_DistanceCut
 
CaloHitVec m_CaloHitVec
 
TrackVec m_TrackVec
 
ClusterVec clusterVector
 

Detailed Description

Definition at line 40 of file KNNClusterAlg.h.

Constructor & Destructor Documentation

gar::rec::alg::KNNClusterAlg::KNNClusterAlg ( fhicl::ParameterSet const &  pset)

Definition at line 22 of file KNNClusterAlg.cxx.

23  {
24  fGeo = gar::providerFrom<geo::GeometryGAr>();
25  this->reconfigure(pset);
26  ClearLists();
27  return;
28  }
gar::geo::GeometryCore const * fGeo
geometry information
Definition: KNNClusterAlg.h:61
void reconfigure(fhicl::ParameterSet const &pset)
gar::rec::alg::KNNClusterAlg::~KNNClusterAlg ( )
virtual

Definition at line 30 of file KNNClusterAlg.cxx.

31  {
32  return;
33  }

Member Function Documentation

void gar::rec::alg::KNNClusterAlg::ClearLists ( )
private

Definition at line 46 of file KNNClusterAlg.cxx.

47  {
48  clusterVector.clear();
49  m_CaloHitVec.clear();
50  m_TrackVec.clear();
51 
52  return;
53  }
void gar::rec::alg::KNNClusterAlg::DoClustering ( )

Definition at line 84 of file KNNClusterAlg.cxx.

85  {
86  GenericHitVec< gar::rec::CaloHit > h;
87 
88  GenericClusterVec< gar::rec::CaloHit > cl;
89 
90  EnergyCut< gar::rec::CaloHit > eCut( m_EnergyCut );
91 
92  XIndex< gar::rec::CaloHit, 280 > xIndex( -350 , 350. );
93 
94  NNDistance< gar::rec::CaloHit, float> dist( m_DistanceCut );
95 
96  /* DEBLEO fGeo>GetECALEndcapStartX() returns 260 cm, which seems wrong;
97  and fGeo->GetECALEndcapOuterX() returns 374.4 cm, also seems wrong. */
98  AlgCluster< gar::rec::CaloHit > converter( fGeo->GetECALEndcapStartX() );
99 
100  int nHit = 0;
101  nHit += m_CaloHitVec.size();
102 
103  // create a vector of generic hits from the collection applying an energy cut
104  addToGenericHitVec( h , m_CaloHitVec , eCut , xIndex ) ;
105 
106  // cluster the hits with a nearest neighbour condition
107  cluster( h.begin() , h.end() , std::back_inserter( cl ) , &dist ) ;
108 
109  MF_LOG_DEBUG("KNNClusterAlg::DoClustering()")
110  << " Passing " << h.size() << " of " << nHit
111  << " hits to clustering (E_cut: " << m_EnergyCut << ") "
112  << " found " << cl.size() << " clusters ";
113 
114  // create Clusters from the clustered GenericHits
115  std::transform( cl.begin(), cl.end(), std::back_inserter( clusterVector ), converter ) ;
116 
117  return;
118  }
void cluster(In first, In last, Out result, Pred *pred)
Definition: NNClusters.h:41
void addToGenericHitVec(GenericHitVec< T > &v, CaloHitVec vec, Pred pred)
Definition: NNClusters.h:208
QAsciiDict< Entry > cl
gar::geo::GeometryCore const * fGeo
geometry information
Definition: KNNClusterAlg.h:61
float GetECALEndcapStartX() const
Definition: GeometryCore.h:975
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
#define MF_LOG_DEBUG(id)
ClusterVec gar::rec::alg::KNNClusterAlg::GetFoundClusters ( ) const
inline

Definition at line 55 of file KNNClusterAlg.h.

55 { return clusterVector; }
void gar::rec::alg::KNNClusterAlg::PrepareAlgo ( const std::vector< art::Ptr< gar::rec::Track > > &  trkVector,
const std::vector< art::Ptr< gar::rec::CaloHit > > &  hitVector,
std::unordered_map< const gar::rec::Track *, art::Ptr< gar::rec::Track > > &  trkMaptoArtPtr,
std::unordered_map< const gar::rec::CaloHit *, art::Ptr< gar::rec::CaloHit > > &  hitMaptoArtPtr 
)

Definition at line 56 of file KNNClusterAlg.cxx.

57  {
58  //Clear the lists
59  ClearLists();
60 
61  //Loop over all tracks
62  for (std::vector< art::Ptr<gar::rec::Track> >::const_iterator iter = trkVector.begin(), iterEnd = trkVector.end(); iter != iterEnd; ++iter)
63  {
64  art::Ptr<gar::rec::Track> trkPtr = *iter;
65  const gar::rec::Track *track = trkPtr.get();
66  m_TrackVec.push_back( const_cast<gar::rec::Track *>(track) );
67  //update the track art ptr map
68  trkMaptoArtPtr.insert( std::make_pair(track, trkPtr) );
69  }
70  //Loop over all hits
71  for (std::vector< art::Ptr<gar::rec::CaloHit> >::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end(); iter != iterEnd; ++iter)
72  {
73  art::Ptr<gar::rec::CaloHit> hitPtr = *iter;
74  const gar::rec::CaloHit *hit = hitPtr.get();
75  m_CaloHitVec.push_back( const_cast<gar::rec::CaloHit *>(hit) );
76  //update the hit art ptr map
77  hitMaptoArtPtr.insert( std::make_pair(hit, hitPtr) );
78  }
79 
80  return;
81  }
struct vector vector
Detector simulation of raw signals on wires.
T const * get() const
Definition: Ptr.h:149
void gar::rec::alg::KNNClusterAlg::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 35 of file KNNClusterAlg.cxx.

36  {
37  fClusterAlgName = pset.get<std::string>("ClusterAlgName");
38 
39  //Algorithm parameters
40  m_EnergyCut = pset.get<float>("EnergyCut", 0.);
41  m_DistanceCut = pset.get<float>("DistanceCut", 5.f);
42 
43  return;
44  }
std::string string
Definition: nybbler.cc:12
bool gar::rec::alg::KNNClusterAlg::usesTracks ( )
inline

Definition at line 49 of file KNNClusterAlg.h.

49 {return false;}

Member Data Documentation

ClusterVec gar::rec::alg::KNNClusterAlg::clusterVector
private

Definition at line 69 of file KNNClusterAlg.h.

std::string gar::rec::alg::KNNClusterAlg::fClusterAlgName
private

Definition at line 63 of file KNNClusterAlg.h.

gar::geo::GeometryCore const* gar::rec::alg::KNNClusterAlg::fGeo
private

geometry information

Definition at line 61 of file KNNClusterAlg.h.

CaloHitVec gar::rec::alg::KNNClusterAlg::m_CaloHitVec
private

Definition at line 67 of file KNNClusterAlg.h.

float gar::rec::alg::KNNClusterAlg::m_DistanceCut
private

Definition at line 65 of file KNNClusterAlg.h.

float gar::rec::alg::KNNClusterAlg::m_EnergyCut
private

Definition at line 64 of file KNNClusterAlg.h.

TrackVec gar::rec::alg::KNNClusterAlg::m_TrackVec
private

Definition at line 68 of file KNNClusterAlg.h.


The documentation for this class was generated from the following files: