Public Member Functions | Private Member Functions | Private Attributes | List of all members
dunefd::IniSegAlg Class Reference

#include <IniSegAlg.h>

Public Member Functions

 IniSegAlg (std::map< size_t, std::vector< dunefd::Hit2D > > clusters)
 
 IniSegAlg (std::vector< art::Ptr< recob::Track > > const &tracks, TVector3 const &mcvtx)
 
void FeedwithMc (TVector2 const &vtx, TVector2 const &dir, TVector3 const &dir3d)
 
void FeedwithMc (TVector3 const &dir3d)
 
std::map< size_t, std::vector< dunefd::Hit2D > > const & GetSelectedCl () const
 
std::vector< dunefd::Hit2D > const & GetCl () const
 
const bool IsFound ()
 
art::Ptr< recob::Track > const & GetTrk () const
 
float const & GetDist () const
 
float const & GetCos () const
 

Private Member Functions

void FindClustersInRad ()
 
void FindCluster ()
 
void SortLess ()
 
void Find3dTrack ()
 
TVector2 ClusterDir (std::vector< Hit2D > const &hits)
 

Private Attributes

std::map< size_t, std::vector< dunefd::Hit2D > > fClusters
 
std::map< size_t, std::vector< dunefd::Hit2D > > fSelCls
 
std::vector< art::Ptr< recob::Track > > fSelTrks
 
art::Ptr< recob::TrackfTrk
 
bool fFound
 
TVector3 fDir3d
 
TVector3 fFront
 
TVector3 fBack
 
std::vector< dunefd::Hit2DfCl
 
TVector2 fMcVtx
 
TVector3 fMcVtx3d
 
TVector2 fDir
 
float fRadius
 
float fDistVtxCl
 
float const fThrcos
 
float fCos
 

Detailed Description

Definition at line 43 of file IniSegAlg.h.

Constructor & Destructor Documentation

dunefd::IniSegAlg::IniSegAlg ( std::map< size_t, std::vector< dunefd::Hit2D > >  clusters)

Definition at line 27 of file IniSegAlg.cxx.

27  :
28 fClusters(clusters),
29 fRadius(10.0),
30 fDistVtxCl(0.0F),
31 fThrcos(0.9),
32 fCos(0.0F)
33 {
34 }
std::map< size_t, std::vector< dunefd::Hit2D > > fClusters
Definition: IniSegAlg.h:69
float const fThrcos
Definition: IniSegAlg.h:89
dunefd::IniSegAlg::IniSegAlg ( std::vector< art::Ptr< recob::Track > > const &  tracks,
TVector3 const &  mcvtx 
)

Definition at line 36 of file IniSegAlg.cxx.

36  :
37 fRadius(10.0),
38 fDistVtxCl(0.0F),
39 fThrcos(0.9),
40 fCos(-9999.0F)
41 {
42  fSelTrks = tracks;
43  fMcVtx3d = mcvtx;
44  fFound = false;
45 }
std::vector< art::Ptr< recob::Track > > fSelTrks
Definition: IniSegAlg.h:73
TVector3 fMcVtx3d
Definition: IniSegAlg.h:84
float const fThrcos
Definition: IniSegAlg.h:89

Member Function Documentation

TVector2 dunefd::IniSegAlg::ClusterDir ( std::vector< Hit2D > const &  hits)
private

Definition at line 80 of file IniSegAlg.cxx.

81 {
82  TVector2 p1 = hits[0].GetPointCm();
83  size_t id = 0;
84  for (size_t i = 0; i < hits.size(); ++i)
85  if (pma::Dist2(hits[0].GetPointCm(), hits[i].GetPointCm()) < 1.0)
86  {
87  id = i;
88  }
89  else break;
90 
91  TVector2 p2 = hits[id].GetPointCm();
92  TVector2 dir = (p2 - p1) * (1 / (p2 - p1).Mod());
93 
94  return dir;
95 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
string dir
void dunefd::IniSegAlg::FeedwithMc ( TVector2 const &  vtx,
TVector2 const &  dir,
TVector3 const &  dir3d 
)

Definition at line 47 of file IniSegAlg.cxx.

48 {
49  fMcVtx = vtx;
50  fDir = dir;
51  fDir3d = dir3d;
53  SortLess();
54  FindCluster();
55 }
TVector2 fMcVtx
Definition: IniSegAlg.h:83
string dir
TVector2 fDir
Definition: IniSegAlg.h:85
void FindClustersInRad()
Definition: IniSegAlg.cxx:63
TVector3 fDir3d
Definition: IniSegAlg.h:76
void dunefd::IniSegAlg::FeedwithMc ( TVector3 const &  dir3d)

Definition at line 57 of file IniSegAlg.cxx.

58 {
59  fDir3d = dir3d;
60  Find3dTrack();
61 }
TVector3 fDir3d
Definition: IniSegAlg.h:76
void dunefd::IniSegAlg::Find3dTrack ( )
private

Definition at line 120 of file IniSegAlg.cxx.

121 {
122  TVector3 larStart;
123  TVector3 larEnd;
124 
125  double maxcos = 0.0;
126  const double thrdist = 10; // cm
127 
128  for (auto& trk: fSelTrks)
129  {
130  std::tie(larStart,larEnd) = trk->Direction<TVector3>(); // correct, check both directions
131  TVector3 dir(larStart[0], larStart[1], larStart[2]);
132 
133  if (!trk->NumberTrajectoryPoints()) continue;
134  TVector3 pos_p = trk->LocationAtPoint<TVector3>(0);
135  TVector3 pos_end = trk->LocationAtPoint<TVector3>(trk->NumberTrajectoryPoints()-1);
136 
137  double dist = std::sqrt(pma::Dist2(pos_p, fMcVtx3d));
138 
139  if (dist > std::sqrt(pma::Dist2(pos_end, fMcVtx3d))) continue;
140 
141  double cos = fDir3d * dir;
142 
143  if ((cos > maxcos) && (dist < thrdist))
144  {
145  maxcos = cos;
146  fTrk = trk;
147  fCos = cos;
148  fFound = true;
149  }
150  }
151 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
std::vector< art::Ptr< recob::Track > > fSelTrks
Definition: IniSegAlg.h:73
string dir
TVector3 fMcVtx3d
Definition: IniSegAlg.h:84
art::Ptr< recob::Track > fTrk
Definition: IniSegAlg.h:74
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
TVector3 fDir3d
Definition: IniSegAlg.h:76
void dunefd::IniSegAlg::FindCluster ( )
private

Definition at line 97 of file IniSegAlg.cxx.

98 {
99  double maxcos = 0;
100  std::map<size_t, std::vector<dunefd::Hit2D> > chosen;
101  for (auto& cl: fSelCls)
102  if (cl.second.size() > 2)
103  {
104  TVector2 dir = ClusterDir(cl.second);
105  double cos = fDir * dir;
106  if (cos > maxcos)
107  {
108  maxcos = cos;
109  chosen[cl.first] = cl.second;
110  fCl.clear();
111  fCl = cl.second;
112  fDistVtxCl = std::sqrt(pma::Dist2(fCl[0].GetPointCm(), fMcVtx));
113  }
114  }
115 
116  fSelCls.clear();
117  fSelCls = chosen;
118 }
std::vector< dunefd::Hit2D > fCl
Definition: IniSegAlg.h:82
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
TVector2 fMcVtx
Definition: IniSegAlg.h:83
string dir
QAsciiDict< Entry > cl
uint size() const
Definition: qasciidict.h:56
TVector2 fDir
Definition: IniSegAlg.h:85
TVector2 ClusterDir(std::vector< Hit2D > const &hits)
Definition: IniSegAlg.cxx:80
std::map< size_t, std::vector< dunefd::Hit2D > > fSelCls
Definition: IniSegAlg.h:70
void dunefd::IniSegAlg::FindClustersInRad ( )
private

Definition at line 63 of file IniSegAlg.cxx.

64 {
65  for (auto& cl: fClusters)
66  for (size_t h = 0; h < cl.second.size(); ++h)
67  if (pma::Dist2(fMcVtx, cl.second[h].GetPointCm()) < fRadius*fRadius)
68  {
69  fSelCls[cl.first] = cl.second;
70  break;
71  }
72 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
TVector2 fMcVtx
Definition: IniSegAlg.h:83
std::map< size_t, std::vector< dunefd::Hit2D > > fClusters
Definition: IniSegAlg.h:69
QAsciiDict< Entry > cl
uint size() const
Definition: qasciidict.h:56
std::map< size_t, std::vector< dunefd::Hit2D > > fSelCls
Definition: IniSegAlg.h:70
std::vector< dunefd::Hit2D > const& dunefd::IniSegAlg::GetCl ( ) const
inline

Definition at line 52 of file IniSegAlg.h.

52 { return fCl; }
std::vector< dunefd::Hit2D > fCl
Definition: IniSegAlg.h:82
float const& dunefd::IniSegAlg::GetCos ( ) const
inline

Definition at line 58 of file IniSegAlg.h.

58 { return fCos; }
float const& dunefd::IniSegAlg::GetDist ( ) const
inline

Definition at line 57 of file IniSegAlg.h.

57 { return fDistVtxCl; }
std::map<size_t, std::vector< dunefd::Hit2D > > const& dunefd::IniSegAlg::GetSelectedCl ( ) const
inline

Definition at line 51 of file IniSegAlg.h.

51 { return fSelCls; }
std::map< size_t, std::vector< dunefd::Hit2D > > fSelCls
Definition: IniSegAlg.h:70
art::Ptr<recob::Track> const& dunefd::IniSegAlg::GetTrk ( ) const
inline

Definition at line 55 of file IniSegAlg.h.

55 { return fTrk; }
art::Ptr< recob::Track > fTrk
Definition: IniSegAlg.h:74
const bool dunefd::IniSegAlg::IsFound ( )
inline

Definition at line 54 of file IniSegAlg.h.

54 { return fFound; }
void dunefd::IniSegAlg::SortLess ( )
private

Definition at line 74 of file IniSegAlg.cxx.

75 {
76  for (auto& cl: fSelCls)
77  std::sort(cl.second.begin(), cl.second.end(), bDistCentLess2D(fMcVtx));
78 }
TVector2 fMcVtx
Definition: IniSegAlg.h:83
QAsciiDict< Entry > cl
std::map< size_t, std::vector< dunefd::Hit2D > > fSelCls
Definition: IniSegAlg.h:70

Member Data Documentation

TVector3 dunefd::IniSegAlg::fBack
private

Definition at line 79 of file IniSegAlg.h.

std::vector< dunefd::Hit2D > dunefd::IniSegAlg::fCl
private

Definition at line 82 of file IniSegAlg.h.

std::map<size_t, std::vector<dunefd::Hit2D> > dunefd::IniSegAlg::fClusters
private

Definition at line 69 of file IniSegAlg.h.

float dunefd::IniSegAlg::fCos
private

Definition at line 90 of file IniSegAlg.h.

TVector2 dunefd::IniSegAlg::fDir
private

Definition at line 85 of file IniSegAlg.h.

TVector3 dunefd::IniSegAlg::fDir3d
private

Definition at line 76 of file IniSegAlg.h.

float dunefd::IniSegAlg::fDistVtxCl
private

Definition at line 88 of file IniSegAlg.h.

bool dunefd::IniSegAlg::fFound
private

Definition at line 75 of file IniSegAlg.h.

TVector3 dunefd::IniSegAlg::fFront
private

Definition at line 78 of file IniSegAlg.h.

TVector2 dunefd::IniSegAlg::fMcVtx
private

Definition at line 83 of file IniSegAlg.h.

TVector3 dunefd::IniSegAlg::fMcVtx3d
private

Definition at line 84 of file IniSegAlg.h.

float dunefd::IniSegAlg::fRadius
private

Definition at line 87 of file IniSegAlg.h.

std::map<size_t, std::vector<dunefd::Hit2D> > dunefd::IniSegAlg::fSelCls
private

Definition at line 70 of file IniSegAlg.h.

std::vector< art::Ptr<recob::Track> > dunefd::IniSegAlg::fSelTrks
private

Definition at line 73 of file IniSegAlg.h.

float const dunefd::IniSegAlg::fThrcos
private

Definition at line 89 of file IniSegAlg.h.

art::Ptr<recob::Track> dunefd::IniSegAlg::fTrk
private

Definition at line 74 of file IniSegAlg.h.


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