13 #include "art/Framework/Core/EDProducer.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "art/Framework/Principal/Handle.h"
17 #include "art/Framework/Principal/Run.h"
18 #include "art/Framework/Principal/SubRun.h"
19 #include "canvas/Utilities/InputTag.h"
20 #include "fhiclcpp/ParameterSet.h"
22 #include "messagefacility/MessageLogger/MessageLogger.h"
43 void produce(art::Event&
e)
override;
55 , fTrackLabel(
p.get<std::string>(
"TrackLabel"))
56 , fMinTrackLength(
p.get<
float>(
"MinTrackLength"))
58 produces<std::vector<ScatterClosestApproach>>();
59 produces<art::Assns<recob::Track, ScatterClosestApproach>>();
65 auto const trackHandle(e.getValidHandle<std::vector<recob::Track>>(
fTrackLabel));
67 std::vector<art::Ptr<recob::Track>>
tracks;
68 art::fill_ptr_vector(tracks, trackHandle);
70 auto closestapproachVec = std::make_unique<std::vector<ScatterClosestApproach>>();
71 auto trackAssns = std::make_unique<art::Assns<recob::Track, ScatterClosestApproach>>();
73 for (
auto const&
track : tracks) {
80 closestapproachVec->push_back(closestapproach);
84 e.put(std::move(closestapproachVec));
85 e.put(std::move(trackAssns));
91 const TVector3 start(track.
Start<TVector3>());
92 const TVector3
dir((start - track.
End<TVector3>()).Unit());
95 float sumClosestApproach(0), maxClosestApproach(0);
103 const TVector3 disp(pos - start);
104 const float proj(disp.Dot(
dir));
105 const float thisClosestApproach((disp - proj *
dir).Mag());
107 sumClosestApproach += thisClosestApproach;
108 maxClosestApproach = std::max(maxClosestApproach, thisClosestApproach);
114 const float meanClosestApproach(sumClosestApproach / counter);
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);
128 sumStdDev += thisClosestApproachDev * thisClosestApproachDev;
131 const float stdDevClosestApproach(std::sqrt(sumStdDev / counter));
ClusterModuleLabel join with tracks
void produce(art::Event &e) override
ScatterClosestApproach CalculateClosestApproach(const recob::Track &track) const
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.
process_name use argoneut_mc_hitfinder track
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Point_t const & Start() const
Access to track position at different points.
Provides recob::Track data product.
TrackScatterClosestApproach(fhicl::ParameterSet const &p)
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.
const art::InputTag fTrackLabel
Point_t const & End() const
TrackScatterClosestApproach & operator=(TrackScatterClosestApproach const &)=delete
const float fMinTrackLength
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: