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

Public Member Functions

void add (const ldmx::HcalHit *eh, const ldmx::HcalGeometry &hex)
 
void cluster (double seed_threshold, double cutoff, double deltaTime)
 
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 hcal::TemplatedClusterFinder< WeightClass >

Definition at line 16 of file TemplatedClusterFinder.h.

Member Function Documentation

◆ add()

template<class WeightClass >
void hcal::TemplatedClusterFinder< WeightClass >::add ( const ldmx::HcalHit eh,
const ldmx::HcalGeometry hex 
)
inline

Definition at line 18 of file TemplatedClusterFinder.h.

18 {
19 clusters_.push_back(WorkingCluster(eh, hex));
20 }

◆ cluster()

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

Definition at line 26 of file TemplatedClusterFinder.h.

26 {
27 int ncluster = clusters_.size();
28 double minwgt = cutoff;
29 std::sort(clusters_.begin(), clusters_.end(), compClusters);
30 do {
31 bool any = false;
32 unsigned int mi(0), mj(0);
33
34 int nseeds = 0;
35 // loop over all clusters:
36 for (unsigned int i = 0; i < clusters_.size(); i++) {
37 // skip if empty
38 if (clusters_[i].empty()) continue;
39 // check if cluster might be a seed minimum seed:
40 bool iseed = (clusters_[i].centroid().E() >= seed_threshold);
41 if (iseed) {
42 nseeds++;
43
44 } else {
45 // Since we sorted initially if we find a hit below seed threshold
46 // it is guaranteed that there will be no seeds after.
47 break;
48 }
49 // loop over the rest of the clusters:
50 for (unsigned int j = i + 1; j < clusters_.size(); j++) {
51 if (clusters_[j].empty() or
52 (!iseed and clusters_[j].centroid().E() < seed_threshold))
53 continue;
54 // calculate weights between the two clusters:
55 double wgt = wgt_(clusters_[i], clusters_[j]); // TODO
56 if (!any or
57 wgt < minwgt) { // minwgt begins at cut-off, this probably wants
58 // to tell us if these can physically be part of
59 // same shower (deltaT, and R cuts)
60 any = true;
61 minwgt = wgt;
62 mi = i;
63 mj = j;
64 }
65 }
66 }
67
68 // if(abs(clusters_[mi].GetTime() - clusters_[mj].GetTime()) > deltaTime)
69 // continue;
70
71 nseeds_ = nseeds;
72 transitionWeights_.insert(std::pair<int, double>(ncluster, minwgt));
73 if (any and minwgt < cutoff) {
74 // put the bigger one in mi
75 if (clusters_[mi].centroid().E() < clusters_[mj].centroid().E()) {
76 std::swap(mi, mj);
77 }
78 // now we have the smallest, merge
79 clusters_[mi].add(clusters_[mj]);
80 clusters_[mj].clear();
81 // decrement cluster count
82 ncluster--;
83 }
84
85 } while (minwgt < cutoff and ncluster > 1);
86 finalwgt_ = minwgt;
87 }

◆ compClusters()

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

Definition at line 22 of file TemplatedClusterFinder.h.

22 {
23 return a.centroid().E() > b.centroid().E();
24 }

◆ getClusters()

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

Definition at line 95 of file TemplatedClusterFinder.h.

95{ return clusters_; }

◆ getNSeeds()

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

Definition at line 91 of file TemplatedClusterFinder.h.

91{ return nseeds_; }

◆ getWeights()

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

Definition at line 93 of file TemplatedClusterFinder.h.

93{ return transitionWeights_; }

◆ getYMax()

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

Definition at line 89 of file TemplatedClusterFinder.h.

89{ return finalwgt_; }

Member Data Documentation

◆ clusters_

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

Definition at line 102 of file TemplatedClusterFinder.h.

◆ finalwgt_

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

Definition at line 99 of file TemplatedClusterFinder.h.

◆ nseeds_

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

Definition at line 100 of file TemplatedClusterFinder.h.

◆ transitionWeights_

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

Definition at line 101 of file TemplatedClusterFinder.h.

◆ wgt_

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

Definition at line 98 of file TemplatedClusterFinder.h.


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