All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sbn::TrackScatterClosestApproach Class Reference
Inheritance diagram for sbn::TrackScatterClosestApproach:

Public Member Functions

 TrackScatterClosestApproach (fhicl::ParameterSet const &p)
 
 TrackScatterClosestApproach (TrackScatterClosestApproach const &)=delete
 
 TrackScatterClosestApproach (TrackScatterClosestApproach &&)=delete
 
TrackScatterClosestApproachoperator= (TrackScatterClosestApproach const &)=delete
 
TrackScatterClosestApproachoperator= (TrackScatterClosestApproach &&)=delete
 
void produce (art::Event &e) override
 

Private Member Functions

ScatterClosestApproach CalculateClosestApproach (const recob::Track &track) const
 

Private Attributes

const art::InputTag fTrackLabel
 
const float fMinTrackLength
 

Detailed Description

Definition at line 30 of file TrackScatterClosestApproach_module.cc.

Constructor & Destructor Documentation

sbn::TrackScatterClosestApproach::TrackScatterClosestApproach ( fhicl::ParameterSet const &  p)
explicit

Definition at line 53 of file TrackScatterClosestApproach_module.cc.

54  : EDProducer { p }
55  , fTrackLabel(p.get<std::string>("TrackLabel"))
56  , fMinTrackLength(p.get<float>("MinTrackLength"))
57 {
58  produces<std::vector<ScatterClosestApproach>>();
59  produces<art::Assns<recob::Track, ScatterClosestApproach>>();
60 }
pdgs p
Definition: selectors.fcl:22
sbn::TrackScatterClosestApproach::TrackScatterClosestApproach ( TrackScatterClosestApproach const &  )
delete
sbn::TrackScatterClosestApproach::TrackScatterClosestApproach ( TrackScatterClosestApproach &&  )
delete

Member Function Documentation

ScatterClosestApproach sbn::TrackScatterClosestApproach::CalculateClosestApproach ( const recob::Track track) const
private

Definition at line 88 of file TrackScatterClosestApproach_module.cc.

89 {
90  // Interpolate the start and end of the track to find the centroid axis
91  const TVector3 start(track.Start<TVector3>());
92  const TVector3 dir((start - track.End<TVector3>()).Unit());
93 
94  // Calculate the perpendicular distance from the centroid to each traj point
95  float sumClosestApproach(0), maxClosestApproach(0);
96  unsigned int counter(0);
97  for (size_t i = 0; i < track.NumberTrajectoryPoints(); i++) {
98  if (!track.HasValidPoint(i))
99  continue;
100  counter++;
101 
102  const TVector3 pos(track.LocationAtPoint<TVector3>(i));
103  const TVector3 disp(pos - start);
104  const float proj(disp.Dot(dir));
105  const float thisClosestApproach((disp - proj * dir).Mag());
106 
107  sumClosestApproach += thisClosestApproach;
108  maxClosestApproach = std::max(maxClosestApproach, thisClosestApproach);
109  }
110 
111  if (!counter)
112  return ScatterClosestApproach();
113 
114  const float meanClosestApproach(sumClosestApproach / counter);
115 
116  // Calculate the spread in ClosestApproach around the mean value
117  float sumStdDev(0);
118  for (size_t i = 0; i < track.NumberTrajectoryPoints(); i++) {
119  if (!track.HasValidPoint(i))
120  continue;
121 
122  const TVector3 pos(track.LocationAtPoint<TVector3>(i));
123  const TVector3 disp(pos - start);
124  const float proj(disp.Dot(dir));
125  const float thisClosestApproach((disp - proj * dir).Mag());
126  const float thisClosestApproachDev(thisClosestApproach - meanClosestApproach);
127 
128  sumStdDev += thisClosestApproachDev * thisClosestApproachDev;
129  }
130 
131  const float stdDevClosestApproach(std::sqrt(sumStdDev / counter));
132 
133  return ScatterClosestApproach(meanClosestApproach, stdDevClosestApproach, maxClosestApproach);
134 }
Point_t const & LocationAtPoint(size_t i) const
bool HasValidPoint(size_t i) const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
Point_t const & Start() const
Access to track position at different points.
tuple dir
Definition: dropbox.py:28
Point_t const & End() const
TrackScatterClosestApproach& sbn::TrackScatterClosestApproach::operator= ( TrackScatterClosestApproach const &  )
delete
TrackScatterClosestApproach& sbn::TrackScatterClosestApproach::operator= ( TrackScatterClosestApproach &&  )
delete
void sbn::TrackScatterClosestApproach::produce ( art::Event &  e)
override

Definition at line 62 of file TrackScatterClosestApproach_module.cc.

63 {
64  // Implementation of required member function here.
65  auto const trackHandle(e.getValidHandle<std::vector<recob::Track>>(fTrackLabel));
66 
67  std::vector<art::Ptr<recob::Track>> tracks;
68  art::fill_ptr_vector(tracks, trackHandle);
69 
70  auto closestapproachVec = std::make_unique<std::vector<ScatterClosestApproach>>();
71  auto trackAssns = std::make_unique<art::Assns<recob::Track, ScatterClosestApproach>>();
72 
73  for (auto const& track : tracks) {
74 
75  if (track->Length() < fMinTrackLength)
76  continue;
77 
78  ScatterClosestApproach closestapproach(this->CalculateClosestApproach(*track));
79 
80  closestapproachVec->push_back(closestapproach);
81  util::CreateAssn(*this, e, *closestapproachVec, track, *trackAssns);
82  }
83 
84  e.put(std::move(closestapproachVec));
85  e.put(std::move(trackAssns));
86 }
ClusterModuleLabel join with tracks
ScatterClosestApproach CalculateClosestApproach(const recob::Track &track) const
process_name use argoneut_mc_hitfinder track
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
do i e

Member Data Documentation

const float sbn::TrackScatterClosestApproach::fMinTrackLength
private

Definition at line 48 of file TrackScatterClosestApproach_module.cc.

const art::InputTag sbn::TrackScatterClosestApproach::fTrackLabel
private

Definition at line 47 of file TrackScatterClosestApproach_module.cc.


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