Public Types | Public Member Functions | List of all members
cluster::ClusterMerger Class Reference

Class merging clusters: recomputes start and end position and hit list. More...

Inheritance diagram for cluster::ClusterMerger:
cluster::ClusterAndHitMerger

Public Types

using HitPtr_t = art::Ptr< recob::Hit >
 type of pointer to hits More...
 
using HitVector_t = std::vector< HitPtr_t >
 vector of pointers to hits More...
 
using ID_t = recob::Cluster::ID_t
 Type of cluster ID. More...
 
using ClusterEnds_t = recob::Cluster::ClusterEnds_t
 

Public Member Functions

 ClusterMerger ()=default
 
 ClusterMerger (recob::Cluster const &cluster)
 
bool Add (recob::Cluster const &cluster)
 Merges a single cluster into this object. More...
 

Accessors

float fEndWires [ClusterEnds_t::NEnds]
 Data referring to start and end of the cluster. More...
 
float fSigmaEndWires [ClusterEnds_t::NEnds]
 Uncertainty on wire coordinate of the start and end of the cluster. More...
 
float fEndTicks [ClusterEnds_t::NEnds]
 Tick coordinate of the start and end of the cluster. More...
 
float fSigmaEndTicks [ClusterEnds_t::NEnds]
 Uncertainty on tick coordinate of the start and end of the cluster. More...
 
float fEndCharges [ClusterEnds_t::NEnds]
 Charge on the start and end wire of the cluster. More...
 
float fAngles [ClusterEnds_t::NEnds]
 Angle of the start and end of the cluster, defined in [-pi,pi]. More...
 
float fOpeningAngles [ClusterEnds_t::NEnds]
 Opening angle of the cluster shape at the start and end of the cluster. More...
 
float fWidth
 A measure of the cluster width, in homogenized units. More...
 
geo::View_t fView
 View for this cluster. More...
 
geo::PlaneID fPlaneID
 Location of the start of the cluster. More...
 
unsigned int n_clusters = 0
 number of clusters added so far More...
 
float StartWire () const
 Returns the wire coordinate of the start of the cluster. More...
 
float StartTick () const
 Returns the tick coordinate of the start of the cluster. More...
 
float SigmaStartWire () const
 Returns the uncertainty on wire coordinate of the start of the cluster. More...
 
float SigmaStartTick () const
 
float EndWire () const
 Returns the wire coordinate of the end of the cluster. More...
 
float EndTick () const
 Returns the tick coordinate of the end of the cluster. More...
 
float SigmaEndWire () const
 Returns the uncertainty on wire coordinate of the end of the cluster. More...
 
float SigmaEndTick () const
 Returns the uncertainty on tick coordinate of the end of the cluster. More...
 
float WireCoord (ClusterEnds_t side) const
 Returns the wire coordinate of one of the end sides of the cluster. More...
 
float TickCoord (ClusterEnds_t side) const
 Returns the tick coordinate of one of the end sides of the cluster. More...
 
float SigmaWireCoord (ClusterEnds_t side) const
 Returns the uncertainty on wire coordinate of one of the end sides of the cluster. More...
 
float SigmaTickCoord (ClusterEnds_t side) const
 Returns the uncertainty on tick coordinate of one of the end sides of the cluster. More...
 
float StartCharge () const
 Returns the charge on the first wire of the cluster. More...
 
float StartAngle () const
 Returns the starting angle of the cluster. More...
 
float StartOpeningAngle () const
 Returns the opening angle at the start of the cluster. More...
 
float EndCharge () const
 Returns the charge on the last wire of the cluster. More...
 
float EndAngle () const
 Returns the ending angle of the cluster. More...
 
float EndOpeningAngle () const
 Returns the opening angle at the end of the cluster. More...
 
float EdgeCharge (ClusterEnds_t side) const
 Returns the charge on the first or last wire of the cluster. More...
 
float Angle (ClusterEnds_t side) const
 Returns the angle at either end of the cluster. More...
 
float OpeningAngle (ClusterEnds_t side) const
 Returns the opening angle at either end of the cluster. More...
 
float Width () const
 A measure of the cluster width, in homogenized units. More...
 
geo::View_t View () const
 Returns the view for this cluster. More...
 
geo::PlaneID Plane () const
 Returns the plane ID this cluster lies on. More...
 
bool hasPlane () const
 Returns whether geometry plane is valid. More...
 
void AdoptEnd (recob::Cluster const &cluster, ClusterEnds_t iEnd)
 Imports all the member of the corresponding end. More...
 
template<typename T >
static void top (T &var, T value)
 
template<typename T >
static void bot (T &var, T value)
 

Detailed Description

Class merging clusters: recomputes start and end position and hit list.

Definition at line 71 of file LineMerger_module.cc.

Member Typedef Documentation

using cluster::ClusterMerger::ClusterEnds_t = recob::Cluster::ClusterEnds_t

Definition at line 80 of file LineMerger_module.cc.

using cluster::ClusterMerger::HitPtr_t = art::Ptr<recob::Hit>

type of pointer to hits

Definition at line 76 of file LineMerger_module.cc.

using cluster::ClusterMerger::HitVector_t = std::vector<HitPtr_t>

vector of pointers to hits

Definition at line 77 of file LineMerger_module.cc.

using cluster::ClusterMerger::ID_t = recob::Cluster::ID_t

Type of cluster ID.

Definition at line 79 of file LineMerger_module.cc.

Constructor & Destructor Documentation

cluster::ClusterMerger::ClusterMerger ( )
default
cluster::ClusterMerger::ClusterMerger ( recob::Cluster const &  cluster)
inline

Definition at line 93 of file LineMerger_module.cc.

93 : ClusterMerger() { Add(cluster); }
Cluster finding and building.
bool Add(recob::Cluster const &cluster)
Merges a single cluster into this object.

Member Function Documentation

bool cluster::ClusterMerger::Add ( recob::Cluster const &  cluster)

Merges a single cluster into this object.

Parameters
clusterthe cluster to be merged
Returns
whether the addition was successful

The two ends of the cluster are merged into this one, that gets extended.

The new cluster must have the same view as the prevopus ones and must lay on the same plane. If the new cluster has invalid plane, the current one is kept; if the current plane is invalid, it is overwritten (that means that if both are invalid, the merged cluster will also have an invalid plane).

Note that this code is crap unless the cluster is track-like.

Definition at line 359 of file LineMerger_module.cc.

360  {
361  if (!cluster.isValid()) return false;
362 
363  if (n_clusters == 0) { // special case: we are still empty
364  AdoptEnd(cluster, ClusterEnds_t::clStart);
365  AdoptEnd(cluster, ClusterEnds_t::clEnd);
366  fWidth = cluster.Width();
367  fView = cluster.View();
368  fPlaneID = cluster.Plane();
369  ++n_clusters;
370  return true;
371  } // if empty
372 
373  if (cluster.View() != View()) return false;
374 
375  if (cluster.hasPlane() && hasPlane() && (cluster.Plane() != Plane())) return false;
376 
377  // this code has been moved here from the old recon::Cluster::operator+
378  // of recob::Cluster v13.
379  if (cluster.StartWire() < StartWire()) { // adopt the new start
380  AdoptEnd(cluster, ClusterEnds_t::clStart);
381  }
382  if (cluster.EndWire() < EndWire()) { // adopt the new end
383  AdoptEnd(cluster, ClusterEnds_t::clEnd);
384  }
385 
386  top(fWidth, cluster.Width()); // extend width
387 
388  if (!hasPlane()) fPlaneID = cluster.Plane();
389 
390  return true;
391  } // ClusterMerger::Add(Cluster)
float EndWire() const
Returns the wire coordinate of the end of the cluster.
Cluster finding and building.
float fWidth
A measure of the cluster width, in homogenized units.
float StartWire() const
Returns the wire coordinate of the start of the cluster.
unsigned int n_clusters
number of clusters added so far
static void top(T &var, T value)
void AdoptEnd(recob::Cluster const &cluster, ClusterEnds_t iEnd)
Imports all the member of the corresponding end.
bool hasPlane() const
Returns whether geometry plane is valid.
geo::View_t fView
View for this cluster.
geo::View_t View() const
Returns the view for this cluster.
geo::PlaneID Plane() const
Returns the plane ID this cluster lies on.
geo::PlaneID fPlaneID
Location of the start of the cluster.
void cluster::ClusterMerger::AdoptEnd ( recob::Cluster const &  cluster,
ClusterEnds_t  iEnd 
)
protected

Imports all the member of the corresponding end.

Definition at line 346 of file LineMerger_module.cc.

347  {
348  const ClusterEnds_t iDestEnd = iSrcEnd;
349  fEndWires[iDestEnd] = cluster.WireCoord(iSrcEnd);
350  fSigmaEndWires[iDestEnd] = cluster.SigmaWireCoord(iSrcEnd);
351  fEndTicks[iDestEnd] = cluster.TickCoord(iSrcEnd);
352  fSigmaEndTicks[iDestEnd] = cluster.SigmaTickCoord(iSrcEnd);
353  fEndCharges[iDestEnd] = cluster.EdgeCharge(iSrcEnd);
354  fAngles[iDestEnd] = cluster.Angle(iSrcEnd);
355  fOpeningAngles[iDestEnd] = cluster.OpeningAngle(iSrcEnd);
356  } // ClusterMerger::AdoptEnd()
float fEndCharges[ClusterEnds_t::NEnds]
Charge on the start and end wire of the cluster.
Cluster finding and building.
float fOpeningAngles[ClusterEnds_t::NEnds]
Opening angle of the cluster shape at the start and end of the cluster.
recob::Cluster::ClusterEnds_t ClusterEnds_t
float fEndWires[ClusterEnds_t::NEnds]
Data referring to start and end of the cluster.
float fSigmaEndWires[ClusterEnds_t::NEnds]
Uncertainty on wire coordinate of the start and end of the cluster.
float fEndTicks[ClusterEnds_t::NEnds]
Tick coordinate of the start and end of the cluster.
float fSigmaEndTicks[ClusterEnds_t::NEnds]
Uncertainty on tick coordinate of the start and end of the cluster.
float fAngles[ClusterEnds_t::NEnds]
Angle of the start and end of the cluster, defined in [-pi,pi].
float cluster::ClusterMerger::Angle ( ClusterEnds_t  side) const
inline

Returns the angle at either end of the cluster.

Definition at line 255 of file LineMerger_module.cc.

256  {
257  return fAngles[side];
258  }
float fAngles[ClusterEnds_t::NEnds]
Angle of the start and end of the cluster, defined in [-pi,pi].
template<typename T >
static void cluster::ClusterMerger::bot ( T &  var,
value 
)
inlinestaticprotected

Definition at line 339 of file LineMerger_module.cc.

340  {
341  if (value < var) var = value;
342  }
int var
Definition: 018_def.c:9
float cluster::ClusterMerger::EdgeCharge ( ClusterEnds_t  side) const
inline

Returns the charge on the first or last wire of the cluster.

Definition at line 247 of file LineMerger_module.cc.

248  {
249  return fEndCharges[side];
250  }
float fEndCharges[ClusterEnds_t::NEnds]
Charge on the start and end wire of the cluster.
float cluster::ClusterMerger::EndAngle ( ) const
inline

Returns the ending angle of the cluster.

Definition at line 233 of file LineMerger_module.cc.

234  {
235  return fAngles[ClusterEnds_t::clEnd];
236  }
float fAngles[ClusterEnds_t::NEnds]
Angle of the start and end of the cluster, defined in [-pi,pi].
float cluster::ClusterMerger::EndCharge ( ) const
inline

Returns the charge on the last wire of the cluster.

Definition at line 226 of file LineMerger_module.cc.

227  {
228  return fEndCharges[ClusterEnds_t::clEnd];
229  }
float fEndCharges[ClusterEnds_t::NEnds]
Charge on the start and end wire of the cluster.
float cluster::ClusterMerger::EndOpeningAngle ( ) const
inline

Returns the opening angle at the end of the cluster.

Definition at line 240 of file LineMerger_module.cc.

241  {
242  return fOpeningAngles[ClusterEnds_t::clEnd];
243  }
float fOpeningAngles[ClusterEnds_t::NEnds]
Opening angle of the cluster shape at the start and end of the cluster.
float cluster::ClusterMerger::EndTick ( ) const
inline

Returns the tick coordinate of the end of the cluster.

Definition at line 152 of file LineMerger_module.cc.

153  {
154  return fEndTicks[ClusterEnds_t::clEnd];
155  }
float fEndTicks[ClusterEnds_t::NEnds]
Tick coordinate of the start and end of the cluster.
float cluster::ClusterMerger::EndWire ( ) const
inline

Returns the wire coordinate of the end of the cluster.

Definition at line 145 of file LineMerger_module.cc.

146  {
147  return fEndWires[ClusterEnds_t::clEnd];
148  }
float fEndWires[ClusterEnds_t::NEnds]
Data referring to start and end of the cluster.
bool cluster::ClusterMerger::hasPlane ( ) const
inline

Returns whether geometry plane is valid.

Definition at line 292 of file LineMerger_module.cc.

293  {
294  return Plane().isValid;
295  }
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:211
geo::PlaneID Plane() const
Returns the plane ID this cluster lies on.
float cluster::ClusterMerger::OpeningAngle ( ClusterEnds_t  side) const
inline

Returns the opening angle at either end of the cluster.

Definition at line 263 of file LineMerger_module.cc.

264  {
265  return fOpeningAngles[side];
266  }
float fOpeningAngles[ClusterEnds_t::NEnds]
Opening angle of the cluster shape at the start and end of the cluster.
geo::PlaneID cluster::ClusterMerger::Plane ( ) const
inline

Returns the plane ID this cluster lies on.

Definition at line 285 of file LineMerger_module.cc.

286  {
287  return fPlaneID;
288  }
geo::PlaneID fPlaneID
Location of the start of the cluster.
float cluster::ClusterMerger::SigmaEndTick ( ) const
inline

Returns the uncertainty on tick coordinate of the end of the cluster.

Definition at line 166 of file LineMerger_module.cc.

167  {
168  return fSigmaEndTicks[ClusterEnds_t::clEnd];
169  }
float fSigmaEndTicks[ClusterEnds_t::NEnds]
Uncertainty on tick coordinate of the start and end of the cluster.
float cluster::ClusterMerger::SigmaEndWire ( ) const
inline

Returns the uncertainty on wire coordinate of the end of the cluster.

Definition at line 159 of file LineMerger_module.cc.

160  {
161  return fSigmaEndWires[ClusterEnds_t::clEnd];
162  }
float fSigmaEndWires[ClusterEnds_t::NEnds]
Uncertainty on wire coordinate of the start and end of the cluster.
float cluster::ClusterMerger::SigmaStartTick ( ) const
inline

Definition at line 138 of file LineMerger_module.cc.

139  {
140  return fSigmaEndTicks[ClusterEnds_t::clStart];
141  }
float fSigmaEndTicks[ClusterEnds_t::NEnds]
Uncertainty on tick coordinate of the start and end of the cluster.
float cluster::ClusterMerger::SigmaStartWire ( ) const
inline

Returns the uncertainty on wire coordinate of the start of the cluster.

Definition at line 131 of file LineMerger_module.cc.

132  {
133  return fSigmaEndWires[ClusterEnds_t::clStart];
134  }
float fSigmaEndWires[ClusterEnds_t::NEnds]
Uncertainty on wire coordinate of the start and end of the cluster.
float cluster::ClusterMerger::SigmaTickCoord ( ClusterEnds_t  side) const
inline

Returns the uncertainty on tick coordinate of one of the end sides of the cluster.

Definition at line 197 of file LineMerger_module.cc.

198  {
199  return fSigmaEndTicks[side];
200  }
float fSigmaEndTicks[ClusterEnds_t::NEnds]
Uncertainty on tick coordinate of the start and end of the cluster.
float cluster::ClusterMerger::SigmaWireCoord ( ClusterEnds_t  side) const
inline

Returns the uncertainty on wire coordinate of one of the end sides of the cluster.

Definition at line 189 of file LineMerger_module.cc.

190  {
191  return fSigmaEndWires[side];
192  }
float fSigmaEndWires[ClusterEnds_t::NEnds]
Uncertainty on wire coordinate of the start and end of the cluster.
float cluster::ClusterMerger::StartAngle ( ) const
inline

Returns the starting angle of the cluster.

Definition at line 212 of file LineMerger_module.cc.

213  {
214  return fAngles[ClusterEnds_t::clStart];
215  }
float fAngles[ClusterEnds_t::NEnds]
Angle of the start and end of the cluster, defined in [-pi,pi].
float cluster::ClusterMerger::StartCharge ( ) const
inline

Returns the charge on the first wire of the cluster.

Definition at line 205 of file LineMerger_module.cc.

206  {
207  return fEndCharges[ClusterEnds_t::clStart];
208  }
float fEndCharges[ClusterEnds_t::NEnds]
Charge on the start and end wire of the cluster.
float cluster::ClusterMerger::StartOpeningAngle ( ) const
inline

Returns the opening angle at the start of the cluster.

Definition at line 219 of file LineMerger_module.cc.

220  {
221  return fOpeningAngles[ClusterEnds_t::clStart];
222  }
float fOpeningAngles[ClusterEnds_t::NEnds]
Opening angle of the cluster shape at the start and end of the cluster.
float cluster::ClusterMerger::StartTick ( ) const
inline

Returns the tick coordinate of the start of the cluster.

Definition at line 124 of file LineMerger_module.cc.

125  {
126  return fEndTicks[ClusterEnds_t::clStart];
127  }
float fEndTicks[ClusterEnds_t::NEnds]
Tick coordinate of the start and end of the cluster.
float cluster::ClusterMerger::StartWire ( ) const
inline

Returns the wire coordinate of the start of the cluster.

Definition at line 117 of file LineMerger_module.cc.

118  {
119  return fEndWires[ClusterEnds_t::clStart];
120  }
float fEndWires[ClusterEnds_t::NEnds]
Data referring to start and end of the cluster.
float cluster::ClusterMerger::TickCoord ( ClusterEnds_t  side) const
inline

Returns the tick coordinate of one of the end sides of the cluster.

Definition at line 181 of file LineMerger_module.cc.

182  {
183  return fEndTicks[side];
184  }
float fEndTicks[ClusterEnds_t::NEnds]
Tick coordinate of the start and end of the cluster.
template<typename T >
static void cluster::ClusterMerger::top ( T &  var,
value 
)
inlinestaticprotected

Definition at line 333 of file LineMerger_module.cc.

334  {
335  if (value > var) var = value;
336  }
int var
Definition: 018_def.c:9
geo::View_t cluster::ClusterMerger::View ( ) const
inline

Returns the view for this cluster.

Definition at line 278 of file LineMerger_module.cc.

279  {
280  return fView;
281  }
geo::View_t fView
View for this cluster.
float cluster::ClusterMerger::Width ( ) const
inline

A measure of the cluster width, in homogenized units.

Definition at line 271 of file LineMerger_module.cc.

272  {
273  return fWidth;
274  }
float fWidth
A measure of the cluster width, in homogenized units.
float cluster::ClusterMerger::WireCoord ( ClusterEnds_t  side) const
inline

Returns the wire coordinate of one of the end sides of the cluster.

Definition at line 173 of file LineMerger_module.cc.

174  {
175  return fEndWires[side];
176  }
float fEndWires[ClusterEnds_t::NEnds]
Data referring to start and end of the cluster.

Member Data Documentation

float cluster::ClusterMerger::fAngles[ClusterEnds_t::NEnds]
protected

Angle of the start and end of the cluster, defined in [-pi,pi].

Definition at line 314 of file LineMerger_module.cc.

float cluster::ClusterMerger::fEndCharges[ClusterEnds_t::NEnds]
protected

Charge on the start and end wire of the cluster.

Definition at line 311 of file LineMerger_module.cc.

float cluster::ClusterMerger::fEndTicks[ClusterEnds_t::NEnds]
protected

Tick coordinate of the start and end of the cluster.

Definition at line 305 of file LineMerger_module.cc.

float cluster::ClusterMerger::fEndWires[ClusterEnds_t::NEnds]
protected

Data referring to start and end of the cluster.

Definition at line 299 of file LineMerger_module.cc.

float cluster::ClusterMerger::fOpeningAngles[ClusterEnds_t::NEnds]
protected

Opening angle of the cluster shape at the start and end of the cluster.

Definition at line 317 of file LineMerger_module.cc.

geo::PlaneID cluster::ClusterMerger::fPlaneID
protected

Location of the start of the cluster.

Definition at line 324 of file LineMerger_module.cc.

float cluster::ClusterMerger::fSigmaEndTicks[ClusterEnds_t::NEnds]
protected

Uncertainty on tick coordinate of the start and end of the cluster.

Definition at line 308 of file LineMerger_module.cc.

float cluster::ClusterMerger::fSigmaEndWires[ClusterEnds_t::NEnds]
protected

Uncertainty on wire coordinate of the start and end of the cluster.

Definition at line 302 of file LineMerger_module.cc.

geo::View_t cluster::ClusterMerger::fView
protected

View for this cluster.

Definition at line 322 of file LineMerger_module.cc.

float cluster::ClusterMerger::fWidth
protected

A measure of the cluster width, in homogenized units.

Definition at line 320 of file LineMerger_module.cc.

unsigned int cluster::ClusterMerger::n_clusters = 0
protected

number of clusters added so far

Definition at line 326 of file LineMerger_module.cc.


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