9 #include "canvas/Persistency/Common/FindManyP.h" 11 #include "cetlib_except/exception.h" 93 if (
p.has_key(
"trackInputTag"))
97 if (
p.has_key(
"showerInputTag"))
101 if (
p.has_key(
"clusterInputTag"))
105 produces<std::vector<recob::Track>>();
106 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
107 produces<art::Assns<recob::PFParticle, recob::Track>>();
110 produces<std::vector<recob::SpacePoint>>();
111 produces<art::Assns<recob::Hit, recob::SpacePoint>>();
119 auto outputTracks = std::make_unique<std::vector<recob::Track>>();
120 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
121 auto outputPfpTAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
122 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
123 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
124 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
134 std::unique_ptr<art::FindManyP<recob::Track>> assocTracks;
136 std::unique_ptr<art::FindManyP<recob::Shower>> assocShowers;
137 std::unique_ptr<art::FindManyP<recob::Seed>> assocSeeds;
139 assocTracks = std::unique_ptr<art::FindManyP<recob::Track>>(
140 new art::FindManyP<recob::Track>(inputPfps,
e,
trkInputTag));
144 assocShowers = std::unique_ptr<art::FindManyP<recob::Shower>>(
145 new art::FindManyP<recob::Shower>(inputPfps,
e,
shwInputTag));
147 assocSeeds = std::unique_ptr<art::FindManyP<recob::Seed>>(
148 new art::FindManyP<recob::Seed>(inputPfps,
e,
pfpInputTag));
151 std::unique_ptr<art::FindManyP<recob::Cluster>> assocClusters =
152 std::unique_ptr<art::FindManyP<recob::Cluster>>(
153 new art::FindManyP<recob::Cluster>(inputPfps,
e,
pfpInputTag));
163 for (
unsigned int iPfp = 0; iPfp < inputPfps->size(); ++iPfp) {
167 const std::vector<art::Ptr<recob::Track>>&
tracks = assocTracks->at(iPfp);
172 std::vector<art::Ptr<recob::Hit>> inHits;
175 inHits.push_back(
hit);
179 std::vector<art::Ptr<recob::Hit>> outHits;
185 bool fitok =
trackMaker_->makeTrack(detProp, track, inHits, outTrack, outHits, optionals);
186 if (!fitok)
continue;
192 <<
"Produced recob::Track required to have 1-1 correspondance between hits and " 197 outputTracks->emplace_back(
std::move(outTrack));
199 outputPfpTAssn->addSingle(pfp, aptr);
201 for (
auto const& trhit : outHits) {
205 outputHits->addSingle(aptr, trhit,
metadata);
208 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
209 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
210 const double fErrXYZ[6] = {0};
212 outputSpacePoints->emplace_back(
std::move(sp));
214 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
215 outputHitSpacePointAssn->addSingle(trhit, apsp);
221 for (
auto it = osp.begin(); it != osp.end(); ++it) {
222 outputSpacePoints->emplace_back(
std::move(it->first));
224 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
225 outputHitSpacePointAssn->addSingle(it->second, apsp);
235 const std::vector<art::Ptr<recob::Shower>>&
showers = assocShowers->at(iPfp);
237 if (showers.size() != 1)
continue;
240 std::vector<art::Ptr<recob::Hit>> inHits;
241 const std::vector<art::Ptr<recob::Cluster>> clustersRange = assocClusters->at(iPfp);
246 inHits.push_back(
hit);
249 for (
unsigned int iShower = 0; iShower < showers.size(); ++iShower) {
258 if (shower->
Energy().size() == 3) mom = shower->
Energy()[2] * 0.001;
259 std::vector<recob::tracking::Point_t>
p;
260 std::vector<recob::tracking::Vector_t>
d;
261 for (
unsigned int i = 0; i < inHits.size(); ++i) {
263 d.push_back(mom *
dir);
270 std::vector<art::Ptr<recob::Hit>> outHits;
277 trackMaker_->makeTrack(detProp, traj, iPfp, inHits, outTrack, outHits, optionals);
278 if (!fitok)
continue;
284 <<
"Produced recob::Track required to have 1-1 correspondance between hits and " 289 outputTracks->emplace_back(
std::move(outTrack));
291 outputPfpTAssn->addSingle(pfp, aptr);
293 for (
auto const& trhit : outHits) {
297 outputHits->addSingle(aptr, trhit,
metadata);
300 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
301 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
302 const double fErrXYZ[6] = {0};
304 outputSpacePoints->emplace_back(
std::move(sp));
306 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
307 outputHitSpacePointAssn->addSingle(trhit, apsp);
313 for (
auto it = osp.begin(); it != osp.end(); ++it) {
314 outputSpacePoints->emplace_back(
std::move(it->first));
316 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
317 outputHitSpacePointAssn->addSingle(it->second, apsp);
328 const std::vector<art::Ptr<recob::Seed>>&
seeds = assocSeeds->at(iPfp);
330 if (seeds.size() != 1)
continue;
333 std::vector<art::Ptr<recob::Hit>> inHits;
334 const std::vector<art::Ptr<recob::Cluster>> clustersRange = assocClusters->at(iPfp);
339 inHits.push_back(
hit);
341 if (inHits.size() < 4)
continue;
343 for (
unsigned int iS = 0;
iS < seeds.size(); ++
iS) {
353 std::vector<recob::tracking::Point_t>
p;
354 std::vector<recob::tracking::Vector_t>
d;
355 for (
unsigned int i = 0; i < inHits.size(); ++i) {
364 std::vector<art::Ptr<recob::Hit>> outHits;
371 trackMaker_->makeTrack(detProp, traj, iPfp, inHits, outTrack, outHits, optionals);
372 if (!fitok)
continue;
378 <<
"Produced recob::Track required to have 1-1 correspondance between hits and " 383 outputTracks->emplace_back(
std::move(outTrack));
385 outputPfpTAssn->addSingle(pfp, aptr);
387 for (
auto const& trhit : outHits) {
391 outputHits->addSingle(aptr, trhit,
metadata);
394 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
395 const double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
396 const double fErrXYZ[6] = {0};
398 outputSpacePoints->emplace_back(
std::move(sp));
400 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
401 outputHitSpacePointAssn->addSingle(trhit, apsp);
407 for (
auto it = osp.begin(); it != osp.end(); ++it) {
408 outputSpacePoints->emplace_back(
std::move(it->first));
410 (*spacePointPtrMaker)(outputSpacePoints->size() - 1);
411 outputHitSpacePointAssn->addSingle(it->second, apsp);
427 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
EDProducer(fhicl::ParameterSet const &pset)
auto groupByIndex(Groups &&groups, std::size_t index) -> decltype(auto)
Returns the group within groups with the specified index.
const std::vector< double > & Energy() const
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.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
const TVector3 & Direction() const
static int max(int a, int b)
std::vector< PointFlags_t > Flags_t
Type of point flag list.
art::InputTag clsInputTag
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