292 auto outputTracks = std::make_unique<std::vector<recob::Track> >();
293 auto outputHitsMeta = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
294 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit> >();
295 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo> > >();
297 auto const tid = getProductID<std::vector<recob::Track> >();
300 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint> >();
301 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint> >();
302 auto const spid = getProductID<std::vector<recob::SpacePoint> >();
308 if (
p_().options().pFromMC() ||
p_().options().dirFromMC()) {
310 for (
unsigned int iMC = 0; iMC < simTracks->size(); ++iMC) {
313 if (mctrack.
PdgCode()!=13)
continue;
314 if (mctrack.
Process()!=
"primary")
continue;
324 auto outputPFAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track> >();
331 for (
unsigned int iPF = 0; iPF < inputPFParticle->size(); ++iPF) {
333 if (
p_().options().trackFromPF()) {
334 const std::vector<art::Ptr<recob::Track> >& tracks =
assocTracks->at(iPF);
336 const std::vector<art::Ptr<recob::Vertex> >& vertices =
assocVertices->at(iPF);
338 if (
p_().options().pFromCalo()) {
342 for (
unsigned int iTrack = 0; iTrack < tracks.size(); ++iTrack) {
346 const int pId =
setPId(iTrack,
trackId, inputPFParticle->at(iPF).PdgCode());
348 const bool flipDir =
setDirFlip(track, mcdir, &vertices);
351 std::vector<art::Ptr<recob::Hit> > inHits;
352 for (
auto it = tkHitsAssn.begin(); it!=tkHitsAssn.end(); ++it) {
353 if (it->first == ptrack) inHits.push_back(it->second);
354 else if (inHits.size()>0)
break;
358 std::vector<art::Ptr<recob::Hit> > outHits;
363 inHits, mom, pId, flipDir, outTrack, outHits, optionals);
364 if (!fitok)
continue;
366 if (
p_().options().keepInputTrajectoryPoints()) {
370 outputTracks->emplace_back(std::move(outTrack));
373 for (
auto const& trhit: outHits) {
376 outputHitsMeta->addSingle(aptr, trhit, metadata);
377 outputHits->addSingle(aptr, trhit);
385 if (
p_().options().showerFromPF()) {
387 const std::vector<art::Ptr<recob::Shower> >& showers =
assocShowers->at(iPF);
388 if (showers.size()==0)
continue;
391 std::vector<art::Ptr<recob::Hit> > inHits;
392 for (
auto itpf = pfClustersAssn.begin(); itpf!=pfClustersAssn.end(); ++itpf) {
393 if (itpf->first == pPF) {
395 for (
auto it = clHitsAssn.
begin(); it!=clHitsAssn.
end(); ++it) {
396 if (it->first == clust) inHits.push_back(it->second);
398 }
else if (inHits.
size()>0)
break;
401 for (
unsigned int iShower = 0; iShower < showers.size(); ++iShower) {
413 std::vector<art::Ptr<recob::Hit> > outHits;
419 auto pid =
p_().options().pdgId();
420 auto mom =
p_().options().pval();
422 shower.
ID(), mom,
pid,
423 outTrack, outHits, optionals);
424 if (!fitok)
continue;
426 outputTracks->emplace_back(std::move(outTrack));
429 for (
auto const& trhit: outHits) {
432 outputHitsMeta->addSingle(aptr, trhit, metadata);
433 outputHits->addSingle(aptr, trhit);
434 if (
p_().options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
435 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
436 double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
437 double fErrXYZ[6] = {0};
439 outputSpacePoints->emplace_back(std::move(sp));
441 outputHitSpacePointAssn->addSingle(trhit, apsp);
451 e.put(std::move(outputTracks));
452 e.put(std::move(outputHitsMeta));
453 e.put(std::move(outputHits));
454 e.put(std::move(outputPFAssn));
455 if (
p_().options().produceTrackFitHitInfo()) {
456 e.put(std::move(outputHitInfo));
458 if (
p_().options().produceSpacePoints()) {
459 e.put(std::move(outputSpacePoints));
460 e.put(std::move(outputHitSpacePointAssn));
467 if (
p_().options().pFromCalo()) {
471 if (
p_().options().idFromCollection()) {
475 for (
unsigned int iTrack = 0; iTrack < inputTracks->size(); ++iTrack) {
481 const bool flipDir =
setDirFlip(track, mcdir);
484 std::vector<art::Ptr<recob::Hit> > inHits;
485 for (
auto it = tkHitsAssn.begin(); it!=tkHitsAssn.end(); ++it) {
486 if (it->first == ptrack) inHits.push_back(it->second);
487 else if (inHits.size()>0)
break;
491 std::vector<art::Ptr<recob::Hit> > outHits;
496 inHits, mom, pId, flipDir, outTrack, outHits, optionals);
497 if (!fitok)
continue;
499 if (
p_().options().keepInputTrajectoryPoints()) {
503 outputTracks->emplace_back(std::move(outTrack));
506 for (
auto const& trhit: outHits) {
509 outputHitsMeta->addSingle(aptr, trhit, metadata);
510 outputHits->addSingle(aptr, trhit);
511 if (
p_().options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
512 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
513 double fXYZ[3] = {tp.X(),tp.Y(),tp.Z()};
514 double fErrXYZ[6] = {0};
516 outputSpacePoints->emplace_back(std::move(sp));
518 outputHitSpacePointAssn->addSingle(trhit, apsp);
524 e.put(std::move(outputTracks));
525 e.put(std::move(outputHitsMeta));
526 e.put(std::move(outputHits));
527 if (
p_().options().produceTrackFitHitInfo()) {
528 e.put(std::move(outputHitInfo));
530 if (
p_().options().produceSpacePoints()) {
531 e.put(std::move(outputSpacePoints));
532 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
trkf::TrackKalmanFitter kalmanFitter
std::unique_ptr< art::FindManyP< recob::Vertex > > assocVertices
recob::tracking::Point_t Point_t
const_iterator begin() const
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
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