LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
FeatureTracker_module.cc
Go to the documentation of this file.
2 
3 #ifndef FEATURETRACKER_H
4 #define FEATURETRACKER_H
5 
6 //
7 // Name: FeatureTracker.h
8 //
9 // Purpose: This module takes features found in 2D and uses them
10 // to produce seeds for 3D tracking.
11 //
12 //
13 //
14 // Ben Jones, MIT
15 //
16 
19 #include "TVector3.h"
23 
27 
28 namespace recob
29 {
30  class Seed;
31  class Hit;
32 }
33 
34 
35 namespace trkf {
36 
37  class BezierTrack;
38  class BezierTrackerAlgorithm;
39 
41  {
42  public:
43 
44  // Constructors, destructor
45 
46  explicit FeatureTracker(fhicl::ParameterSet const& pset);
47  virtual ~FeatureTracker();
48 
49 
50  // Overrides.
51 
52  void reconfigure(fhicl::ParameterSet const& pset);
53  void beginJob();
54  void produce(art::Event& evt);
55  void endJob();
56 
57 
58 
59 
60  private:
61 
62  // Fcl Attributes.
63 
64  std::string fTruthModuleLabel;
65  std::string fHitModuleLabel;
66  std::string fCalDataModuleLabel;
67 
68  void GetProjectedEnds(TVector3 xyz, std::vector<double>& uvw, std::vector<double>& t, int tpc=0, int cryo=0);
69 
70  std::map<int, std::vector<double> > ExtractEndPointTimes(std::vector<recob::EndPoint2D> EndPoints);
71 
72  std::vector<recob::SpacePoint> Get3DFeaturePoints(std::vector<recob::EndPoint2D> EndPoints, art::PtrVector<recob::Hit> Hits);
73 
74  std::vector<recob::Seed> GetValidLines(std::vector<recob::SpacePoint>& sps,
75  bool ApplyFilter = true);
76 
77  void RemoveDuplicatePaths(std::vector<recob::Seed>& Seeds,
78  std::vector<int>& ConnectionPoint1,
79  std::vector<int>& ConnectionPoint2);
80 
81  recob::Seed ExtendSeed(recob::Seed TheSeed);
82 
83 
84  std::map<int, std::map<int, double> > GetConnectionMap(std::vector<recob::Seed>& Seeds, double ADCThresh, double FracThresh);
85 
86  std::vector<trkf::BezierTrack> GenerateBezierTracks(std::map<int,std::map<int,double> > , std::vector<recob::Seed>);
87 
88  bool CheckSeedLineInt(recob::Seed& TheSeed);
89 
92 
93 
96 
97  std::map<int, std::vector<double> > fEndPointTimes;
99  };
100 }
101 
102 #endif
103 
105 
106 
107 namespace trkf {
109 }
110 
111 #include <vector>
115 
118 #include "lardataobj/RecoBase/Hit.h"
123 
124 
125 
126 namespace trkf {
127 
128  FeatureTracker::FeatureTracker(const fhicl::ParameterSet& pset):
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  }
135 
137  {
138  }
139 
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  }
149 
151  {}
152 
153 
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  }
204 
205 
206 
207 
208  //---------------------------------------------------------------------
209 
210  std::map<int, std::vector<double> > FeatureTracker::ExtractEndPointTimes(std::vector<recob::EndPoint2D> EndPoints)
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  }
225 
226 
227 
228  //---------------------------------------------------------------------
229 
230  std::vector<recob::Seed> FeatureTracker::GetValidLines(std::vector<recob::SpacePoint>& spts, bool ApplyFilter)
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  }
311 
312  //--------------------------------------------------
313 
314  void FeatureTracker::RemoveDuplicatePaths(std::vector<recob::Seed>& Seeds,
315  std::vector<int>& ConnectionPoint1,
316  std::vector<int>& ConnectionPoint2)
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  }
385 
386 
387 
388 
389 
390  //---------------------------------------------------------------------
391 
392  void FeatureTracker::GetProjectedEnds(TVector3 xyz, std::vector<double>& uvw, std::vector<double>&t, int tpc, int cryo)
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  }
410 
411  //----------------------------------------------------------------------
412 
413  std::vector<recob::SpacePoint> FeatureTracker::Get3DFeaturePoints(std::vector<recob::EndPoint2D> EndPoints, art::PtrVector<recob::Hit> Hits)
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  }
462 
463 
464 
465 
466  //----------------------------------------------------------------------
467 
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  }
514 
515  //---------------------------------------------------
516 
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  }
556 
557 
558  //----------------------------------------------------------------------
559 
560  std::map<int, std::map<int, double> > FeatureTracker::GetConnectionMap(std::vector<recob::Seed>& Seeds, double ADCThresh, double FracThresh)
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  }
739 
740  //----------------------------------------------------------------------
741 
742  std::vector<trkf::BezierTrack> FeatureTracker::GenerateBezierTracks(std::map<int,std::map<int,double> > ConnMap, std::vector<recob::Seed> Seeds)
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  }
787 
788 
789 
790  //----------------------------------------------------------------------
792  {
793 
794  }
795 }
796 
Float_t s
Definition: plot.C:23
std::vector< float > line_integrals(trkf::BezierTrack &, size_t Steps, float threshold)
std::map< int, std::map< int, double > > GetConnectionMap(std::vector< recob::Seed > &Seeds, double ADCThresh, double FracThresh)
Reconstruction base classes.
void RemoveDuplicatePaths(std::vector< recob::Seed > &Seeds, std::vector< int > &ConnectionPoint1, std::vector< int > &ConnectionPoint2)
Encapsulate the construction of a single cyostat.
bool CheckSeedLineInt(recob::Seed &TheSeed)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
iterator begin()
Definition: PtrVector.h:223
Declaration of signal hit object.
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)
trkf::SpacePointAlg fSP
recob::Seed ExtendSeed(recob::Seed TheSeed)
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)
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
void GetProjectedEnds(TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
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 >)
intermediate_table::const_iterator const_iterator
TH2F const & GetWireDataHist(unsigned int)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
void SetPoint(double *Pt, double *Err)
Definition: Seed.cxx:148
void beginJob()
Definition: Breakpoints.cc:14
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
algorithm to find feature 2D points
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
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.
iterator end()
Definition: PtrVector.h:237
Float_t d
Definition: plot.C:237
std::vector< recob::SpacePoint > Get3DFeaturePoints(std::vector< recob::EndPoint2D > EndPoints, art::PtrVector< recob::Hit > Hits)
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
Utility object to perform functions of association.
void reconfigure(fhicl::ParameterSet const &pset)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
art::ServiceHandle< geo::Geometry > fGeometryHandle
Declaration of basic channel signal object.
void GetClosestApproach(recob::Hit const &hit, double &s, double &Distance) const
void produce(art::Event &evt)
double GetLength() const
Algorithm for generating space points from hits.
Namespace collecting geometry-related classes utilities.
void GetDirection(double *Dir, double *Err) const
Definition: Seed.cxx:102
art framework interface to geometry description
Encapsulate the construction of a single detector plane.
corner::CornerFinderAlg fCorner
void SetDirection(double *Dir, double *Err)
Definition: Seed.cxx:137