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);
410 std::vector< std::vector<double> > dQdx;
412 tcol->push_back(
recob::Track(xyz, dircos, dQdx, mom, tcol->size()));
421 std::vector<art::Ptr<recob::Hit> > trkhits;
422 for (
size_t ihit = 0; ihit<hitlist.size(); ++ihit){
424 trkhits.push_back(hitlist[ihit]);
434 std::vector<std::vector<unsigned int>> trkidx;
437 for (
size_t itrk1 = 0; itrk1<trkpts.size(); ++itrk1){
438 for (
size_t itrk2 = itrk1+1; itrk2<trkpts.size(); ++itrk2){
442 for (
size_t i = 0; i<trkidx.size(); ++i){
443 for (
size_t j = 0; j<trkidx[i].size(); ++j){
444 if (trkidx[i][j]==itrk1) found1 = i;
445 if (trkidx[i][j]==itrk2) found2 = i;
449 if (found1==-1&&found2==-1){
450 std::vector<unsigned int>
tmp;
451 tmp.push_back(itrk1);
452 tmp.push_back(itrk2);
453 trkidx.push_back(tmp);
455 else if(found1==-1&&found2!=-1){
456 trkidx[found2].push_back(itrk1);
458 else if(found1!=-1&&found2==-1){
459 trkidx[found1].push_back(itrk2);
461 else if (found1!=found2){
462 trkidx[found1].insert(trkidx[found1].
end(),
463 trkidx[found2].
begin(),
464 trkidx[found2].
end());
465 trkidx.erase(trkidx.begin()+found2);
470 for (
size_t itrk = 0; itrk<trkpts.size(); ++itrk){
472 for (
size_t i = 0; i<trkidx.size(); ++i){
473 for (
size_t j = 0; j<trkidx[i].size(); ++j){
474 if (trkidx[i][j]==itrk) found =
true;
478 std::vector<unsigned int>
tmp;
480 trkidx.push_back(tmp);
485 trkidx.resize(trkpts.size());
486 for (
size_t i = 0; i<trkpts.size(); ++i){
487 trkidx[i].push_back(i);
492 for (
size_t i = 0; i<trkidx.size(); ++i){
494 std::vector<trkPoint> finaltrkpts;
496 std::vector<art::Ptr<recob::Cluster>> clustersPerTrack;
498 std::vector<art::Ptr<recob::Hit> > hitlist;
499 for(
size_t j = 0; j<trkidx[i].size(); ++j){
500 for (
size_t k = 0; k<trkpts[trkidx[i][j]].size(); ++k){
501 finaltrkpts.push_back(trkpts[trkidx[i][j]][k]);
502 hitlist.push_back(trkpts[trkidx[i][j]][k].
hit);
504 for (
size_t iclu = 0; iclu<matchedclusters[trkidx[i][j]].size(); ++iclu){
506 clustersPerTrack.push_back(
cluster);
518 size_t spStart = spcol->size();
519 std::vector<recob::SpacePoint> spacepoints;
520 for (
size_t ipt = 0; ipt<finaltrkpts.size(); ++ipt){
524 hitcoord[0] = finaltrkpts[ipt].pos.X();
525 hitcoord[1] = finaltrkpts[ipt].pos.Y();
526 hitcoord[2] = finaltrkpts[ipt].pos.Z();
532 spStart + spacepoints.size());
533 spacepoints.push_back(mysp);
534 spcol->push_back(mysp);
537 size_t spEnd = spcol->size();
538 if(spacepoints.size()>0){
540 std::vector<TVector3> xyz(spacepoints.size());
541 std::vector<TVector3> dircos(spacepoints.size());
542 for(
size_t s = 0;
s < spacepoints.size(); ++
s){
543 xyz[
s] = TVector3(spacepoints[
s].XYZ());
544 dircos[
s] = finaltrkpts[
s].dir;
546 if (spacepoints.size()>1){
548 TVector3 xyz1 = TVector3(spacepoints[
s+1].XYZ());
549 TVector3
dir = xyz1-xyz[
s];
550 if (dir.Angle(dircos[
s])>0.8*TMath::Pi()){
551 dircos[
s] = -dircos[
s];
555 TVector3 dir = xyz[
s]-xyz[
s-1];
556 if (dir.Angle(dircos[
s])>0.8*TMath::Pi()){
557 dircos[
s] = -dircos[
s];
563 std::vector< std::vector<double> > dQdx;
565 tcol->push_back(
recob::Track(xyz, dircos, dQdx, mom, tcol->size()));
574 std::vector<art::Ptr<recob::Hit> > trkhits;
575 for (
size_t ihit = 0; ihit<hitlist.size(); ++ihit){
577 trkhits.push_back(hitlist[ihit]);
588 << std::setfill(
' ');
590 for(
unsigned int i = 0; i<tcol->size(); ++i)
mf::LogVerbatim(
"Summary") << tcol->at(i) ;
593 evt.
put(std::move(tcol));
594 evt.
put(std::move(spcol));
595 evt.
put(std::move(tspassn));
596 evt.
put(std::move(tcassn));
597 evt.
put(std::move(thassn));
598 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)
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)
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.
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