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 SimpleClustering.h.

Constructor & Destructor Documentation

tss::Cluster2D::Cluster2D ( void  )
inline

Definition at line 41 of file SimpleClustering.h.

41 : 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.

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

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)
Definition: Utilities.cxx:37
std::vector< const tss::Hit2D * > fHits
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)
Definition: Utilities.cxx:37
std::vector< const tss::Hit2D * > fHits
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)
Definition: Utilities.cxx:37
std::vector< const tss::Hit2D * > fHits
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 }
std::vector< const tss::Hit2D * > fHits
double dist2(const TVector2 &p2d) const
const tss::Hit2D* tss::Cluster2D::end ( void  ) const
inline

Definition at line 83 of file SimpleClustering.h.

84  {
85  if (fHits.size()) return fHits.back();
86  else return 0;
87  }
std::vector< const tss::Hit2D * > fHits
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 }
std::vector< const tss::Hit2D * > fHits
const std::vector< const tss::Hit2D* >& tss::Cluster2D::hits ( void  ) const
inline

Definition at line 48 of file SimpleClustering.h.

48 { return fHits; }
std::vector< const tss::Hit2D * > fHits
std::vector< const tss::Hit2D* >& tss::Cluster2D::hits ( void  )
inline

Definition at line 49 of file SimpleClustering.h.

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

Definition at line 100 of file SimpleClustering.h.

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

Definition at line 98 of file SimpleClustering.h.

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

Definition at line 103 of file SimpleClustering.h.

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

Definition at line 95 of file SimpleClustering.h.

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

Definition at line 53 of file 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)
Definition: Utilities.cxx:37
std::vector< const tss::Hit2D * > fHits
size_t size(void) const
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 }
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.

73  {
74  for (const auto h : clu.hits()) fHits.push_back(h);
75  clu.hits().clear();
76  }
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 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 }
std::vector< const tss::Hit2D * > fHits
size_t size(void) const
const Hit2D& tss::Cluster2D::operator[] ( size_t  index) const
inline

Definition at line 46 of file SimpleClustering.h.

46 { return *(fHits[index]); }
std::vector< const tss::Hit2D * > fHits
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)
Definition: Utilities.cxx:37
std::vector< const tss::Hit2D * > fHits
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:16
void tss::Cluster2D::push_back ( const tss::Hit2D hit)
inline

Definition at line 66 of file SimpleClustering.h.

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.

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 }
std::vector< const tss::Hit2D * > fHits
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 }
std::vector< const tss::Hit2D * > fHits
Detector simulation of raw signals on wires.
void tss::Cluster2D::setTag ( bool  b)
inline

Definition at line 96 of file SimpleClustering.h.

96 { fTag = b; }
static bool * b
Definition: config.cpp:1043
size_t tss::Cluster2D::size ( void  ) const
inline

Definition at line 44 of file SimpleClustering.h.

44 { return fHits.size(); }
std::vector< const tss::Hit2D * > fHits
void tss::Cluster2D::sort ( void  )
inline

Definition at line 88 of file SimpleClustering.h.

89  {
90  if (fHits.size() > 2)
91  std::sort(fHits.begin() + 1, fHits.end(),
92  tss::bDistToPointLess(fHits.front()->Point2D()));
93  }
std::vector< const tss::Hit2D * > fHits
const tss::Hit2D* tss::Cluster2D::start ( void  ) const
inline

Definition at line 78 of file SimpleClustering.h.

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

Definition at line 101 of file SimpleClustering.h.

101 { fDenseEnd = b; }
static bool * b
Definition: config.cpp:1043
void tss::Cluster2D::tagDenseStart ( bool  b)
inline

Definition at line 99 of file SimpleClustering.h.

99 { fDenseStart = b; }
static bool * b
Definition: config.cpp:1043
void tss::Cluster2D::tagEM ( bool  b)
inline

Definition at line 104 of file SimpleClustering.h.

104 { fIsEM = b; }
static bool * b
Definition: config.cpp:1043
void tss::Cluster2D::take_from ( tss::Cluster2D clu,
size_t  idx 
)
inline

Definition at line 67 of file SimpleClustering.h.

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 116 of file SimpleClustering.h.

bool tss::Cluster2D::fDenseStart
private

Definition at line 116 of file SimpleClustering.h.

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

Definition at line 114 of file SimpleClustering.h.

bool tss::Cluster2D::fIsEM
private

Definition at line 116 of file SimpleClustering.h.

bool tss::Cluster2D::fTag
private

Definition at line 116 of file SimpleClustering.h.


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