LDMX Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ecal::TemplatedClusterFinder< WeightClass > Class Template Reference

Public Member Functions

void add (const ldmx::EcalHit *eh, const ldmx::EcalGeometry &hex)
 
void cluster (double seed_threshold, double cutoff)
 
double getYMax () const
 
int getNSeeds () const
 
std::map< int, double > getWeights () const
 
std::vector< WorkingClustergetClusters () const
 

Static Public Member Functions

static bool compClusters (const WorkingCluster &a, const WorkingCluster &b)
 

Private Attributes

WeightClass wgt_
 
double finalwgt_
 
int nseeds_
 
std::map< int, double > transitionWeights_
 
std::vector< WorkingClusterclusters_
 

Detailed Description

template<class WeightClass>
class ecal::TemplatedClusterFinder< WeightClass >

Definition at line 19 of file TemplatedClusterFinder.h.

Member Function Documentation

◆ add()

template<class WeightClass >
void ecal::TemplatedClusterFinder< WeightClass >::add ( const ldmx::EcalHit eh,
const ldmx::EcalGeometry hex 
)
inline

Definition at line 21 of file TemplatedClusterFinder.h.

21 {
22 clusters_.push_back(WorkingCluster(eh, hex));
23 }

◆ cluster()

template<class WeightClass >
void ecal::TemplatedClusterFinder< WeightClass >::cluster ( double  seed_threshold,
double  cutoff 
)
inline

Definition at line 29 of file TemplatedClusterFinder.h.

29 {
30 int ncluster = clusters_.size();
31 double minwgt = cutoff;
32
33 std::sort(clusters_.begin(), clusters_.end(), compClusters);
34 do {
35 bool any = false;
36 size_t mi(0), mj(0);
37
38 int nseeds = 0;
39
40 for (size_t i = 0; i < clusters_.size(); i++) {
41 if (clusters_[i].empty()) continue;
42
43 bool iseed = (clusters_[i].centroid().E() >= seed_threshold);
44 if (iseed) {
45 nseeds++;
46 } else {
47 // Since we sorted initially if we find a hit below seed threshold
48 // it is guaranteed that there will be no seeds after.
49 break;
50 }
51
52 for (size_t j = i + 1; j < clusters_.size(); j++) {
53 if (clusters_[j].empty() ||
54 (!iseed && clusters_[j].centroid().E() < seed_threshold))
55 continue;
56 double wgt = wgt_(clusters_[i], clusters_[j]);
57 if (!any || wgt < minwgt) {
58 any = true;
59 minwgt = wgt;
60 mi = i;
61 mj = j;
62 }
63 }
64 }
65
66 nseeds_ = nseeds;
67 transitionWeights_.insert(std::pair<int, double>(ncluster, minwgt));
68
69 if (any && minwgt < cutoff) {
70 // put the bigger one in mi
71 if (clusters_[mi].centroid().E() < clusters_[mj].centroid().E()) {
72 std::swap(mi, mj);
73 }
74 // now we have the smallest, merge
75 clusters_[mi].add(clusters_[mj]);
76 clusters_[mj].clear();
77 // decrement cluster count
78 ncluster--;
79 }
80
81 } while (minwgt < cutoff && ncluster > 1);
82 finalwgt_ = minwgt;
83 }

◆ compClusters()

template<class WeightClass >
static bool ecal::TemplatedClusterFinder< WeightClass >::compClusters ( const WorkingCluster a,
const WorkingCluster b 
)
inlinestatic

Definition at line 25 of file TemplatedClusterFinder.h.

25 {
26 return a.centroid().E() > b.centroid().E();
27 }

◆ getClusters()

template<class WeightClass >
std::vector< WorkingCluster > ecal::TemplatedClusterFinder< WeightClass >::getClusters ( ) const
inline

Definition at line 91 of file TemplatedClusterFinder.h.

91{ return clusters_; }

◆ getNSeeds()

template<class WeightClass >
int ecal::TemplatedClusterFinder< WeightClass >::getNSeeds ( ) const
inline

Definition at line 87 of file TemplatedClusterFinder.h.

87{ return nseeds_; }

◆ getWeights()

template<class WeightClass >
std::map< int, double > ecal::TemplatedClusterFinder< WeightClass >::getWeights ( ) const
inline

Definition at line 89 of file TemplatedClusterFinder.h.

89{ return transitionWeights_; }

◆ getYMax()

template<class WeightClass >
double ecal::TemplatedClusterFinder< WeightClass >::getYMax ( ) const
inline

Definition at line 85 of file TemplatedClusterFinder.h.

85{ return finalwgt_; }

Member Data Documentation

◆ clusters_

template<class WeightClass >
std::vector<WorkingCluster> ecal::TemplatedClusterFinder< WeightClass >::clusters_
private

Definition at line 98 of file TemplatedClusterFinder.h.

◆ finalwgt_

template<class WeightClass >
double ecal::TemplatedClusterFinder< WeightClass >::finalwgt_
private

Definition at line 95 of file TemplatedClusterFinder.h.

◆ nseeds_

template<class WeightClass >
int ecal::TemplatedClusterFinder< WeightClass >::nseeds_
private

Definition at line 96 of file TemplatedClusterFinder.h.

◆ transitionWeights_

template<class WeightClass >
std::map<int, double> ecal::TemplatedClusterFinder< WeightClass >::transitionWeights_
private

Definition at line 97 of file TemplatedClusterFinder.h.

◆ wgt_

template<class WeightClass >
WeightClass ecal::TemplatedClusterFinder< WeightClass >::wgt_
private

Definition at line 94 of file TemplatedClusterFinder.h.


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