11 #include "art/Persistency/Common/PtrMaker.h"
20 #include "art/Framework/Core/EDProducer.h"
21 #include "art/Framework/Core/ModuleMacros.h"
22 #include "art/Framework/Principal/Event.h"
23 #include "canvas/Persistency/Common/Assns.h"
24 #include "canvas/Utilities/InputTag.h"
25 #include "messagefacility/MessageLogger/MessageLogger.h"
26 #include "fhiclcpp/types/Atom.h"
27 #include "fhiclcpp/types/Sequence.h"
28 #include "fhiclcpp/types/Name.h"
29 #include "fhiclcpp/types/Comment.h"
32 #include "Math/SMatrix.h"
67 Comment(
"tag of the recob::Hit data products to produce tracks with.")
72 Comment(
"number of hits per track; last takes all remaining ones.")
84 produces<std::vector<recob::TrackTrajectory>>();
85 produces<art::Assns<recob::TrackTrajectory, recob::Hit>>();
86 produces<std::vector<recob::Track>>();
87 produces<std::vector<std::vector<recob::TrackFitHitInfo>>>();
88 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
89 produces<art::Assns<recob::Track, recob::TrackTrajectory>>();
92 virtual void produce(art::Event& event)
override;
110 auto trajectories = std::make_unique<std::vector<recob::TrackTrajectory>>();
111 auto tracks = std::make_unique<std::vector<recob::Track>>();
113 = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
115 = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
116 auto hitTrajectoryAssn
117 = std::make_unique<art::Assns<recob::TrackTrajectory, recob::Hit>>();
118 auto trackTrajectoryAssn
119 = std::make_unique<art::Assns<recob::Track, recob::TrackTrajectory>>();
121 auto hitHandle =
event.getValidHandle<std::vector<recob::Hit>>(
hitsTag);
122 auto const& hits = *hitHandle;
124 art::PtrMaker<recob::TrackTrajectory> trajectoryPtrMaker(event);
125 art::PtrMaker<recob::Track> trackPtrMaker(event);
126 unsigned int iTrack = 0;
127 unsigned int usedHits = 0;
128 while (usedHits < hits.size()) {
131 unsigned int const nTrackHits = (iTrack <
hitsPerTrack.size())
132 ? std::min(
hitsPerTrack[iTrack], (
unsigned int)(hits.size() - usedHits))
133 : (hits.size() - usedHits)
139 std::size_t
const firstHit = usedHits;
143 std::vector<recob::TrackFitHitInfo> fitInfo;
144 for (
unsigned int iPoint = 0; iPoint < nTrackHits; ++iPoint) {
169 pos.emplace_back(iPoint, iPoint, iPoint);
170 mom.emplace_back(2.0, 1.0, 0.0);
171 flags.emplace_back(usedHits++, pointFlags);
176 double(iPoint) * 2.5,
177 double(iPoint) * 1.5,
179 { ROOT::Math::SMatrixIdentity{} },
180 hits[usedHits + iPoint].WireID()
185 trajectories->emplace_back();
187 trajectories->emplace_back
188 (std::move(pos), std::move(mom), std::move(flags),
true);
194 auto const trajPtr = trajectoryPtrMaker(trajectories->size() - 1U);
195 for (std::size_t iHit = firstHit; iHit < usedHits; ++iHit)
196 hitTrajectoryAssn->addSingle(trajPtr, { hitHandle, iHit });
202 (trajectories->back(), 2112, 1.0, nTrackHits, {}, {}, iTrack);
203 tracks->push_back(std::move(
track));
208 trackFitInfo->push_back(std::move(fitInfo));
213 auto const trackPtr = trackPtrMaker(iTrack);
214 for (std::size_t iHit = firstHit; iHit < usedHits; ++iHit) {
216 auto const hitIndex = iHit - firstHit;
218 hitTrackAssn->addSingle(trackPtr, { hitHandle, iHit }, hitInfo);
225 trackTrajectoryAssn->addSingle(trackPtr, trajPtr);
227 mf::LogVerbatim(
"TrackProxyTrackMaker")
228 <<
"New track #" << tracks->back().ID()
229 <<
" with " << nTrackHits <<
" hits";
238 mf::LogInfo(
"TrackProxyTrackMaker")
239 <<
"Produced " <<
tracks->size() <<
" tracks from " << usedHits <<
" hits.";
241 event.put(std::move(trajectories));
242 event.put(std::move(hitTrajectoryAssn));
243 event.put(std::move(
tracks));
244 event.put(std::move(trackFitInfo));
245 event.put(std::move(hitTrackAssn));
246 event.put(std::move(trackTrajectoryAssn));
std::vector< unsigned int > hitsPerTrack
Hits per produced track.
virtual void produce(art::Event &event) override
static constexpr Flag_t Suspicious
The point reconstruction is somehow questionable.
ClusterModuleLabel join with tracks
static constexpr Flag_t NoPoint
The trajectory point is not defined.
Declaration of signal hit object.
art::EDProducer::Table< Config > Parameters
tracking::Positions_t Positions_t
Type of trajectory point list.
process_name use argoneut_mc_hitfinder track
tracking::Momenta_t Momenta_t
Type of momentum list.
BEGIN_PROLOG vertical distance to the surface Name
Data product for reconstructed trajectory in space.
art::InputTag hitsTag
Input hit collection label.
static constexpr Flag_t HitIgnored
Hit was not included for the computation of the trajectory.
std::vector< PointFlags_t > Flags_t
Type of point flag list.
Set of flags pertaining a point of the track.
Provides recob::Track data product.
fhicl::Atom< art::InputTag > hitsTag
Flags_t::Mask_t Mask_t
Type of mask of bits.
TrackProxyTrackMaker(Parameters const &config)
static constexpr Flag_t DetectorIssue
The hit is associated to a problematic channel.
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
fhicl::Sequence< unsigned int > hitsPerTrack
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: