13 #include "cetlib_except/exception.h" 93 produces<std::vector<recob::Track> >();
94 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
95 produces<art::Assns<recob::PFParticle, recob::Track> >();
96 if (
doTrackFitHitInfo_) produces<std::vector<std::vector<recob::TrackFitHitInfo> > >();
98 produces<std::vector<recob::SpacePoint> >();
99 produces<art::Assns<recob::Hit, recob::SpacePoint> >();
106 auto outputTracks = std::make_unique<std::vector<recob::Track> >();
107 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
108 auto outputPfpTAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track> >();
109 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo> > >();
110 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint> >();
111 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint> >();
120 std::unique_ptr<art::FindManyP<recob::Track> > assocTracks;
122 std::unique_ptr<art::FindManyP<recob::Shower> > assocShowers;
123 std::unique_ptr<art::FindManyP<recob::Seed> > assocSeeds;
140 for (
unsigned int iPfp = 0; iPfp < inputPfps->size(); ++iPfp) {
146 const std::vector<art::Ptr<recob::Track> >& tracks = assocTracks->at(iPfp);
151 std::vector<art::Ptr<recob::Hit> > inHits;
157 std::vector<art::Ptr<recob::Hit> > outHits;
163 bool fitok =
trackMaker_->makeTrack(
track, inHits, outTrack, outHits, optionals);
164 if (!fitok)
continue;
169 throw cet::exception(
"TrackProducerFromPFParticle") <<
"Produced recob::Track required to have 1-1 correspondance between hits and points.\n";
173 outputTracks->emplace_back(std::move(outTrack));
175 outputPfpTAssn->addSingle(pfp, aptr);
177 for (
auto const& trhit: outHits) {
179 outputHits->addSingle(aptr, trhit, metadata);
182 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
183 const double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
184 const double fErrXYZ[6] = {0};
186 outputSpacePoints->emplace_back(std::move(sp));
188 outputHitSpacePointAssn->addSingle(trhit, apsp);
194 for (
auto it = osp.begin(); it!=osp.end(); ++it ) {
195 outputSpacePoints->emplace_back(std::move(it->first));
197 outputHitSpacePointAssn->addSingle(it->second,apsp);
209 const std::vector<art::Ptr<recob::Shower> >& showers = assocShowers->at(iPfp);
211 if (showers.size()!=1)
continue;
214 std::vector<art::Ptr<recob::Hit> > inHits;
215 const std::vector<art::Ptr<recob::Cluster> > clustersRange = assocClusters->at(iPfp);
222 for (
unsigned int iShower = 0; iShower < showers.size(); ++iShower) {
228 std::vector<recob::tracking::Point_t> p;
229 std::vector<recob::tracking::Vector_t>
d;
230 for (
unsigned int i=0; i<inHits.size(); ++i) {
238 std::vector<art::Ptr<recob::Hit> > outHits;
244 bool fitok =
trackMaker_->makeTrack(traj, iPfp, inHits, outTrack, outHits, optionals);
245 if (!fitok)
continue;
250 throw cet::exception(
"TrackProducerFromPFParticle") <<
"Produced recob::Track required to have 1-1 correspondance between hits and points.\n";
254 outputTracks->emplace_back(std::move(outTrack));
256 outputPfpTAssn->addSingle(pfp, aptr);
258 for (
auto const& trhit: outHits) {
260 outputHits->addSingle(aptr, trhit, metadata);
263 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
264 const double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
265 const double fErrXYZ[6] = {0};
267 outputSpacePoints->emplace_back(std::move(sp));
269 outputHitSpacePointAssn->addSingle(trhit, apsp);
275 for (
auto it = osp.begin(); it!=osp.end(); ++it ) {
276 outputSpacePoints->emplace_back(std::move(it->first));
278 outputHitSpacePointAssn->addSingle(it->second,apsp);
291 const std::vector<art::Ptr<recob::Seed> >&
seeds = assocSeeds->at(iPfp);
293 if (seeds.size()!=1)
continue;
296 std::vector<art::Ptr<recob::Hit> > inHits;
297 const std::vector<art::Ptr<recob::Cluster> > clustersRange = assocClusters->at(iPfp);
303 if (inHits.size()<4)
continue;
305 for (
unsigned int iS = 0; iS < seeds.size(); ++iS) {
315 std::vector<recob::tracking::Point_t> p;
316 std::vector<recob::tracking::Vector_t>
d;
317 for (
unsigned int i=0; i<inHits.size(); ++i) {
325 std::vector<art::Ptr<recob::Hit> > outHits;
331 bool fitok =
trackMaker_->makeTrack(traj, iPfp, inHits, outTrack, outHits, optionals);
332 if (!fitok)
continue;
337 throw cet::exception(
"TrackProducerFromPFParticle") <<
"Produced recob::Track required to have 1-1 correspondance between hits and points.\n";
341 outputTracks->emplace_back(std::move(outTrack));
343 outputPfpTAssn->addSingle(pfp, aptr);
345 for (
auto const& trhit: outHits) {
347 outputHits->addSingle(aptr, trhit, metadata);
350 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
351 const double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
352 const double fErrXYZ[6] = {0};
354 outputSpacePoints->emplace_back(std::move(sp));
356 outputHitSpacePointAssn->addSingle(trhit, apsp);
362 for (
auto it = osp.begin(); it!=osp.end(); ++it ) {
363 outputSpacePoints->emplace_back(std::move(it->first));
365 outputHitSpacePointAssn->addSingle(it->second,apsp);
377 e.put(std::move(outputTracks));
378 e.put(std::move(outputHits));
379 e.put(std::move(outputPfpTAssn));
381 e.put(std::move(outputHitInfo));
384 e.put(std::move(outputSpacePoints));
385 e.put(std::move(outputHitSpacePointAssn));
const TVector3 & ShowerStart() const
bool spacePointsFromTrajP_
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
art::InputTag pfpInputTag
void GetPoint(double *Pt, double *Err) const
auto groupByIndex(Groups &&groups, std::size_t index) -> decltype(auto)
Returns the group within groups with the specified index.
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Cluster finding and building.
TrackProducerFromPFParticle(fhicl::ParameterSet const &p)
auto associated_groups(A const &assns)
Helper functions to access associations in order.
void produce(art::Event &e) override
std::unique_ptr< trkmkr::TrackMaker > trackMaker_
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 ...
#define DEFINE_ART_MODULE(klass)
A trajectory in space reconstructed from hits.
T get(std::string const &key) const
const TVector3 & Direction() const
std::vector< PointFlags_t > Flags_t
Type of point flag list.
Declaration of cluster object.
Detector simulation of raw signals on wires.
Produce a reco::Track collection, as a result of the fit of an existing recob::PFParticle collection...
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
std::vector< TrajPoint > seeds
art::InputTag shwInputTag
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
Helper functions to access associations in order.
TrackProducerFromPFParticle & operator=(TrackProducerFromPFParticle const &)=delete
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