BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcSagTraj.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: MdcSagTraj.cxx,v 1.3 2009/12/17 00:38:40 zhangy Exp $
4//
5// Description:
6// Class MdcSagTraj
7//
8//
9//
10// Environment:
11// Software developed for the BaBar Detector at the SLAC B-Factory.
12//
13// Author List:
14// R. Stroili originator
15//
16//
17// Copyright Information:
18// Copyright (C) 1998 INFN & Padova University
19//
20// History:
21// Migration for BESIII MDC
22//
23//------------------------------------------------------------------------
24
25//-----------------------
26// This Class's Header --
27//-----------------------
28#include "MdcGeom/MdcSagTraj.h"
29
30//-------------
31// C Headers --
32//-------------
33extern "C" {}
34
35//---------------
36// C++ Headers --
37//---------------
38#include <assert.h>
39
40//-------------------------------
41// Collaborating Class Headers --
42//-------------------------------
43#include "MdcGeom/Trajectory.h"
44
45//-----------------------------------------------------------------------
46// Local Macros, Typedefs, Structures, Unions and Forward Declarations --
47//-----------------------------------------------------------------------
48
49// ----------------------------------------
50// -- Public Function Member Definitions --
51// ----------------------------------------
52
53//----------------
54// Constructors --
55//----------------
56MdcSagTraj::MdcSagTraj( const double sag, const HepPoint3D& start, const HepPoint3D& stop )
57 : TrkGeomTraj( 0.0, start.distance( stop ) ), _sag( sag ), _start( start ), _stop( stop ) {
58 //_direction = stop - start;
59 _direction = ( (CLHEP::Hep3Vector)stop ) - ( (CLHEP::Hep3Vector)start );
60 _length = _direction.mag();
61 assert( _length != 0 );
62
63 _direction.setMag( 1.0 );
64 _a = _sag * 4. / ( _length * _length );
65 _b = -_a * _length;
66}
67
69 : TrkGeomTraj( 0.0, other._start.distance( other._stop ) )
70 , _sag( other._sag )
71 , _a( other._a )
72 , _b( other._b )
73 , _length( other._length )
74 , _start( other._start )
75 , _stop( other._stop )
76 , _direction( other._direction ) {}
77
79//-------------
80// Methods --
81//-------------
82MdcSagTraj* MdcSagTraj::clone() const { return new MdcSagTraj( *this ); }
83
84//-------------
85// Operators --
86//-------------
87//-----------------------------------------------------------------------------
89 if ( &other != this )
90 {
91 for ( int iend = 0; iend < 2; iend++ ) flightrange[iend] = other.flightrange[iend];
92 _start = other._start;
93 _stop = other._stop;
94 _sag = other._sag;
95 _a = other._a;
96 _b = other._b;
97 _length = other._length;
98 _direction = other._direction;
99 }
100 return *this;
101}
102
103Hep3Vector MdcSagTraj::deviation( double flightlen ) const {
104 // only correction in y
105 // Hep3Vector deviation(0., (_a*flightlen+_b)*flightlen, 0.);
106 // Hep3Vector deviaH(0.,cosh((flightlen-_length/2.)/_a_H)+_b_H,0.);
107 // return deviation;
108 return Hep3Vector( 0., ( _a * flightlen + _b ) * flightlen, 0. );
109}
110
111HepPoint3D MdcSagTraj::position( double flightlen ) const {
112 static HepPoint3D tmppos;
113 tmppos = _start;
114 // CHANGE tmppos += _direction*flightlen;
115 tmppos += (HepPoint3D)_direction * flightlen; // yzhang TEMP
116 tmppos.setY( tmppos.y() + ( _a * flightlen + _b ) * flightlen );
117 return tmppos;
118}
119
120Hep3Vector MdcSagTraj::direction( double flightlen ) const {
121 if ( flightlen <= 0. ) return _direction;
122 // Hep3Vector dir = _direction*flightlen + delDirect(flightlen);
123 static Hep3Vector tmpdir;
124 tmpdir = _direction * flightlen;
125 // register double newy = tmpdir.y() + 2.*_a*flightlen+_b;
126 // tmpdir.setY(newy);
127 tmpdir.setY( tmpdir.y() + 2. * _a * flightlen + _b );
128 // tmpdir += delDirect(flightlen);
129 tmpdir.setMag( 1.0 );
130 return tmpdir;
131}
132
133Hep3Vector MdcSagTraj::delDirect( double /*flightlen*/ ) const {
134 return Hep3Vector( 0., 2. * _a, 0. );
135}
136
137void MdcSagTraj::getInfo( double flightlen, HepPoint3D& pos, Hep3Vector& dir ) const {
138 // std::cout<<"Dyz*"<<"MdcSagTraj01 "<<std::endl;//yzhang DEBUG
139 // Written using +=, etc to avoid temporaries
140 pos = _start;
141 // CHANGE pos += _direction*flightlen;
142 pos += (HepPoint3D)_direction * flightlen;
143
144 dir = _direction;
145 if ( flightlen > 0. )
146 {
147 pos.setY( pos.y() + deltaY( flightlen ) );
148 dir.setY( dir.y() + 2. * _a * flightlen + _b );
149 dir.setMag( 1.0 );
150 }
151}
152
153void MdcSagTraj::getInfo( double flightlen, HepPoint3D& pos, Hep3Vector& dir,
154 Hep3Vector& delDir ) const {
155 // std::cout<<"Dyz*"<<"MdcSagTraj011 "<<std::endl;//yzhang DEBUG
156
157 pos = _start;
158 // CHANGE pos += _direction*flightlen ;
159 pos += (HepPoint3D)_direction * flightlen;
160
161 pos.setY( pos.y() + ( _a * flightlen + _b ) * flightlen );
162
163 dir = _direction;
164 dir.setY( dir.y() + 2 * _a * flightlen + _b );
165 // Note: `dir' is on purpose not normalized (WDH, Jan 2003)
166
167 delDir.setX( 0. );
168 delDir.setY( 2. * _a );
169 delDir.setZ( 0. );
170}
171
172double MdcSagTraj::curvature( double /*f*/ ) const { return _sag; }
173
174double MdcSagTraj::distTo1stError( double flightlen, double tol, int pathDir ) const {
175 double dtmp = pathDir * 2. * _a * flightlen + _b;
176
177 return dtmp == 0. ? 9999.e4 : fabs( tol / dtmp );
178}
179
180double MdcSagTraj::distTo2ndError( double /*s*/, double /*tol*/, int /*pathDir*/ ) const {
181 return 999.e4;
182 // return _a==0. ? 999.e4 : tol/(2.*_a);
183}
184
185// Support Visitor pattern (see TrkGeomTraj.h)
186void MdcSagTraj::accept( TrkGeomTrajVisitor& /*visitor*/ ) const {
187 std::cout << "ErrMsg(error)"
188 << "accept visitor NOT implemented yet" << std::endl;
189}
virtual ~MdcSagTraj()
HepPoint3D position(double) const
double curvature(double f=0.) const
MdcSagTraj & operator=(const MdcSagTraj &)
MdcSagTraj * clone() const
Hep3Vector delDirect(double) const
void getInfo(double fltLen, HepPoint3D &, Hep3Vector &direction) const
virtual double distTo2ndError(double s, double tol, int pathDir) const
virtual double distTo1stError(double s, double tol, int pathDir) const
MdcSagTraj(const double sag, const HepPoint3D &point1, const HepPoint3D &point2)
Hep3Vector direction(double) const
void accept(TrkGeomTrajVisitor &visitor) const
TrkGeomTraj(double lowlim, double hilim)