271 std::unique_ptr<std::vector<recob::Track> > tcol (
new std::vector<recob::Track>);
272 std::unique_ptr<std::vector<recob::SpacePoint> > spcol(
new std::vector<recob::SpacePoint>);
291 std::vector<art::Ptr<recob::Cluster> > clusterlist;
302 std::vector<std::vector<trkPoint>> trkpts(matchedclusters.size());
303 for (
size_t itrk = 0; itrk<matchedclusters.size(); ++itrk){
305 std::vector<art::Ptr<recob::Hit> > hitlist;
306 for (
size_t iclu = 0; iclu<matchedclusters[itrk].size(); ++iclu){
308 std::vector< art::Ptr<recob::Hit> >
hits = fm.at(matchedclusters[itrk][iclu]);
309 for (
size_t ihit = 0; ihit<hits.size(); ++ihit){
310 hitlist.push_back(hits[ihit]);
317 for (
size_t i = 0; i<hitlist.size(); ++i){
321 trkpt.
hit = hitlist[i];
322 trkpts[itrk].push_back(trkpt);
334 size_t spStart = spcol->size();
335 std::vector<recob::SpacePoint> spacepoints;
352 spStart + spacepoints.size());
353 spacepoints.push_back(mysp);
354 spcol->push_back(mysp);
358 size_t spEnd = spcol->size();
363 std::sort(spacepoints.begin(),spacepoints.end(),
spt_sort_x0);
364 std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,
spt_sort_x0);
367 std::sort(spacepoints.begin(),spacepoints.end(),
spt_sort_x1);
368 std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,
spt_sort_x1);
371 std::sort(spacepoints.begin(),spacepoints.end(),
spt_sort_y0);
372 std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,
spt_sort_y0);
375 std::sort(spacepoints.begin(),spacepoints.end(),
spt_sort_y1);
376 std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,
spt_sort_y1);
379 std::sort(spacepoints.begin(),spacepoints.end(),
spt_sort_z0);
380 std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,
spt_sort_z0);
383 std::sort(spacepoints.begin(),spacepoints.end(),
spt_sort_z1);
384 std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,
spt_sort_z1);
387 if(spacepoints.size()>0){
390 std::vector<TVector3> xyz(spacepoints.size());
391 for(
size_t s = 0;
s < spacepoints.size(); ++
s){
392 xyz[
s] = TVector3(spacepoints[
s].XYZ());
395 TVector3 startpointVec,endpointVec, DirCos;
396 startpointVec = xyz[0];
397 endpointVec = xyz.back();
398 DirCos = endpointVec - startpointVec;
404 catch(...){std::cout<<
"The Spacepoint is infinitely small"<<std::endl;
408 std::vector<TVector3> dircos(spacepoints.size(), DirCos);
422 std::vector<art::Ptr<recob::Hit> > trkhits;
423 for (
size_t ihit = 0; ihit<hitlist.size(); ++ihit){
425 trkhits.push_back(hitlist[ihit]);
435 std::vector<std::vector<unsigned int>> trkidx;
438 for (
size_t itrk1 = 0; itrk1<trkpts.size(); ++itrk1){
439 for (
size_t itrk2 = itrk1+1; itrk2<trkpts.size(); ++itrk2){
443 for (
size_t i = 0; i<trkidx.size(); ++i){
444 for (
size_t j = 0; j<trkidx[i].size(); ++j){
445 if (trkidx[i][j]==itrk1) found1 = i;
446 if (trkidx[i][j]==itrk2) found2 = i;
450 if (found1==-1&&found2==-1){
451 std::vector<unsigned int>
tmp;
452 tmp.push_back(itrk1);
453 tmp.push_back(itrk2);
454 trkidx.push_back(tmp);
456 else if(found1==-1&&found2!=-1){
457 trkidx[found2].push_back(itrk1);
459 else if(found1!=-1&&found2==-1){
460 trkidx[found1].push_back(itrk2);
462 else if (found1!=found2){
463 trkidx[found1].insert(trkidx[found1].
end(),
464 trkidx[found2].
begin(),
465 trkidx[found2].
end());
466 trkidx.erase(trkidx.begin()+found2);
471 for (
size_t itrk = 0; itrk<trkpts.size(); ++itrk){
473 for (
size_t i = 0; i<trkidx.size(); ++i){
474 for (
size_t j = 0; j<trkidx[i].size(); ++j){
475 if (trkidx[i][j]==itrk) found =
true;
479 std::vector<unsigned int>
tmp;
481 trkidx.push_back(tmp);
486 trkidx.resize(trkpts.size());
487 for (
size_t i = 0; i<trkpts.size(); ++i){
488 trkidx[i].push_back(i);
493 for (
size_t i = 0; i<trkidx.size(); ++i){
495 std::vector<trkPoint> finaltrkpts;
497 std::vector<art::Ptr<recob::Cluster>> clustersPerTrack;
499 std::vector<art::Ptr<recob::Hit> > hitlist;
500 for(
size_t j = 0; j<trkidx[i].size(); ++j){
501 for (
size_t k = 0; k<trkpts[trkidx[i][j]].size(); ++k){
502 finaltrkpts.push_back(trkpts[trkidx[i][j]][k]);
503 hitlist.push_back(trkpts[trkidx[i][j]][k].
hit);
505 for (
size_t iclu = 0; iclu<matchedclusters[trkidx[i][j]].size(); ++iclu){
507 clustersPerTrack.push_back(
cluster);
519 size_t spStart = spcol->size();
520 std::vector<recob::SpacePoint> spacepoints;
521 for (
size_t ipt = 0; ipt<finaltrkpts.size(); ++ipt){
525 hitcoord[0] = finaltrkpts[ipt].pos.X();
526 hitcoord[1] = finaltrkpts[ipt].pos.Y();
527 hitcoord[2] = finaltrkpts[ipt].pos.Z();
533 spStart + spacepoints.size());
534 spacepoints.push_back(mysp);
535 spcol->push_back(mysp);
538 size_t spEnd = spcol->size();
539 if(spacepoints.size()>0){
541 std::vector<TVector3> xyz(spacepoints.size());
542 std::vector<TVector3> dircos(spacepoints.size());
543 for(
size_t s = 0;
s < spacepoints.size(); ++
s){
544 xyz[
s] = TVector3(spacepoints[
s].XYZ());
545 dircos[
s] = finaltrkpts[
s].dir;
547 if (spacepoints.size()>1){
549 TVector3 xyz1 = TVector3(spacepoints[
s+1].XYZ());
550 TVector3
dir = xyz1-xyz[
s];
551 if (dir.Angle(dircos[
s])>0.8*TMath::Pi()){
552 dircos[
s] = -dircos[
s];
556 TVector3 dir = xyz[
s]-xyz[
s-1];
557 if (dir.Angle(dircos[
s])>0.8*TMath::Pi()){
558 dircos[
s] = -dircos[
s];
576 std::vector<art::Ptr<recob::Hit> > trkhits;
577 for (
size_t ihit = 0; ihit<hitlist.size(); ++ihit){
579 trkhits.push_back(hitlist[ihit]);
590 << std::setfill(
' ');
592 for(
unsigned int i = 0; i<tcol->size(); ++i)
mf::LogVerbatim(
"Summary") << tcol->at(i) ;
595 evt.
put(std::move(tcol));
596 evt.
put(std::move(spcol));
597 evt.
put(std::move(tspassn));
598 evt.
put(std::move(tcassn));
599 evt.
put(std::move(thassn));
600 evt.
put(std::move(shassn));
bool spt_sort_x1(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool sp_sort_x1(const trkPoint &tp1, const trkPoint &tp2)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void SPTReco(std::vector< art::Ptr< recob::Hit > > &fHits)
bool sp_sort_y1(const trkPoint &tp1, const trkPoint &tp2)
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
TrackTrajectory::Flags_t Flags_t
std::vector< TVector3 > trajPos
bool sp_sort_z1(const trkPoint &tp1, const trkPoint &tp2)
bool MatchTrack(const std::vector< trkPoint > &trkpts1, const std::vector< trkPoint > &trkpts2, double discut, double angcut)
art::Ptr< recob::Hit > hit
std::vector< TVector3 > trkDir
bool fTrajOnly
Only use trajectory points from TrackTrajectoryAlg for debugging.
Cluster finding and building.
trkf::CosmicTrackerAlg fCTAlg
bool fStitchTracks
Stitch tracks from different TPCs.
double fAngCut
Angle cut for track merging.
bool sp_sort_z0(const trkPoint &tp1, const trkPoint &tp2)
bool sp_sort_y0(const trkPoint &tp1, const trkPoint &tp2)
ProductID put(std::unique_ptr< PROD > &&product)
bool sp_sort_x0(const trkPoint &tp1, const trkPoint &tp2)
void push_back(Ptr< U > const &p)
A trajectory in space reconstructed from hits.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< std::vector< unsigned int > > matchedclusters
bool spt_sort_y0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool spt_sort_z1(const recob::SpacePoint h1, const recob::SpacePoint h2)
void ClusterMatch(const std::vector< art::Ptr< recob::Cluster > > &clusterlist, const art::FindManyP< recob::Hit > &fm)
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)
cluster::ClusterMatchTQ fClusterMatch
double fDisCut
Distance cut for track merging.
Detector simulation of raw signals on wires.
std::vector< TVector3 > trkPos
std::string fClusterModuleLabel
label for input cluster collection
bool spt_sort_z0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
bool spt_sort_x0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool spt_sort_y1(const recob::SpacePoint h1, const recob::SpacePoint h2)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
constexpr double kBogusD
obviously bogus double value
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::string fSortDir
sort space points
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::vector< std::vector< art::Ptr< recob::Hit > > > trajHit