84 auto outputTracks = std::make_unique<std::vector<recob::Track>>();
85 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
86 auto outputTTjTAssn = std::make_unique<art::Assns<recob::TrackTrajectory, recob::Track>>();
87 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
88 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
89 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
92 art::PtrMaker<recob::Track> trackPtrMaker(
e);
93 art::PtrMaker<recob::SpacePoint> spacePointPtrMaker(
e);
96 art::ValidHandle<std::vector<recob::TrackTrajectory>> inputTrajs =
97 e.getValidHandle<std::vector<recob::TrackTrajectory>>(
trajInputTag);
98 auto const& tjHitsAssn =
99 *
e.getValidHandle<art::Assns<recob::TrackTrajectory, recob::Hit>>(
trajInputTag);
102 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
e);
108 unsigned int iTraj = 0;
109 for (
auto hitsRange : trajectoriesWithHits) {
112 art::Ptr<recob::TrackTrajectory> traj(inputTrajs, iTraj++);
113 std::vector<art::Ptr<recob::Hit>> inHits;
114 for (art::Ptr<recob::Hit>
const&
hit : hitsRange)
115 inHits.push_back(
hit);
119 std::vector<art::Ptr<recob::Hit>> outHits;
125 bool fitok =
trackMaker_->makeTrack(
detProp, traj, inHits, outTrack, outHits, optionals);
126 if (!fitok)
continue;
131 throw cet::exception(
"TrackProducerFromTrackTrajectory")
132 <<
"Produced recob::Track required to have 1-1 correspondance between hits and points.\n";
136 outputTracks->emplace_back(std::move(outTrack));
137 const art::Ptr<recob::Track> aptr = trackPtrMaker(outputTracks->size() - 1);
138 outputTTjTAssn->addSingle(traj, aptr);
140 for (
auto const& trhit : outHits) {
141 outputHits->addSingle(aptr, trhit);
144 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
145 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
146 const double fErrXYZ[6] = {0};
148 outputSpacePoints->emplace_back(std::move(sp));
149 const art::Ptr<recob::SpacePoint> apsp = spacePointPtrMaker(outputSpacePoints->size() - 1);
150 outputHitSpacePointAssn->addSingle(trhit, apsp);
156 for (
auto it = osp.begin(); it != osp.end(); ++it) {
157 outputSpacePoints->emplace_back(std::move(it->first));
158 const art::Ptr<recob::SpacePoint> apsp = spacePointPtrMaker(outputSpacePoints->size() - 1);
159 outputHitSpacePointAssn->addSingle(it->second, apsp);
166 e.put(std::move(outputTracks));
167 e.put(std::move(outputHits));
168 e.put(std::move(outputTTjTAssn));
171 e.put(std::move(outputSpacePoints));
172 e.put(std::move(outputHitSpacePointAssn));
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
auto associated_groups(A const &assns)
Helper functions to access associations in order.
bool spacePointsFromTrajP_
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
art::InputTag trajInputTag
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
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: