302 auto outputTracks = std::make_unique<std::vector<recob::Track> >();
303 auto outputHitsMeta = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
304 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit> >();
305 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo> > >();
307 auto const tid = getProductID<std::vector<recob::Track> >();
310 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint> >();
311 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint> >();
312 auto const spid = getProductID<std::vector<recob::SpacePoint> >();
318 if (
p_().options().pFromMC() ||
p_().options().dirFromMC()) {
320 for (
unsigned int iMC = 0; iMC < simTracks->size(); ++iMC) {
323 if (mctrack.
PdgCode()!=13)
continue;
324 if (mctrack.
Process()!=
"primary")
continue;
334 auto outputPFAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track> >();
341 for (
unsigned int iPF = 0; iPF < inputPFParticle->size(); ++iPF) {
343 if (
p_().options().trackFromPF()) {
344 const std::vector<art::Ptr<recob::Track> >& tracks =
assocTracks->at(iPF);
346 const std::vector<art::Ptr<recob::Vertex> >& vertices =
assocVertices->at(iPF);
348 if (
p_().options().pFromCalo()) {
352 for (
unsigned int iTrack = 0; iTrack < tracks.size(); ++iTrack) {
356 const int pId =
setPId(iTrack,
trackId, inputPFParticle->at(iPF).PdgCode());
358 const bool flipDir =
setDirFlip(track, mcdir, &vertices);
361 std::vector<art::Ptr<recob::Hit> > inHits;
362 for (
auto it = tkHitsAssn.begin(); it!=tkHitsAssn.end(); ++it) {
363 if (it->first == ptrack) inHits.push_back(it->second);
364 else if (inHits.size()>0)
break;
368 std::vector<art::Ptr<recob::Hit> > outHits;
373 inHits, mom, pId, flipDir, outTrack, outHits, optionals);
374 if (!fitok)
continue;
376 if (
p_().options().keepInputTrajectoryPoints()) {
380 outputTracks->emplace_back(std::move(outTrack));
383 for (
auto const& trhit: outHits) {
386 outputHitsMeta->addSingle(aptr, trhit, metadata);
387 outputHits->addSingle(aptr, trhit);
395 if (
p_().options().showerFromPF()) {
397 const std::vector<art::Ptr<recob::Shower> >& showers =
assocShowers->at(iPF);
398 if (showers.size()==0)
continue;
401 std::vector<art::Ptr<recob::Hit> > inHits;
402 for (
auto itpf = pfClustersAssn.begin(); itpf!=pfClustersAssn.end(); ++itpf) {
403 if (itpf->first == pPF) {
405 for (
auto it = clHitsAssn.
begin(); it!=clHitsAssn.
end(); ++it) {
406 if (it->first == clust) inHits.push_back(it->second);
408 }
else if (inHits.
size()>0)
break;
411 for (
unsigned int iShower = 0; iShower < showers.size(); ++iShower) {
423 std::vector<art::Ptr<recob::Hit> > outHits;
429 auto pid =
p_().options().pdgId();
430 auto mom =
p_().options().pval();
432 shower.
ID(), mom,
pid,
433 outTrack, outHits, optionals);
434 if (!fitok)
continue;
436 outputTracks->emplace_back(std::move(outTrack));
439 for (
auto const& trhit: outHits) {
442 outputHitsMeta->addSingle(aptr, trhit, metadata);
443 outputHits->addSingle(aptr, trhit);
444 if (
p_().options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
445 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
446 double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
447 double fErrXYZ[6] = {0};
449 outputSpacePoints->emplace_back(std::move(sp));
451 outputHitSpacePointAssn->addSingle(trhit, apsp);
461 e.
put(std::move(outputTracks));
462 e.
put(std::move(outputHitsMeta));
463 e.
put(std::move(outputHits));
464 e.
put(std::move(outputPFAssn));
465 if (
p_().options().produceTrackFitHitInfo()) {
466 e.
put(std::move(outputHitInfo));
468 if (
p_().options().produceSpacePoints()) {
469 e.
put(std::move(outputSpacePoints));
470 e.
put(std::move(outputHitSpacePointAssn));
477 if (
p_().options().pFromCalo()) {
481 if (
p_().options().idFromCollection()) {
485 for (
unsigned int iTrack = 0; iTrack < inputTracks->size(); ++iTrack) {
491 const bool flipDir =
setDirFlip(track, mcdir);
494 std::vector<art::Ptr<recob::Hit> > inHits;
495 for (
auto it = tkHitsAssn.begin(); it!=tkHitsAssn.end(); ++it) {
496 if (it->first == ptrack) inHits.push_back(it->second);
497 else if (inHits.size()>0)
break;
501 std::vector<art::Ptr<recob::Hit> > outHits;
506 inHits, mom, pId, flipDir, outTrack, outHits, optionals);
507 if (!fitok)
continue;
509 if (
p_().options().keepInputTrajectoryPoints()) {
513 outputTracks->emplace_back(std::move(outTrack));
516 for (
auto const& trhit: outHits) {
519 outputHitsMeta->addSingle(aptr, trhit, metadata);
520 outputHits->addSingle(aptr, trhit);
521 if (
p_().options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
522 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
523 double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
524 double fErrXYZ[6] = {0};
526 outputSpacePoints->emplace_back(std::move(sp));
528 outputHitSpacePointAssn->addSingle(trhit, apsp);
534 e.
put(std::move(outputTracks));
535 e.
put(std::move(outputHitsMeta));
536 e.
put(std::move(outputHits));
537 if (
p_().options().produceTrackFitHitInfo()) {
538 e.
put(std::move(outputHitInfo));
540 if (
p_().options().produceSpacePoints()) {
541 e.
put(std::move(outputSpacePoints));
542 e.
put(std::move(outputHitSpacePointAssn));
const TVector3 & ShowerStart() const
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
art::InputTag pidInputTag
recob::tracking::SMatrixSym55 SMatrixSym55
art::InputTag simTrackInputTag
void restoreInputPoints(const recob::Trajectory &track, const std::vector< art::Ptr< recob::Hit > > &inHits, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit > > &outHits) const
bool fitTrack(const recob::TrackTrajectory &traj, int tkID, const SMatrixSym55 &covVtx, const SMatrixSym55 &covEnd, const std::vector< art::Ptr< recob::Hit > > &hits, const double pval, const int pdgid, const bool flipDirection, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit > > &outHits, trkmkr::OptionalOutputs &optionals) const
Fit track starting from TrackTrajectory.
art::InputTag pfParticleInputTag
EDProductGetter const * productGetter(ProductID const) const
art::InputTag caloInputTag
std::unique_ptr< art::FindManyP< recob::Vertex > > assocVertices
recob::tracking::Point_t Point_t
const_iterator begin() const
ProductID put(std::unique_ptr< PROD > &&product)
bool setDirFlip(const recob::Track &track, TVector3 &mcdir, const std::vector< art::Ptr< recob::Vertex > > *vertices=0) const
double setMomValue(art::Ptr< recob::Track > ptrack, const std::unique_ptr< art::FindManyP< anab::Calorimetry > > &trackCalo, const double pMC, const int pId) const
art::InputTag trackInputTag
art::InputTag showerInputTag
std::unique_ptr< art::FindManyP< anab::ParticleID > > trackId
const TVector3 & Direction() const
const TLorentzVector & Momentum() const
const_iterator end() const
trkf::TrackKalmanFitter * kalmanFitter
const SMatrixSym55 & EndCovarianceLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
std::unique_ptr< art::FindManyP< anab::Calorimetry > > trackCalo
std::unique_ptr< art::FindManyP< recob::Shower > > assocShowers
const std::string & Process() const
int setPId(const unsigned int iTrack, const std::unique_ptr< art::FindManyP< anab::ParticleID > > &trackId, const int pfPid=0) const
const MCStep & Start() const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
recob::tracking::Vector_t Vector_t
const SMatrixSym55 & VertexCovarianceLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
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:
std::unique_ptr< art::FindManyP< recob::Track > > assocTracks