LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
trkf::KHitContainerWireX Class Reference

#include "KHitContainerWireX.h"

Inheritance diagram for trkf::KHitContainerWireX:
trkf::KHitContainer

Public Member Functions

 KHitContainerWireX ()
 Default constructor. More...
 
virtual ~KHitContainerWireX ()
 Destructor. More...
 
void fill (const art::PtrVector< recob::Hit > &hits, int only_plane) override
 Fill container. More...
 
const std::list< KHitGroup > & getSorted () const
 Sorted list. More...
 
std::list< KHitGroup > & getSorted ()
 Sorted list. More...
 
const std::list< KHitGroup > & getUnsorted () const
 Unsorted list. More...
 
std::list< KHitGroup > & getUnsorted ()
 Unsorted list. More...
 
const std::list< KHitGroup > & getUnused () const
 Unused list. More...
 
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...
 

Detailed Description

Definition at line 25 of file KHitContainerWireX.h.

Constructor & Destructor Documentation

trkf::KHitContainerWireX::KHitContainerWireX ( )

Default constructor.

Default Constructor.

Definition at line 23 of file KHitContainerWireX.cxx.

24  {}
trkf::KHitContainerWireX::~KHitContainerWireX ( )
virtual

Destructor.

Definition at line 27 of file KHitContainerWireX.cxx.

28  {}

Member Function Documentation

void trkf::KHitContainer::clear ( )
inherited

Clear all lists.

Definition at line 29 of file KHitContainer.cxx.

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

Referenced by trkf::KHitContainer::getUnused().

30  {
31  fSorted.clear();
32  fUnsorted.clear();
33  fUnused.clear();
34  }
std::list< KHitGroup > fUnused
Unused KHitGroup objects.
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:99
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:98
void trkf::KHitContainerWireX::fill ( const art::PtrVector< recob::Hit > &  hits,
int  only_plane 
)
overridevirtual

Fill container.

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 KHitWireX objects and inserts them into the base class. Hits corresponding to the same readout wire are grouped together as KHitGroup objects.

Implements trkf::KHitContainer.

Definition at line 42 of file KHitContainerWireX.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().

Referenced by trkf::TrackKalmanCheater::produce().

44  {
45  // Get services.
46 
48 
49  // Make a temporary map from channel number to KHitGroup objects.
50  // The KHitGroup pointers are borrowed references to KHitGroup
51  // objects stored by value in the base class.
52 
53  std::map<unsigned int, KHitGroup*> group_map;
54 
55  // Loop over hits.
56 
58  ihit != hits.end(); ++ihit) {
59  const recob::Hit& hit = **ihit;
60 
61  // Extract the wire id from the Hit.
62  geo::WireID hitWireID = hit.WireID();
63 
64  uint32_t channel = hit.Channel();
65 
66  // Choose plane.
67  if(only_plane >= 0 && hitWireID.Plane != (unsigned int)(only_plane))
68  continue;
69 
70  // See if we need to make a new KHitGroup.
71 
72  KHitGroup* pgr = 0;
73  if(group_map.count(channel) == 0) {
74  getUnsorted().push_back(KHitGroup());
75  pgr = &(getUnsorted().back());
76  group_map[channel] = pgr;
77  }
78  else
79  pgr = group_map[channel];
80  if (!pgr) {
81  throw cet::exception("KHitContainerWireX")
82  << __func__ << ": no group map for channel " << channel << "\n";
83  }
84 
85  // Get surface from KHitGroup (might be null pointer).
86 
87  const std::shared_ptr<const Surface>& psurf = pgr->getSurface();
88 
89  // Construct KHitWireX object.
90 
91  std::shared_ptr<const KHitBase> phit(new KHitWireX(*ihit, psurf));
92 
93  // Insert hit into KHitGroup.
94 
95  pgr->addHit(phit);
96  }
97  }
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
iterator begin()
Definition: PtrVector.h:223
iterator end()
Definition: PtrVector.h:237
const std::list< KHitGroup > & getUnsorted() const
Unsorted list.
Definition: KHitContainer.h:72
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Detector simulation of raw signals on wires.
data_t::const_iterator const_iterator
Definition: PtrVector.h:61
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int trkf::KHitContainer::getPreferredPlane ( ) const
inherited

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

Definition at line 107 of file KHitContainer.cxx.

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

Referenced by trkf::KHitContainer::getUnused().

108  {
109  // Count hits in each plane.
110 
111  std::vector<unsigned int> planehits(3, 0);
112 
113  // Loop over KHitGroups in the unsorted list.
114 
116  igr != fUnsorted.end(); ++igr) {
117 
118  const KHitGroup& gr = *igr;
119 
120  // Get plane of this KHitGroup.
121 
122  int plane = gr.getPlane();
123  ++planehits.at(plane);
124  }
125 
126  // Figure out which plane has the most hits.
127 
128  unsigned int prefplane = 0;
129  for(unsigned int i=0; i<planehits.size(); ++i) {
130  if(planehits[i] >= planehits[prefplane])
131  prefplane = i;
132  }
133  return prefplane;
134  }
intermediate_table::const_iterator const_iterator
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:99
const std::list<KHitGroup>& trkf::KHitContainer::getSorted ( ) const
inlineinherited

Sorted list.

Definition at line 71 of file KHitContainer.h.

References trkf::KHitContainer::fSorted.

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

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

Sorted list.

Definition at line 77 of file KHitContainer.h.

References trkf::KHitContainer::fSorted.

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

Unsorted list.

Definition at line 78 of file KHitContainer.h.

References trkf::KHitContainer::fUnsorted.

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

Unused list.

Definition at line 73 of file KHitContainer.h.

References trkf::KHitContainer::fUnused.

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

std::list<KHitGroup>& trkf::KHitContainer::getUnused ( )
inlineinherited
void trkf::KHitContainer::reset ( )
inherited

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

Definition at line 37 of file KHitContainer.cxx.

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

Referenced by trkf::KHitContainer::getUnused().

38  {
39  fUnsorted.splice(fUnsorted.end(), fSorted);
40  fUnsorted.splice(fUnsorted.end(), fUnused);
41  }
std::list< KHitGroup > fUnused
Unused KHitGroup objects.
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:99
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:98
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 52 of file KHitContainer.cxx.

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

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

55  {
56  if(!prop)
57  throw cet::exception("KHitContainer") << __func__ << ": no propagator" << "\n";
58 
59  // Maybe transfer all objects in unsorted list to the sorted list.
60 
61  if(addUnsorted)
62  fSorted.splice(fSorted.end(), fUnsorted);
63 
64  // Loop over objects in sorted list.
65 
66  for(std::list<KHitGroup>::iterator igr = fSorted.begin();
67  igr != fSorted.end();) {
68 
69  KHitGroup& gr = *igr;
70 
71  // Get destination surface.
72 
73  const std::shared_ptr<const Surface>& psurf = gr.getSurface();
74 
75  // Make a fresh copy of the track and propagate it to
76  // the destination surface.
77 
78  KTrack trkp = trk;
79  boost::optional<double> dist = prop->vec_prop(trkp, psurf, dir, false, 0, 0);
80  if(!dist) {
81 
82  // If propagation failed, reset the path flag for this surface
83  // and move the KHitGroup to the unsorted list. Be careful to
84  // keep the list iterator valid.
85 
86  gr.setPath(false, 0.);
88  ++igr;
89  fUnsorted.splice(fUnsorted.end(), fSorted, it);
90  }
91  else {
92 
93  // Otherwise (if propagation succeeded), set the path distance
94  // and advance the iterator to the next KHitGroup.
95 
96  gr.setPath(true, *dist);
97  ++igr;
98  }
99  }
100 
101  // Finally, sort the sorted list in order of path distance.
102 
103  fSorted.sort();
104  }
intermediate_table::iterator iterator
std::list< KHitGroup > fUnsorted
Unsorted KHitGroup objects.
Definition: KHitContainer.h:99
TDirectory * dir
Definition: macro.C:5
std::list< KHitGroup > fSorted
Sorted KHitGroup objects.
Definition: KHitContainer.h:98
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

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