LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::KHitContainerWireLine Class Referenceabstract

#include "KHitContainerWireLine.h"

Inheritance diagram for trkf::KHitContainerWireLine:
trkf::KHitContainer

Public Member Functions

virtual void fill (detinfo::DetectorPropertiesData const &clock_data, const art::PtrVector< recob::Hit > &hits, int only_plane)=0
 
const std::list< KHitGroup > & getSorted () const
 
std::list< KHitGroup > & getSorted ()
 Sorted list. More...
 
const std::list< KHitGroup > & getUnsorted () const
 
std::list< KHitGroup > & getUnsorted ()
 Unsorted list. More...
 
const std::list< KHitGroup > & getUnused () const
 
std::list< KHitGroup > & getUnused ()
 Unused list. More...
 
void clear ()
 Clear all lists. More...
 
void reset ()
 Move all objects to unsorted list (from sorted and unused lists). More...
 
void sort (const KTrack &trk, bool addUnsorted, const Propagator &prop, Propagator::PropDirection dir=Propagator::UNKNOWN)
 (Re)sort objects in unsorted and sorted lists. More...
 
unsigned int getPreferredPlane () const
 Return the plane with the most KHitGroups in the unsorted list. More...
 

Private Member Functions

void fill (const detinfo::DetectorPropertiesData &detProp, const art::PtrVector< recob::Hit > &hits, int only_plane) override
 

Detailed Description

Definition at line 25 of file KHitContainerWireLine.h.

Member Function Documentation

void trkf::KHitContainer::clear ( )
inherited

Clear all lists.

Definition at line 20 of file KHitContainer.cxx.

References trkf::KHitContainer::fSorted, trkf::KHitContainer::fUnsorted, and trkf::KHitContainer::fUnused.

21  {
22  fSorted.clear();
23  fUnsorted.clear();
24  fUnused.clear();
25  }
std::list< KHitGroup > fUnused
Unused KHitGroup objects.
Definition: KHitContainer.h:99
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:98
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:97
void trkf::KHitContainerWireLine::fill ( const detinfo::DetectorPropertiesData detProp,
const art::PtrVector< recob::Hit > &  hits,
int  only_plane 
)
overrideprivate

Fill container.

Arguments:

hits - RecoBase/Hit collection. only_plane - Choose hits from this plane if >= 0.

This method converts the hits in the input collection into KHitWireLine objects and inserts them into the base class.

Definition at line 31 of file KHitContainerWireLine.cxx.

References trkf::KHitGroup::addHit(), art::PtrVector< T >::begin(), recob::Hit::Channel(), art::PtrVector< T >::end(), trkf::KHitGroup::getSurface(), trkf::KHitContainer::getUnsorted(), geo::PlaneID::Plane, and recob::Hit::WireID().

34  {
35  // Get services.
36 
38 
39  // Loop over hits.
40 
41  for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
42  ++ihit) {
43  const recob::Hit& hit = **ihit;
44 
45  // Extract the wireid from the Hit.
46  geo::WireID hitWireID = hit.WireID();
47 
48  uint32_t channel = hit.Channel();
49 
50  // Choose plane.
51  if (only_plane >= 0 && hitWireID.Plane != (unsigned int)(only_plane)) continue;
52 
53  // Make a new KHitGroup for each hit.
54 
55  getUnsorted().push_back(KHitGroup());
56  KHitGroup* pgr = &(getUnsorted().back());
57  if (!pgr) {
58  throw cet::exception("KHitContainerWireLine")
59  << __func__ << ": no group map for channel " << channel << "\n";
60  }
61 
62  pgr->addHit(std::make_shared<KHitWireLine>(detProp, *ihit, pgr->getSurface()));
63  }
64  }
iterator begin()
Definition: PtrVector.h:217
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
typename data_t::const_iterator const_iterator
Definition: PtrVector.h:55
iterator end()
Definition: PtrVector.h:231
const std::list< KHitGroup > & getUnsorted() const
Definition: KHitContainer.h:70
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
Detector simulation of raw signals on wires.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:268
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual void trkf::KHitContainer::fill ( detinfo::DetectorPropertiesData const &  clock_data,
const art::PtrVector< recob::Hit > &  hits,
int  only_plane 
)
pure virtualinherited
unsigned int trkf::KHitContainer::getPreferredPlane ( ) const
inherited

Return the plane with the most KHitGroups in the unsorted list.

Definition at line 94 of file KHitContainer.cxx.

References trkf::KHitContainer::fUnsorted, and trkf::KHitGroup::getPlane().

95  {
96  // Count hits in each plane.
97 
98  std::vector<unsigned int> planehits(3, 0);
99 
100  // Loop over KHitGroups in the unsorted list.
101 
102  for (std::list<KHitGroup>::const_iterator igr = fUnsorted.begin(); igr != fUnsorted.end();
103  ++igr) {
104 
105  const KHitGroup& gr = *igr;
106 
107  // Get plane of this KHitGroup.
108 
109  int plane = gr.getPlane();
110  ++planehits.at(plane);
111  }
112 
113  // Figure out which plane has the most hits.
114 
115  unsigned int prefplane = 0;
116  for (unsigned int i = 0; i < planehits.size(); ++i) {
117  if (planehits[i] >= planehits[prefplane]) prefplane = i;
118  }
119  return prefplane;
120  }
intermediate_table::const_iterator const_iterator
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:98
const std::list<KHitGroup>& trkf::KHitContainer::getSorted ( ) const
inlineinherited

Definition at line 69 of file KHitContainer.h.

Referenced by trkf::KalmanFilterAlg::buildTrack(), and trkf::KalmanFilterAlg::extendTrack().

69 { return fSorted; }
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:97
std::list<KHitGroup>& trkf::KHitContainer::getSorted ( )
inlineinherited

Sorted list.

Definition at line 75 of file KHitContainer.h.

const std::list<KHitGroup>& trkf::KHitContainer::getUnsorted ( ) const
inlineinherited

Definition at line 70 of file KHitContainer.h.

Referenced by trkf::KalmanFilterAlg::buildTrack(), trkf::KalmanFilterAlg::extendTrack(), fill(), and trkf::KHitContainerWireX::fill().

70 { return fUnsorted; }
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:98
std::list<KHitGroup>& trkf::KHitContainer::getUnsorted ( )
inlineinherited

Unsorted list.

Definition at line 76 of file KHitContainer.h.

const std::list<KHitGroup>& trkf::KHitContainer::getUnused ( ) const
inlineinherited

Definition at line 71 of file KHitContainer.h.

Referenced by trkf::KalmanFilterAlg::buildTrack(), and trkf::KalmanFilterAlg::extendTrack().

71 { return fUnused; }
std::list< KHitGroup > fUnused
Unused KHitGroup objects.
Definition: KHitContainer.h:99
std::list<KHitGroup>& trkf::KHitContainer::getUnused ( )
inlineinherited

Unused list.

Definition at line 77 of file KHitContainer.h.

References clear(), dir, and lar_content::UNKNOWN.

void trkf::KHitContainer::reset ( )
inherited

Move all objects to unsorted list (from sorted and unused lists).

Definition at line 28 of file KHitContainer.cxx.

References trkf::KHitContainer::fSorted, trkf::KHitContainer::fUnsorted, and trkf::KHitContainer::fUnused.

29  {
30  fUnsorted.splice(fUnsorted.end(), fSorted);
31  fUnsorted.splice(fUnsorted.end(), fUnused);
32  }
std::list< KHitGroup > fUnused
Unused KHitGroup objects.
Definition: KHitContainer.h:99
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:98
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:97
void trkf::KHitContainer::sort ( const KTrack trk,
bool  addUnsorted,
const Propagator prop,
Propagator::PropDirection  dir = Propagator::UNKNOWN 
)
inherited

(Re)sort objects in unsorted and sorted lists.

(Re)sort objects in unsorted and sorted lists.

Arguments:

trk - Track to be propagated. addUnsorted - If true, include unsorted objects in sort. prop - Propagator. dir - Propagation direction.

Definition at line 43 of file KHitContainer.cxx.

References larg4::dist(), trkf::KHitContainer::fSorted, trkf::KHitContainer::fUnsorted, trkf::KHitGroup::getSurface(), trkf::KHitGroup::setPath(), and trkf::Propagator::vec_prop().

Referenced by trkf::KalmanFilterAlg::buildTrack(), and trkf::KalmanFilterAlg::extendTrack().

47  {
48  // Maybe transfer all objects in unsorted list to the sorted list.
49 
50  if (addUnsorted) fSorted.splice(fSorted.end(), fUnsorted);
51 
52  // Loop over objects in sorted list.
53 
54  for (std::list<KHitGroup>::iterator igr = fSorted.begin(); igr != fSorted.end();) {
55 
56  KHitGroup& gr = *igr;
57 
58  // Get destination surface.
59 
60  const std::shared_ptr<const Surface>& psurf = gr.getSurface();
61 
62  // Make a fresh copy of the track and propagate it to
63  // the destination surface.
64 
65  KTrack trkp = trk;
66  std::optional<double> dist = prop.vec_prop(trkp, psurf, dir, false, 0, 0);
67  if (!dist) {
68 
69  // If propagation failed, reset the path flag for this surface
70  // and move the KHitGroup to the unsorted list. Be careful to
71  // keep the list iterator valid.
72 
73  gr.setPath(false, 0.);
75  ++igr;
76  fUnsorted.splice(fUnsorted.end(), fSorted, it);
77  }
78  else {
79 
80  // Otherwise (if propagation succeeded), set the path distance
81  // and advance the iterator to the next KHitGroup.
82 
83  gr.setPath(true, *dist);
84  ++igr;
85  }
86  }
87 
88  // Finally, sort the sorted list in order of path distance.
89 
90  fSorted.sort();
91  }
intermediate_table::iterator iterator
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:98
TDirectory * dir
Definition: macro.C:5
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:97

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