00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "MdcGeom/MdcSagTraj.h"
00029
00030
00031
00032
00033 extern "C" {
00034 }
00035
00036
00037
00038
00039 #include <assert.h>
00040
00041
00042
00043
00044 #include "MdcGeom/Trajectory.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 MdcSagTraj::MdcSagTraj( const double sag, const HepPoint3D& start,
00058 const HepPoint3D& stop )
00059 : TrkGeomTraj(0.0,start.distance(stop)), _sag(sag), _start(start), _stop(stop)
00060 {
00061
00062 _direction = ((CLHEP::Hep3Vector) stop) - ((CLHEP::Hep3Vector) start);
00063 _length = _direction.mag();
00064 assert( _length != 0 );
00065
00066 _direction.setMag(1.0);
00067 _a = _sag*4./(_length*_length);
00068 _b = -_a*_length;
00069
00070 }
00071
00072 MdcSagTraj::MdcSagTraj( const MdcSagTraj& other )
00073 : TrkGeomTraj(0.0,other._start.distance(other._stop)),
00074 _sag(other._sag), _a(other._a), _b(other._b), _length(other._length),
00075 _start(other._start), _stop(other._stop),
00076 _direction(other._direction)
00077 {}
00078
00079 MdcSagTraj::~MdcSagTraj(){;}
00080
00081
00082
00083 MdcSagTraj*
00084 MdcSagTraj::clone() const
00085 {
00086 return new MdcSagTraj(*this);
00087 }
00088
00089
00090
00091
00092
00093 MdcSagTraj&
00094 MdcSagTraj::operator = (const MdcSagTraj& other)
00095 {
00096 if(&other != this){
00097 for(int iend=0;iend<2;iend++)
00098 flightrange[iend] = other.flightrange[iend];
00099 _start = other._start;
00100 _stop = other._stop;
00101 _sag = other._sag;
00102 _a = other._a;
00103 _b = other._b;
00104 _length = other._length;
00105 _direction = other._direction;
00106 }
00107 return *this;
00108 }
00109
00110 Hep3Vector
00111 MdcSagTraj::deviation( double flightlen ) const
00112 {
00113
00114
00115
00116
00117 return Hep3Vector(0., (_a*flightlen+_b)*flightlen, 0.);
00118 }
00119
00120 HepPoint3D
00121 MdcSagTraj::position(double flightlen) const
00122 {
00123 static HepPoint3D tmppos;
00124 tmppos = _start;
00125
00126 tmppos += (HepPoint3D) _direction*flightlen;
00127 tmppos.setY(tmppos.y()+(_a*flightlen+_b)*flightlen);
00128 return tmppos;
00129 }
00130
00131 Hep3Vector
00132 MdcSagTraj::direction( double flightlen ) const {
00133 if ( flightlen <= 0. ) return _direction;
00134
00135 static Hep3Vector tmpdir;
00136 tmpdir = _direction*flightlen;
00137
00138
00139 tmpdir.setY(tmpdir.y() + 2.*_a*flightlen+_b);
00140
00141 tmpdir.setMag(1.0);
00142 return tmpdir;
00143 }
00144
00145 Hep3Vector
00146 MdcSagTraj::delDirect( double ) const
00147 {
00148 return Hep3Vector(0., 2.*_a, 0.);
00149 }
00150
00151 void
00152 MdcSagTraj::getInfo(double flightlen, HepPoint3D& pos, Hep3Vector& dir) const
00153 {
00154
00155
00156 pos = _start;
00157
00158 pos += (HepPoint3D) _direction*flightlen;
00159
00160 dir = _direction;
00161 if ( flightlen > 0. ) {
00162 pos.setY(pos.y() + deltaY(flightlen));
00163 dir.setY(dir.y() + 2.*_a*flightlen+_b);
00164 dir.setMag(1.0);
00165 }
00166 }
00167
00168 void
00169 MdcSagTraj::getInfo( double flightlen, HepPoint3D& pos, Hep3Vector& dir,
00170 Hep3Vector& delDir ) const
00171 {
00172
00173
00174 pos = _start;
00175
00176 pos += (HepPoint3D) _direction*flightlen ;
00177
00178 pos.setY( pos.y() + (_a*flightlen+_b)*flightlen) ;
00179
00180 dir = _direction;
00181 dir.setY( dir.y() + 2*_a*flightlen+_b) ;
00182
00183
00184 delDir.setX(0.);
00185 delDir.setY(2.*_a);
00186 delDir.setZ(0.);
00187 }
00188
00189 double
00190 MdcSagTraj::curvature( double ) const
00191 {
00192 return _sag;
00193 }
00194
00195 double
00196 MdcSagTraj::distTo1stError(double flightlen, double tol, int pathDir) const
00197 {
00198 double dtmp = pathDir*2.*_a*flightlen+_b;
00199
00200 return dtmp==0. ? 9999.e4 : fabs(tol/dtmp);
00201 }
00202
00203 double
00204 MdcSagTraj::distTo2ndError(double , double , int ) const
00205 {
00206 return 999.e4 ;
00207
00208 }
00209
00210
00211 void
00212 MdcSagTraj::accept(TrkGeomTrajVisitor& ) const
00213 {
00214 std::cout<<"ErrMsg(error)"<<"accept visitor NOT implemented yet"<<std::endl;
00215 }
00216