118 auto outputTracks = std::make_unique<std::vector<recob::Track>>();
119 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
120 auto outputPfpTAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
121 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
122 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
123 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
133 std::unique_ptr<art::FindManyP<recob::Track>> assocTracks;
135 std::unique_ptr<art::FindManyP<recob::Shower>> assocShowers;
136 std::unique_ptr<art::FindManyP<recob::Seed>> assocSeeds;
138 assocTracks = std::unique_ptr<art::FindManyP<recob::Track>>(
143 assocShowers = std::unique_ptr<art::FindManyP<recob::Shower>>(
146 assocSeeds = std::unique_ptr<art::FindManyP<recob::Seed>>(
150 std::unique_ptr<art::FindManyP<recob::Cluster>> assocClusters =
151 std::unique_ptr<art::FindManyP<recob::Cluster>>(
162 for (
unsigned int iPfp = 0; iPfp < inputPfps->size(); ++iPfp) {
166 const std::vector<art::Ptr<recob::Track>>& tracks = assocTracks->at(iPfp);
171 std::vector<art::Ptr<recob::Hit>> inHits;
174 inHits.push_back(
hit);
179 trkmkr::OptionalOutputs optionals;
184 bool fitok =
trackMaker_->makeTrack(detProp,
track, inHits, outTrack, outHits, optionals);
185 if (!fitok) continue;
189 if (outTrack.NumberTrajectoryPoints() != outHits.
size()) {
191 <<
"Produced recob::Track required to have 1-1 correspondance between hits and " 196 outputTracks->emplace_back(std::move(outTrack));
198 outputPfpTAssn->addSingle(pfp, aptr);
200 for (
auto const& trhit : outHits) {
202 outputTracks->back().HasValidPoint(ip) ? ip : std::numeric_limits<int>::max(),
203 -std::numeric_limits<double>::max());
204 outputHits->addSingle(aptr, trhit, metadata);
207 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
208 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
209 const double fErrXYZ[6] = {0};
211 outputSpacePoints->emplace_back(std::move(sp));
213 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
214 outputHitSpacePointAssn->addSingle(trhit, apsp);
219 auto osp = optionals.spacePointHitPairs();
220 for (
auto it = osp.begin(); it != osp.end(); ++it) {
221 outputSpacePoints->emplace_back(std::move(it->first));
223 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
224 outputHitSpacePointAssn->addSingle(it->second, apsp);
227 if (
doTrackFitHitInfo_) { outputHitInfo->emplace_back(optionals.trackFitHitInfos()); }
234 const std::vector<art::Ptr<recob::Shower>>& showers = assocShowers->at(iPfp);
236 if (showers.size() != 1)
continue;
239 std::vector<art::Ptr<recob::Hit>> inHits;
240 const std::vector<art::Ptr<recob::Cluster>> clustersRange = assocClusters->at(iPfp);
245 inHits.push_back(
hit);
248 for (
unsigned int iShower = 0; iShower < showers.
size(); ++iShower) {
257 if (shower->
Energy().size() == 3) mom = shower->
Energy()[2] * 0.001;
258 std::vector<recob::tracking::Point_t> p;
259 std::vector<recob::tracking::Vector_t>
d;
260 for (
unsigned int i = 0; i < inHits.size(); ++i) {
262 d.push_back(mom *
dir);
269 std::vector<art::Ptr<recob::Hit>> outHits;
276 trackMaker_->makeTrack(detProp, traj, iPfp, inHits, outTrack, outHits, optionals);
277 if (!fitok)
continue;
283 <<
"Produced recob::Track required to have 1-1 correspondance between hits and " 288 outputTracks->emplace_back(std::move(outTrack));
290 outputPfpTAssn->addSingle(pfp, aptr);
292 for (
auto const& trhit : outHits) {
294 outputTracks->back().HasValidPoint(ip) ? ip : std::numeric_limits<int>::max(),
295 -std::numeric_limits<double>::max());
296 outputHits->addSingle(aptr, trhit, metadata);
299 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
300 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
301 const double fErrXYZ[6] = {0};
303 outputSpacePoints->emplace_back(std::move(sp));
305 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
306 outputHitSpacePointAssn->addSingle(trhit, apsp);
312 for (
auto it = osp.begin(); it != osp.end(); ++it) {
313 outputSpacePoints->emplace_back(std::move(it->first));
315 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
316 outputHitSpacePointAssn->addSingle(it->second, apsp);
327 const std::vector<art::Ptr<recob::Seed>>&
seeds = assocSeeds->at(iPfp);
329 if (seeds.size() != 1)
continue;
332 std::vector<art::Ptr<recob::Hit>> inHits;
333 const std::vector<art::Ptr<recob::Cluster>> clustersRange = assocClusters->at(iPfp);
338 inHits.push_back(hit);
340 if (inHits.size() < 4) continue;
342 for (
unsigned int iS = 0; iS < seeds.size(); ++iS) {
352 std::vector<recob::tracking::Point_t> p;
353 std::vector<recob::tracking::Vector_t>
d;
354 for (
unsigned int i = 0; i < inHits.size(); ++i) {
363 std::vector<art::Ptr<recob::Hit>> outHits;
370 trackMaker_->makeTrack(detProp, traj, iPfp, inHits, outTrack, outHits, optionals);
371 if (!fitok)
continue;
377 <<
"Produced recob::Track required to have 1-1 correspondance between hits and " 382 outputTracks->emplace_back(std::move(outTrack));
384 outputPfpTAssn->addSingle(pfp, aptr);
386 for (
auto const& trhit : outHits) {
388 outputTracks->back().HasValidPoint(ip) ? ip : std::numeric_limits<int>::max(),
389 -std::numeric_limits<double>::max());
390 outputHits->addSingle(aptr, trhit, metadata);
393 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
394 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
395 const double fErrXYZ[6] = {0};
397 outputSpacePoints->emplace_back(std::move(sp));
399 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
400 outputHitSpacePointAssn->addSingle(trhit, apsp);
406 for (
auto it = osp.begin(); it != osp.end(); ++it) {
407 outputSpacePoints->emplace_back(std::move(it->first));
409 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
410 outputHitSpacePointAssn->addSingle(it->second, apsp);
420 e.
put(std::move(outputTracks));
421 e.
put(std::move(outputHits));
422 e.
put(std::move(outputPfpTAssn));
425 e.
put(std::move(outputSpacePoints));
426 e.
put(std::move(outputHitSpacePointAssn));
const TVector3 & ShowerStart() const
bool spacePointsFromTrajP_
Namespace for general, non-LArSoft-specific utilities.
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
Reconstruction base classes.
art::InputTag pfpInputTag
void GetPoint(double *Pt, double *Err) const
const std::vector< double > & Energy() const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
for(Int_t i=0;i< nentries;i++)
Cluster finding and building.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
auto associated_groups(A const &assns)
Helper functions to access associations in order.
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
Ptr(H, T) -> Ptr< detail::not_map_vector_t< typename H::element_type >>
A trajectory in space reconstructed from hits.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
const TVector3 & Direction() const
std::vector< PointFlags_t > Flags_t
Type of point flag list.
art::InputTag clsInputTag
Detector simulation of raw signals on wires.
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
std::vector< TrajPoint > seeds
auto groupByIndex(Groups &&groups, std::size_t index) -> decltype(auto)
Returns the group within groups with the specified index.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
art::InputTag shwInputTag
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
art::InputTag trkInputTag
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
void GetDirection(double *Dir, double *Err) const
void initSpacePoints()
initialize the output vector of SpHitPair
Struct holding optional TrackMaker outputs.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception