22 #include "cetlib_except/exception.h" 59 for(
unsigned int p=0; p!=BezierPoints.size()-1; ++p)
61 Length+=(BezierPoints.at(p+1)-BezierPoints.at(p)).Mag();
76 for(
int i=0; i!=3; ++i) PtSepVec[i]=Pt2[i]-Pt1[i];
81 pow(PtSepVec[2],2),0.5);
83 double Dir1Length = pow(Dir1[0]*Dir1[0]+
87 double Dir2Length = pow(Dir2[0]*Dir2[0]+
91 if((PtSepVec[0]*Dir1[0]+PtSepVec[1]*Dir1[1]+PtSepVec[2]*Dir1[2])>0)
92 Scales[0] = PtSep / (3.*Dir1Length);
94 Scales[0] = 0 - PtSep / (3.*Dir1Length);
96 if((PtSepVec[0]*Dir2[0]+PtSepVec[1]*Dir2[1]+PtSepVec[2]*Dir2[2])>0)
97 Scales[1] = 0 - PtSep / (3.*Dir2Length);
99 Scales[1] = PtSep / (3.*Dir2Length);
111 xyz[0]=BezierPoint[0];
112 xyz[1]=BezierPoint[1];
113 xyz[2]=BezierPoint[2];
134 double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Mid3[3], Dummy[3];
140 if(s<=0.)
return TVector3(Pt1[0],Pt1[1],Pt1[2]);
141 if(s>=1.)
return TVector3(Pt2[0],Pt2[1],Pt2[2]);
143 TVector3 pt1(Pt1[0],Pt1[1],Pt1[2]);
144 TVector3 pt2(Pt2[0],Pt2[1],Pt2[2]);
145 TVector3 dir1(Dir1[0],Dir1[1],Dir1[2]);
146 TVector3 dir2(Dir2[0],Dir2[1],Dir2[2]);
148 double lambda1 = (pt1-pt2).Dot(dir1-dir2)/(pow(dir2.Dot(dir1),2)-dir2.Mag2()*dir1.Mag2());
149 double lambda2 = (pt2-pt1).Dot(dir2-dir1)/(pow(dir1.Dot(dir2),2)-dir1.Mag2()*dir2.Mag2());
154 if(lambda1>0) Sign1=1;
157 if(lambda2>0) Sign2=1;
161 for(
int i=0; i!=3; i++)
163 Mid1[i]=Pt1[i] + Sign1*Dir1[i];
164 Mid2[i]=0.5*(Pt1[i] + lambda1 * Dir1[i] + Pt2[i] +lambda2 * Dir2[i]);
165 Mid3[i]=Pt2[i] - Sign2*Dir2[i];
168 + 4.*ns*ns*ns*s * Mid1[i]
169 + 6.*ns*ns*s*s * Mid2[i]
170 + 4.*ns*s*s*s * Mid3[i]
185 double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Dummy[3];
191 if(s<=0.)
return TVector3(Pt1[0],Pt1[1],Pt1[2]);
192 if(s>=1.)
return TVector3(Pt2[0],Pt2[1],Pt2[2]);
199 for(
int i=0; i!=3; i++)
201 Mid1[i]=Pt1[i]+Dir1[i]*DirScales[0];
202 Mid2[i]=Pt2[i]+Dir2[i]*DirScales[1];
204 ns * ns * ns * Pt1[i]
205 + 3.* ns * ns * s * Mid1[i]
206 + 3.* ns * s * s * Mid2[i]
207 + s * s * s * Pt2[i];
236 std::vector<TVector3> ReturnVec;
239 double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Dummy[3];
249 for(
int i=0; i!=3; i++)
251 Mid1[i]=Pt1[i]+Dir1[i]*DirScales[0];
252 Mid2[i]=Pt2[i]+Dir2[i]*DirScales[1];
253 for(
int p=0; p!=N; p++)
255 double t = float(p) / float(N-1);
259 + 3.*nt*nt*t * Mid1[i]
260 + 3.*nt*t*t * Mid2[i]
274 std::vector<TVector3> ReturnVec;
277 double Pt1[3], Pt2[3], Dir1[3], Dir2[3], Mid1[3], Mid2[3], Mid3[3], Dummy[3];
283 TVector3 pt1(Pt1[0],Pt1[1],Pt1[2]);
284 TVector3 pt2(Pt2[0],Pt2[1],Pt2[2]);
285 TVector3 dir1(Dir1[0],Dir1[1],Dir1[2]);
286 TVector3 dir2(Dir2[0],Dir2[1],Dir2[2]);
289 double lambda1 = (pt1-pt2).Dot(dir1-dir2)/(pow(dir2.Dot(dir1),2)-dir2.Mag2()*dir1.Mag2());
290 double lambda2 = (pt2-pt1).Dot(dir2-dir1)/(pow(dir1.Dot(dir2),2)-dir1.Mag2()*dir2.Mag2());
294 if(lambda1>0) Sign1=1;
297 if(lambda2>0) Sign2=1;
300 for(
int i=0; i!=3; i++)
304 Mid1[i]=Pt1[i] + Sign1*Dir1[i];
305 Mid2[i]=0.5*(Pt1[i] + lambda1 * Dir1[i] + Pt2[i] +lambda2 * Dir2[i]);
306 Mid3[i]=Pt2[i] - Sign2*Dir2[i];
307 for(
int p=0; p!=N; p++)
309 double t = float(p) / float(N-1);
313 + 4.*nt*nt*nt*t * Mid1[i]
314 + 6.*nt*nt*t*t * Mid2[i]
315 + 4.*nt*t*t*t * Mid3[i]
TVector3 GetBezierPointQuartic(recob::Seed const &s1, recob::Seed const &s2, float t)
TVector3 GetBezierPoint(recob::Seed const &s1, recob::Seed const &s2, float t)
Declaration of signal hit object.
void GetPoint(double *Pt, double *Err) const
TVector3 GetBezierPointCubic(recob::Seed const &s1, recob::Seed const &s2, float t)
std::vector< TVector3 > GetBezierPointsCubic(recob::Seed const &s1, recob::Seed const &s2, int N=100)
Service for finding 3D track seeds.
double GetSegmentLength(recob::Seed const &s1, recob::Seed const &s2)
void GetDirectionScales(double *Pt1, double *Pt2, double *Dir1, double *Dir2, double *Scales)
void GetBezierPointXYZ(recob::Seed const &s1, recob::Seed const &s2, float t, double *xyz)
std::vector< TVector3 > GetBezierPoints(recob::Seed const &s1, recob::Seed const &s2, int N=100)
void GetDirection(double *Dir, double *Err) const
std::vector< TVector3 > GetBezierPointsQuartic(recob::Seed const &s1, recob::Seed const &s2, int N=100)