332 auto tracks = std::make_unique<std::vector<recob::Track>>();
333 auto allsp = std::make_unique<std::vector<recob::SpacePoint>>();
334 auto vtxs = std::make_unique<std::vector<recob::Vertex>>();
335 auto kinks = std::make_unique<
336 std::vector<recob::Vertex>>();
337 auto nodes = std::make_unique<std::vector<recob::Vertex>>();
338 auto t0s = std::make_unique<std::vector<anab::T0>>();
339 auto cosmicTags = std::make_unique<std::vector<anab::CosmicTag>>();
341 auto trk2hit_oldway = std::make_unique<
344 auto trk2hit = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
346 auto trk2sp = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
347 auto trk2t0 = std::make_unique<art::Assns<recob::Track, anab::T0>>();
348 auto trk2ct = std::make_unique<art::Assns<recob::Track, anab::CosmicTag>>();
350 auto sp2hit = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
351 auto vtx2trk = std::make_unique<
355 std::make_unique<art::Assns<recob::Track, recob::Vertex>>();
357 auto pfps = std::make_unique<std::vector<recob::PFParticle>>();
359 auto pfp2clu = std::make_unique<art::Assns<recob::PFParticle, recob::Cluster>>();
360 auto pfp2vtx = std::make_unique<art::Assns<recob::PFParticle, recob::Vertex>>();
361 auto pfp2trk = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
366 std::vector<art::Ptr<recob::Hit>> allhitlist;
380 size_t mvaLength = 0;
383 auto cluListHandle =
evt.getValidHandle<std::vector<recob::Cluster>>(
fCluModuleLabel);
384 auto splitCluHandle =
evt.getValidHandle<std::vector<recob::Cluster>>(
fEmModuleLabel);
388 pmalgTracker.init(hitsFromClusters, hitsFromEmParts);
393 if (init<4>(
evt, pmalgTracker)) { mvaLength = 4; }
394 else if (init<3>(
evt, pmalgTracker)) {
397 else if (init<2>(
evt, pmalgTracker)) {
406 auto cluListHandle =
evt.getValidHandle<std::vector<recob::Cluster>>(
fCluModuleLabel);
408 pmalgTracker.init(hitsFromClusters);
415 int retCode = pmalgTracker.build(clockData, detProp);
424 else if (retCode == 1)
432 auto const&
result = pmalgTracker.result();
435 size_t spStart = 0, spEnd = 0;
436 double sp_pos[3], sp_err[6];
437 for (
size_t i = 0; i < 3; ++i)
439 for (
size_t i = 0; i < 6; ++i)
450 for (
size_t trkIndex = 0; trkIndex <
result.
size(); ++trkIndex) {
478 if (trk->
size() < 2)
continue;
482 pdg = getPdgFromCnnOnHits<4>(
evt, *(
result[trkIndex].Track()));
483 else if (mvaLength == 3)
484 pdg = getPdgFromCnnOnHits<3>(
evt, *(
result[trkIndex].Track()));
485 else if (mvaLength == 2)
486 pdg = getPdgFromCnnOnHits<2>(
evt, *(
result[trkIndex].Track()));
491 auto const trkPtr = make_trkptr(
tracks->size() - 1);
497 auto const t0Ptr = make_t0ptr(t0s->size() - 1);
498 trk2t0->addSingle(trkPtr, t0Ptr);
504 std::vector<float> trkEnd0;
505 std::vector<float> trkEnd1;
511 for (
int i = 0; i < 3; ++i) {
515 if (i == driftDir) { shift = trk->
Nodes()[0]->GetDriftShift(); }
516 trkEnd0.push_back(trk->
Nodes()[0]->Point3D()[i] - shift);
517 trkEnd1.push_back(trk->
Nodes()[trk->
Nodes().size() - 1]->Point3D()[i] - shift);
522 for (
const auto t : tags) {
523 cosmicTags->emplace_back(trkEnd0, trkEnd1, 1,
t);
524 auto const cosmicPtr = make_ctptr(cosmicTags->size() - 1);
525 trk2ct->addSingle(trkPtr, cosmicPtr);
530 for (
size_t h = 0, cnt = 0;
h < trk->
size();
h++) {
536 trk2hit_oldway->addSingle(
541 spStart = allsp->
size();
543 for (
size_t h = 0;
h < trk->
size(); ++
h) {
551 if ((
h == 0) || (std::fabs(sp_pos[0] - hx) > 1.0e-5) ||
552 (std::fabs(sp_pos[1] - hy) > 1.0e-5) || (std::fabs(sp_pos[2] - hz) > 1.0e-5)) {
570 spEnd = allsp->size();
575 auto vsel = pmalgTracker.getVertices(
577 auto ksel = pmalgTracker.getKinks();
578 std::map<size_t, art::Ptr<recob::Vertex>> frontVtxs;
583 for (
auto const& v : vsel) {
584 xyz[0] = v.first.X();
585 xyz[1] = v.first.Y();
586 xyz[2] = v.first.Z();
587 mf::LogVerbatim(
"Summary") <<
" vtx:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2]
588 <<
" (" << v.second.size() <<
" tracks)";
590 size_t vidx = vtxs->size();
591 vtxs->push_back(recob::Vertex(xyz, vidx));
593 auto const vptr = make_vtxptr(vidx);
594 if (!v.second.empty()) {
595 for (
const auto& vEntry : v.second) {
596 size_t tidx = vEntry.first;
597 bool isFront = vEntry.second;
599 if (isFront) frontVtxs[tidx] = vptr;
601 auto const tptr = make_trkptr(tidx);
602 vtx2trk->addSingle(vptr, tptr);
606 mf::LogWarning(
"PMAlgTrackMaker") <<
"No tracks found at this vertex.";
610 for (
auto const&
k : ksel) {
611 xyz[0] =
k.first.X();
612 xyz[1] =
k.first.Y();
613 xyz[2] =
k.first.Z();
614 mf::LogVerbatim(
"Summary") <<
" kink:" << xyz[0] <<
":" << xyz[1] <<
":" << xyz[2];
616 size_t kidx = kinks->size();
617 size_t tidx =
k.second;
620 recob::Vertex(xyz, tidx));
622 auto const tptr = make_trkptr(tidx);
623 auto const kptr = make_kinkptr(kidx);
624 trk2kink->addSingle(tptr, kptr);
632 auto const& trk = *(
result[
t].Track());
633 for (
auto const* node : trk.
Nodes()) {
634 xyz[0] = node->Point3D().X();
635 xyz[1] = node->Point3D().Y();
636 xyz[2] = node->Point3D().Z();
644 if (
result[
t].Parent() >= 0) parentIdx = (
size_t)
result[
t].Parent();
646 std::vector<size_t> daughterIdxs;
647 for (
size_t idx :
result[
t].Daughters()) {
648 daughterIdxs.push_back(idx);
651 size_t pfpidx = pfps->size();
652 pfps->emplace_back((*
tracks)[
t].ParticleId(), pfpidx, parentIdx, daughterIdxs);
654 auto const pfpptr = make_pfpptr(pfpidx);
655 auto const tptr = make_trkptr(
t);
656 pfp2trk->addSingle(pfpptr, tptr);
662 pfp2vtx->addSingle(pfpptr, vptr);
664 mf::LogWarning(
"PMAlgTrackMaker") <<
"Front vertex for PFParticle is missing.";
668 <<
" PFParticles created for reconstructed tracks.";
671 std::vector<size_t> daughterIdxs;
672 for (
size_t idx :
result.parents()[
t].Daughters()) {
673 daughterIdxs.push_back(idx);
676 size_t pfpidx = pfps->size();
678 pfps->emplace_back(0, pfpidx, parentIdx, daughterIdxs);
682 auto const pfpptr = make_pfpptr(pfpidx);
684 frontVtxs[daughterIdxs.front()];
686 pfp2vtx->addSingle(pfpptr, vptr);
688 mf::LogWarning(
"PMAlgTrackMaker") <<
"Front vertex for PFParticle is missing.";
691 mf::LogVerbatim(
"Summary") << pfps->size() <<
" PFParticles created in total.";
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.
static const std::string kKinksName
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
bool IsEnabled() const noexcept
Planes which measure X direction.
TVector3 const & Point3D() const
Planes which measure Z direction.
fhicl::Atom< bool > RunVertexing
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
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
pma::ProjectionMatchingAlg::Config fPmaConfig
void push_back(Ptr< U > const &p)
bool HasTagFlag(ETag value) const noexcept
pma::PMAlgVertexing::Config fPmaVtxConfig
art::InputTag fCluModuleLabel
bool isNull() const noexcept
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.
unsigned int FrontTPC() const
unsigned int FrontCryo() const
pma::PMAlgCosmicTagger::Config fPmaTaggingConfig
ETag GetTag() const noexcept
art::InputTag fHitModuleLabel
size_t CompleteMissingWires(detinfo::DetectorPropertiesData const &detProp, unsigned int view)
void push_back(pma::Hit3D *hit)
std::map< size_t, std::vector< double > > dedx_map
fhicl::Atom< float > TrackLikeThreshold
double GetRawdEdxSequence(std::map< size_t, std::vector< double >> &dedx, unsigned int view=geo::kZ, unsigned int skip=0, bool inclDisabled=false) const
double Dx() const noexcept
bool HasT0() const noexcept
art::InputTag fEmModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
art::InputTag fWireModuleLabel
art::Ptr< recob::Hit > const & Hit2DPtr() const
std::vector< TH1F * > fAdcInRejectedPoints
bool fSaveOnlyBranchingVtx
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::vector< pma::Node3D * > const & Nodes() const noexcept
pma::PMAlgTracker::Config fPmaTrackerConfig
2D representation of charge deposited in the TDC/wire plane
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< TH1F * > fAdcInPassingPoints
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
static const std::string kNodesName