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>>();
401 std::vector<art::Ptr<recob::Cluster>> clusterlist;
404 std::vector<art::Ptr<recob::Vertex>> vtxlist;
414 if (clusterlist.size() == 0)
return;
421 art::FindManyP<recob::Cluster, unsigned short> fmVtxCls(VtxListHandle, evt,
fVertexModuleLabel);
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};
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];
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) {
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)
639 unsigned short parentIndex = USHRT_MAX;
644 for (
unsigned short ivx = 0; ivx <
vtx.size(); ++ivx) {
645 if (!
vtx[ivx].Neutrino)
continue;
650 size_t vStart = vcol->size();
653 size_t vEnd = vcol->size();
656 vtx[ivx].ID = -
vtx[ivx].ID;
665 for (
unsigned short ii = 0; ii <
pfpToTrkID.size(); ++ii) {
673 <<
"daughters tID " << tID <<
" pdg " <<
trk[tIndex].PDGCode <<
" ipf " << ipf
674 <<
" parentIndex " << parentIndex <<
" dtr size " << dtrIndices.size();
679 size_t tStart = tcol->size();
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();
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;
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;
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;
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";
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::string fHitModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
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)
unsigned int Nplanes() const
Number of planes in this tpc.
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.
std::vector< unsigned short > pfpToTrkID
void PlnMatch(detinfo::DetectorPropertiesData const &detProp, art::FindManyP< recob::Hit > const &fmCluHits)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
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.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
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.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
A trajectory in space reconstructed from hits.
unsigned int NTPC() const
Number of TPCs in this cryostat.
std::vector< vtxPar > vtx
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
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.
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
void MakeClusterChains(detinfo::DetectorPropertiesData const &detProp, art::FindManyP< recob::Hit > const &fmCluHits)
Hierarchical representation of particle flow.
float StartCharge() const
Returns the charge on the first wire of the cluster.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
void PrintClusters(detinfo::DetectorPropertiesData const &detProp) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool lessThan(CluLen c1, CluLen c2)
void FillChgNear(detinfo::DetectorPropertiesData const &detProp)
std::vector< bool > fMakeAlgTracks
std::vector< short > fMatchAlgs
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
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.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception
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.