CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkPoca.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkPoca.cxx,v 1.4 2010/09/26 00:31:59 zhangy Exp $
4//
5// Description:
6//
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Author(s): Steve Schaffner, largely taken from Art Snyder
12//
13//------------------------------------------------------------------------
14//#include "BaBar/BaBar.h"
15#include "MdcGeom/Trajectory.h"
16#include "TrkBase/TrkPoca.h"
17#include "CLHEP/Vector/ThreeVector.h"
18#include "CLHEP/Matrix/Vector.h"
19#include "CLHEP/Geometry/Point3D.h"
20#include "TrkBase/TrkErrCode.h"
21
22TrkPoca::TrkPoca(const Trajectory& traj1, double f1,
23 const Trajectory& traj2, double f2, double prec)
24: TrkPocaBase(f1,f2,prec), _doca(-9999.)
25{
26 minimize(traj1,f1,traj2,f2);
27 if (status().failure()) return;
28 calcDist(traj1,traj2);
29}
30
31TrkPoca::TrkPoca(const Trajectory& traj, double flt,
32 const HepPoint3D& pt, double prec)
33: TrkPocaBase(flt,prec)
34{
35 minimize(traj,flt,pt);
36 if (status().failure()) return;
37 _doca = (traj.position(flt1()) - pt).mag();
38}
39
40void
41TrkPoca::calcDist(const Trajectory& traj1, const Trajectory& traj2)
42{
43 // Does a final calculation of the distance -- getting the sign right.
44 // In case of (nearly) parallel, returns error and distance.
45
46 // A bunch of unsightly uninitialized variables:
47 static Hep3Vector dir1,dir2;
48 static HepPoint3D pos1,pos2;
49
50 traj1.getInfo(flt1(), pos1, dir1);
51 traj2.getInfo(flt2(), pos2, dir2);
52 Hep3Vector delta = ((CLHEP::Hep3Vector)pos2) - ((CLHEP::Hep3Vector)pos1);
53 Hep3Vector between = dir1.cross( dir2 ); // cross-product
54
55 if (status().success() != 3) { // Not parallel:
56 between = between.unit();
57 _doca = delta.dot(between);
58 } else { // Parallel:
59 // Arbitrary sign convention
60 double sign = (dir1.dot(dir2) > 0.) ? -1. : 1.;
61 _doca = (delta - delta.dot(dir1) * dir1).mag();
62 _doca *= sign;
63 }
64}
TFile * f1
virtual HepPoint3D position(double) const =0
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &direction) const =0
void minimize(const Trajectory &traj1, double f1, const Trajectory &traj2, double f2)
Definition: TrkPocaBase.cxx:32
TrkPoca(const Trajectory &traj1, double flt1, const Trajectory &traj2, double flt2, double precision=1.e-5)
Definition: TrkPoca.cxx:22