All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
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 larreco/larreco/ClusterFinder/TrackShowerSplitter/Segmentation2D/SimpleClustering.h.

Constructor & Destructor Documentation

tss::Cluster2D::Cluster2D ( void  )
inline
tss::Cluster2D::Cluster2D ( const std::vector< const tss::Hit2D * > &  hits)

Member Function Documentation

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

Definition at line 41 of file SimpleClustering.cxx.

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  {
50  d = pma::Dist2(fHits[h]->Point2D(), p2d);
51  if (d < dmin) { dmin = d; hout = fHits[h]; idx = h; }
52  }
53  return hout;
54 }
TVector2 const & Point2D() const
Definition: TssHit2D.h:36
double Dist2(const TVector2 &v1, const TVector2 &v2)
while getopts h
double tss::Cluster2D::dist2 ( const TVector2 &  p2d) const

Definition at line 124 of file SimpleClustering.cxx.

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

Definition at line 140 of file SimpleClustering.cxx.

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

Definition at line 157 of file SimpleClustering.cxx.

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

Definition at line 83 of file larreco/larreco/ClusterFinder/TrackShowerSplitter/Segmentation2D/SimpleClustering.h.

84  {
85  if (fHits.size()) return fHits.back();
86  else return 0;
87  }
bool tss::Cluster2D::has ( const tss::Hit2D hit) const

Definition at line 116 of file SimpleClustering.cxx.

117 {
118  for (size_t i = 0; i < fHits.size(); ++i)
119  if (fHits[i] == hit) return true;
120  return false;
121 }
const std::vector< const tss::Hit2D* >& tss::Cluster2D::hits ( void  ) const
inline
std::vector< const tss::Hit2D* >& tss::Cluster2D::hits ( void  )
inline
bool tss::Cluster2D::isDenseEnd ( void  ) const
inline
bool tss::Cluster2D::isDenseStart ( void  ) const
inline
bool tss::Cluster2D::isEM ( void  ) const
inline
bool tss::Cluster2D::isTagged ( void  ) const
inline
double tss::Cluster2D::length2 ( void  ) const
inline

Definition at line 53 of file larreco/larreco/ClusterFinder/TrackShowerSplitter/Segmentation2D/SimpleClustering.h.

54  {
55  if (size() > 1) return pma::Dist2(fHits.front()->Point2D(), fHits.back()->Point2D());
56  else return 0.0;
57  }
double Dist2(const TVector2 &v1, const TVector2 &v2)
const TVector2 tss::Cluster2D::max ( void  ) const

Definition at line 98 of file SimpleClustering.cxx.

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

Definition at line 72 of file larreco/larreco/ClusterFinder/TrackShowerSplitter/Segmentation2D/SimpleClustering.h.

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

Definition at line 80 of file SimpleClustering.cxx.

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

Definition at line 57 of file SimpleClustering.cxx.

58 {
59  idx = 0;
60  if (!fHits.size()) return 0;
61 
62  TVector2 mean(0., 0.);
63  for (size_t h = 0; h < fHits.size(); ++h)
64  {
65  mean += fHits[h]->Point2D();
66  }
67  mean *= 1.0 / fHits.size();
68 
69  const tss::Hit2D* hout = fHits.front();
70  double d, dmax = pma::Dist2(hout->Point2D(), mean);
71  for (size_t h = 1; h < fHits.size(); ++h)
72  {
73  d = pma::Dist2(fHits[h]->Point2D(), mean);
74  if (d > dmax) { dmax = d; hout = fHits[h]; idx = h; }
75  }
76  return hout;
77 }
TVector2 const & Point2D() const
Definition: TssHit2D.h:36
double Dist2(const TVector2 &v1, const TVector2 &v2)
while getopts h
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
bool tss::Cluster2D::release ( const tss::Hit2D hit)

Definition at line 31 of file SimpleClustering.cxx.

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

Definition at line 19 of file SimpleClustering.cxx.

20 {
21  const tss::Hit2D* hit = 0;
22  if (idx < fHits.size())
23  {
24  hit = fHits[idx];
25  fHits.erase(fHits.begin() + idx);
26  }
27  return hit;
28 }
process_name hit
Definition: cheaterreco.fcl:51
void tss::Cluster2D::setTag ( bool  b)
inline
size_t tss::Cluster2D::size ( void  ) const
inline
void tss::Cluster2D::sort ( void  )
inline
const tss::Hit2D* tss::Cluster2D::start ( void  ) const
inline

Definition at line 78 of file larreco/larreco/ClusterFinder/TrackShowerSplitter/Segmentation2D/SimpleClustering.h.

79  {
80  if (fHits.size()) return fHits.front();
81  else return 0;
82  }
void tss::Cluster2D::tagDenseEnd ( bool  b)
inline
void tss::Cluster2D::tagDenseStart ( bool  b)
inline
void tss::Cluster2D::tagEM ( bool  b)
inline
void tss::Cluster2D::take_from ( tss::Cluster2D clu,
size_t  idx 
)
inline

Definition at line 67 of file larreco/larreco/ClusterFinder/TrackShowerSplitter/Segmentation2D/SimpleClustering.h.

68  {
69  const tss::Hit2D* hit = clu.release_at(idx);
70  if (hit) push_back(hit);
71  }
process_name hit
Definition: cheaterreco.fcl:51
const Hit2D * release_at(size_t idx)

Member Data Documentation

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

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