BOSS 8.0.0
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 "TrkBase/TrkPoca.h"
16#include "CLHEP/Geometry/Point3D.h"
17#include "CLHEP/Matrix/Vector.h"
18#include "CLHEP/Vector/ThreeVector.h"
19#include "MdcGeom/Trajectory.h"
20#include "TrkBase/TrkErrCode.h"
21
22TrkPoca::TrkPoca( const Trajectory& traj1, double f1, const Trajectory& traj2, double f2,
23 double prec )
24 : TrkPocaBase( f1, f2, prec ), _doca( -9999. ) {
25 minimize( traj1, f1, traj2, f2 );
26 if ( status().failure() ) return;
27 calcDist( traj1, traj2 );
28}
29
30TrkPoca::TrkPoca( const Trajectory& traj, double flt, const HepPoint3D& pt, double prec )
31 : TrkPocaBase( flt, prec ) {
32 minimize( traj, flt, pt );
33 if ( status().failure() ) return;
34 _doca = ( traj.position( flt1() ) - pt ).mag();
35}
36
37void TrkPoca::calcDist( const Trajectory& traj1, const Trajectory& traj2 ) {
38 // Does a final calculation of the distance -- getting the sign right.
39 // In case of (nearly) parallel, returns error and distance.
40
41 // A bunch of unsightly uninitialized variables:
42 static Hep3Vector dir1, dir2;
43 static HepPoint3D pos1, pos2;
44
45 traj1.getInfo( flt1(), pos1, dir1 );
46 traj2.getInfo( flt2(), pos2, dir2 );
47 Hep3Vector delta = ( (CLHEP::Hep3Vector)pos2 ) - ( (CLHEP::Hep3Vector)pos1 );
48 Hep3Vector between = dir1.cross( dir2 ); // cross-product
49
50 if ( status().success() != 3 )
51 { // Not parallel:
52 between = between.unit();
53 _doca = delta.dot( between );
54 }
55 else
56 { // Parallel:
57 // Arbitrary sign convention
58 double sign = ( dir1.dot( dir2 ) > 0. ) ? -1. : 1.;
59 _doca = ( delta - delta.dot( dir1 ) * dir1 ).mag();
60 _doca *= sign;
61 }
62}
HepGeom::Point3D< double > HepPoint3D
TFile * f1
virtual HepPoint3D position(double) const =0
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &direction) const =0
TrkPocaBase(double flt1, double flt2, double precision)
void minimize(const Trajectory &traj1, double f1, const Trajectory &traj2, double f2)
TrkPoca(const Trajectory &traj1, double flt1, const Trajectory &traj2, double flt2, double precision=1.e-5)
Definition TrkPoca.cxx:22