LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 38 of file SimpleClustering.h.

Constructor & Destructor Documentation

tss::Cluster2D::Cluster2D ( void  )
inline

Definition at line 42 of file SimpleClustering.h.

References hits().

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

Definition at line 13 of file SimpleClustering.cxx.

References fHits.

13  :
14  fDenseStart(false), fDenseEnd(false), fIsEM(false)
15 {
16  fHits.reserve(hits.size());
17  for (size_t h = 0; h < hits.size(); ++h) fHits.push_back(hits[h]);
18 }
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 43 of file SimpleClustering.cxx.

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

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

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

Definition at line 126 of file SimpleClustering.cxx.

References pma::Dist2(), and fHits.

Referenced by dist2().

127 {
128  if (fHits.size())
129  {
130  double d2, min_d2 = pma::Dist2(fHits.front()->Point2D(), p2d);
131  for (size_t i = 1; i < fHits.size(); ++i)
132  {
133  d2 = pma::Dist2(fHits[i]->Point2D(), p2d);
134  if (d2 < min_d2) { min_d2 = d2; }
135  }
136  return min_d2;
137  }
138  else return 0.0;
139 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
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  {
147  double d2, min_d2 = pma::Dist2(fHits.front()->Point2D(), p2d);
148  for (size_t i = 1; i < fHits.size(); ++i)
149  {
150  d2 = pma::Dist2(fHits[i]->Point2D(), p2d);
151  if (d2 < min_d2) { min_d2 = d2; hIdx = i; }
152  }
153  return min_d2;
154  }
155  else return 0.0;
156 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
std::vector< const tss::Hit2D * > fHits
double tss::Cluster2D::dist2 ( const tss::Cluster2D clu) const

Definition at line 159 of file SimpleClustering.cxx.

References dist2(), and fHits.

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

Definition at line 84 of file SimpleClustering.h.

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

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

Definition at line 118 of file SimpleClustering.cxx.

References fHits.

119 {
120  for (size_t i = 0; i < fHits.size(); ++i)
121  if (fHits[i] == hit) return true;
122  return false;
123 }
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 50 of file SimpleClustering.h.

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

Definition at line 101 of file SimpleClustering.h.

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

Definition at line 99 of file SimpleClustering.h.

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

Definition at line 104 of file SimpleClustering.h.

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

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

Definition at line 96 of file SimpleClustering.h.

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

Definition at line 54 of file SimpleClustering.h.

References pma::Dist2().

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

Definition at line 100 of file SimpleClustering.cxx.

References fHits, and size().

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

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

Definition at line 73 of file SimpleClustering.h.

References hits().

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

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

Definition at line 82 of file SimpleClustering.cxx.

References fHits, and size().

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

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

Definition at line 47 of file SimpleClustering.h.

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

Definition at line 59 of file SimpleClustering.cxx.

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

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

60 {
61  idx = 0;
62  if (!fHits.size()) return 0;
63 
64  TVector2 mean(0., 0.);
65  for (size_t h = 0; h < fHits.size(); ++h)
66  {
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  {
75  d = pma::Dist2(fHits[h]->Point2D(), mean);
76  if (d > dmax) { dmax = d; hout = fHits[h]; idx = h; }
77  }
78  return hout;
79 }
TVector2 const & Point2D(void) const
Definition: TssHit2D.h:37
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
std::vector< const tss::Hit2D * > fHits
Float_t d
Definition: plot.C:237
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
void tss::Cluster2D::push_back ( const tss::Hit2D hit)
inline

Definition at line 67 of file SimpleClustering.h.

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

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

Definition at line 33 of file SimpleClustering.cxx.

References fHits.

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

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

Definition at line 21 of file SimpleClustering.cxx.

References fHits.

Referenced by take_from().

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

Definition at line 97 of file SimpleClustering.h.

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

Definition at line 89 of file SimpleClustering.h.

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

90  {
91  if (fHits.size() > 2)
92  std::sort(fHits.begin() + 1, fHits.end(),
93  tss::bDistToPointLess(fHits.front()->Point2D()));
94  }
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()) return fHits.front();
82  else return 0;
83  }
std::vector< const tss::Hit2D * > fHits
void tss::Cluster2D::tagDenseEnd ( bool  b)
inline

Definition at line 102 of file SimpleClustering.h.

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

Definition at line 100 of file SimpleClustering.h.

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

Definition at line 105 of file SimpleClustering.h.

References max, and min.

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

Definition at line 68 of file SimpleClustering.h.

References release_at().

69  {
70  const tss::Hit2D* hit = clu.release_at(idx);
71  if (hit) push_back(hit);
72  }
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 117 of file SimpleClustering.h.

bool tss::Cluster2D::fDenseStart
private

Definition at line 117 of file SimpleClustering.h.

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

Definition at line 115 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 117 of file SimpleClustering.h.

bool tss::Cluster2D::fTag
private

Definition at line 117 of file SimpleClustering.h.


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