384 auto tcol = std::make_unique<std::vector<recob::Track>>();
385 auto thassn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
386 auto vcol = std::make_unique<std::vector<recob::Vertex>>();
387 auto pcol = std::make_unique<std::vector<recob::PFParticle>>();
388 auto ptassn = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
389 auto pcassn = std::make_unique<art::Assns<recob::PFParticle, recob::Cluster>>();
390 auto psassn = std::make_unique<art::Assns<recob::PFParticle, recob::Seed>>();
391 auto pvassn = std::make_unique<art::Assns<recob::PFParticle, recob::Vertex>>();
394 auto scol = std::make_unique<std::vector<recob::Seed>>();
395 auto shassn = std::make_unique<art::Assns<recob::Seed, recob::Hit>>();
398 art::Handle<std::vector<recob::Hit>> allhitsListHandle;
400 art::Handle<std::vector<recob::Cluster>> clusterListHandle;
401 std::vector<art::Ptr<recob::Cluster>> clusterlist;
403 art::Handle<std::vector<recob::Vertex>> VtxListHandle;
404 std::vector<art::Ptr<recob::Vertex>> vtxlist;
409 art::fill_ptr_vector(
allhits, allhitsListHandle);
413 art::fill_ptr_vector(clusterlist, clusterListHandle);
414 if (clusterlist.size() == 0)
return;
420 art::fill_ptr_vector(vtxlist, VtxListHandle);
423 std::vector<CluLen> clulens;
425 unsigned short ipl, icl,
end, itr, tID, tIndex;
433 std::vector<art::Ptr<recob::Hit>> tmpHits;
434 std::vector<art::Ptr<recob::Cluster>> tmpCls;
435 std::vector<art::Ptr<recob::Vertex>> tmpVtx;
438 std::vector<size_t> dtrIndices;
441 double sPos[3], sDir[3];
442 double sErr[3] = {0, 0, 0};
445 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
evt);
448 std::vector<art::Ptr<recob::Hit>> clusterhits;
449 for (icl = 0; icl < clusterlist.size(); ++icl) {
450 ipl = clusterlist[icl]->Plane().Plane;
451 clusterhits = fmCluHits.at(icl);
452 if (clusterhits[0]->
WireID().Wire != std::nearbyint(clusterlist[icl]->EndWire())) {
453 std::cout <<
"CCTM Cluster-Hit End wire mis-match " << clusterhits[0]->WireID().Wire
454 <<
" vs " << std::nearbyint(clusterlist[icl]->EndWire()) <<
" Bail out! \n";
457 for (
unsigned short iht = 0; iht < clusterhits.size(); ++iht) {
458 if (clusterhits[iht]->
WireID().Plane != ipl) {
459 std::cout <<
"CCTM Cluster-Hit plane mis-match " << ipl <<
" vs "
460 << clusterhits[iht]->WireID().Plane <<
" on hit " << iht <<
" Bail out! \n";
473 for (ipl = 0; ipl < 3; ++ipl) {
480 for (ipl = 0; ipl <
nplanes; ++ipl) {
483 for (icl = 0; icl < clusterlist.size(); ++icl) {
484 if (clusterlist[icl]->
Plane().Cryostat !=
cstat)
continue;
485 if (clusterlist[icl]->
Plane().TPC !=
tpc)
continue;
486 if (clusterlist[icl]->
Plane().
Plane != ipl)
continue;
489 clulen.length = clusterlist[icl]->EndWire();
490 clulens.push_back(clulen);
492 if (clulens.size() == 0)
continue;
494 std::sort(clulens.begin(), clulens.end(),
lessThan);
495 if (clulens.size() == 0)
continue;
496 for (
unsigned short ii = 0; ii < clulens.size(); ++ii) {
497 const unsigned short icl = clulens[ii].index;
499 clstr.EvtIndex = icl;
506 clstr.Slope[1] = std::tan(cluster.
StartAngle());
510 clstr.ChgNear[1] = 0;
511 clstr.VtxIndex[1] = -1;
512 clstr.mVtxIndex[1] = -1;
513 clstr.BrkIndex[1] = -1;
516 clstr.Wire[0] = cluster.
EndWire();
517 clstr.Time[0] = cluster.
EndTick();
519 clstr.Angle[0] = cluster.
EndAngle();
520 clstr.Slope[0] = std::tan(cluster.
EndAngle());
522 if (clstr.Time[1] > clstr.Time[0]) {
532 clstr.ChgNear[1] = 0;
533 clstr.VtxIndex[0] = -1;
534 clstr.mVtxIndex[0] = -1;
535 clstr.BrkIndex[0] = -1;
539 clstr.Length = (
unsigned short)(0.5 + clstr.Wire[1] - clstr.Wire[0]);
541 if (clstr.TotChg <= 0) clstr.TotChg = 1;
542 clusterhits = fmCluHits.at(icl);
543 if (clusterhits.size() == 0) {
544 mf::LogError(
"CCTM") <<
"No associated cluster hits " << icl;
548 clstr.TotChg *= clstr.Length / (float)clusterhits.size();
549 cls[ipl].push_back(clstr);
557 for (
unsigned short ivx = 0; ivx < vtxlist.size(); ++ivx) {
561 vtxlist[ivx]->XYZ(xyz);
565 aVtx.nClusInPln[0] = 0;
566 aVtx.nClusInPln[1] = 0;
567 aVtx.nClusInPln[2] = 0;
568 std::vector<art::Ptr<recob::Cluster>>
const& vtxCls = fmVtxCls.at(ivx);
569 std::vector<const unsigned short*>
const& vtxClsEnd = fmVtxCls.data(ivx);
570 for (
unsigned short vcass = 0; vcass < vtxCls.size(); ++vcass) {
571 icl = vtxCls[vcass].key();
573 ipl = vtxCls[vcass]->Plane().Plane;
574 end = *vtxClsEnd[vcass];
576 throw cet::exception(
"CCTM")
577 <<
"Invalid end data from vertex - cluster association" <<
end;
581 for (
unsigned short jcl = 0; jcl <
cls[ipl].size(); ++jcl) {
582 if (
cls[ipl][jcl].EvtIndex == icl) {
583 cls[ipl][jcl].VtxIndex[
end] = ivx;
584 ++aVtx.nClusInPln[ipl];
590 throw cet::exception(
"CCTM") <<
"Bad index from vertex - cluster association" << icl;
623 for (
unsigned short ipf = 0; ipf <
pfpToTrkID.size(); ++ipf) {
626 if (tID >
trk.size() + 1) {
627 mf::LogWarning(
"CCTM") <<
"Bad track ID";
632 mf::LogVerbatim(
"CCTM") <<
"PFParticle " << ipf <<
" tID " << tID;
633 for (
unsigned short jpf = 0; jpf <
pfpToTrkID.size(); ++jpf) {
635 if (
trk[itr].MomID == tID) dtrIndices.push_back(jpf);
636 if (
trk[itr].MomID == tID)
637 mf::LogVerbatim(
"CCTM") <<
" dtr jpf " << jpf <<
" itr " << itr;
639 unsigned short parentIndex = USHRT_MAX;
643 pcol->emplace_back(std::move(pfp));
644 for (
unsigned short ivx = 0; ivx <
vtx.size(); ++ivx) {
645 if (!
vtx[ivx].Neutrino)
continue;
650 size_t vStart = vcol->size();
652 vcol->emplace_back(std::move(
vertex));
653 size_t vEnd = vcol->size();
656 vtx[ivx].ID = -
vtx[ivx].ID;
665 for (
unsigned short ii = 0; ii <
pfpToTrkID.size(); ++ii) {
672 mf::LogVerbatim(
"CCTM")
673 <<
"daughters tID " << tID <<
" pdg " <<
trk[tIndex].PDGCode <<
" ipf " << ipf
674 <<
" parentIndex " << parentIndex <<
" dtr size " << dtrIndices.size();
676 pcol->emplace_back(std::move(pfp));
679 size_t tStart = tcol->size();
691 tcol->emplace_back(std::move(
track));
692 size_t tEnd = tcol->size();
696 trk[tIndex].ID = -
trk[tIndex].ID;
699 for (ipl = 0; ipl <
nplanes; ++ipl)
701 tmpHits.end(),
trk[tIndex].TrkHits[ipl].begin(),
trk[tIndex].TrkHits[ipl].end());
706 unsigned short itj = 0;
707 if (end > 0) itj =
trk[tIndex].TrjPos.size() - 1;
708 for (
unsigned short ii = 0; ii < 3; ++ii) {
709 sPos[ii] =
trk[tIndex].TrjPos[itj](ii);
710 sDir[ii] =
trk[tIndex].TrjDir[itj](ii);
712 size_t sStart = scol->size();
714 scol->emplace_back(std::move(
seed));
715 size_t sEnd = scol->size();
720 for (ipl = 0; ipl <
nplanes; ++ipl)
726 for (
unsigned short ii = 0; ii <
trk[tIndex].ClsEvtIndices.size(); ++ii) {
727 icl =
trk[tIndex].ClsEvtIndices[ii];
728 tmpCls.push_back(clusterlist[icl]);
734 for (
unsigned short itr = 0; itr <
trk.size(); ++itr) {
736 if (
trk[itr].ID < 0)
continue;
748 tcol->emplace_back(std::move(
track));
750 for (ipl = 0; ipl <
nplanes; ++ipl)
752 tmpHits.end(),
trk[itr].TrkHits[ipl].begin(),
trk[itr].TrkHits[ipl].end());
756 for (
unsigned short ivx = 0; ivx <
vtx.size(); ++ivx) {
757 if (
vtx[ivx].ID < 0)
continue;
762 vcol->emplace_back(std::move(
vertex));
766 double orphanLen = 0;
767 for (ipl = 0; ipl <
nplanes; ++ipl) {
768 for (icl = 0; icl <
cls[ipl].size(); ++icl) {
769 if (
cls[ipl][icl].
Length > 40 &&
cls[ipl][icl].InTrack < 0) {
770 orphanLen +=
cls[ipl][icl].Length;
772 mf::LogVerbatim(
"CCTM")
773 <<
"Orphan long cluster " << ipl <<
":" << icl <<
":" <<
cls[ipl][icl].Wire[0]
774 <<
":" << (int)
cls[ipl][icl].Time[0] <<
" length " <<
cls[ipl][icl].
Length;
781 std::cout <<
"Total orphan length " << orphanLen <<
"\n";
788 evt.put(std::move(pcol));
789 evt.put(std::move(ptassn));
790 evt.put(std::move(pcassn));
791 evt.put(std::move(pvassn));
792 evt.put(std::move(psassn));
793 evt.put(std::move(tcol));
794 evt.put(std::move(thassn));
795 evt.put(std::move(scol));
796 evt.put(std::move(vcol));
std::string fHitModuleLabel
float Length(const PFPStruct &pfp)
std::vector< MatchPars > matcomb
art::ServiceHandle< geo::Geometry const > geom
std::string fVertexModuleLabel
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
std::array< float, 3 > ChgNorm
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
void SortMatches(detinfo::DetectorPropertiesData const &detProp, art::FindManyP< recob::Hit > const &fmCluHits, unsigned short procCode)
std::vector< art::Ptr< recob::Hit > > allhits
TrackTrajectory::Flags_t Flags_t
float StartWire() const
Returns the wire coordinate of the start of the cluster.
std::array< std::vector< art::Ptr< recob::Hit > >, 3 > seedHits
Plane(const Point_t &planePos, const Vector_t &planeDir)
Constructor from reference position on the plane and direction orthogonal to the plane.
std::string fClusterModuleLabel
Set of hits with a 2D structure.
float EndTick() const
Returns the tick coordinate of the end of the cluster.
process_name use argoneut_mc_hitfinder track
std::vector< unsigned short > pfpToTrkID
std::vector< TrkPar > trk
void PlnMatch(detinfo::DetectorPropertiesData const &detProp, art::FindManyP< recob::Hit > const &fmCluHits)
std::array< std::vector< clPar >, 3 > cls
void FitVertices(detinfo::DetectorPropertiesData const &detProp)
float StartAngle() const
Returns the starting angle of the cluster.
Definition of vertex object for LArSoft.
std::array< std::vector< art::Ptr< recob::Hit > >, 3 > trkHits
std::array< std::vector< ClsChainPar >, 3 > clsChain
float EndCharge() const
Returns the charge on the last wire of the cluster.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
A trajectory in space reconstructed from hits.
auto end(FixedBins< T, C > const &) noexcept
std::vector< vtxPar > vtx
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
void MakeClusterChains(detinfo::DetectorPropertiesData const &detProp, art::FindManyP< recob::Hit > const &fmCluHits)
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
Hierarchical representation of particle flow.
float StartCharge() const
Returns the charge on the first wire of the cluster.
void PrintClusters(detinfo::DetectorPropertiesData const &detProp) const
bool lessThan(CluLen c1, CluLen c2)
void FillChgNear(detinfo::DetectorPropertiesData const &detProp)
std::vector< bool > fMakeAlgTracks
std::vector< short > fMatchAlgs
float EndAngle() const
Returns the ending angle of the cluster.
recob::tracking::Plane Plane
void VtxMatch(detinfo::DetectorPropertiesData const &detProp, art::FindManyP< recob::Hit > const &fmCluHits)
float StartTick() const
Returns the tick coordinate of the start of the cluster.
BEGIN_PROLOG could also be cout
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::array< std::vector< unsigned short >, 3 > vxCls
float Integral() const
Returns the total charge of the cluster from hit shape.
float EndWire() const
Returns the wire coordinate of the end of the cluster.