BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrkReco/include/TrkReco/TRunge.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TRunge.h,v 1.28 2012/05/28 05:16:29 maoh Exp $
3//-----------------------------------------------------------------------------
4// Filename : TRunge.h
5// Section : Tracking
6// Owner : Kenji Inami
7// Email : inami@bmail.kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to represent a track using Runge Kutta method
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13// #ifdef TRKRECO_DEBUG_DETAIL
14// #define TRKRECO_DEBUG
15// #endif
16#ifndef TRUNGE_FLAG_
17#define TRUNGE_FLAG_
18
19#define Runge 64
20// This must be writen in TTrackBase.h
21
22// #define HEP_SHORT_NAMES
23#ifndef CLHEP_POINT3D_H
24# include "CLHEP/Geometry/Point3D.h"
25#endif
26#ifndef ENABLE_BACKWARDS_COMPATIBILITY
27typedef HepGeom::Point3D<double> HepPoint3D;
28#endif
29
30#ifndef CLHEP_VECTOR3D_H
31# include "CLHEP/Geometry/Vector3D.h"
32#endif
33#ifndef ENABLE_BACKWARDS_COMPATIBILITY
34typedef HepGeom::Vector3D<double> HepVector3D;
35#endif
36typedef HepGeom::Transform3D HepTransform3D;
37// #include "helix/Helix.h"
38// #include "coil/Bfield.h"
39// #include "TrkReco/Helix.h"
40#include "TrackUtil/Bfield.h"
41#include "TrackUtil/Helix.h"
42#include "TrkReco/TRunge.h"
43#include "TrkReco/TTrackBase.h"
44
45#include "GaudiKernel/IInterface.h"
46#include "GaudiKernel/Kernel.h"
47#include "GaudiKernel/Service.h"
48#include "MagneticFieldSvc/IBesMagFieldSvc.h"
49// #include "MagneticField/MagneticFieldSvc.h"
50
51#include "CLHEP/Geometry/Point3D.h"
52#include "CLHEP/Geometry/Transform3D.h"
53#include "CLHEP/Matrix/SymMatrix.h"
54#include "CLHEP/Matrix/Vector.h"
55#include "CLHEP/Vector/LorentzVector.h"
56#include "CLHEP/Vector/ThreeVector.h"
57#include "MdcRecEvent/RecMdcTrack.h"
58#include "TrkReco/RkFitMaterial.h"
59class TRungeFitter;
60class TTrack;
61class TMLink;
62
63#define TRunge_MAXstep 10000
64/// A class to represent a track in tracking.
65class TRunge : public TTrackBase {
66
67public:
68 /// Constructors
70 TRunge( const TTrack& );
71 TRunge( const Helix& );
72 TRunge( const TRunge& );
74 /// Destructor
76
77public: // General information
78 /// returns object type
79 unsigned objectType( void ) const;
80
81public: // Extractors
82 /// Track parameters (at pivot)
83 double dr( void ) const;
84 double phi0( void ) const;
85 double kappa( void ) const;
86 double dz( void ) const;
87 double tanl( void ) const;
88
89 /// pivot position
90 const HepPoint3D& pivot( void ) const;
91
92 /// returns helix parameter
93 const Vector& a( void ) const;
94
95 /// returns error matrix
96 const SymMatrix& Ea( void ) const;
97
98 /// returns helix class
99 Helix helix( void ) const;
100
101 /// returns NDF
102 unsigned ndf( void ) const;
103
104 /// returns chi2.
105 double chi2( void ) const;
106
107 /// returns reduced-chi2
108 double reducedchi2( void ) const;
109
110 /// returns B field ID
111 int BfieldID( void ) const;
112
113 /// returns step size
114 double StepSize( void ) const;
115
116 /// return error parameters for fitting with step size control
117 const double* Yscal( void ) const;
118 double Eps( void ) const;
119 double StepSizeMax( void ) const;
120 double StepSizeMin( void ) const;
121
122 /// return mass
123 float Mass( void ) const;
124
125 /// return max flight length
126 double MaxFlightLength( void ) const;
127
128public: // Executors
129public: // Utilities
130 /// calculates the closest approach to a wire in real space.
131 /// Results are stored in TMLink. Return value is negative if error happened.
132 int approach( TMLink&, const RkFitMaterial, bool sagCorrection = true );
133 int approach( TMLink&, float& tof, HepVector3D& p, const RkFitMaterial,
134 bool sagCorrection = true );
135
136 /// caluculate closest points between a line and this track
137 int approach_line( TMLink&, const HepPoint3D&, const HepVector3D&, HepPoint3D& onLine,
138 HepPoint3D& onTrack, const RkFitMaterial material );
139 int approach_line( TMLink&, const HepPoint3D&, const HepVector3D&, HepPoint3D& onLine,
140 HepPoint3D& onTrack, float& tof, HepVector3D& p,
141 const RkFitMaterial material );
142 int approach_line( TMLink&, const HepPoint3D&, const HepVector3D&, HepPoint3D& onLine,
143 HepPoint3D& onTrack, float& tof, HepVector3D& p,
144 const RkFitMaterial material, unsigned& stepNum );
145
146 /// caluculate closest point between a point and this track
148 const RkFitMaterial material );
149
150public: // Modifiers
151 /// set new pivot
152 const HepPoint3D& pivot( const HepPoint3D& );
153
154 /// set helix parameter
155 const Vector& a( const Vector& );
156
157 /// set helix error matrix
158 const SymMatrix& Ea( const SymMatrix& );
159
160 /// set B field map ID
161 int BfieldID( int );
162
163 /// set step size to calc. trajectory
164 double StepSize( double );
165
166 /// set error parameters for fitting with step size control
167 const double* Yscal( const double* );
168 double Eps( double );
169 double StepSizeMax( double );
170 double StepSizeMin( double );
171
172 /// set mass for tof calc.
173 float Mass( float );
174
175 // set max flight length
176 double MaxFlightLength( double );
177
178 double DisToWire( TMLink&, double, HepPoint3D, HepPoint3D& );
179 double dEpath( double, double, double ) const;
180 void eloss( double path, const RkFitMaterial* material, double mass, double y[6],
181 int index ) const;
182
183public: // utilities for local use
184 /// make the trajectory in cache, return the number of step
185 unsigned Fly( const RkFitMaterial material );
186 unsigned Fly_SC( void ); // fly with stepsize control
187 double intersect_cylinder( double r ) const;
188 double intersect_yz_plane( const HepTransform3D& plane, double x ) const;
189 double intersect_zx_plane( const HepTransform3D& plane, double y ) const;
190 double intersect_xy_plane( double z ) const;
191 /// propagate the track using 4th-order Runge-Kutta method
192 void Propagate( double y[6], const double& step, const RkFitMaterial material );
193 void Function( const double y[6], double f[6] );
194 // for propagate with quality check
195 void Propagate1( const double y[6], const double dydx[6], const double& step,
196 double yout[6] );
197 void Propagate_QC( double y[6], double dydx[6], const double& steptry, const double& eps,
198 const double yscal[6], double& stepdid, double& stepnext );
199
200 /// set first point (position, momentum) s=0, phi=0
201 void SetFirst( double y[6] ) const;
202 /// access to trajectory cache
203 unsigned Nstep( void ) const;
204 int GetXP( unsigned stepNum, double y[6] ) const;
205 // y[6] = (x,y,z,px,py,pz) output: error=-1
206 int GetStep( unsigned stepNum, double& step ) const;
207
208 /// set flight length using wire hits
209 double SetFlightLength( void );
210
211private:
212 // track parameters updated when fitted
213 HepPoint3D _pivot;
214 Vector _a; // dr,phi0,kappa,dz,tanl
215 SymMatrix _Ea;
216
217 double _chi2;
218 unsigned _ndf;
219
220 static TRungeFitter _fitter;
221
222 friend class TRungeFitter;
223
224 Bfield* _bfield;
225 int _bfieldID;
226
227 double _maxflightlength;
228
229 double _stepSize; // default step size
230 // if 0, step size will be made automatically
231 double _yscal[6];
232 double _eps; // used for step size control
233 double _stepSizeMax;
234 double _stepSizeMin;
235
236 float _mass;
237 const RkFitMaterial FitMdcMaterial;
238
239private:
240 // caches
241 float _mass2; //=_mass*_mass;
242 int _charge;
243
244 mutable double _y[TRunge_MAXstep][6]; //(x,y,z,px,py,pz)
245 mutable double _h[TRunge_MAXstep]; // step size in each step
246 mutable unsigned _Nstep; // 0:not cached the trajectory
247private:
248 IBesMagFieldSvc* getPmgnIMF() const;
249 mutable IBesMagFieldSvc* m_pmgnIMF;
250};
251
252inline unsigned TRunge::objectType( void ) const { return Runge; }
253#endif /* TRUNGE_FLAG_ */
HepGeom::Vector3D< double > HepVector3D
double mass
HepGeom::Point3D< double > HepPoint3D
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
EvtTensor3C eps(const EvtVector3R &v)
HepGeom::Point3D< double > HepPoint3D
HepGeom::Vector3D< double > HepVector3D
A class to fit a TTrackBase object to a 3D line.
A class to represent a track in tracking.
double Eps(double)
double dr(void) const
Track parameters (at pivot).
int GetXP(unsigned stepNum, double y[6]) const
double kappa(void) const
double MaxFlightLength(double)
double MaxFlightLength(void) const
return max flight length
Helix helix(void) const
returns helix class
double StepSizeMin(double)
int BfieldID(int)
set B field map ID
void SetFirst(double y[6]) const
set first point (position, momentum) s=0, phi=0
unsigned Nstep(void) const
access to trajectory cache
TRunge(const Helix &)
TRunge(const TRunge &)
double phi0(void) const
double intersect_yz_plane(const HepTransform3D &plane, double x) const
const Vector & a(void) const
returns helix parameter
int approach(TMLink &, float &tof, HepVector3D &p, const RkFitMaterial, bool sagCorrection=true)
~TRunge()
Destructor.
void eloss(double path, const RkFitMaterial *material, double mass, double y[6], int index) const
int approach_line(TMLink &, const HepPoint3D &, const HepVector3D &, HepPoint3D &onLine, HepPoint3D &onTrack, float &tof, HepVector3D &p, const RkFitMaterial material)
double intersect_xy_plane(double z) const
const SymMatrix & Ea(const SymMatrix &)
set helix error matrix
double SetFlightLength(void)
set flight length using wire hits
TRunge(const TTrack &)
int approach_point(TMLink &, const HepPoint3D &, HepPoint3D &onTrack, const RkFitMaterial material)
caluculate closest point between a point and this track
double intersect_zx_plane(const HepTransform3D &plane, double y) const
double DisToWire(TMLink &, double, HepPoint3D, HepPoint3D &)
void Propagate_QC(double y[6], double dydx[6], const double &steptry, const double &eps, const double yscal[6], double &stepdid, double &stepnext)
TRunge(const RecMdcTrack &)
int approach(TMLink &, const RkFitMaterial, bool sagCorrection=true)
void Propagate1(const double y[6], const double dydx[6], const double &step, double yout[6])
const Vector & a(const Vector &)
set helix parameter
double StepSize(void) const
returns step size
float Mass(float)
set mass for tof calc.
const HepPoint3D & pivot(const HepPoint3D &)
set new pivot
unsigned objectType(void) const
returns object type
const double * Yscal(void) const
return error parameters for fitting with step size control
double StepSizeMax(void) const
double dz(void) const
double Eps(void) const
int approach_line(TMLink &, const HepPoint3D &, const HepVector3D &, HepPoint3D &onLine, HepPoint3D &onTrack, float &tof, HepVector3D &p, const RkFitMaterial material, unsigned &stepNum)
int approach_line(TMLink &, const HepPoint3D &, const HepVector3D &, HepPoint3D &onLine, HepPoint3D &onTrack, const RkFitMaterial material)
caluculate closest points between a line and this track
const SymMatrix & Ea(void) const
returns error matrix
double StepSizeMax(double)
const HepPoint3D & pivot(void) const
pivot position
void Propagate(double y[6], const double &step, const RkFitMaterial material)
propagate the track using 4th-order Runge-Kutta method
double reducedchi2(void) const
returns reduced-chi2
float Mass(void) const
return mass
TRunge()
Constructors.
double StepSize(double)
set step size to calc. trajectory
int BfieldID(void) const
returns B field ID
void Function(const double y[6], double f[6])
double StepSizeMin(void) const
int GetStep(unsigned stepNum, double &step) const
double tanl(void) const
double dEpath(double, double, double) const
unsigned Fly_SC(void)
unsigned Fly(const RkFitMaterial material)
make the trajectory in cache, return the number of step
unsigned ndf(void) const
returns NDF
double chi2(void) const
returns chi2.
const double * Yscal(const double *)
set error parameters for fitting with step size control
double intersect_cylinder(double r) const
A virtual class for a track class in tracking.
A class to represent a track in tracking.