LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
tss::Cluster2D Class Reference

#include "SimpleClustering.h"

Public Member Functions

 Cluster2D (void)
 
 Cluster2D (const std::vector< const tss::Hit2D * > &hits)
 
size_t size (void) const
 
const Hit2Doperator[] (size_t index) const
 
const std::vector< const tss::Hit2D * > & hits (void) const
 
std::vector< const tss::Hit2D * > & hits (void)
 
bool has (const tss::Hit2D *hit) const
 
double length2 (void) const
 
double dist2 (const TVector2 &p2d) const
 
double dist2 (const TVector2 &p2d, size_t &hIdx) const
 
double dist2 (const tss::Cluster2D &clu) const
 
const Hit2Drelease_at (size_t idx)
 
bool release (const tss::Hit2D *hit)
 
void push_back (const tss::Hit2D *hit)
 
void take_from (tss::Cluster2D &clu, size_t idx)
 
void merge (tss::Cluster2D &clu)
 
const tss::Hit2Dstart (void) const
 
const tss::Hit2Dend (void) const
 
void sort (void)
 
bool isTagged (void) const
 
void setTag (bool b)
 
bool isDenseStart (void) const
 
void tagDenseStart (bool b)
 
bool isDenseEnd (void) const
 
void tagDenseEnd (bool b)
 
bool isEM (void) const
 
void tagEM (bool b)
 
const Hit2Dclosest (const TVector2 &p2d, size_t &idx) const
 
const Hit2Doutermost (size_t &idx) const
 
const TVector2 min (void) const
 
const TVector2 max (void) const
 

Private Attributes

std::vector< const tss::Hit2D * > fHits
 
bool fTag
 
bool fDenseStart
 
bool fDenseEnd
 
bool fIsEM
 

Detailed Description

Definition at line 37 of file SimpleClustering.h.

Constructor & Destructor Documentation

tss::Cluster2D::Cluster2D ( void  )
inline

Definition at line 39 of file SimpleClustering.h.

References hits().

39 : fTag(false), fDenseStart(false), fDenseEnd(false), fIsEM(false) {}
tss::Cluster2D::Cluster2D ( const std::vector< const tss::Hit2D * > &  hits)

Definition at line 11 of file SimpleClustering.cxx.

References fHits.

12  : fDenseStart(false), fDenseEnd(false), fIsEM(false)
13 {
14  fHits.reserve(hits.size());
15  for (size_t h = 0; h < hits.size(); ++h)
16  fHits.push_back(hits[h]);
17 }
std::vector< const tss::Hit2D * > fHits

Member Function Documentation

const tss::Hit2D * tss::Cluster2D::closest ( const TVector2 &  p2d,
size_t &  idx 
) const

Definition at line 41 of file SimpleClustering.cxx.

References d, pma::Dist2(), fHits, and tss::Hit2D::Point2D().

Referenced by tss::Segmentation2D::run().

42 {
43  idx = 0;
44  if (!fHits.size()) return 0;
45 
46  const tss::Hit2D* hout = fHits.front();
47  double d, dmin = pma::Dist2(hout->Point2D(), p2d);
48  for (size_t h = 1; h < fHits.size(); ++h) {
49  d = pma::Dist2(fHits[h]->Point2D(), p2d);
50  if (d < dmin) {
51  dmin = d;
52  hout = fHits[h];
53  idx = h;
54  }
55  }
56  return hout;
57 }
TVector2 const & Point2D() const
Definition: TssHit2D.h:31
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
std::vector< const tss::Hit2D * > fHits
Float_t d
Definition: plot.C:235
double tss::Cluster2D::dist2 ( const TVector2 &  p2d) const

Definition at line 127 of file SimpleClustering.cxx.

References pma::Dist2(), and fHits.

Referenced by dist2().

128 {
129  if (fHits.size()) {
130  double d2, min_d2 = pma::Dist2(fHits.front()->Point2D(), p2d);
131  for (size_t i = 1; i < fHits.size(); ++i) {
132  d2 = pma::Dist2(fHits[i]->Point2D(), p2d);
133  if (d2 < min_d2) { min_d2 = d2; }
134  }
135  return min_d2;
136  }
137  else
138  return 0.0;
139 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
std::vector< const tss::Hit2D * > fHits
double tss::Cluster2D::dist2 ( const TVector2 &  p2d,
size_t &  hIdx 
) const

Definition at line 142 of file SimpleClustering.cxx.

References pma::Dist2(), and fHits.

143 {
144  hIdx = 0;
145  if (fHits.size()) {
146  double d2, min_d2 = pma::Dist2(fHits.front()->Point2D(), p2d);
147  for (size_t i = 1; i < fHits.size(); ++i) {
148  d2 = pma::Dist2(fHits[i]->Point2D(), p2d);
149  if (d2 < min_d2) {
150  min_d2 = d2;
151  hIdx = i;
152  }
153  }
154  return min_d2;
155  }
156  else
157  return 0.0;
158 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
std::vector< const tss::Hit2D * > fHits
double tss::Cluster2D::dist2 ( const tss::Cluster2D clu) const

Definition at line 161 of file SimpleClustering.cxx.

References dist2(), and fHits.

162 {
163  if (fHits.size()) {
164  double d2, min_d2 = clu.dist2(fHits.front()->Point2D());
165  for (size_t i = 1; i < fHits.size(); ++i) {
166  d2 = clu.dist2(fHits[i]->Point2D());
167  if (d2 < min_d2) { min_d2 = d2; }
168  }
169  return min_d2;
170  }
171  else
172  return 0.0;
173 }
double dist2(const TVector2 &p2d) const
std::vector< const tss::Hit2D * > fHits
const tss::Hit2D* tss::Cluster2D::end ( void  ) const
inline

Definition at line 86 of file SimpleClustering.h.

Referenced by tss::Segmentation2D::buildSegment(), and tss::Segmentation2D::run().

87  {
88  if (fHits.size())
89  return fHits.back();
90  else
91  return 0;
92  }
std::vector< const tss::Hit2D * > fHits
bool tss::Cluster2D::has ( const tss::Hit2D hit) const

Definition at line 119 of file SimpleClustering.cxx.

References fHits.

120 {
121  for (size_t i = 0; i < fHits.size(); ++i)
122  if (fHits[i] == hit) return true;
123  return false;
124 }
std::vector< const tss::Hit2D * > fHits
const std::vector<const tss::Hit2D*>& tss::Cluster2D::hits ( void  ) const
inline
std::vector<const tss::Hit2D*>& tss::Cluster2D::hits ( void  )
inline

Definition at line 47 of file SimpleClustering.h.

47 { return fHits; }
std::vector< const tss::Hit2D * > fHits
bool tss::Cluster2D::isDenseEnd ( void  ) const
inline

Definition at line 104 of file SimpleClustering.h.

104 { return fDenseEnd; }
bool tss::Cluster2D::isDenseStart ( void  ) const
inline

Definition at line 102 of file SimpleClustering.h.

102 { return fDenseStart; }
bool tss::Cluster2D::isEM ( void  ) const
inline

Definition at line 107 of file SimpleClustering.h.

Referenced by tss::Segmentation2D::Cl2InsideCl1().

107 { return fIsEM; }
bool tss::Cluster2D::isTagged ( void  ) const
inline

Definition at line 99 of file SimpleClustering.h.

99 { return fTag; }
double tss::Cluster2D::length2 ( void  ) const
inline

Definition at line 51 of file SimpleClustering.h.

References pma::Dist2(), and util::size().

52  {
53  if (size() > 1)
54  return pma::Dist2(fHits.front()->Point2D(), fHits.back()->Point2D());
55  else
56  return 0.0;
57  }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
std::vector< const tss::Hit2D * > fHits
size_t size(void) const
const TVector2 tss::Cluster2D::max ( void  ) const

Definition at line 102 of file SimpleClustering.cxx.

References fHits, and size().

Referenced by tss::Segmentation2D::Cl2InsideCl1().

103 {
104 
105  TVector2 maximum = fHits[0]->Point2D();
106 
107  for (size_t i = 1; i < size(); ++i) {
108  const TVector2 h = fHits[i]->Point2D();
109 
110  if (h.X() > maximum.X()) maximum.Set(h.X(), h.Y());
111  if (h.Y() > maximum.Y()) maximum.Set(maximum.X(), h.Y());
112  }
113 
114  return maximum;
115 }
std::vector< const tss::Hit2D * > fHits
size_t size(void) const
void tss::Cluster2D::merge ( tss::Cluster2D clu)
inline

Definition at line 72 of file SimpleClustering.h.

References hits().

Referenced by tss::SimpleClustering::run().

73  {
74  for (const auto h : clu.hits())
75  fHits.push_back(h);
76  clu.hits().clear();
77  }
const std::vector< const tss::Hit2D * > & hits(void) const
std::vector< const tss::Hit2D * > fHits
const TVector2 tss::Cluster2D::min ( void  ) const

Definition at line 85 of file SimpleClustering.cxx.

References fHits, and size().

Referenced by tss::Segmentation2D::Cl2InsideCl1().

86 {
87 
88  TVector2 minimum = fHits[0]->Point2D();
89 
90  for (size_t i = 1; i < size(); ++i) {
91  const TVector2 h = fHits[i]->Point2D();
92 
93  if (h.X() < minimum.X()) minimum.Set(h.X(), h.Y());
94  if (h.Y() < minimum.Y()) minimum.Set(minimum.X(), h.Y());
95  }
96 
97  return minimum;
98 }
std::vector< const tss::Hit2D * > fHits
size_t size(void) const
const Hit2D& tss::Cluster2D::operator[] ( size_t  index) const
inline

Definition at line 44 of file SimpleClustering.h.

44 { return *(fHits[index]); }
std::vector< const tss::Hit2D * > fHits
const tss::Hit2D * tss::Cluster2D::outermost ( size_t &  idx) const

Definition at line 60 of file SimpleClustering.cxx.

References d, pma::Dist2(), fHits, pmtana::mean(), and tss::Hit2D::Point2D().

Referenced by tss::Segmentation2D::run().

61 {
62  idx = 0;
63  if (!fHits.size()) return 0;
64 
65  TVector2 mean(0., 0.);
66  for (size_t h = 0; h < fHits.size(); ++h) {
67  mean += fHits[h]->Point2D();
68  }
69  mean *= 1.0 / fHits.size();
70 
71  const tss::Hit2D* hout = fHits.front();
72  double d, dmax = pma::Dist2(hout->Point2D(), mean);
73  for (size_t h = 1; h < fHits.size(); ++h) {
74  d = pma::Dist2(fHits[h]->Point2D(), mean);
75  if (d > dmax) {
76  dmax = d;
77  hout = fHits[h];
78  idx = h;
79  }
80  }
81  return hout;
82 }
TVector2 const & Point2D() const
Definition: TssHit2D.h:31
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
std::vector< const tss::Hit2D * > fHits
Float_t d
Definition: plot.C:235
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
void tss::Cluster2D::push_back ( const tss::Hit2D hit)
inline

Definition at line 66 of file SimpleClustering.h.

Referenced by tss::Segmentation2D::buildSegment(), and tss::Segmentation2D::selectRing().

66 { fHits.push_back(hit); }
std::vector< const tss::Hit2D * > fHits
bool tss::Cluster2D::release ( const tss::Hit2D hit)

Definition at line 31 of file SimpleClustering.cxx.

References fHits.

Referenced by tss::Segmentation2D::buildSegment(), and tss::Segmentation2D::run().

32 {
33  for (size_t h = 0; h < fHits.size(); ++h)
34  if (fHits[h] == hit) {
35  fHits.erase(fHits.begin() + h);
36  return true;
37  }
38  return false;
39 }
std::vector< const tss::Hit2D * > fHits
const tss::Hit2D * tss::Cluster2D::release_at ( size_t  idx)

Definition at line 20 of file SimpleClustering.cxx.

References fHits.

Referenced by take_from().

21 {
22  const tss::Hit2D* hit = 0;
23  if (idx < fHits.size()) {
24  hit = fHits[idx];
25  fHits.erase(fHits.begin() + idx);
26  }
27  return hit;
28 }
std::vector< const tss::Hit2D * > fHits
Detector simulation of raw signals on wires.
void tss::Cluster2D::setTag ( bool  b)
inline

Definition at line 100 of file SimpleClustering.h.

100 { fTag = b; }
void tss::Cluster2D::sort ( void  )
inline

Definition at line 93 of file SimpleClustering.h.

Referenced by tss::Segmentation2D::buildSegment().

94  {
95  if (fHits.size() > 2)
96  std::sort(fHits.begin() + 1, fHits.end(), tss::bDistToPointLess(fHits.front()->Point2D()));
97  }
std::vector< const tss::Hit2D * > fHits
const tss::Hit2D* tss::Cluster2D::start ( void  ) const
inline

Definition at line 79 of file SimpleClustering.h.

Referenced by tss::Segmentation2D::buildSegment().

80  {
81  if (fHits.size())
82  return fHits.front();
83  else
84  return 0;
85  }
std::vector< const tss::Hit2D * > fHits
void tss::Cluster2D::tagDenseEnd ( bool  b)
inline

Definition at line 105 of file SimpleClustering.h.

105 { fDenseEnd = b; }
void tss::Cluster2D::tagDenseStart ( bool  b)
inline

Definition at line 103 of file SimpleClustering.h.

103 { fDenseStart = b; }
void tss::Cluster2D::tagEM ( bool  b)
inline

Definition at line 108 of file SimpleClustering.h.

108 { fIsEM = b; }
void tss::Cluster2D::take_from ( tss::Cluster2D clu,
size_t  idx 
)
inline

Definition at line 67 of file SimpleClustering.h.

References release_at().

68  {
69  const tss::Hit2D* hit = clu.release_at(idx);
70  if (hit) push_back(hit);
71  }
void push_back(const tss::Hit2D *hit)
const Hit2D * release_at(size_t idx)
Detector simulation of raw signals on wires.

Member Data Documentation

bool tss::Cluster2D::fDenseEnd
private

Definition at line 119 of file SimpleClustering.h.

bool tss::Cluster2D::fDenseStart
private

Definition at line 119 of file SimpleClustering.h.

std::vector<const tss::Hit2D*> tss::Cluster2D::fHits
private

Definition at line 117 of file SimpleClustering.h.

Referenced by closest(), Cluster2D(), dist2(), has(), max(), min(), outermost(), release(), and release_at().

bool tss::Cluster2D::fIsEM
private

Definition at line 119 of file SimpleClustering.h.

bool tss::Cluster2D::fTag
private

Definition at line 119 of file SimpleClustering.h.


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