LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
trkf::FeatureTracker Class Reference
Inheritance diagram for trkf::FeatureTracker:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 FeatureTracker (fhicl::ParameterSet const &pset)
 
virtual ~FeatureTracker ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void beginJob ()
 
void produce (art::Event &evt)
 
void endJob ()
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

void GetProjectedEnds (TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
 
std::map< int, std::vector< double > > ExtractEndPointTimes (std::vector< recob::EndPoint2D > EndPoints)
 
std::vector< recob::SpacePointGet3DFeaturePoints (std::vector< recob::EndPoint2D > EndPoints, art::PtrVector< recob::Hit > Hits)
 
std::vector< recob::SeedGetValidLines (std::vector< recob::SpacePoint > &sps, bool ApplyFilter=true)
 
void RemoveDuplicatePaths (std::vector< recob::Seed > &Seeds, std::vector< int > &ConnectionPoint1, std::vector< int > &ConnectionPoint2)
 
recob::Seed ExtendSeed (recob::Seed TheSeed)
 
std::map< int, std::map< int, double > > GetConnectionMap (std::vector< recob::Seed > &Seeds, double ADCThresh, double FracThresh)
 
std::vector< trkf::BezierTrackGenerateBezierTracks (std::map< int, std::map< int, double > >, std::vector< recob::Seed >)
 
bool CheckSeedLineInt (recob::Seed &TheSeed)
 

Private Attributes

std::string fTruthModuleLabel
 
std::string fHitModuleLabel
 
std::string fCalDataModuleLabel
 
trkf::SpacePointAlg fSP
 
corner::CornerFinderAlg fCorner
 
double fLineIntThreshold
 
double fLineIntFraction
 
std::map< int, std::vector< double > > fEndPointTimes
 
art::ServiceHandle< geo::GeometryfGeometryHandle
 

Detailed Description

Definition at line 40 of file FeatureTracker_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

trkf::FeatureTracker::FeatureTracker ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 128 of file FeatureTracker_module.cc.

References reconfigure().

128  :
129  fSP(pset.get<fhicl::ParameterSet>("SpacepointPset")),
130  fCorner(pset.get<fhicl::ParameterSet>("CornerPset"))
131  {
132  reconfigure(pset);
133  produces< std::vector<recob::Seed> >();
134  }
trkf::SpacePointAlg fSP
void reconfigure(fhicl::ParameterSet const &pset)
corner::CornerFinderAlg fCorner
trkf::FeatureTracker::~FeatureTracker ( )
virtual

Definition at line 136 of file FeatureTracker_module.cc.

137  {
138  }

Member Function Documentation

void trkf::FeatureTracker::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 150 of file FeatureTracker_module.cc.

151  {}
bool trkf::FeatureTracker::CheckSeedLineInt ( recob::Seed TheSeed)
private

Definition at line 517 of file FeatureTracker_module.cc.

References fCorner, fLineIntFraction, fLineIntThreshold, recob::Seed::GetDirection(), recob::Seed::GetPoint(), GetProjectedEnds(), corner::CornerFinderAlg::GetWireDataHist(), and corner::CornerFinderAlg::line_integral().

Referenced by ExtendSeed().

518  {
519 
520  double Pt[3],Dir[3],Err[3];
521  TheSeed.GetPoint(Pt,Err);
522  TheSeed.GetDirection(Dir,Err);
523 
524  TVector3 endi, endj;
525 
526  for(size_t i=0; i!=3; ++i)
527  {
528  endi[i] = Pt[i]+Dir[i];
529  endj[i] = Pt[i]-Dir[i];
530  }
531 
532  std::vector<double> t_i, t_j;
533 
534  std::vector<double> uvw_i;
535  std::vector<double> uvw_j;
536 
537  GetProjectedEnds(endi, uvw_i, t_i, 0, 0);
538  GetProjectedEnds(endj, uvw_j, t_j, 0, 0);
539 
540  for(size_t p=0; p!=uvw_i.size(); ++p)
541  {
542  TH2F const& RawHist = fCorner.GetWireDataHist(p);
543 
544  double lineint =
545  fCorner.line_integral(RawHist,
546  uvw_i.at(p), t_i.at(p),
547  uvw_j.at(p), t_j.at(p),
549  if(lineint < fLineIntFraction)
550  {
551  return false;
552  }
553  }
554  return true;
555  }
void GetPoint(double *Pt, double *Err) const
Definition: Seed.cxx:112
float line_integral(TH2F const &hist, int x1, float y1, int x2, float y2, float threshold)
void GetProjectedEnds(TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
TH2F const & GetWireDataHist(unsigned int)
void GetDirection(double *Dir, double *Err) const
Definition: Seed.cxx:102
corner::CornerFinderAlg fCorner
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void trkf::FeatureTracker::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 791 of file FeatureTracker_module.cc.

792  {
793 
794  }
recob::Seed trkf::FeatureTracker::ExtendSeed ( recob::Seed  TheSeed)
private

Definition at line 468 of file FeatureTracker_module.cc.

References CheckSeedLineInt(), recob::Seed::GetDirection(), recob::Seed::GetPoint(), recob::Seed::SetDirection(), and recob::Seed::SetPoint().

469  {
470 
471  double ExtendFrac=1.1;
472 
473  // Extend Forward
474  bool SuccessfulExtend = true;
475  while(SuccessfulExtend)
476  {
477  recob::Seed NewSeed = TheSeed;
478  double Dir[3], Err[3];
479  double Pt[3];
480  NewSeed.GetDirection( Dir, Err );
481  NewSeed.GetPoint( Pt, Err );
482  for(size_t i=0; i!=3; ++i)
483  {
484  Dir[i] *= ExtendFrac;
485  Pt[i] += Dir[i] * ( ExtendFrac - 1. ) * 0.5;
486  NewSeed.SetPoint( Pt, Err );
487  NewSeed.SetDirection( Dir, Err );
488  }
489  SuccessfulExtend = CheckSeedLineInt(NewSeed);
490  if(SuccessfulExtend) TheSeed = NewSeed;
491  }
492 
493  // Extend backward
494  SuccessfulExtend = true;
495  while(SuccessfulExtend)
496  {
497  recob::Seed NewSeed = TheSeed;
498  double Dir[3], Err[3];
499  double Pt[3];
500  NewSeed.GetDirection( Dir, Err );
501  NewSeed.GetPoint( Pt, Err );
502  for(size_t i=0; i!=3; ++i)
503  {
504  Dir[i] *= ExtendFrac;
505  Pt[i] -= Dir[i] * ( ExtendFrac - 1. ) * 0.5;
506  NewSeed.SetPoint( Pt, Err );
507  NewSeed.SetDirection( Dir, Err );
508  }
509  SuccessfulExtend = CheckSeedLineInt(NewSeed);
510  if(SuccessfulExtend) TheSeed = NewSeed;
511  }
512  return TheSeed;
513  }
bool CheckSeedLineInt(recob::Seed &TheSeed)
void GetPoint(double *Pt, double *Err) const
Definition: Seed.cxx:112
void SetPoint(double *Pt, double *Err)
Definition: Seed.cxx:148
void GetDirection(double *Dir, double *Err) const
Definition: Seed.cxx:102
void SetDirection(double *Dir, double *Err)
Definition: Seed.cxx:137
std::map< int, std::vector< double > > trkf::FeatureTracker::ExtractEndPointTimes ( std::vector< recob::EndPoint2D EndPoints)
private

Definition at line 210 of file FeatureTracker_module.cc.

Referenced by produce().

211  {
212  std::map<int, std::vector<double> > EndPointTimesInPlane;
213  for(size_t i=0; i!=EndPoints.size(); ++i)
214  {
215  EndPointTimesInPlane[EndPoints.at(i).View()].push_back(EndPoints.at(i).DriftTime());
216  }
217 
218  for(std::map<int, std::vector<double> >::iterator itEpTime = EndPointTimesInPlane.begin();
219  itEpTime != EndPointTimesInPlane.end(); ++itEpTime)
220  {
221  std::sort(itEpTime->second.begin(), itEpTime->second.end());
222  }
223  return EndPointTimesInPlane;
224  }
std::vector< trkf::BezierTrack > trkf::FeatureTracker::GenerateBezierTracks ( std::map< int, std::map< int, double > >  ConnMap,
std::vector< recob::Seed Seeds 
)
private

Definition at line 742 of file FeatureTracker_module.cc.

Referenced by produce().

743  {
744  std::vector<trkf::BezierTrack> ReturnVec;
745 
746  std::vector<std::vector<int> > CollectedSeeds;
747  std::map<int, bool> AlreadyCounted;
748 
749 
750 
751  bool StillFinding=true;
752 
753 
754  for(size_t baseseed=0; baseseed!=Seeds.size(); ++baseseed)
755  {
756  if(!AlreadyCounted[baseseed])
757  {
758  std::vector<int> SeedsThisTrack;
759  SeedsThisTrack.clear();
760 
761  SeedsThisTrack.push_back(baseseed);
762  while(StillFinding)
763  {
764  StillFinding=false;
765  for(size_t i=0; i!=SeedsThisTrack.size(); ++i)
766  {
767  for(size_t j=0; j!=Seeds.size(); ++j)
768  {
769  if((!AlreadyCounted[j])&&(ConnMap[SeedsThisTrack[i]][j]>0))
770  {
771  SeedsThisTrack.push_back(j);
772  AlreadyCounted[j]=true;
773  StillFinding=true;
774  }
775  }
776  }
777  }
778  CollectedSeeds.push_back(SeedsThisTrack);
779  }
780  }
781  std::cout<<"Found " << CollectedSeeds.size()<< " sensible collections. Sizes:"<<std::endl;
782  for(size_t i=0; i!=CollectedSeeds.size(); ++i)
783  std::cout<<" " << CollectedSeeds.at(i).size()<<std::endl;
784 
785  return std::vector<trkf::BezierTrack>();
786  }
std::vector< recob::SpacePoint > trkf::FeatureTracker::Get3DFeaturePoints ( std::vector< recob::EndPoint2D EndPoints,
art::PtrVector< recob::Hit Hits 
)
private

Definition at line 413 of file FeatureTracker_module.cc.

References art::PtrVector< T >::begin(), detinfo::DetectorProperties::ConvertXToTicks(), art::PtrVector< T >::end(), fEndPointTimes, fSP, trkf::SpacePointAlg::makeSpacePoints(), and art::PtrVector< T >::push_back().

Referenced by produce().

414  {
415 
416  art::PtrVector<recob::Hit> HitsForEndPoints;
417 
418  // Loop through the hits looking for the ones which match corners
419  for(std::vector<recob::EndPoint2D>::const_iterator itEP=EndPoints.begin(); itEP!=EndPoints.end(); ++itEP)
420  {
421  int EPMatchCount=0;
422 
423  for(art::PtrVector<recob::Hit>::const_iterator itHit = Hits.begin(); itHit != Hits.end(); ++itHit)
424  {
425 
426 
427  if(
428  (itEP->View() == (*itHit)->View()) &&
429  (itEP->WireID().Wire == (*itHit)->WireID().Wire))
430  {
431  HitsForEndPoints.push_back(*itHit);
432  EPMatchCount++;
433 
434  }
435  }
436 
437  }
438  std::vector<recob::SpacePoint> spts;
439  fSP.makeSpacePoints(HitsForEndPoints, spts);
440 
441  // This is temporary for debugging purposes
442  const detinfo::DetectorProperties* det = lar::providerFrom<detinfo::DetectorPropertiesService>();
443 
444  for(size_t i=0; i!=spts.size(); ++i)
445  {
446  for(size_t p=0; p!=3; ++p)
447  {
448  double Closest =100000;
449  double spt_t = det->ConvertXToTicks(spts.at(i).XYZ()[0], p, 0, 0);
450  for(size_t epTime=0; epTime!=fEndPointTimes[p].size(); ++epTime)
451  {
452  if( fabs(fEndPointTimes[p].at(epTime) - spt_t)<Closest)
453  {
454  Closest =fabs(fEndPointTimes[p].at(epTime)-spt_t);
455  }
456  }
457  }
458 
459  }
460  return spts;
461  }
iterator begin()
Definition: PtrVector.h:223
trkf::SpacePointAlg fSP
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
intermediate_table::const_iterator const_iterator
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
iterator end()
Definition: PtrVector.h:237
std::map< int, std::vector< double > > fEndPointTimes
data_t::const_iterator const_iterator
Definition: PtrVector.h:61
void makeSpacePoints(const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
std::map< int, std::map< int, double > > trkf::FeatureTracker::GetConnectionMap ( std::vector< recob::Seed > &  Seeds,
double  ADCThresh,
double  FracThresh 
)
private

Definition at line 560 of file FeatureTracker_module.cc.

References fCorner, trkf::BezierTrack::GetClosestApproach(), trkf::BezierTrack::GetLength(), corner::CornerFinderAlg::line_integrals(), and geo::GeometryCore::NearestWire().

Referenced by produce().

561  {
562 
564  std::vector<TVector3> WireDirs;
565 
566  double EndThresh = 0.5;
567 
568  std::map<int,bool> RedundantSeeds;
569 
570  std::map<int, std::map<int, double> > ConnectionMap;
571 
572  for(size_t i=0; i!=Seeds.size(); ++i)
573  {
574  for(size_t j=0; j!=i; ++j)
575  {
576  std::vector<recob::Seed > SeedsVec;
577  SeedsVec.push_back(Seeds.at(i));
578  SeedsVec.push_back(Seeds.at(j));
579 
580  trkf::BezierTrack TestTrack(SeedsVec);
581 
582  std::vector<float> LineScore = fCorner.line_integrals(TestTrack, 100, ADCThresh);
583 
584  bool HasConnection=true;
585 
586  for(size_t view =0; view!=LineScore.size(); ++view)
587  {
588  if(LineScore.at(view)<FracThresh)
589  {
590  HasConnection=false;
591  }
592  }
593  double Seed1Pt[3], Seed2Pt[3], Seed1Dir[3], Seed2Dir[3], Err[3];
594 
595  Seeds.at(i).GetPoint(Seed1Pt,Err);
596  Seeds.at(j).GetPoint(Seed2Pt,Err);
597  Seeds.at(i).GetDirection(Seed1Dir,Err);
598  Seeds.at(j).GetDirection(Seed2Dir,Err);
599 
600  TVector3 Seed1End1, Seed1End2, Seed2End1, Seed2End2;
601 
602  for(size_t index=0; index!=3; ++index)
603  {
604  Seed1End1[index]=Seed1Pt[index]+Seed1Dir[index];
605  Seed1End2[index]=Seed1Pt[index]-Seed1Dir[index];
606  Seed2End1[index]=Seed2Pt[index]+Seed2Dir[index];
607  Seed2End2[index]=Seed2Pt[index]-Seed2Dir[index];
608  }
609 
610  if( ( (Seed1End1-Seed2End1).Mag() < EndThresh)
611  ||( (Seed1End2-Seed2End1).Mag() < EndThresh)
612  ||( (Seed1End1-Seed2End2).Mag() < EndThresh)
613  ||( (Seed1End2-Seed2End2).Mag() < EndThresh))
614  HasConnection=true;
615 
616  if(HasConnection)
617  {
618 
619  double Pt[3]; double Dir[3]; double Err[3];
620  TVector3 End1; TVector3 End2;
621 
622  ConnectionMap[i][j] = ConnectionMap[j][i] = TestTrack.GetLength();
623  for(size_t isd=0; isd!=Seeds.size(); ++isd)
624  {
625  if((isd!=i)&&(isd!=j)&&(RedundantSeeds[i]!=true)&&(RedundantSeeds[j]!=true)&&(RedundantSeeds[isd]!=true))
626  {
627  Seeds.at(isd).GetPoint(Pt,Err);
628  Seeds.at(isd).GetDirection(Dir,Err);
629  TVector3 End1;
630  TVector3 End2;
631  for(size_t index=0; index!=3; ++index)
632  {
633  End1[index]=Pt[index]+Dir[index];
634  End2[index]=Pt[index]-Dir[index];
635  }
636  double s1, s2, d1,d2;
637  TestTrack.GetClosestApproach(End1,s1,d1);
638  TestTrack.GetClosestApproach(End2,s2,d2);
639 
640  // std::cout<<"in 3D : " << d1 << ", " <<d2<<std::endl;
641  if((d1<1.)&&(d2<1.))
642  {
643  std::cout<<" meets 3D throw condition"<<std::endl;
644  }
645 
646  bool NoFails=true;
647  for(size_t p=0; p!=3; ++p)
648  {
649  int t=0, c=0;
650  uint32_t wire1 = geom->NearestWire(End1, p, t, c);
651  uint32_t wire2 = geom->NearestWire(End2, p, t, c);
652  double dp1, sp1, dp2, sp2;
653  TestTrack.GetClosestApproach(wire1, p, t, c, End1[0], sp1,dp1);
654  TestTrack.GetClosestApproach(wire2, p, t, c, End2[0], sp2,dp2);
655  // std::cout<<p<<": [ "<< dp1 <<", "<<dp2<<" ] " ;
656  if((dp1>1.0)||(dp2>1.0)) NoFails = false;
657  }
658 
659  if(NoFails)
660  {
661  std::cout<<"Propose throwing out seed " << isd<<std::endl;
662  RedundantSeeds[isd]=true;
663  }
664  }
665  }
666  }
667  }
668 
669 
670  }
671 
672  // Now we need to throw out all the seeds we marked as redundant
673  std::map<int, std::map<int, double> > FilteredMap;
674 
675  std::vector<int> OldNew;
676  for(size_t i=0; i!=Seeds.size(); ++i)
677  {
678  OldNew.push_back(i);
679  }
680 
681  for(int i=Seeds.size()-1; i!=-1; --i)
682  {
683  if(RedundantSeeds[i])
684  {
685  Seeds.erase(Seeds.begin()+i);
686  OldNew.erase(OldNew.begin()+i);
687  }
688  }
689 
690  for(size_t i=0; i!=OldNew.size(); ++i)
691  {
692  for(size_t j=0; j!=OldNew.size(); ++j)
693  {
694  FilteredMap[i][j] = ConnectionMap[OldNew[i]][OldNew[j]];
695  }
696  }
697 
698  ConnectionMap = FilteredMap;
699 
700 
701  // Deal with loops by throwing out the longest paths.
702  for(size_t i=0; i!=Seeds.size(); ++i)
703  {
704  for(size_t j=0; j!=i; ++j)
705  {
706  if(ConnectionMap[i][j]>0)
707  {
708  for(size_t k=0; k!=Seeds.size(); ++k)
709  {
710  if((ConnectionMap[i][k]>0)&&(ConnectionMap[k][j]>0))
711  {
712  if( ( ConnectionMap[i][k] > ConnectionMap[i][j]) && ( ConnectionMap[i][k] > ConnectionMap[j][k]))
713  ConnectionMap[i][j] = ConnectionMap[j][i] = ConnectionMap[k][j] = ConnectionMap[j][k] = 0;
714  else if( ( ConnectionMap[i][j] > ConnectionMap[i][k]) && ( ConnectionMap[i][j] > ConnectionMap[j][k]))
715  ConnectionMap[j][k] = ConnectionMap[k][j] = ConnectionMap[i][k] = ConnectionMap[k][i] = 0;
716  else
717  ConnectionMap[i][j] = ConnectionMap[j][i] = ConnectionMap[i][k] = ConnectionMap[k][i] = 0;
718 
719  }
720  }
721  }
722  }
723  }
724 
725  for(size_t i=0; i!=Seeds.size(); ++i)
726  {
727  int Count=0;
728  for(size_t j=0; j!=Seeds.size(); ++j)
729  {
730  if(ConnectionMap[i][j]>0)
731  Count++;
732  }
733  std::cout<<" After delooping, seed " << i << " is connected " << Count << " times"<<std::endl;
734 
735  }
736  return FilteredMap;
737 
738  }
std::vector< float > line_integrals(trkf::BezierTrack &, size_t Steps, float threshold)
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
corner::CornerFinderAlg fCorner
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
void trkf::FeatureTracker::GetProjectedEnds ( TVector3  xyz,
std::vector< double > &  uvw,
std::vector< double > &  t,
int  tpc = 0,
int  cryo = 0 
)
private

Definition at line 392 of file FeatureTracker_module.cc.

References detinfo::DetectorProperties::ConvertXToTicks().

Referenced by CheckSeedLineInt(), and GetValidLines().

393  {
394 
395  const detinfo::DetectorProperties* det = lar::providerFrom<detinfo::DetectorPropertiesService>();
397 
398  int NPlanes=geo->Cryostat(cryo).TPC(tpc).Nplanes();
399 
400  uvw.resize(NPlanes);
401  t.resize(NPlanes);
402 
403  for(int plane = 0; plane != NPlanes; plane++)
404  {
405  uvw[plane] = geo->NearestWire(xyz, plane, tpc, cryo);
406  t[plane] = det->ConvertXToTicks(xyz[0], plane, tpc, cryo);
407  }
408 
409  }
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
Namespace collecting geometry-related classes utilities.
std::vector< recob::Seed > trkf::FeatureTracker::GetValidLines ( std::vector< recob::SpacePoint > &  sps,
bool  ApplyFilter = true 
)
private

Definition at line 230 of file FeatureTracker_module.cc.

References d, fCorner, fLineIntFraction, fLineIntThreshold, GetProjectedEnds(), corner::CornerFinderAlg::GetWireDataHist(), corner::CornerFinderAlg::line_integral(), and RemoveDuplicatePaths().

Referenced by produce().

231  {
232  std::vector<recob::Seed> SeedsToReturn;
233 
234  std::vector<int> ConnectionPoint1;
235  std::vector<int> ConnectionPoint2;
236  std::map<int, std::vector<int> > SeedConnections;
237 
238  for(size_t i=0; i!=spts.size(); ++i)
239  {
240  for(size_t j=0; j!=i; ++j)
241  {
242 
243 
244  TVector3 xyz_i;
245  TVector3 xyz_j;
246 
247  std::vector<double> t_i, t_j;
248 
249  std::vector<double> uvw_i;
250  std::vector<double> uvw_j;
251 
252  for(size_t d=0; d!=3; ++d)
253  {
254  xyz_i[d] = spts.at(i).XYZ()[d];
255  xyz_j[d] = spts.at(j).XYZ()[d];
256  }
257 
258 
259  GetProjectedEnds(xyz_i, uvw_i, t_i, 0, 0);
260  GetProjectedEnds(xyz_j, uvw_j, t_j, 0, 0);
261 
262  bool ThisLineGood=true;
263 
264  for(size_t p=0; p!=uvw_i.size(); ++p)
265  {
266  TH2F const& RawHist = fCorner.GetWireDataHist(p);
267 
268  double lineint =
269  fCorner.line_integral(RawHist,
270  uvw_i.at(p), t_i.at(p),
271  uvw_j.at(p), t_j.at(p),
273 
274  if(lineint < fLineIntFraction)
275  {
276 
277  ThisLineGood=false;
278  }
279  }
280  if(ThisLineGood)
281  {
282  double Err[3];
283  double Pos[3];
284  double Dir[3];
285 
286  for(size_t d=0; d!=3; ++d)
287  {
288  Pos[d] = 0.5*(xyz_i[d] + xyz_j[d]);
289  Dir[d] = 0.5*(xyz_i[d] - xyz_j[d]);
290  Err[d] = 0;
291  }
292 
293  ConnectionPoint1.push_back(i);
294  ConnectionPoint2.push_back(j);
295 
296  SeedsToReturn.push_back(recob::Seed(Pos,Dir,Err,Err));
297  }
298 
299  }
300 
301  }
302 
303  if(ApplyFilter)
304  {
305  RemoveDuplicatePaths(SeedsToReturn, ConnectionPoint1, ConnectionPoint2);
306  mf::LogInfo("FeatureTracker") <<"Seeds after filter " << SeedsToReturn.size()<<" seeds"<<std::endl;
307  }
308 
309  return SeedsToReturn;
310  }
void RemoveDuplicatePaths(std::vector< recob::Seed > &Seeds, std::vector< int > &ConnectionPoint1, std::vector< int > &ConnectionPoint2)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
float line_integral(TH2F const &hist, int x1, float y1, int x2, float y2, float threshold)
void GetProjectedEnds(TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
TH2F const & GetWireDataHist(unsigned int)
Float_t d
Definition: plot.C:237
corner::CornerFinderAlg fCorner
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void trkf::FeatureTracker::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 154 of file FeatureTracker_module.cc.

References ExtractEndPointTimes(), fCalDataModuleLabel, fCorner, fEndPointTimes, fGeometryHandle, fHitModuleLabel, GenerateBezierTracks(), Get3DFeaturePoints(), corner::CornerFinderAlg::get_feature_points(), art::DataViewImpl::getByLabel(), GetConnectionMap(), GetValidLines(), corner::CornerFinderAlg::GrabWires(), art::PtrVector< T >::push_back(), art::Event::put(), and tca::seeds.

155  {
156 
157  // Extract hits PtrVector from event
159  evt.getByLabel(fHitModuleLabel, hith);
160 
162  for(unsigned int i = 0; i < hith->size(); ++i){
163  art::Ptr<recob::Hit> prod(hith, i);
164  hitvec.push_back(prod);
165  }
166 
167  //We need to grab out the wires.
169  evt.getByLabel(fCalDataModuleLabel,wireHandle);
170  std::vector<recob::Wire> const& wireVec(*wireHandle);
171 
172  //First, have it process the wires.
174 
175  std::vector<recob::EndPoint2D> EndPoints;
177 
179 
180  std::vector<recob::SpacePoint> sps = Get3DFeaturePoints(EndPoints, hitvec);
181 
182  std::vector<recob::Seed> SeedsToStore = GetValidLines( sps, true );
183 
184  std::map<int, std::map<int, double> > ConnMap = GetConnectionMap(SeedsToStore, 3, 0.90);
185 
186  /* for(size_t i=0; i!=SeedsToStore.size(); ++i)
187  {
188  SeedsToStore[i] = ExtendSeed(SeedsToStore.at(i));
189  }
190 
191 
192  ConnMap = GetConnectionMap(SeedsToStore, 3, 0.90);
193  */
194 
195  std::vector<trkf::BezierTrack> BTracks = GenerateBezierTracks(ConnMap, SeedsToStore);
196 
197  std::unique_ptr< std::vector<recob::Seed > > seeds ( new std::vector<recob::Seed>);
198 
199  for(size_t i=0; i!=SeedsToStore.size(); ++i)
200  seeds->push_back(SeedsToStore.at(i));
201 
202  evt.put(std::move(seeds));
203  }
std::map< int, std::map< int, double > > GetConnectionMap(std::vector< recob::Seed > &Seeds, double ADCThresh, double FracThresh)
void get_feature_points(std::vector< recob::EndPoint2D > &, geo::Geometry const &)
std::map< int, std::vector< double > > ExtractEndPointTimes(std::vector< recob::EndPoint2D > EndPoints)
std::vector< recob::Seed > GetValidLines(std::vector< recob::SpacePoint > &sps, bool ApplyFilter=true)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void GrabWires(std::vector< recob::Wire > const &wireVec, geo::Geometry const &)
std::vector< trkf::BezierTrack > GenerateBezierTracks(std::map< int, std::map< int, double > >, std::vector< recob::Seed >)
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
std::vector< recob::SpacePoint > Get3DFeaturePoints(std::vector< recob::EndPoint2D > EndPoints, art::PtrVector< recob::Hit > Hits)
std::map< int, std::vector< double > > fEndPointTimes
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:11
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
art::ServiceHandle< geo::Geometry > fGeometryHandle
corner::CornerFinderAlg fCorner
void trkf::FeatureTracker::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 140 of file FeatureTracker_module.cc.

References fCalDataModuleLabel, fHitModuleLabel, fLineIntFraction, fLineIntThreshold, and fhicl::ParameterSet::get().

Referenced by FeatureTracker().

141  {
142  fHitModuleLabel = pset.get<std::string>("HitModuleLabel");
143  fLineIntFraction = pset.get<double>("LineIntFraction");
144  fLineIntThreshold = pset.get<double>("LineIntThreshold");
145  fhicl::ParameterSet CornerPset = pset.get<fhicl::ParameterSet>("CornerPset");
146  fCalDataModuleLabel = CornerPset.get<std::string>("CalDataModuleLabel");
147 
148  }
T get(std::string const &key) const
Definition: ParameterSet.h:231
void trkf::FeatureTracker::RemoveDuplicatePaths ( std::vector< recob::Seed > &  Seeds,
std::vector< int > &  ConnectionPoint1,
std::vector< int > &  ConnectionPoint2 
)
private

Definition at line 314 of file FeatureTracker_module.cc.

References s.

Referenced by GetValidLines().

317  {
318 
319  std::map<int, bool> MarkedForRemoval;
320 
321  std::map<int, std::vector<int> > SeedsSharingPoint;
322  for(size_t i=0; i!=Seeds.size(); ++i)
323  {
324  SeedsSharingPoint[ConnectionPoint1[i] ].push_back(i);
325  SeedsSharingPoint[ConnectionPoint2[i] ].push_back(i);
326  }
327 
328  for(size_t s=0; s!=Seeds.size(); ++s)
329  {
330 
331  int StartPt = ConnectionPoint1.at(s);
332  int EndPt = ConnectionPoint2.at(s);
333  int MidPt = -1;
334 
335  for(size_t SeedsWithThisStart =0; SeedsWithThisStart!=SeedsSharingPoint[StartPt].size(); SeedsWithThisStart++)
336  {
337  int i = SeedsSharingPoint[StartPt].at(SeedsWithThisStart);
338  if(ConnectionPoint1.at(i)==StartPt)
339  MidPt = ConnectionPoint2.at(i);
340  else if(ConnectionPoint2.at(i)==StartPt)
341  MidPt = ConnectionPoint1.at(i);
342 
343  for(size_t SeedsWithThisMid =0; SeedsWithThisMid!=SeedsSharingPoint[MidPt].size(); SeedsWithThisMid++)
344  {
345  int j = SeedsSharingPoint[MidPt].at(SeedsWithThisMid);
346  if((ConnectionPoint1.at(j)==EndPt)||(ConnectionPoint2.at(j)==EndPt))
347  {
348 
349  double Lengthi = Seeds.at(i).GetLength();
350  double Lengthj = Seeds.at(j).GetLength();
351  double Lengths = Seeds.at(s).GetLength();
352 
353  if((Lengths>Lengthi)&&(Lengths>Lengthj))
354  {
355  MarkedForRemoval[i]=true;
356  MarkedForRemoval[j]=true;
357  }
358 
359  if((Lengthi>Lengths)&&(Lengthi>Lengthj))
360  {
361  MarkedForRemoval[s]=true;
362  MarkedForRemoval[j]=true;
363  }
364  if((Lengthj>Lengthi)&&(Lengthj>Lengths))
365  {
366  MarkedForRemoval[s]=true;
367  MarkedForRemoval[i]=true;
368  }
369  }
370  }
371  }
372  }
373  for(std::map<int,bool>::reverse_iterator itrem = MarkedForRemoval.rbegin();
374  itrem != MarkedForRemoval.rend(); ++itrem)
375  {
376  if(itrem->second==true)
377  {
378  Seeds.erase( Seeds.begin() + itrem->first);
379  ConnectionPoint1.erase( ConnectionPoint1.begin() + itrem->first);
380  ConnectionPoint2.erase( ConnectionPoint2.begin() + itrem->first);
381  }
382  }
383 
384  }
Float_t s
Definition: plot.C:23
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

std::string trkf::FeatureTracker::fCalDataModuleLabel
private

Definition at line 66 of file FeatureTracker_module.cc.

Referenced by produce(), and reconfigure().

corner::CornerFinderAlg trkf::FeatureTracker::fCorner
private
std::map<int, std::vector<double> > trkf::FeatureTracker::fEndPointTimes
private

Definition at line 97 of file FeatureTracker_module.cc.

Referenced by Get3DFeaturePoints(), and produce().

art::ServiceHandle<geo::Geometry> trkf::FeatureTracker::fGeometryHandle
private

Definition at line 98 of file FeatureTracker_module.cc.

Referenced by produce().

std::string trkf::FeatureTracker::fHitModuleLabel
private

Definition at line 65 of file FeatureTracker_module.cc.

Referenced by produce(), and reconfigure().

double trkf::FeatureTracker::fLineIntFraction
private

Definition at line 95 of file FeatureTracker_module.cc.

Referenced by CheckSeedLineInt(), GetValidLines(), and reconfigure().

double trkf::FeatureTracker::fLineIntThreshold
private

Definition at line 94 of file FeatureTracker_module.cc.

Referenced by CheckSeedLineInt(), GetValidLines(), and reconfigure().

trkf::SpacePointAlg trkf::FeatureTracker::fSP
private

Definition at line 90 of file FeatureTracker_module.cc.

Referenced by Get3DFeaturePoints().

std::string trkf::FeatureTracker::fTruthModuleLabel
private

Definition at line 64 of file FeatureTracker_module.cc.


The documentation for this class was generated from the following file: