LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
cluster::ClusterAndHitMerger Class Reference

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

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

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

 ClusterAndHitMerger ()=default
 
 ClusterAndHitMerger (recob::Cluster const &cluster, HitVector_t const &cluster_hits)
 
bool Add (recob::Cluster const &cluster, HitVector_t const &cluster_hits, bool prepend=false)
 Merges a single cluster into this object. More...
 
bool Add (recob::Cluster const &cluster)
 Merges a single cluster into this object. More...
 
Accessors
HitVector_t const & Hits () const
 Returns a constant reference to the current list of hits. More...
 
unsigned int NHits () const
 Number of hits in the cluster. More...
 

Protected Member Functions

void AddHits (HitVector_t const &cluster_hits, bool prepend)
 

Protected Attributes

HitVector_t hits
 hits in the cluster 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
 Data referring to start and end of the cluster. More...
 
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)
 Data referring to start and end of the cluster. More...
 
template<typename T >
static void bot (T &var, T value)
 Data referring to start and end of the cluster. More...
 

Detailed Description

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

Definition at line 275 of file LineMerger_module.cc.

Member Typedef Documentation

type of pointer to hits

Definition at line 280 of file LineMerger_module.cc.

vector of pointers to hits

Definition at line 281 of file LineMerger_module.cc.

Type of cluster ID.

Definition at line 80 of file LineMerger_module.cc.

Constructor & Destructor Documentation

cluster::ClusterAndHitMerger::ClusterAndHitMerger ( )
default
cluster::ClusterAndHitMerger::ClusterAndHitMerger ( recob::Cluster const &  cluster,
HitVector_t const &  cluster_hits 
)
inline

Definition at line 285 of file LineMerger_module.cc.

286  {
287  Add(cluster, cluster_hits);
288  }
Cluster finding and building.
bool Add(recob::Cluster const &cluster, HitVector_t const &cluster_hits, bool prepend=false)
Merges a single cluster into this object.

Member Function Documentation

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

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 240 of file LineMerger_module.cc.

References recob::Cluster::EndWire(), recob::Cluster::hasPlane(), recob::Cluster::isValid(), recob::Cluster::Plane(), recob::Cluster::StartWire(), recob::Cluster::View(), and recob::Cluster::Width().

Referenced by Add().

241  {
242  if (!cluster.isValid()) return false;
243 
244  if (n_clusters == 0) { // special case: we are still empty
245  AdoptEnd(cluster, ClusterEnds_t::clStart);
246  AdoptEnd(cluster, ClusterEnds_t::clEnd);
247  fWidth = cluster.Width();
248  fView = cluster.View();
249  fPlaneID = cluster.Plane();
250  ++n_clusters;
251  return true;
252  } // if empty
253 
254  if (cluster.View() != View()) return false;
255 
256  if (cluster.hasPlane() && hasPlane() && (cluster.Plane() != Plane())) return false;
257 
258  // this code has been moved here from the old recon::Cluster::operator+
259  // of recob::Cluster v13.
260  if (cluster.StartWire() < StartWire()) { // adopt the new start
261  AdoptEnd(cluster, ClusterEnds_t::clStart);
262  }
263  if (cluster.EndWire() < EndWire()) { // adopt the new end
264  AdoptEnd(cluster, ClusterEnds_t::clEnd);
265  }
266 
267  top(fWidth, cluster.Width()); // extend width
268 
269  if (!hasPlane()) fPlaneID = cluster.Plane();
270 
271  return true;
272  } // 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)
Data referring to start and end of the cluster.
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.
bool cluster::ClusterAndHitMerger::Add ( recob::Cluster const &  cluster,
HitVector_t const &  cluster_hits,
bool  prepend = false 
)

Merges a single cluster into this object.

Parameters
clusterthe cluster to be merged
cluster_hitsthe list of hits in this cluster
prependif true, hits are inserted at the beginning of the list
Returns
whether the addition was successful
See also
ClusterMerger::Add()

The two ends of the cluster are merged into this one, that gets extended. Hit lists are merged too: no check on existing hits nor double addition.

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

Definition at line 326 of file LineMerger_module.cc.

References cluster::ClusterMerger::Add(), and tca::AddHits().

330  {
331  if (!ClusterMerger::Add(cluster)) return false;
332 
333  AddHits(cluster_hits, prepend);
334  return true;
335  } // ClusterAndHitMerger::Add()
Cluster finding and building.
void AddHits(HitVector_t const &cluster_hits, bool prepend)
bool Add(recob::Cluster const &cluster)
Merges a single cluster into this object.
void cluster::ClusterAndHitMerger::AddHits ( HitVector_t const &  cluster_hits,
bool  prepend 
)
inlineprotected

Definition at line 319 of file LineMerger_module.cc.

320  {
321  hits.insert(prepend ? hits.begin() : hits.end(), cluster_hits.begin(), cluster_hits.end());
322  } // AddHits()
HitVector_t hits
hits in the cluster
void cluster::ClusterMerger::AdoptEnd ( recob::Cluster const &  cluster,
ClusterEnds_t  iEnd 
)
protectedinherited

Imports all the member of the corresponding end.

Definition at line 228 of file LineMerger_module.cc.

References recob::Cluster::Angle(), recob::Cluster::EdgeCharge(), recob::Cluster::OpeningAngle(), recob::Cluster::SigmaTickCoord(), recob::Cluster::SigmaWireCoord(), recob::Cluster::TickCoord(), and recob::Cluster::WireCoord().

229  {
230  const ClusterEnds_t iDestEnd = iSrcEnd;
231  fEndWires[iDestEnd] = cluster.WireCoord(iSrcEnd);
232  fSigmaEndWires[iDestEnd] = cluster.SigmaWireCoord(iSrcEnd);
233  fEndTicks[iDestEnd] = cluster.TickCoord(iSrcEnd);
234  fSigmaEndTicks[iDestEnd] = cluster.SigmaTickCoord(iSrcEnd);
235  fEndCharges[iDestEnd] = cluster.EdgeCharge(iSrcEnd);
236  fAngles[iDestEnd] = cluster.Angle(iSrcEnd);
237  fOpeningAngles[iDestEnd] = cluster.OpeningAngle(iSrcEnd);
238  } // 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
inlineinherited

Returns the angle at either end of the cluster.

Definition at line 165 of file LineMerger_module.cc.

165 { return fAngles[side]; }
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 
)
inlinestaticprotectedinherited

Data referring to start and end of the cluster.

Definition at line 222 of file LineMerger_module.cc.

References value.

223  {
224  if (value < var) var = value;
225  }
double value
Definition: spectrum.C:18
float cluster::ClusterMerger::EdgeCharge ( ClusterEnds_t  side) const
inlineinherited

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

Definition at line 162 of file LineMerger_module.cc.

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

Returns the ending angle of the cluster.

Definition at line 156 of file LineMerger_module.cc.

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

Returns the charge on the last wire of the cluster.

Definition at line 153 of file LineMerger_module.cc.

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

Returns the opening angle at the end of the cluster.

Definition at line 159 of file LineMerger_module.cc.

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

Returns the tick coordinate of the end of the cluster.

Definition at line 123 of file LineMerger_module.cc.

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

Returns the wire coordinate of the end of the cluster.

Definition at line 120 of file LineMerger_module.cc.

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

Returns whether geometry plane is valid.

Definition at line 180 of file LineMerger_module.cc.

180 { return Plane().isValid; }
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:194
geo::PlaneID Plane() const
Returns the plane ID this cluster lies on.
HitVector_t const& cluster::ClusterAndHitMerger::Hits ( ) const
inline

Returns a constant reference to the current list of hits.

Definition at line 309 of file LineMerger_module.cc.

References hits().

309 { return hits; }
HitVector_t hits
hits in the cluster
unsigned int cluster::ClusterAndHitMerger::NHits ( ) const
inline

Number of hits in the cluster.

Definition at line 312 of file LineMerger_module.cc.

References hits().

312 { return hits.size(); }
HitVector_t hits
hits in the cluster
float cluster::ClusterMerger::OpeningAngle ( ClusterEnds_t  side) const
inlineinherited

Returns the opening angle at either end of the cluster.

Definition at line 168 of file LineMerger_module.cc.

168 { return fOpeningAngles[side]; }
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
inlineinherited

Returns the plane ID this cluster lies on.

Definition at line 177 of file LineMerger_module.cc.

177 { return fPlaneID; }
geo::PlaneID fPlaneID
Location of the start of the cluster.
float cluster::ClusterMerger::SigmaEndTick ( ) const
inlineinherited

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

Definition at line 129 of file LineMerger_module.cc.

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

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

Definition at line 126 of file LineMerger_module.cc.

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

Data referring to start and end of the cluster.

Definition at line 117 of file LineMerger_module.cc.

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

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

Definition at line 114 of file LineMerger_module.cc.

114 { return fSigmaEndWires[ClusterEnds_t::clStart]; }
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
inlineinherited

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

Definition at line 141 of file LineMerger_module.cc.

141 { return fSigmaEndTicks[side]; }
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
inlineinherited

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

Definition at line 138 of file LineMerger_module.cc.

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

Returns the starting angle of the cluster.

Definition at line 147 of file LineMerger_module.cc.

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

Returns the charge on the first wire of the cluster.

Definition at line 144 of file LineMerger_module.cc.

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

Returns the opening angle at the start of the cluster.

Definition at line 150 of file LineMerger_module.cc.

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

Returns the tick coordinate of the start of the cluster.

Definition at line 111 of file LineMerger_module.cc.

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

Returns the wire coordinate of the start of the cluster.

Definition at line 108 of file LineMerger_module.cc.

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

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

Definition at line 135 of file LineMerger_module.cc.

135 { return fEndTicks[side]; }
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 
)
inlinestaticprotectedinherited

Data referring to start and end of the cluster.

Definition at line 217 of file LineMerger_module.cc.

References value.

218  {
219  if (value > var) var = value;
220  }
double value
Definition: spectrum.C:18
geo::View_t cluster::ClusterMerger::View ( ) const
inlineinherited

Returns the view for this cluster.

Definition at line 174 of file LineMerger_module.cc.

174 { return fView; }
geo::View_t fView
View for this cluster.
float cluster::ClusterMerger::Width ( ) const
inlineinherited

A measure of the cluster width, in homogenized units.

Definition at line 171 of file LineMerger_module.cc.

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

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

Definition at line 132 of file LineMerger_module.cc.

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

Member Data Documentation

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

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

Definition at line 199 of file LineMerger_module.cc.

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

Charge on the start and end wire of the cluster.

Definition at line 196 of file LineMerger_module.cc.

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

Tick coordinate of the start and end of the cluster.

Definition at line 190 of file LineMerger_module.cc.

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

Data referring to start and end of the cluster.

Definition at line 184 of file LineMerger_module.cc.

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

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

Definition at line 202 of file LineMerger_module.cc.

geo::PlaneID cluster::ClusterMerger::fPlaneID
protectedinherited

Location of the start of the cluster.

Definition at line 209 of file LineMerger_module.cc.

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

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

Definition at line 193 of file LineMerger_module.cc.

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

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

Definition at line 187 of file LineMerger_module.cc.

geo::View_t cluster::ClusterMerger::fView
protectedinherited

View for this cluster.

Definition at line 207 of file LineMerger_module.cc.

float cluster::ClusterMerger::fWidth
protectedinherited

A measure of the cluster width, in homogenized units.

Definition at line 205 of file LineMerger_module.cc.

HitVector_t cluster::ClusterAndHitMerger::hits
protected

hits in the cluster

Definition at line 317 of file LineMerger_module.cc.

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

number of clusters added so far

Definition at line 211 of file LineMerger_module.cc.


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