LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
geo::part::WidthPartition< Data > Class Template Reference

Partition of area along the width dimension. More...

#include "Partitions.h"

Inheritance diagram for geo::part::WidthPartition< Data >:
geo::part::PartitionSortedByRange< Data,&PartitionBase::Area_t::width > geo::part::SortedPartition< Data, details::PartitionSorterByAreaRangeLower< Range > > geo::part::PartitionContainer< Data > geo::part::PartitionWithData< Data > geo::part::Partition< Data > geo::part::PartitionBase geo::part::AreaOwner

Public Types

using Base_t = PartitionSortedByRange< Data,&PartitionBase::Area_t::width >
 Base class. More...
 
using Base_t = SortedPartition< Data, details::PartitionSorterByAreaRangeLower< Range >>
 
using Base_t = PartitionContainer< Data >
 
using Partition_t = Partition< Data >
 Base type of the partition. More...
 
using Sorter_t = details::PartitionSorterByAreaRangeLower< Range >
 Type of sorter being used. More...
 
using Data_t = typename Partition_t::Data_t
 
using Area_t = typename Partition_t::Area_t
 
using Subpartitions_t = typename Base_t::Subpartitions_t
 
using AreaRangeMember_t = AreaOwner::AreaRangeMember_t
 

Public Member Functions

virtual Base_t::Partition_t const * findPart (double w, double) const override
 Returns the only partition which could contain the specified depth. More...
 
virtual Data_tatPoint (double w, double d) const override
 Returns stored datum only if point is covered, nullptr otherwise. More...
 
virtual Data_tdata () const override
 Returns the datum directly stored (nullptr if none). More...
 
std::string describe (std::string indent, std::string firstIndent) const
 Returns a description of the partition. More...
 
std::string describe (std::string indent="") const
 Returns a description of the partition. More...
 
template<typename Pred >
void walk (Pred &&pred) const
 Applies pred to all partitions. More...
 
std::size_t nParts () const
 Returns the number of subparts in the partition (0 if simple element). More...
 
bool contains (double w, double d) const
 Returns whether the specified point is covered by this object. More...
 
Area_t const & area () const
 Returns the covered area. More...
 
template<typename Stream >
void dumpArea (Stream &&out) const
 Output the owned area into an output stream. More...
 

Protected Member Functions

Partition_t const * findPartWithKey (double key) const
 Returns the only partition which could contain the specified key. More...
 
void initParts ()
 Performs initialization on the specified subpartition list. More...
 
std::size_t size () const
 Returns the number of contained subpartitions. More...
 
virtual Subpartitions_t const & parts () const override
 Returns a list of the subpartitions owned. More...
 
virtual std::string doDescribe (std::string indent, std::string firstIndent) const override
 Describes this and each of the subpartitions. More...
 
std::string describeArea (std::string indent, std::string firstIndent) const
 Returns a description of the partition area. More...
 

Static Protected Member Functions

template<typename Pred >
static void walk (Partition_t const *start, Pred &&pred)
 Applies pred to start partition first, and then to all subpartitions. More...
 

Protected Attributes

Sorter_t sorter
 Object used for sorting and binary search. More...
 
Subpartitions_t myParts
 List of subpartitions. More...
 

Static Protected Attributes

static Subpartitions_t const NoSubparts
 Subpartitions (if any). More...
 

Private Member Functions

virtual std::string describeIntro () const override
 Introduction to the description of the subpartitions. More...
 

Detailed Description

template<typename Data>
class geo::part::WidthPartition< Data >

Partition of area along the width dimension.

Definition at line 449 of file Partitions.h.

Member Typedef Documentation

Definition at line 377 of file Partitions.h.

template<typename Data >
using geo::part::WidthPartition< Data >::Base_t = PartitionSortedByRange<Data, &PartitionBase::Area_t::width>

Base class.

Definition at line 452 of file Partitions.h.

template<typename Data >
using geo::part::PartitionSortedByRange< Data, Range >::Base_t = SortedPartition<Data, details::PartitionSorterByAreaRangeLower<Range>>

Definition at line 422 of file Partitions.h.

template<typename Data >
using geo::part::SortedPartition< Data, Sorter >::Base_t = PartitionContainer<Data>

Definition at line 371 of file Partitions.h.

Definition at line 376 of file Partitions.h.

Base type of the partition.

Definition at line 372 of file Partitions.h.

Type of sorter being used.

Definition at line 373 of file Partitions.h.

Definition at line 378 of file Partitions.h.

Member Function Documentation

Area_t const& geo::part::AreaOwner::area ( ) const
inlineinherited
template<typename Data >
auto geo::part::PartitionContainer< Data >::atPoint ( double  w,
double  d 
) const
overridevirtualinherited

Returns stored datum only if point is covered, nullptr otherwise.

Reimplemented from geo::part::PartitionWithData< Data >.

Definition at line 750 of file Partitions.h.

References d, part, and w.

751 {
752  if (!Base_t::contains(w, d)) return nullptr; // not our point at all
753  // it's ours; see if it belongs to a subpart
754  auto part = findPart(w, d);
755  return part ? part->atPoint(w, d) : Base_t::data();
756 }
bool contains(double w, double d) const
Returns whether the specified point is covered by this object.
Definition: Partitions.h:45
TString part[npart]
Definition: Style.C:32
Float_t d
Definition: plot.C:235
virtual Partition_t const * findPart(double w, double d) const =0
Returns the only partition which could contain the specified width.
virtual Data_t * data() const override
Returns the datum directly stored (nullptr if none).
Definition: Partitions.h:271
Float_t w
Definition: plot.C:20
bool geo::part::AreaOwner::contains ( double  w,
double  d 
) const
inlineinherited

Returns whether the specified point is covered by this object.

Definition at line 45 of file Partitions.h.

References geo::part::AreaOwner::area(), and lar::util::simple_geo::Rectangle< Data >::contains().

45 { return area().contains(w, d); }
bool contains(Data_t w, Data_t d) const
Returns whether the specified point is in the area.
Definition: SimpleGeo.h:441
Float_t d
Definition: plot.C:235
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:48
Float_t w
Definition: plot.C:20
template<typename Data >
virtual Data_t* geo::part::PartitionWithData< Data >::data ( ) const
inlineoverridevirtualinherited

Returns the datum directly stored (nullptr if none).

Reimplemented from geo::part::Partition< Data >.

Definition at line 271 of file Partitions.h.

Referenced by geo::part::GridPartition< Data >::doDescribe().

271 { return myData; }
Data_t * myData
The contained datum.
Definition: Partitions.h:280
template<typename Data>
std::string geo::part::Partition< Data >::describe ( std::string  indent,
std::string  firstIndent 
) const
inlineinherited

Returns a description of the partition.

Definition at line 204 of file Partitions.h.

205  {
206  return doDescribe(indent, firstIndent);
207  }
virtual std::string doDescribe(std::string indent, std::string firstIndent) const
Returns a description of the partition.
Definition: Partitions.h:243
std::string indent(std::size_t const i)
template<typename Data>
std::string geo::part::Partition< Data >::describe ( std::string  indent = "") const
inlineinherited

Returns a description of the partition.

Definition at line 210 of file Partitions.h.

References geo::part::Partition< Data >::describe(), and art::detail::indent().

Referenced by geo::part::Partition< Data >::describe().

210 { return describe(indent, indent); }
std::string indent(std::size_t const i)
std::string describe(std::string indent, std::string firstIndent) const
Returns a description of the partition.
Definition: Partitions.h:204
std::string geo::part::PartitionBase::describeArea ( std::string  indent,
std::string  firstIndent 
) const
inlineprotectedinherited

Returns a description of the partition area.

Definition at line 551 of file Partitions.h.

References geo::part::AreaOwner::dumpArea().

Referenced by geo::part::Partition< Data >::doDescribe().

553 {
554  std::ostringstream sstr;
555  sstr << firstIndent << "partition covers ";
556  dumpArea(sstr);
557  return sstr.str();
558 }
void dumpArea(Stream &&out) const
Output the owned area into an output stream.
Definition: Partitions.h:52
template<typename Data >
std::string geo::part::WidthPartition< Data >::describeIntro ( ) const
overrideprivatevirtual

Introduction to the description of the subpartitions.

Reimplemented from geo::part::PartitionContainer< Data >.

Definition at line 824 of file Partitions.h.

References util::size().

825 {
826  std::ostringstream sstr;
827  sstr << Base_t::size() << " partitions along width covering " << Base_t::area();
828  return sstr.str();
829 }
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:48
std::size_t size() const
Returns the number of contained subpartitions.
Definition: Partitions.h:318
template<typename Data >
std::string geo::part::PartitionContainer< Data >::doDescribe ( std::string  indent,
std::string  firstIndent 
) const
overrideprotectedvirtualinherited

Describes this and each of the subpartitions.

Reimplemented from geo::part::PartitionWithData< Data >.

Reimplemented in geo::part::GridPartition< Data >.

Definition at line 760 of file Partitions.h.

References geo::part::describePartitionData(), and part.

762 {
763  std::string msg = firstIndent + describeIntro();
764  if (Base_t::data()) {
765  std::ostringstream sstr;
766  sstr << ", and ";
768  msg += sstr.str();
769  }
770 
771  for (auto const& part : parts()) {
772  msg += "\n" + indent + " * ";
773  msg += part->describe(indent + " ", "");
774  }
775 
776  return msg;
777 }
void describePartitionData(Stream &&out, Data const *data, std::string indent="", std::string firstIndent="")
Describes a data object for Partition::describe() method.
Definition: Partitions.h:697
TString part[npart]
Definition: Style.C:32
std::string indent(std::size_t const i)
virtual Subpartitions_t const & parts() const override
Returns a list of the subpartitions owned.
Definition: Partitions.h:321
virtual Data_t * data() const override
Returns the datum directly stored (nullptr if none).
Definition: Partitions.h:271
virtual std::string describeIntro() const
Introduction to the description of the subpartitions.
Definition: Partitions.h:781
template<typename Stream >
void geo::part::AreaOwner::dumpArea ( Stream &&  out) const
inlineinherited

Output the owned area into an output stream.

Definition at line 52 of file Partitions.h.

References geo::part::AreaOwner::area().

Referenced by geo::part::PartitionBase::describeArea().

53  {
54  std::forward<Stream>(out) << area();
55  }
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:48
template<typename Data >
virtual Base_t::Partition_t const* geo::part::WidthPartition< Data >::findPart ( double  w,
double   
) const
inlineoverridevirtual

Returns the only partition which could contain the specified depth.

Implements geo::part::PartitionContainer< Data >.

Definition at line 457 of file Partitions.h.

458  {
459  return Base_t::findPartWithKey(w);
460  }
Partition_t const * findPartWithKey(double key) const
Returns the only partition which could contain the specified key.
Float_t w
Definition: plot.C:20
Partition_t const* geo::part::SortedPartition< Data, details::PartitionSorterByAreaRangeLower< Range > >::findPartWithKey ( double  key) const
protectedinherited

Returns the only partition which could contain the specified key.

void geo::part::SortedPartition< Data, details::PartitionSorterByAreaRangeLower< Range > >::initParts ( )
protectedinherited

Performs initialization on the specified subpartition list.

template<typename Data>
std::size_t geo::part::Partition< Data >::nParts ( ) const
inlineinherited

Returns the number of subparts in the partition (0 if simple element).

Definition at line 234 of file Partitions.h.

Referenced by geo::part::GridPartition< Data >::detectSeparators().

234 { return parts().size(); }
virtual Subpartitions_t const & parts() const
Returns a list of all subpartitions.
Definition: Partitions.h:240
template<typename Data >
virtual Subpartitions_t const& geo::part::PartitionContainer< Data >::parts ( ) const
inlineoverrideprotectedvirtualinherited

Returns a list of the subpartitions owned.

Reimplemented from geo::part::Partition< Data >.

Definition at line 321 of file Partitions.h.

Referenced by geo::part::GridPartition< Data >::computeDepthSeps(), and geo::part::GridPartition< Data >::computeWidthSeps().

321 { return myParts; }
Subpartitions_t myParts
List of subpartitions.
Definition: Partitions.h:315
template<typename Data >
std::size_t geo::part::PartitionContainer< Data >::size ( ) const
inlineprotectedinherited

Returns the number of contained subpartitions.

Definition at line 318 of file Partitions.h.

Referenced by geo::part::GridPartition< Data >::GridPartition().

318 { return parts().size(); }
virtual Subpartitions_t const & parts() const override
Returns a list of the subpartitions owned.
Definition: Partitions.h:321
template<typename Data>
template<typename Pred >
void geo::part::Partition< Data >::walk ( Pred &&  pred) const
inlineinherited

Applies pred to all partitions.

Template Parameters
Preda predicate type
Parameters
predthe predicate to be applied

The predicate pred is applied to this partition first, and then to all subpartitions in no specified order.

The predicate is any object behaving like a unary function of signature:

void predicate(Partition<Data> const& part);

If the predicate returns a value, that value is ignored. The predicate is forwarded while "walking" through the partitions.

Definition at line 228 of file Partitions.h.

229  {
230  walk(this, pred);
231  }
void walk(Pred &&pred) const
Applies pred to all partitions.
Definition: Partitions.h:228
template<typename Data >
template<typename Pred >
void geo::part::Partition< Data >::walk ( Partition_t const *  start,
Pred &&  pred 
)
staticprotectedinherited

Applies pred to start partition first, and then to all subpartitions.

Definition at line 715 of file Partitions.h.

References geo::part::Partition< Data >::parts().

716 {
717  if (!start) return;
718  pred(*start);
719 
720  // recursive implementation
721  for (auto const& subPart : start->parts())
722  subPart->walk(std::forward<Pred>(pred));
723 }

Member Data Documentation

template<typename Data >
Subpartitions_t geo::part::PartitionContainer< Data >::myParts
protectedinherited

List of subpartitions.

Definition at line 315 of file Partitions.h.

template<typename Data>
geo::part::Partition< Data >::Subpartitions_t const geo::part::Partition< Data >::NoSubparts
staticprotectedinherited

Subpartitions (if any).

Definition at line 237 of file Partitions.h.

Object used for sorting and binary search.

Definition at line 406 of file Partitions.h.


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