327 auto tracks = std::make_unique< std::vector< recob::Track > >();
328 auto allsp = std::make_unique< std::vector< recob::SpacePoint > >();
329 auto vtxs = std::make_unique< std::vector< recob::Vertex > >();
330 auto kinks = std::make_unique< std::vector< recob::Vertex > >();
331 auto nodes = std::make_unique< std::vector< recob::Vertex > >();
332 auto t0s = std::make_unique< std::vector< anab::T0 > >();
333 auto cosmicTags = std::make_unique< std::vector< anab::CosmicTag > >();
335 auto trk2hit_oldway = std::make_unique< art::Assns< recob::Track, recob::Hit > >();
336 auto trk2hit = std::make_unique< art::Assns< recob::Track, recob::Hit, recob::TrackHitMeta > >();
338 auto trk2sp = std::make_unique< art::Assns< recob::Track, recob::SpacePoint > >();
339 auto trk2t0 = std::make_unique< art::Assns< recob::Track, anab::T0 > >();
340 auto trk2ct = std::make_unique< art::Assns< recob::Track, anab::CosmicTag > >();
342 auto sp2hit = std::make_unique< art::Assns< recob::SpacePoint, recob::Hit > >();
343 auto vtx2trk = std::make_unique< art::Assns< recob::Vertex, recob::Track > >();
344 auto trk2kink = std::make_unique< art::Assns< recob::Track, recob::Vertex > >();
346 auto pfps = std::make_unique< std::vector< recob::PFParticle > >();
348 auto pfp2clu = std::make_unique< art::Assns<recob::PFParticle, recob::Cluster> >();
349 auto pfp2vtx = std::make_unique< art::Assns<recob::PFParticle, recob::Vertex> >();
350 auto pfp2trk = std::make_unique< art::Assns< recob::PFParticle, recob::Track > >();
355 auto allHitListHandle =
evt.getValidHandle< std::vector<recob::Hit> >(
fHitModuleLabel);
356 std::vector< art::Ptr<recob::Hit> > allhitlist;
364 size_t mvaLength = 0;
367 auto cluListHandle =
evt.getValidHandle< std::vector<recob::Cluster> >(
fCluModuleLabel);
368 auto splitCluHandle =
evt.getValidHandle< std::vector<recob::Cluster> >(
fEmModuleLabel);
372 pmalgTracker.init(hitsFromClusters, hitsFromEmParts);
377 if (init<4>(
evt, pmalgTracker) ) { mvaLength = 4; }
378 else if (init<3>(
evt, pmalgTracker)) { mvaLength = 3; }
379 else if (init<2>(
evt, pmalgTracker)) { mvaLength = 2; }
382 throw cet::exception(
"PMAlgTrackMaker") <<
"No EM/track MVA data products." << std::endl;
387 auto cluListHandle =
evt.getValidHandle< std::vector<recob::Cluster> >(
fCluModuleLabel);
389 pmalgTracker.init(hitsFromClusters);
394 int retCode = pmalgTracker.build();
403 else if (retCode == 1)
mf::LogVerbatim(
"Summary") << retCode <<
" track ready";
409 auto const & result = pmalgTracker.result();
412 size_t spStart = 0, spEnd = 0;
413 double sp_pos[3], sp_err[6];
414 for (
size_t i = 0; i < 3; ++i) sp_pos[i] = 0.0;
415 for (
size_t i = 0; i < 6; ++i) sp_err[i] = 1.0;
424 tracks->reserve(result.size());
425 for (
size_t trkIndex = 0; trkIndex < result.size(); ++trkIndex)
439 if (trk->
size()<2)
continue;
442 if (mvaLength == 4) pdg = getPdgFromCnnOnHits<4>(
evt, *(result[trkIndex].Track()));
443 else if (mvaLength == 3) pdg = getPdgFromCnnOnHits<3>(
evt, *(result[trkIndex].Track()));
444 else if (mvaLength == 2) pdg = getPdgFromCnnOnHits<2>(
evt, *(result[trkIndex].Track()));
449 auto const trkPtr = make_trkptr(tracks->size() - 1);
454 t0s->push_back(
anab::T0(trk->
GetT0(), 0, 3, tracks->back().ID()));
456 auto const t0Ptr = make_t0ptr(t0s->size() - 1);
457 trk2t0->addSingle(trkPtr, t0Ptr);
463 std::vector<float> trkEnd0;
464 std::vector<float> trkEnd1;
469 for(
int i = 0; i < 3; ++i){
474 shift = trk->
Nodes()[0]->GetDriftShift();
476 trkEnd0.push_back(trk->
Nodes()[0]->Point3D()[i] - shift);
477 trkEnd1.push_back(trk->
Nodes()[trk->
Nodes().size()-1]->Point3D()[i] - shift);
482 for (
const auto t : tags)
484 cosmicTags->emplace_back(trkEnd0, trkEnd1, 1, t);
485 auto const cosmicPtr = make_ctptr(cosmicTags->size()-1);
486 trk2ct->addSingle(trkPtr,cosmicPtr);
491 for (
size_t h = 0, cnt = 0; h < trk->
size(); h++)
497 trk2hit->addSingle(trkPtr, h3d->
Hit2DPtr(), metadata);
498 trk2hit_oldway->addSingle(trkPtr, h3d->
Hit2DPtr());
502 spStart = allsp->
size();
504 for (
size_t h = 0; h < trk->
size(); ++h)
509 double hx = h3d->
Point3D().X();
510 double hy = h3d->
Point3D().Y();
511 double hz = h3d->
Point3D().Z();
514 (std::fabs(sp_pos[0] - hx) > 1.0e-5) ||
515 (std::fabs(sp_pos[1] - hy) > 1.0e-5) ||
516 (std::fabs(sp_pos[2] - hz) > 1.0e-5))
523 sp_pos[0] = hx; sp_pos[1] = hy; sp_pos[2] = hz;
533 spEnd = allsp->size();
535 if (spEnd > spStart)
util::CreateAssn(*
this, evt, *tracks, *allsp, *trk2sp, spStart, spEnd);
539 auto ksel = pmalgTracker.getKinks();
540 std::map< size_t, art::Ptr<recob::Vertex> > frontVtxs;
545 for (
auto const & v : vsel)
547 xyz[0] = v.first.X(); xyz[1] = v.first.Y(); xyz[2] = v.first.Z();
549 <<
" vtx:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2]
550 <<
" (" << v.second.size() <<
" tracks)";
552 size_t vidx = vtxs->size();
555 auto const vptr = make_vtxptr(vidx);
556 if (!v.second.empty())
558 for (
const auto & vEntry : v.second)
560 size_t tidx = vEntry.first;
561 bool isFront = vEntry.second;
563 if (isFront) frontVtxs[tidx] = vptr;
565 auto const tptr = make_trkptr(tidx);
566 vtx2trk->addSingle(vptr, tptr);
569 else mf::LogWarning(
"PMAlgTrackMaker") <<
"No tracks found at this vertex.";
573 for (
auto const & k : ksel)
575 xyz[0] = k.first.X(); xyz[1] = k.first.Y(); xyz[2] = k.first.Z();
576 mf::LogVerbatim(
"Summary") <<
" kink:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2];
578 size_t kidx = kinks->size();
579 size_t tidx = k.second;
583 auto const tptr = make_trkptr(tidx);
584 auto const kptr = make_kinkptr(kidx);
585 trk2kink->addSingle(tptr, kptr);
593 for (
size_t t = 0; t < result.size(); ++t)
595 auto const & trk = *(result[t].Track());
596 for (
auto const * node : trk.
Nodes())
598 xyz[0] = node->Point3D().X(); xyz[1] = node->Point3D().Y(); xyz[2] = node->Point3D().Z();
604 for (
size_t t = 0; t < result.size(); ++t)
607 if (result[t].Parent() >= 0) parentIdx = (
size_t)result[t].Parent();
609 std::vector< size_t > daughterIdxs;
610 for (
size_t idx : result[t].Daughters()) { daughterIdxs.push_back(idx); }
612 size_t pfpidx = pfps->size();
613 pfps->emplace_back((*tracks)[t].ParticleId(), pfpidx, parentIdx, daughterIdxs);
615 auto const pfpptr = make_pfpptr(pfpidx);
616 auto const tptr = make_trkptr(t);
617 pfp2trk->addSingle(pfpptr, tptr);
623 if (!vptr.
isNull()) pfp2vtx->addSingle(pfpptr, vptr);
624 else mf::LogWarning(
"PMAlgTrackMaker") <<
"Front vertex for PFParticle is missing.";
627 mf::LogVerbatim(
"Summary") << pfps->size() <<
" PFParticles created for reconstructed tracks.";
628 mf::LogVerbatim(
"Summary") <<
"Adding " << result.parents().size() <<
" primary PFParticles.";
629 for (
size_t t = 0; t < result.parents().size(); ++t)
631 std::vector< size_t > daughterIdxs;
632 for (
size_t idx : result.parents()[t].Daughters()) { daughterIdxs.push_back(idx); }
634 size_t pfpidx = pfps->size();
636 pfps->emplace_back(0, pfpidx, parentIdx, daughterIdxs);
641 auto const pfpptr = make_pfpptr(pfpidx);
643 if (!vptr.
isNull()) pfp2vtx->addSingle(pfpptr, vptr);
644 else mf::LogWarning(
"PMAlgTrackMaker") <<
"Front vertex for PFParticle is missing.";
647 mf::LogVerbatim(
"Summary") << pfps->size() <<
" PFParticles created in total.";
652 evt.put(std::move(tracks));
653 evt.put(std::move(allsp));
654 evt.put(std::move(vtxs));
657 evt.put(std::move(t0s));
658 evt.put(std::move(cosmicTags));
660 evt.put(std::move(trk2hit_oldway));
661 evt.put(std::move(trk2hit));
662 evt.put(std::move(trk2sp));
663 evt.put(std::move(trk2t0));
664 evt.put(std::move(trk2ct));
666 evt.put(std::move(sp2hit));
667 evt.put(std::move(vtx2trk));
670 evt.put(std::move(pfps));
671 evt.put(std::move(pfp2clu));
672 evt.put(std::move(pfp2vtx));
673 evt.put(std::move(pfp2trk));
bool SelectHits(float fraction=1.0F)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
bool HasTagFlag(ETag value) const
static const std::string kKinksName
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
unsigned int FrontTPC(void) const
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
bool IsEnabled(void) const
Planes which measure X direction.
std::vector< pma::Node3D * > const & Nodes(void) const
Planes which measure Z direction.
fhicl::Atom< bool > RunVertexing
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
art::Ptr< recob::Hit > const & Hit2DPtr(void) const
Definition of vertex object for LArSoft.
Planes which measure Y direction.
std::vector< anab::CosmicTagID_t > getCosmicTag(const pma::Track3D::ETag pmaTag) const
geo::GeometryCore const * fGeom
pma::PMAlgStitching::Config fPmaStitchConfig
std::vector< TH1F * > fAdcInRejectedPoints
pma::ProjectionMatchingAlg::Config fPmaConfig
void push_back(Ptr< U > const &p)
pma::PMAlgVertexing::Config fPmaVtxConfig
art::InputTag fCluModuleLabel
size_t CompleteMissingWires(unsigned int view)
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
pma::PMAlgCosmicTagger::Config fPmaTaggingConfig
unsigned int FrontCryo(void) const
art::InputTag fHitModuleLabel
void push_back(pma::Hit3D *hit)
TVector3 const & Point3D(void) const
fhicl::Atom< float > TrackLikeThreshold
art::InputTag fEmModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
art::InputTag fWireModuleLabel
double GetRawdEdxSequence(std::map< size_t, std::vector< double > > &dedx, unsigned int view=geo::kZ, unsigned int skip=0, bool inclDisabled=false) const
std::vector< TH1F * > fAdcInPassingPoints
bool fSaveOnlyBranchingVtx
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::map< size_t, std::vector< double > > dedx_map
pma::PMAlgTracker::Config fPmaTrackerConfig
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
cet::coded_exception< error, detail::translate > exception
static const std::string kNodesName