Public Member Functions | Private Attributes | Friends | List of all members
recob::Seed Class Reference

#include <Seed.h>

Public Member Functions

 Seed ()
 
 Seed (double *Pt, double *Dir, double *PtErr, double *DirErr)
 
void GetDirection (double *Dir, double *Err) const
 
void GetPoint (double *Pt, double *Err) const
 
double GetLength () const
 
void Print () const
 
void SetDirection (double *Dir, double *Err)
 
void SetPoint (double *Pt, double *Err)
 
double GetAngle (Seed const &AnotherSeed) const
 
double GetProjDiscrepancy (Seed const &AnotherSeed) const
 
double GetProjAngleDiscrepancy (Seed const &AnotherSeed) const
 
double GetDistance (Seed const &AnotherSeed) const
 
Seed Reverse ()
 
void GetVectorBetween (Seed const &AnotherSeed, double *xyz) const
 
double GetDistanceFrom (SpacePoint const &SomePoint) const
 
int GetPointingSign (Seed const &AnotherSeed) const
 
 Seed (double *Pt, double *Dir)
 
void SetDirection (double *Dir)
 
void SetPoint (double *Pt)
 
bool IsValid () const
 
void SetValidity (bool Validity)
 

Private Attributes

double fSeedPoint [3]
 
double fSeedDirection [3]
 
double fSeedPointError [3]
 
double fSeedDirectionError [3]
 
bool fIsValid
 

Friends

std::ostream & operator<< (std::ostream &stream, Seed const &a)
 
bool operator< (const Seed &a, const Seed &b)
 

Detailed Description

Definition at line 20 of file Seed.h.

Constructor & Destructor Documentation

recob::Seed::Seed ( )

Definition at line 21 of file Seed.cxx.

22  {
23  fIsValid=false;
24  }
bool fIsValid
Definition: Seed.h:31
recob::Seed::Seed ( double *  Pt,
double *  Dir,
double *  PtErr,
double *  DirErr 
)

Definition at line 41 of file Seed.cxx.

42  {
43  for(int i=0; i!=3; i++)
44  {
45  fSeedPoint[i] = Pt[i];
46  fSeedDirection[i] = Dir[i];
47  fSeedPointError[i] = PtErr[i];
48  fSeedDirectionError[i] = DirErr[i];
49  }
50  fIsValid=true;
51  }
double fSeedDirection[3]
Definition: Seed.h:28
bool fIsValid
Definition: Seed.h:31
double fSeedDirectionError[3]
Definition: Seed.h:30
double fSeedPoint[3]
Definition: Seed.h:27
double fSeedPointError[3]
Definition: Seed.h:29
recob::Seed::Seed ( double *  Pt,
double *  Dir 
)

Definition at line 28 of file Seed.cxx.

29  {
30  for(int i=0; i!=3; i++)
31  {
32  fSeedPoint[i] = Pt[i];
33  fSeedDirection[i] = Dir[i];
34  fSeedPointError[i] = 0;
35  fSeedDirectionError[i] = 0;
36  }
37  fIsValid=true;
38  }
double fSeedDirection[3]
Definition: Seed.h:28
bool fIsValid
Definition: Seed.h:31
double fSeedDirectionError[3]
Definition: Seed.h:30
double fSeedPoint[3]
Definition: Seed.h:27
double fSeedPointError[3]
Definition: Seed.h:29

Member Function Documentation

double recob::Seed::GetAngle ( Seed const &  AnotherSeed) const

Definition at line 192 of file Seed.cxx.

193  {
194  double OtherDir[3];
195  double OtherDirErr[3];
196  AnotherSeed.GetDirection(OtherDir,OtherDirErr);
197 
198  double OtherMag = AnotherSeed.GetLength();
199  double ThisMag = GetLength();
200 
201  /*
202  std::cout<<"Seed angle calc: " <<
203  OtherMag<< " " << ThisMag << " " <<
204  ( (OtherDir[0]*fSeedDirection[0] +
205  OtherDir[1]*fSeedDirection[1] +
206  OtherDir[2]*fSeedDirection[2] ) / (ThisMag*OtherMag)) <<
207  std::endl;
208  */
209 
210 
211  // Need a tiny offset, as acos(1.0) gives unpredictable results due to
212  // floating point precision
213  double eta = 0.00001;
214 
215  return std::acos( ( OtherDir[0]*fSeedDirection[0] +
216  OtherDir[1]*fSeedDirection[1] +
217  OtherDir[2]*fSeedDirection[2] - eta) / (ThisMag*OtherMag));
218  }
double fSeedDirection[3]
Definition: Seed.h:28
double GetLength() const
Definition: Seed.cxx:155
void recob::Seed::GetDirection ( double *  Dir,
double *  Err 
) const

Definition at line 98 of file Seed.cxx.

99  {
100  for(int i=0; i!=3; i++)
101  {
102  rDir[i] = fSeedDirection[i];
103  if (rDirErr) rDirErr[i] = fSeedDirectionError[i];
104  }
105  }
double fSeedDirection[3]
Definition: Seed.h:28
double fSeedDirectionError[3]
Definition: Seed.h:30
double recob::Seed::GetDistance ( Seed const &  AnotherSeed) const

Definition at line 239 of file Seed.cxx.

240  {
241  double OtherPt[3];
242  double OtherPtErr[3];
243 
244  AnotherSeed.GetPoint( OtherPt, OtherPtErr );
245 
246  return pow( pow(OtherPt[0]-fSeedPoint[0],2)+
247  pow(OtherPt[1]-fSeedPoint[1],2)+
248  pow(OtherPt[2]-fSeedPoint[2],2), 0.5);
249  }
constexpr T pow(T x)
Definition: pow.h:72
double fSeedPoint[3]
Definition: Seed.h:27
double recob::Seed::GetDistanceFrom ( recob::SpacePoint const &  SomePoint) const

Definition at line 253 of file Seed.cxx.

254  {
255  double SPxyz[3];
256  SPxyz[0]=SomePoint.XYZ()[0];
257  SPxyz[1]=SomePoint.XYZ()[1];
258  SPxyz[2]=SomePoint.XYZ()[2];
259 
260  // std::cout<<"Seed Dir Vec " << fSeedDirection[0]<<" " <<fSeedDirection[1]<< " " << fSeedDirection[2]<<std::endl;
261 
262  double ThisSeedLength =
263  pow( pow(fSeedDirection[0],2) +
264  pow(fSeedDirection[1],2) +
265  pow(fSeedDirection[2],2) , 0.5);
266 
267 
268  double SPProjOnSeed =
269  ( fSeedDirection[0] * ( SPxyz[0] - fSeedPoint[0] ) +
270  fSeedDirection[1] * ( SPxyz[1] - fSeedPoint[1] ) +
271  fSeedDirection[2] * ( SPxyz[2] - fSeedPoint[2] ) )
272  / ThisSeedLength;
273 
274  // std::cout<<"proj : " <<SPProjOnSeed<<std::endl;
275  // std::cout<<"Seed len :" << ThisSeedLength<<std::endl;
276 
277  if(SPProjOnSeed > (ThisSeedLength))
278  {
279  // std::cout<<"Seed over end"<<std::endl;
280  return
281  pow(pow(fSeedPoint[0] + fSeedDirection[0] - SPxyz[0], 2) +
282  pow(fSeedPoint[1] + fSeedDirection[1] - SPxyz[1], 2) +
283  pow(fSeedPoint[2] + fSeedDirection[2] - SPxyz[2], 2), 0.5);
284  }
285  else if(SPProjOnSeed<(0-ThisSeedLength))
286  {
287  // std::cout<<"Seed under end"<<std::endl;
288  return
289  pow(pow(fSeedPoint[0] - fSeedDirection[0] - SPxyz[0], 2) +
290  pow(fSeedPoint[1] - fSeedDirection[1] - SPxyz[1], 2) +
291  pow(fSeedPoint[2] - fSeedDirection[2] - SPxyz[2], 2), 0.5);
292 
293  }
294  else
295  {
296  // std::cout<<"Seed valid region"<<std::endl;
297  double crossprod[3];
298  CrossProd( fSeedPoint[0]+fSeedDirection[0]-SPxyz[0],
299  fSeedPoint[1]+fSeedDirection[1]-SPxyz[1],
300  fSeedPoint[2]+fSeedDirection[2]-SPxyz[2],
301  SPxyz[0]-fSeedPoint[0],
302  SPxyz[1]-fSeedPoint[1],
303  SPxyz[2]-fSeedPoint[2],
304  crossprod[0], crossprod[1], crossprod[2]);
305 
306  return
307  pow( pow(crossprod[0],2) +
308  pow(crossprod[1],2) +
309  pow(crossprod[2],2), 0.5) /
310  pow( pow(fSeedDirection[0],2) +
311  pow(fSeedDirection[1],2) +
312  pow(fSeedDirection[2],2), 0.5);
313 
314  }
315  }
double fSeedDirection[3]
Definition: Seed.h:28
constexpr T pow(T x)
Definition: pow.h:72
void CrossProd(double x1, double x2, double x3, double y1, double y2, double y3, double &out1, double &out2, double &out3)
Definition: Seed.cxx:331
double fSeedPoint[3]
Definition: Seed.h:27
double recob::Seed::GetLength ( void  ) const

Definition at line 155 of file Seed.cxx.

156  {
157  return pow(pow(fSeedDirection[0],2)+
158  pow(fSeedDirection[1],2)+
159  pow(fSeedDirection[2],2),0.5);
160  }
double fSeedDirection[3]
Definition: Seed.h:28
constexpr T pow(T x)
Definition: pow.h:72
void recob::Seed::GetPoint ( double *  Pt,
double *  Err 
) const

Definition at line 108 of file Seed.cxx.

109  {
110  for(int i=0; i!=3; i++)
111  {
112  rPt[i] = fSeedPoint[i];
113  if (rPtErr) rPtErr[i] = fSeedPointError[i];
114  }
115  }
double fSeedPoint[3]
Definition: Seed.h:27
double fSeedPointError[3]
Definition: Seed.h:29
int recob::Seed::GetPointingSign ( Seed const &  AnotherSeed) const

Definition at line 318 of file Seed.cxx.

319  {
320  double OtherPos[3], OtherErr[3];
321  AnotherSeed.GetPoint(OtherPos,OtherErr);
322  double DotProd =
323  (OtherPos[0]-fSeedPoint[0])*fSeedDirection[0]+
324  (OtherPos[1]-fSeedPoint[1])*fSeedDirection[1]+
325  (OtherPos[2]-fSeedPoint[2])*fSeedDirection[2];
326  return ((DotProd>0)-(DotProd<0));
327  }
double fSeedDirection[3]
Definition: Seed.h:28
double DotProd(const Vector3_t &v1, const Vector3_t &v2)
Definition: PFPUtils.h:128
double fSeedPoint[3]
Definition: Seed.h:27
double recob::Seed::GetProjAngleDiscrepancy ( Seed const &  AnotherSeed) const

Definition at line 164 of file Seed.cxx.

165  {
166  double OtherPt[3];
167  double OtherPtErr[3];
168 
169  AnotherSeed.GetPoint( OtherPt, OtherPtErr );
170 
171  TVector3 OtherPtV( OtherPt[0], OtherPt[1], OtherPt[2] );
172  TVector3 ThisDirV( fSeedDirection[0], fSeedDirection[1], fSeedDirection[2] );
173  TVector3 ThisPtV( fSeedPoint[0], fSeedPoint[1], fSeedPoint[2] );
174 
175  return (OtherPtV-ThisPtV).Angle(ThisDirV.Unit());
176  }
double fSeedDirection[3]
Definition: Seed.h:28
double fSeedPoint[3]
Definition: Seed.h:27
double recob::Seed::GetProjDiscrepancy ( Seed const &  AnotherSeed) const

Definition at line 222 of file Seed.cxx.

223  {
224  double OtherPt[3];
225  double OtherPtErr[3];
226 
227  AnotherSeed.GetPoint( OtherPt, OtherPtErr );
228 
229  TVector3 OtherPtV( OtherPt[0], OtherPt[1], OtherPt[2] );
230  TVector3 ThisDirV( fSeedDirection[0], fSeedDirection[1], fSeedDirection[2] );
231  TVector3 ThisPtV( fSeedPoint[0], fSeedPoint[1], fSeedPoint[2] );
232 
233 
234  return ((OtherPtV-ThisPtV) - ThisDirV.Unit()*(ThisDirV.Unit().Dot(OtherPtV-ThisPtV))).Mag();
235  }
double fSeedDirection[3]
Definition: Seed.h:28
double fSeedPoint[3]
Definition: Seed.h:27
void recob::Seed::GetVectorBetween ( Seed const &  AnotherSeed,
double *  xyz 
) const

Definition at line 179 of file Seed.cxx.

180  {
181  double xyzother[3], err[3];
182  AnotherSeed.GetPoint(xyzother,err);
183 
184  xyz[0] = xyzother[0]-fSeedPoint[0];
185  xyz[1] = xyzother[1]-fSeedPoint[1];
186  xyz[2] = xyzother[2]-fSeedPoint[2];
187 
188  }
void err(const char *fmt,...)
Definition: message.cpp:226
double fSeedPoint[3]
Definition: Seed.h:27
bool recob::Seed::IsValid ( ) const

Definition at line 70 of file Seed.cxx.

71  {
72  return fIsValid;
73  }
bool fIsValid
Definition: Seed.h:31
void recob::Seed::Print ( void  ) const

Definition at line 55 of file Seed.cxx.

56  {
57  std::cout<<"Printing seed contents : "
58  << fSeedPoint[0]<<" "
59  <<fSeedPoint[1]<< " "
60  <<fSeedPoint[2]<<", "
61  << fSeedDirection[0]
62  <<" " <<fSeedDirection[1]
63  <<" " << fSeedDirection[2]
64  <<std::endl;
65 
66  }
double fSeedDirection[3]
Definition: Seed.h:28
double fSeedPoint[3]
Definition: Seed.h:27
QTextStream & endl(QTextStream &s)
Seed recob::Seed::Reverse ( )

Definition at line 77 of file Seed.cxx.

78  {
79  double NewSeedDir[3];
80  for(size_t n=0; n!=3; ++n)
81  {
82  NewSeedDir[n]=-fSeedDirection[n];
83  }
84  return Seed(fSeedPoint, NewSeedDir, fSeedPointError, fSeedDirectionError);
85 
86  }
double fSeedDirection[3]
Definition: Seed.h:28
double fSeedDirectionError[3]
Definition: Seed.h:30
std::void_t< T > n
double fSeedPoint[3]
Definition: Seed.h:27
double fSeedPointError[3]
Definition: Seed.h:29
void recob::Seed::SetDirection ( double *  Dir,
double *  Err 
)

Definition at line 133 of file Seed.cxx.

134  {
135  for(int i=0; i!=3; i++)
136  {
137  fSeedDirection[i] = Dir[i];
138  fSeedDirectionError[i] = Err[i];
139  }
140  fIsValid=true;
141  }
double fSeedDirection[3]
Definition: Seed.h:28
bool fIsValid
Definition: Seed.h:31
double fSeedDirectionError[3]
Definition: Seed.h:30
void recob::Seed::SetDirection ( double *  Dir)

Definition at line 119 of file Seed.cxx.

120  {
121  double Empty[3]={0,0,0};
122  SetDirection(Dir, Empty);
123  }
void SetDirection(double *Dir, double *Err)
Definition: Seed.cxx:133
void recob::Seed::SetPoint ( double *  Pt,
double *  Err 
)

Definition at line 144 of file Seed.cxx.

145  {
146  for(int i=0; i!=3; i++)
147  {
148  fSeedPoint[i] = Pt[i];
149  fSeedPointError[i] = Err[i];
150  }
151  fIsValid=true;
152  }
bool fIsValid
Definition: Seed.h:31
double fSeedPoint[3]
Definition: Seed.h:27
double fSeedPointError[3]
Definition: Seed.h:29
void recob::Seed::SetPoint ( double *  Pt)

Definition at line 126 of file Seed.cxx.

127  {
128  double Empty[3]={0,0,0};
129  SetPoint(Pt, Empty);
130  }
void SetPoint(double *Pt, double *Err)
Definition: Seed.cxx:144
void recob::Seed::SetValidity ( bool  Validity)

Definition at line 90 of file Seed.cxx.

91  {
92  fIsValid=Validity;
93  }
bool fIsValid
Definition: Seed.h:31

Friends And Related Function Documentation

bool operator< ( const Seed a,
const Seed b 
)
friend

Definition at line 357 of file Seed.cxx.

358  {
359  if (a.fSeedPoint[2] != b.fSeedPoint[2])
360  { return a.fSeedPoint[2] < b.fSeedPoint[2]; }
361  else if (a.fSeedPoint[1] != b.fSeedPoint[1])
362  { return a.fSeedPoint[1] < b.fSeedPoint[1]; }
363 
364  return a.fSeedPoint[0] < b.fSeedPoint[0];
365 
366  }
const double a
static bool * b
Definition: config.cpp:1043
std::ostream& operator<< ( std::ostream &  stream,
Seed const &  a 
)
friend

Definition at line 341 of file Seed.cxx.

342  {
343  o << "Printing seed contents : "
344  << a.fSeedPoint[0] << " "
345  << a.fSeedPoint[1] << " "
346  << a.fSeedPoint[2] << ", "
347  << a.fSeedDirection[0] << " "
348  << a.fSeedDirection[1] << " "
349  << a.fSeedDirection[2];
350 
351  return o;
352  }
const double a

Member Data Documentation

bool recob::Seed::fIsValid
private

Definition at line 31 of file Seed.h.

double recob::Seed::fSeedDirection[3]
private

Definition at line 28 of file Seed.h.

double recob::Seed::fSeedDirectionError[3]
private

Definition at line 30 of file Seed.h.

double recob::Seed::fSeedPoint[3]
private

Definition at line 27 of file Seed.h.

double recob::Seed::fSeedPointError[3]
private

Definition at line 29 of file Seed.h.


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