BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkDifPieceTraj Class Reference

#include <TrkDifPieceTraj.h>

Inheritance diagram for TrkDifPieceTraj:

Public Member Functions

 TrkDifPieceTraj (const TrkSimpTraj &, const double lowlim, const double hilim)
 TrkDifPieceTraj (TrkSimpTraj *, const double lowlim, const double hilim)
 TrkDifPieceTraj (const TrkDifPieceTraj &)
 TrkDifPieceTraj (const std::vector< TrkSimpTraj * > &trajs)
virtual ~TrkDifPieceTraj ()
TrkDifPieceTrajoperator= (const TrkDifPieceTraj &)
bool operator== (const TrkDifPieceTraj &other) const
TrkDifPieceTrajinvert ()
TrkDifPieceTrajclone () const
void getDFInfo (double fltLen, DifPoint &pos, DifVector &direction, DifVector &delDirect) const
void getDFInfo2 (double fltlen, DifPoint &pos, DifVector &direction) const
HepPoint3D position (double) const
Hep3Vector direction (double) const
double curvature (double f=0.) const
Hep3Vector delDirect (double) const
void getInfo (double fltLen, HepPoint3D &, Hep3Vector &direction) const
void getInfo (double fltLen, HepPoint3D &, Hep3Vector &direction, Hep3Vector &delDirect) const
double distTo1stError (double s, double tol, int pathDir) const
double distTo2ndError (double s, double tol, int pathDir) const
const TrkSimpTrajlocalTrajectory (double, double &) const
bool locallyValid (double glen, double tol=0.0) const
void setFlightRange (double newrange[2])
void print (std::ostream &os) const
void printAll (std::ostream &os) const
const TrkErrCodeappend (double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCodeprepend (double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCodeappend (double gfltlen, TrkSimpTraj *, double &gap)
const TrkErrCodeprepend (double gfltlen, TrkSimpTraj *, double &gap)
const TrkErrCodeappend (double, const TrkDifPieceTraj &, double &gap)
const TrkErrCodeprepend (double, const TrkDifPieceTraj &, double &gap)
const TrkErrCodeappend (TrkSimpTraj *traj, double &gap)
const TrkErrCodeprepend (TrkSimpTraj *traj, double &gap)
HepMatrix derivDeflect (double fltlen, deflectDirection) const
HepMatrix derivDisplace (double fltlen, deflectDirection idir) const
HepMatrix derivPFract (double fltlen) const
 TrkDifPieceTraj (const TrkSimpTraj &, const double lowlim, const double hilim)
 TrkDifPieceTraj (TrkSimpTraj *, const double lowlim, const double hilim)
 TrkDifPieceTraj (const TrkDifPieceTraj &)
 TrkDifPieceTraj (const std::vector< TrkSimpTraj * > &trajs)
virtual ~TrkDifPieceTraj ()
TrkDifPieceTrajoperator= (const TrkDifPieceTraj &)
bool operator== (const TrkDifPieceTraj &other) const
TrkDifPieceTrajinvert ()
TrkDifPieceTrajclone () const
void getDFInfo (double fltLen, DifPoint &pos, DifVector &direction, DifVector &delDirect) const
void getDFInfo2 (double fltlen, DifPoint &pos, DifVector &direction) const
HepPoint3D position (double) const
Hep3Vector direction (double) const
double curvature (double f=0.) const
Hep3Vector delDirect (double) const
void getInfo (double fltLen, HepPoint3D &, Hep3Vector &direction) const
void getInfo (double fltLen, HepPoint3D &, Hep3Vector &direction, Hep3Vector &delDirect) const
double distTo1stError (double s, double tol, int pathDir) const
double distTo2ndError (double s, double tol, int pathDir) const
const TrkSimpTrajlocalTrajectory (double, double &) const
bool locallyValid (double glen, double tol=0.0) const
void setFlightRange (double newrange[2])
void print (std::ostream &os) const
void printAll (std::ostream &os) const
const TrkErrCodeappend (double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCodeprepend (double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCodeappend (double gfltlen, TrkSimpTraj *, double &gap)
const TrkErrCodeprepend (double gfltlen, TrkSimpTraj *, double &gap)
const TrkErrCodeappend (double, const TrkDifPieceTraj &, double &gap)
const TrkErrCodeprepend (double, const TrkDifPieceTraj &, double &gap)
const TrkErrCodeappend (TrkSimpTraj *traj, double &gap)
const TrkErrCodeprepend (TrkSimpTraj *traj, double &gap)
HepMatrix derivDeflect (double fltlen, deflectDirection) const
HepMatrix derivDisplace (double fltlen, deflectDirection idir) const
HepMatrix derivPFract (double fltlen) const
 TrkDifPieceTraj (const TrkSimpTraj &, const double lowlim, const double hilim)
 TrkDifPieceTraj (TrkSimpTraj *, const double lowlim, const double hilim)
 TrkDifPieceTraj (const TrkDifPieceTraj &)
 TrkDifPieceTraj (const std::vector< TrkSimpTraj * > &trajs)
virtual ~TrkDifPieceTraj ()
TrkDifPieceTrajoperator= (const TrkDifPieceTraj &)
bool operator== (const TrkDifPieceTraj &other) const
TrkDifPieceTrajinvert ()
TrkDifPieceTrajclone () const
void getDFInfo (double fltLen, DifPoint &pos, DifVector &direction, DifVector &delDirect) const
void getDFInfo2 (double fltlen, DifPoint &pos, DifVector &direction) const
HepPoint3D position (double) const
Hep3Vector direction (double) const
double curvature (double f=0.) const
Hep3Vector delDirect (double) const
void getInfo (double fltLen, HepPoint3D &, Hep3Vector &direction) const
void getInfo (double fltLen, HepPoint3D &, Hep3Vector &direction, Hep3Vector &delDirect) const
double distTo1stError (double s, double tol, int pathDir) const
double distTo2ndError (double s, double tol, int pathDir) const
const TrkSimpTrajlocalTrajectory (double, double &) const
bool locallyValid (double glen, double tol=0.0) const
void setFlightRange (double newrange[2])
void print (std::ostream &os) const
void printAll (std::ostream &os) const
const TrkErrCodeappend (double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCodeprepend (double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCodeappend (double gfltlen, TrkSimpTraj *, double &gap)
const TrkErrCodeprepend (double gfltlen, TrkSimpTraj *, double &gap)
const TrkErrCodeappend (double, const TrkDifPieceTraj &, double &gap)
const TrkErrCodeprepend (double, const TrkDifPieceTraj &, double &gap)
const TrkErrCodeappend (TrkSimpTraj *traj, double &gap)
const TrkErrCodeprepend (TrkSimpTraj *traj, double &gap)
HepMatrix derivDeflect (double fltlen, deflectDirection) const
HepMatrix derivDisplace (double fltlen, deflectDirection idir) const
HepMatrix derivPFract (double fltlen) const
Public Member Functions inherited from TrkDifTraj
 TrkDifTraj (const double lowlim=-99999., const double hilim=99999.)
virtual ~TrkDifTraj ()
 TrkDifTraj (const double lowlim=-99999., const double hilim=99999.)
virtual ~TrkDifTraj ()
 TrkDifTraj (const double lowlim=-99999., const double hilim=99999.)
virtual ~TrkDifTraj ()
Public Member Functions inherited from Trajectory
 Trajectory (double lowlim, double hilim)
virtual ~Trajectory ()
double distTo0thError (double s, double tol, int pathDir) const
bool validFlightDistance (double f, double tolerance=0.0) const
double lowRange () const
double hiRange () const
double range () const
 Trajectory (double lowlim, double hilim)
virtual ~Trajectory ()
double distTo0thError (double s, double tol, int pathDir) const
bool validFlightDistance (double f, double tolerance=0.0) const
double lowRange () const
double hiRange () const
double range () const
 Trajectory (double lowlim, double hilim)
virtual ~Trajectory ()
double distTo0thError (double s, double tol, int pathDir) const
bool validFlightDistance (double f, double tolerance=0.0) const
double lowRange () const
double hiRange () const
double range () const

Protected Member Functions

int resize (double len, trkDirection)
int trajIndex (const double &global, double &local) const
double localDist (int index, double globdist) const
double globalDist (int index, double locdist) const
int resize (double len, trkDirection)
int trajIndex (const double &global, double &local) const
double localDist (int index, double globdist) const
double globalDist (int index, double locdist) const
int resize (double len, trkDirection)
int trajIndex (const double &global, double &local) const
double localDist (int index, double globdist) const
double globalDist (int index, double locdist) const
Protected Member Functions inherited from Trajectory
Trajectoryoperator= (const Trajectory &)
Trajectoryoperator= (const Trajectory &)
Trajectoryoperator= (const Trajectory &)

Protected Attributes

std::deque< TrkSimpTraj * > _localtraj
std::deque< double > _globalrange
int _lastIndex
Protected Attributes inherited from Trajectory
double flightrange [2]

Detailed Description

Constructor & Destructor Documentation

◆ TrkDifPieceTraj() [1/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const TrkSimpTraj & seed,
const double lowlim,
const double hilim )

Definition at line 30 of file TrkDifPieceTraj.cxx.

32 : TrkDifTraj( lowlim, hilim ), _lastIndex( -1 ) {
33 // _localtraj.reserve(16); _globalrange.reserve(16);
34 _localtraj.push_back( (TrkSimpTraj*)seed.clone() );
35 assert( lowlim < hilim );
36 _globalrange.push_back( lowlim );
37 _globalrange.push_back( hilim );
38 // don't assume the local trajectory has the same range, but do respect it's starting point
39 double locrange[2];
40 locrange[0] = seed.lowRange();
41 locrange[1] = hilim - lowlim + locrange[0];
42 _localtraj.front()->setFlightRange( locrange );
43}
TrkDifTraj(const double lowlim=-99999., const double hilim=99999.)
virtual TrkSimpTraj * clone() const =0

Referenced by append(), clone(), invert(), operator=(), operator==(), prepend(), printAll(), and TrkDifPieceTraj().

◆ TrkDifPieceTraj() [2/12]

TrkDifPieceTraj::TrkDifPieceTraj ( TrkSimpTraj * seed,
const double lowlim,
const double hilim )

Definition at line 45 of file TrkDifPieceTraj.cxx.

46 : TrkDifTraj( lowlim, hilim ), _lastIndex( -1 ) {
47 // _localtraj.reserve(16); _globalrange.reserve(16);
48 assert( lowlim < hilim );
49 _globalrange.push_back( lowlim );
50 _globalrange.push_back( hilim );
51 // don't assume the local trajectory has the same range, but do respect it's starting point
52 double locrange[2];
53 locrange[0] = seed->lowRange();
54 locrange[1] = hilim - lowlim + locrange[0];
55 seed->setFlightRange( locrange );
56 _localtraj.push_back( seed );
57}
virtual void setFlightRange(double newrange[2])

◆ TrkDifPieceTraj() [3/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const TrkDifPieceTraj & other)

Definition at line 60 of file TrkDifPieceTraj.cxx.

61 : TrkDifTraj( other.lowRange(), other.hiRange() )
62 , _globalrange( other._globalrange )
63 , _lastIndex( other._lastIndex ) {
64 //
65 // deep-copy all the trajectory pieces
66 //
67 // _localtraj.reserve(other._localtraj.size());
68 typedef std::deque<TrkSimpTraj*>::const_iterator iter_t;
69 iter_t end = other._localtraj.end();
70 for ( iter_t i = other._localtraj.begin(); i != end; ++i )
71 _localtraj.push_back( (TrkSimpTraj*)( *i )->clone() );
72}
Index other(Index i, Index j)

◆ TrkDifPieceTraj() [4/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const std::vector< TrkSimpTraj * > & trajs)

Definition at line 74 of file TrkDifPieceTraj.cxx.

74 {
75 // _localtraj.reserve(trajs.size());_globalrange.reserve(trajs.size()+1);
76 // intialize
77 TrkSimpTraj* prevtraj( 0 );
78 for ( std::vector<TrkSimpTraj*>::const_iterator itraj = trajs.begin(); itraj != trajs.end();
79 ++itraj )
80 {
81 TrkSimpTraj* newtraj = ( *itraj )->clone();
82 assert( newtraj != 0 );
83 if ( prevtraj != 0 )
84 {
85 // Hopefully the trajs are in order
86 TrkErrCode add;
87 double gap;
88 if ( newtraj->lowRange() > prevtraj->lowRange() ) add = append( newtraj, gap );
89 else add = prepend( newtraj, gap );
90 if ( add.failure() )
91 {
92#ifdef MDCPATREC_WARNING
93 std::cout << "ErrMsg(warning) "
94 << "construction from vector of trajs failed" << add << std::endl;
95#endif
96 delete newtraj;
97 break;
98 }
99 }
100 else
101 {
102 // Initial global flightlength is defined by the first trajectory
103 _localtraj.push_back( newtraj );
104 _globalrange.push_back( newtraj->lowRange() );
105 _globalrange.push_back( newtraj->hiRange() );
106 // set the global range
107 flightrange[0] = _globalrange.front();
108 flightrange[1] = _globalrange.back();
109 }
110 prevtraj = _localtraj[itraj - trajs.begin()];
111 }
112}
const TrkErrCode & append(double gfltlen, const TrkSimpTraj &, double &gap)
const TrkErrCode & prepend(double gfltlen, const TrkSimpTraj &, double &gap)

◆ ~TrkDifPieceTraj() [1/3]

TrkDifPieceTraj::~TrkDifPieceTraj ( )
virtual

Definition at line 114 of file TrkDifPieceTraj.cxx.

114 {
115 std::for_each( _localtraj.begin(), _localtraj.end(), bes::Collection::DeleteObject() );
116}

◆ TrkDifPieceTraj() [5/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const TrkSimpTraj & ,
const double lowlim,
const double hilim )

◆ TrkDifPieceTraj() [6/12]

TrkDifPieceTraj::TrkDifPieceTraj ( TrkSimpTraj * ,
const double lowlim,
const double hilim )

◆ TrkDifPieceTraj() [7/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const TrkDifPieceTraj & )

◆ TrkDifPieceTraj() [8/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const std::vector< TrkSimpTraj * > & trajs)

◆ ~TrkDifPieceTraj() [2/3]

virtual TrkDifPieceTraj::~TrkDifPieceTraj ( )
virtual

◆ TrkDifPieceTraj() [9/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const TrkSimpTraj & ,
const double lowlim,
const double hilim )

◆ TrkDifPieceTraj() [10/12]

TrkDifPieceTraj::TrkDifPieceTraj ( TrkSimpTraj * ,
const double lowlim,
const double hilim )

◆ TrkDifPieceTraj() [11/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const TrkDifPieceTraj & )

◆ TrkDifPieceTraj() [12/12]

TrkDifPieceTraj::TrkDifPieceTraj ( const std::vector< TrkSimpTraj * > & trajs)

◆ ~TrkDifPieceTraj() [3/3]

virtual TrkDifPieceTraj::~TrkDifPieceTraj ( )
virtual

Member Function Documentation

◆ append() [1/12]

const TrkErrCode & TrkDifPieceTraj::append ( double gfltlen,
const TrkSimpTraj & nexttraj,
double & gap )

Definition at line 255 of file TrkDifPieceTraj.cxx.

256 {
257 return append( glen, nexttraj.clone(), gap );
258}

Referenced by append(), append(), and TrkDifPieceTraj().

◆ append() [2/12]

const TrkErrCode & TrkDifPieceTraj::append ( double gfltlen,
const TrkSimpTraj & ,
double & gap )

◆ append() [3/12]

const TrkErrCode & TrkDifPieceTraj::append ( double gfltlen,
const TrkSimpTraj & ,
double & gap )

◆ append() [4/12]

const TrkErrCode & TrkDifPieceTraj::append ( double gfltlen,
TrkSimpTraj * nexttraj,
double & gap )

Definition at line 157 of file TrkDifPieceTraj.cxx.

157 {
158 static TrkErrCode retval;
159 retval = TrkErrCode( TrkErrCode::succeed );
160 // simple range checks
161 if ( glen >= lowRange() )
162 {
163 // resize the end if necessary
164 int nremoved = resize( glen, trkOut );
165 if ( nremoved > 0 )
166 {
167#ifdef MDCPATREC_WARNING
168 std::cout << "ErrMsg(warning)"
169 << "append removed " << nremoved << " old trajectories" << std::endl;
170#endif
171 }
172 // Compute POCA for this trajectory to the point at the end of the existing trajectory
173 HepPoint3D endpoint = position( glen );
174 HepPoint3D newend = nexttraj->position( nexttraj->lowRange() );
175 gap = newend.distance( endpoint );
176 double range[2];
177 range[0] = nexttraj->lowRange();
178 range[1] = nexttraj->hiRange();
179 double delta = max( hiRange() - glen, range[1] - range[0] );
180 if ( gap > _TOL )
181 { // Don't invoke POCA if the point is too close
182 TrkPoca endpoca( *nexttraj, nexttraj->lowRange(), endpoint, _TOL );
183 if ( endpoca.status().failure() )
184 {
185 retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
186 return retval;
187 }
188 range[0] = endpoca.flt1();
189 gap = endpoca.doca();
190 }
191 // make sure the global range stays at least as long as before
192 range[1] = range[0] + delta;
193 // resize it
194 nexttraj->setFlightRange( range );
195 // append the trajectory
196 _localtraj.push_back( nexttraj );
197 // append the new global range
198 _globalrange.push_back( glen + delta );
199 flightrange[1] = glen + delta;
200 }
201 else
202 retval = TrkErrCode( TrkErrCode::fail, 6, " cannot append before minimum flight range" );
203 return retval;
204}
HepGeom::Point3D< double > HepPoint3D
#define max(a, b)
virtual HepPoint3D position(double) const =0
HepPoint3D position(double) const
int resize(double len, trkDirection)

◆ append() [5/12]

const TrkErrCode & TrkDifPieceTraj::append ( double gfltlen,
TrkSimpTraj * ,
double & gap )

◆ append() [6/12]

const TrkErrCode & TrkDifPieceTraj::append ( double gfltlen,
TrkSimpTraj * ,
double & gap )

◆ append() [7/12]

const TrkErrCode & TrkDifPieceTraj::append ( double glen,
const TrkDifPieceTraj & other,
double & gap )

Definition at line 266 of file TrkDifPieceTraj.cxx.

267 {
268 static TrkErrCode retval;
269 retval = TrkErrCode( TrkErrCode::succeed );
270 // find POCA between the trajectories.
271 double mylen = glen;
272 HepPoint3D myend = position( mylen );
273 double otherlen = other.lowRange();
274 HepPoint3D otherstart = other.position( otherlen );
275 gap = otherstart.distance( myend );
276 if ( gap > _TOL )
277 { // Don't invoke POCA if the point is too close
278 TrkPoca endpoca( other, other.lowRange(), myend, _TOL );
279 if ( endpoca.status().failure() )
280 {
281 retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
282 return retval;
283 }
284 gap = endpoca.doca();
285 otherlen = endpoca.flt1();
286 }
287 // get the local trajectory piece at this fltlen
288 double loclen( 0 );
289 double piecegap;
290 // loop over segments in the other trajectory
291 for ( int itraj = other.trajIndex( otherlen, loclen ); itraj < other._localtraj.size();
292 itraj++ )
293 {
294 // append the piece from the other trajectory
295 retval = append( mylen, *( other._localtraj[itraj] ), piecegap );
296 if ( retval.failure() ) break;
297 // move forward
298 mylen = hiRange();
299 }
300 return retval;
301}

◆ append() [8/12]

const TrkErrCode & TrkDifPieceTraj::append ( double ,
const TrkDifPieceTraj & ,
double & gap )

◆ append() [9/12]

const TrkErrCode & TrkDifPieceTraj::append ( double ,
const TrkDifPieceTraj & ,
double & gap )

◆ append() [10/12]

const TrkErrCode & TrkDifPieceTraj::append ( TrkSimpTraj * traj,
double & gap )

Definition at line 698 of file TrkDifPieceTraj.cxx.

698 {
699 static TrkErrCode retval;
700 retval = TrkErrCode( TrkErrCode::succeed );
701 // find out where this piece is relative to the existing pieces.
702 HepPoint3D end = newtraj->position( newtraj->lowRange() );
703 TrkPoca poca( *this, newtraj->lowRange(), end, _TOL );
704 if ( poca.status().success() )
705 {
706 // find the local trajectory pieces at either end
707 double local;
708 int index = trajIndex( poca.flt1(), local );
709 TrkSimpTraj* oldtraj = _localtraj[index];
710 // Make sure we're beyond the end of the existing trajectory
711 if ( index == _localtraj.size() - 1 && poca.flt1() > hiRange() )
712 {
713 // we want to split the gap between the traj pieces evenly,
714 double gapstart = globalDist( index, oldtraj->hiRange() );
715 double gapend = poca.flt1();
716 double gapmid = ( gapend + gapstart ) / 2.0;
717 HepPoint3D mid = position( gapmid );
718 // approximate initial (local) fltlen for poca
719 double locmid = newtraj->lowRange() - gapend + gapmid;
720 TrkPoca midpoca( *newtraj, locmid, mid, _TOL );
721 if ( midpoca.status().success() )
722 {
723 // create a 0-length copy of the new traj to associate with the midpoint.
724 // This insures correct coverage of the global flight range
725 TrkSimpTraj* gaptraj = (TrkSimpTraj*)( newtraj->clone() );
726 assert( gaptraj != 0 );
727 double range[2];
728 range[0] = midpoca.flt1();
729 range[1] = range[0];
730 gaptraj->setFlightRange( range );
731 // insert the trajectories
732 _localtraj.push_back( gaptraj );
733 _localtraj.push_back( newtraj );
734 // append the new global range
735 _globalrange.back() = gapmid;
736 _globalrange.push_back( gapend );
737 _globalrange.push_back( gapend + newtraj->range() );
738 // extend the piece-trajs own range
739 flightrange[1] = _globalrange.back();
740 // measure the gap at the midpoint
741 gap = mid.distance( newtraj->position( midpoca.flt1() ) );
742 }
743 else retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
744 }
745 else retval = TrkErrCode( TrkErrCode::fail, 8, "invalid range" );
746 }
747 else retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
748 return retval;
749}
int trajIndex(const double &global, double &local) const

◆ append() [11/12]

const TrkErrCode & TrkDifPieceTraj::append ( TrkSimpTraj * traj,
double & gap )

◆ append() [12/12]

const TrkErrCode & TrkDifPieceTraj::append ( TrkSimpTraj * traj,
double & gap )

◆ clone() [1/3]

TrkDifPieceTraj * TrkDifPieceTraj::clone ( ) const
inlinevirtual

Implements Trajectory.

Definition at line 48 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkBase/TrkDifPieceTraj.h.

48{ return new TrkDifPieceTraj( *this ); }
TrkDifPieceTraj(const TrkSimpTraj &, const double lowlim, const double hilim)

◆ clone() [2/3]

TrkDifPieceTraj * TrkDifPieceTraj::clone ( ) const
inlinevirtual

Implements Trajectory.

Definition at line 48 of file InstallArea/x86_64-el9-gcc13-opt/include/TrkBase/TrkDifPieceTraj.h.

48{ return new TrkDifPieceTraj( *this ); }

◆ clone() [3/3]

TrkDifPieceTraj * TrkDifPieceTraj::clone ( ) const
inlinevirtual

Implements Trajectory.

Definition at line 48 of file Reconstruction/MdcPatRec/TrkBase/include/TrkBase/TrkDifPieceTraj.h.

48{ return new TrkDifPieceTraj( *this ); }

◆ curvature() [1/3]

double TrkDifPieceTraj::curvature ( double f = 0.) const
virtual

Implements Trajectory.

Definition at line 435 of file TrkDifPieceTraj.cxx.

435 {
436 //
437 // First, find the right trajectory piece, then give the local curvature
438 //
439 double localflight( 0.0 );
440 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
441 return loctraj->curvature( localflight );
442}
virtual double curvature(double) const =0
const TrkSimpTraj * localTrajectory(double, double &) const

◆ curvature() [2/3]

double TrkDifPieceTraj::curvature ( double f = 0.) const
virtual

Implements Trajectory.

◆ curvature() [3/3]

double TrkDifPieceTraj::curvature ( double f = 0.) const
virtual

Implements Trajectory.

◆ delDirect() [1/3]

Hep3Vector TrkDifPieceTraj::delDirect ( double flightdist) const
virtual

Implements Trajectory.

Definition at line 444 of file TrkDifPieceTraj.cxx.

444 {
445 //
446 // First, find the right trajectory piece, then give the local value
447 //
448 double localflight( 0.0 );
449 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
450 return loctraj->delDirect( localflight );
451}
virtual Hep3Vector delDirect(double) const =0

Referenced by getDFInfo(), and getInfo().

◆ delDirect() [2/3]

Hep3Vector TrkDifPieceTraj::delDirect ( double ) const
virtual

Implements Trajectory.

◆ delDirect() [3/3]

Hep3Vector TrkDifPieceTraj::delDirect ( double ) const
virtual

Implements Trajectory.

◆ derivDeflect() [1/3]

HepMatrix TrkDifPieceTraj::derivDeflect ( double fltlen,
deflectDirection idir ) const
virtual

Implements TrkKalDeriv.

Definition at line 680 of file TrkDifPieceTraj.cxx.

680 {
681 double localflight( 0.0 );
682 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
683 return loctraj->derivDeflect( localflight, idir );
684}
virtual HepMatrix derivDeflect(double fltlen, deflectDirection idir) const =0

◆ derivDeflect() [2/3]

HepMatrix TrkDifPieceTraj::derivDeflect ( double fltlen,
deflectDirection  ) const
virtual

Implements TrkKalDeriv.

◆ derivDeflect() [3/3]

HepMatrix TrkDifPieceTraj::derivDeflect ( double fltlen,
deflectDirection  ) const
virtual

Implements TrkKalDeriv.

◆ derivDisplace() [1/3]

HepMatrix TrkDifPieceTraj::derivDisplace ( double fltlen,
deflectDirection idir ) const
virtual

Implements TrkKalDeriv.

Definition at line 686 of file TrkDifPieceTraj.cxx.

686 {
687 double localflight( 0.0 );
688 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
689 return loctraj->derivDisplace( localflight, idir );
690}
virtual HepMatrix derivDisplace(double fltlen, deflectDirection idir) const =0

◆ derivDisplace() [2/3]

HepMatrix TrkDifPieceTraj::derivDisplace ( double fltlen,
deflectDirection idir ) const
virtual

Implements TrkKalDeriv.

◆ derivDisplace() [3/3]

HepMatrix TrkDifPieceTraj::derivDisplace ( double fltlen,
deflectDirection idir ) const
virtual

Implements TrkKalDeriv.

◆ derivPFract() [1/3]

HepMatrix TrkDifPieceTraj::derivPFract ( double fltlen) const
virtual

Implements TrkKalDeriv.

Definition at line 692 of file TrkDifPieceTraj.cxx.

692 {
693 double localflight( 0.0 );
694 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
695 return loctraj->derivPFract( localflight );
696}
virtual HepMatrix derivPFract(double fltlen) const =0

◆ derivPFract() [2/3]

HepMatrix TrkDifPieceTraj::derivPFract ( double fltlen) const
virtual

Implements TrkKalDeriv.

◆ derivPFract() [3/3]

HepMatrix TrkDifPieceTraj::derivPFract ( double fltlen) const
virtual

Implements TrkKalDeriv.

◆ direction() [1/3]

Hep3Vector TrkDifPieceTraj::direction ( double flightdist) const
virtual

Implements Trajectory.

Definition at line 426 of file TrkDifPieceTraj.cxx.

426 {
427 //
428 // First, find the right trajectory piece, then give the local direction
429 //
430 double localflight( 0.0 );
431 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
432 return loctraj->direction( localflight );
433}
virtual Hep3Vector direction(double) const =0

Referenced by getDFInfo(), getDFInfo2(), getInfo(), and getInfo().

◆ direction() [2/3]

Hep3Vector TrkDifPieceTraj::direction ( double ) const
virtual

Implements Trajectory.

◆ direction() [3/3]

Hep3Vector TrkDifPieceTraj::direction ( double ) const
virtual

Implements Trajectory.

◆ distTo1stError() [1/3]

double TrkDifPieceTraj::distTo1stError ( double s,
double tol,
int pathDir ) const
virtual

Implements Trajectory.

Definition at line 472 of file TrkDifPieceTraj.cxx.

472 {
473 //
474 // First, find the right trajectory piece
475 //
476 double localflight( 0.0 );
477 int index = trajIndex( flightdist, localflight );
478 const TrkSimpTraj* loctraj = _localtraj[index];
479 //
480 // Ask the local piece for it's dist, and take the minimum of this or the
481 // distance to the next trajectory piece
482 //
483 double localdist = loctraj->distTo1stError( localflight, tol, dir );
484 //
485 // Take the minimum of this distance and the distance to the next trajectory
486 double dist = localdist;
487 if ( dir > 0 )
488 {
489 if ( index < _localtraj.size() - 1 )
490 dist = min( localdist, _globalrange[index + 1] - flightdist ) + STEPEPSILON;
491 }
492 else
493 {
494 if ( index > 0 ) dist = min( localdist, flightdist - _globalrange[index] ) + STEPEPSILON;
495 }
496 return dist;
497}
#define min(a, b)
virtual double distTo1stError(double s, double tol, int pathDir) const =0

◆ distTo1stError() [2/3]

double TrkDifPieceTraj::distTo1stError ( double s,
double tol,
int pathDir ) const
virtual

Implements Trajectory.

◆ distTo1stError() [3/3]

double TrkDifPieceTraj::distTo1stError ( double s,
double tol,
int pathDir ) const
virtual

Implements Trajectory.

◆ distTo2ndError() [1/3]

double TrkDifPieceTraj::distTo2ndError ( double s,
double tol,
int pathDir ) const
virtual

Implements Trajectory.

Definition at line 499 of file TrkDifPieceTraj.cxx.

499 {
500 //
501 // First, find the right trajectory piece
502 //
503 double localflight( 0.0 );
504 int index = trajIndex( flightdist, localflight );
505 const TrkSimpTraj* loctraj = _localtraj[index];
506 //
507 // Ask the local piece for it's dist, and take the minimum of this or the
508 // distance to the next trajectory piece
509 //
510 double localdist = loctraj->distTo2ndError( localflight, tol, dir );
511 //
512 // Take the minimum of this distance and the distance to the next trajectory
513 double dist = localdist;
514 if ( dir > 0 )
515 {
516 if ( index < _localtraj.size() - 1 )
517 dist = min( localdist, _globalrange[index + 1] - flightdist ) + STEPEPSILON;
518 }
519 else
520 {
521 if ( index > 0 ) dist = min( localdist, flightdist - _globalrange[index] ) + STEPEPSILON;
522 }
523 return dist;
524}
virtual double distTo2ndError(double s, double tol, int pathDir) const =0

◆ distTo2ndError() [2/3]

double TrkDifPieceTraj::distTo2ndError ( double s,
double tol,
int pathDir ) const
virtual

Implements Trajectory.

◆ distTo2ndError() [3/3]

double TrkDifPieceTraj::distTo2ndError ( double s,
double tol,
int pathDir ) const
virtual

Implements Trajectory.

◆ getDFInfo() [1/3]

void TrkDifPieceTraj::getDFInfo ( double fltLen,
DifPoint & pos,
DifVector & direction,
DifVector & delDirect ) const
virtual

Implements TrkDifTraj.

Definition at line 118 of file TrkDifPieceTraj.cxx.

119 {
120 //
121 // First, find the right trajectory piece, then give the local position
122 //
123 double localflight( 0.0 );
124 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
125 loctraj->getDFInfo( localflight, pos, direction, delDirect );
126}
Hep3Vector direction(double) const
Hep3Vector delDirect(double) const
virtual void getDFInfo(double fltLen, DifPoint &pos, DifVector &direction, DifVector &delDirect) const =0

◆ getDFInfo() [2/3]

void TrkDifPieceTraj::getDFInfo ( double fltLen,
DifPoint & pos,
DifVector & direction,
DifVector & delDirect ) const
virtual

Implements TrkDifTraj.

◆ getDFInfo() [3/3]

void TrkDifPieceTraj::getDFInfo ( double fltLen,
DifPoint & pos,
DifVector & direction,
DifVector & delDirect ) const
virtual

Implements TrkDifTraj.

◆ getDFInfo2() [1/3]

void TrkDifPieceTraj::getDFInfo2 ( double fltlen,
DifPoint & pos,
DifVector & direction ) const
virtual

Reimplemented from TrkDifTraj.

Definition at line 128 of file TrkDifPieceTraj.cxx.

129 {
130 //
131 // First, find the right trajectory piece, then give the local position
132 //
133 double localflight( 0.0 );
134 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
135 loctraj->getDFInfo2( localflight, pos, direction );
136}
virtual void getDFInfo2(double fltLen, DifPoint &pos, DifVector &direction) const

◆ getDFInfo2() [2/3]

void TrkDifPieceTraj::getDFInfo2 ( double fltlen,
DifPoint & pos,
DifVector & direction ) const
virtual

Reimplemented from TrkDifTraj.

◆ getDFInfo2() [3/3]

void TrkDifPieceTraj::getDFInfo2 ( double fltlen,
DifPoint & pos,
DifVector & direction ) const
virtual

Reimplemented from TrkDifTraj.

◆ getInfo() [1/6]

void TrkDifPieceTraj::getInfo ( double fltLen,
HepPoint3D & point,
Hep3Vector & direction ) const
virtual

Implements Trajectory.

Definition at line 453 of file TrkDifPieceTraj.cxx.

453 {
454 //
455 // First, find the right trajectory piece, then call the local function
456 //
457 double localflight( 0.0 );
458 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
459 loctraj->getInfo( localflight, point, dir );
460}
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &direction) const =0

◆ getInfo() [2/6]

void TrkDifPieceTraj::getInfo ( double fltLen,
HepPoint3D & ,
Hep3Vector & direction ) const
virtual

Implements Trajectory.

◆ getInfo() [3/6]

void TrkDifPieceTraj::getInfo ( double fltLen,
HepPoint3D & ,
Hep3Vector & direction ) const
virtual

Implements Trajectory.

◆ getInfo() [4/6]

void TrkDifPieceTraj::getInfo ( double fltLen,
HepPoint3D & point,
Hep3Vector & direction,
Hep3Vector & delDirect ) const
virtual

Implements Trajectory.

Definition at line 462 of file TrkDifPieceTraj.cxx.

463 {
464 //
465 // First, find the right trajectory piece, then call the local function
466 //
467 double localflight( 0.0 );
468 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
469 loctraj->getInfo( localflight, point, dir, deldirect );
470}

◆ getInfo() [5/6]

void TrkDifPieceTraj::getInfo ( double fltLen,
HepPoint3D & ,
Hep3Vector & direction,
Hep3Vector & delDirect ) const
virtual

Implements Trajectory.

◆ getInfo() [6/6]

void TrkDifPieceTraj::getInfo ( double fltLen,
HepPoint3D & ,
Hep3Vector & direction,
Hep3Vector & delDirect ) const
virtual

Implements Trajectory.

◆ globalDist() [1/3]

double TrkDifPieceTraj::globalDist ( int index,
double locdist ) const
inlineprotected

Definition at line 134 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkBase/TrkDifPieceTraj.h.

134 {
135 return _globalrange[index] + locdist - _localtraj[index]->lowRange();
136 }

Referenced by append(), and prepend().

◆ globalDist() [2/3]

double TrkDifPieceTraj::globalDist ( int index,
double locdist ) const
inlineprotected

Definition at line 134 of file InstallArea/x86_64-el9-gcc13-opt/include/TrkBase/TrkDifPieceTraj.h.

134 {
135 return _globalrange[index] + locdist - _localtraj[index]->lowRange();
136 }

◆ globalDist() [3/3]

double TrkDifPieceTraj::globalDist ( int index,
double locdist ) const
inlineprotected

Definition at line 134 of file Reconstruction/MdcPatRec/TrkBase/include/TrkBase/TrkDifPieceTraj.h.

134 {
135 return _globalrange[index] + locdist - _localtraj[index]->lowRange();
136 }

◆ invert() [1/3]

TrkDifPieceTraj & TrkDifPieceTraj::invert ( )

Definition at line 340 of file TrkDifPieceTraj.cxx.

340 {
341 // make local copies & clear data members
342 std::deque<TrkSimpTraj*> trajcopy;
343 trajcopy.swap( _localtraj );
344 std::deque<double> rangecopy;
345 rangecopy.swap( _globalrange );
346 assert( _localtraj.size() == 0 );
347 assert( _globalrange.size() == 0 );
348 // global range starts at the end of the old range
349 _globalrange.push_back( -rangecopy.back() );
350 // loop over the trajectory pieces in backwards order
351 for ( int itraj = trajcopy.size() - 1; itraj >= 0; itraj-- )
352 {
353 // invert the simptraj and re-append it
354 _localtraj.push_back( &( trajcopy[itraj]->invert() ) );
355 // set the global range
356 _globalrange.push_back( -rangecopy[itraj] );
357 }
358 // reset this traj's range
359 double range[2];
360 range[0] = -hiRange();
361 range[1] = -lowRange();
363 return *this;
364}
TrkDifPieceTraj & invert()

Referenced by invert().

◆ invert() [2/3]

TrkDifPieceTraj & TrkDifPieceTraj::invert ( )

◆ invert() [3/3]

TrkDifPieceTraj & TrkDifPieceTraj::invert ( )

◆ localDist() [1/3]

double TrkDifPieceTraj::localDist ( int index,
double globdist ) const
inlineprotected

Definition at line 130 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkBase/TrkDifPieceTraj.h.

130 {
131 return _localtraj[index]->lowRange() + globdist - _globalrange[index];
132 }

Referenced by setFlightRange(), and trajIndex().

◆ localDist() [2/3]

double TrkDifPieceTraj::localDist ( int index,
double globdist ) const
inlineprotected

Definition at line 130 of file InstallArea/x86_64-el9-gcc13-opt/include/TrkBase/TrkDifPieceTraj.h.

130 {
131 return _localtraj[index]->lowRange() + globdist - _globalrange[index];
132 }

◆ localDist() [3/3]

double TrkDifPieceTraj::localDist ( int index,
double globdist ) const
inlineprotected

Definition at line 130 of file Reconstruction/MdcPatRec/TrkBase/include/TrkBase/TrkDifPieceTraj.h.

130 {
131 return _localtraj[index]->lowRange() + globdist - _globalrange[index];
132 }

◆ locallyValid() [1/3]

bool TrkDifPieceTraj::locallyValid ( double glen,
double tol = 0.0 ) const

Definition at line 803 of file TrkDifPieceTraj.cxx.

803 {
804 double localflight( 0.0 );
805 const TrkSimpTraj* loctraj = localTrajectory( glen, localflight );
806 return loctraj != 0 &&
807 localflight - tol <= loctraj->hiRange() & localflight + tol >= loctraj->lowRange();
808}

◆ locallyValid() [2/3]

bool TrkDifPieceTraj::locallyValid ( double glen,
double tol = 0.0 ) const

◆ locallyValid() [3/3]

bool TrkDifPieceTraj::locallyValid ( double glen,
double tol = 0.0 ) const

◆ localTrajectory() [1/3]

const TrkSimpTraj * TrkDifPieceTraj::localTrajectory ( double flightdist,
double & localflight ) const
virtual

Implements TrkDifTraj.

Definition at line 526 of file TrkDifPieceTraj.cxx.

527 {
528 //
529 // Find and return the right trajectory piece
530 //
531 int index = trajIndex( flightdist, localflight );
532 return _localtraj[index];
533}

Referenced by curvature(), delDirect(), derivDeflect(), derivDisplace(), derivPFract(), direction(), getDFInfo(), getDFInfo2(), getInfo(), getInfo(), locallyValid(), and position().

◆ localTrajectory() [2/3]

const TrkSimpTraj * TrkDifPieceTraj::localTrajectory ( double ,
double &  ) const
virtual

Implements TrkDifTraj.

◆ localTrajectory() [3/3]

const TrkSimpTraj * TrkDifPieceTraj::localTrajectory ( double ,
double &  ) const
virtual

Implements TrkDifTraj.

◆ operator=() [1/3]

TrkDifPieceTraj & TrkDifPieceTraj::operator= ( const TrkDifPieceTraj & other)

Definition at line 138 of file TrkDifPieceTraj.cxx.

138 {
139 if ( &other == this ) return *this;
140 flightrange[0] = other.flightrange[0];
141 flightrange[1] = other.flightrange[1];
142 _globalrange = other._globalrange;
143 //
144 // deep-copy all the trajectory pieces
145 //
146 std::for_each( _localtraj.begin(), _localtraj.end(), bes::Collection::DeleteObject() );
147 _localtraj.clear(); // _localtraj.reserve(other._localtraj.size());
148 typedef std::deque<TrkSimpTraj*>::const_iterator iter_t;
149 for ( iter_t i = other._localtraj.begin(); i != other._localtraj.end(); ++i )
150 _localtraj.push_back( ( *i )->clone() );
151 return *this;
152}

◆ operator=() [2/3]

TrkDifPieceTraj & TrkDifPieceTraj::operator= ( const TrkDifPieceTraj & )

◆ operator=() [3/3]

TrkDifPieceTraj & TrkDifPieceTraj::operator= ( const TrkDifPieceTraj & )

◆ operator==() [1/3]

bool TrkDifPieceTraj::operator== ( const TrkDifPieceTraj & other) const

Definition at line 810 of file TrkDifPieceTraj.cxx.

810 {
811 bool retval( true );
812 if ( retval ) retval = _globalrange == other._globalrange;
813 if ( retval ) retval = _localtraj.size() == other._localtraj.size();
814 // loop over component trajs
815 std::deque<TrkSimpTraj*>::const_iterator miter = _localtraj.begin();
816 std::deque<TrkSimpTraj*>::const_iterator oiter = other._localtraj.begin();
817 while ( retval && miter != _localtraj.end() && oiter != other._localtraj.end() )
818 {
819 retval = ( *oiter )->parameters()->parameter() == ( *miter )->parameters()->parameter() &&
820 ( *oiter )->parameters()->covariance() == ( *miter )->parameters()->covariance();
821 miter++;
822 oiter++;
823 }
824 return retval;
825}

◆ operator==() [2/3]

bool TrkDifPieceTraj::operator== ( const TrkDifPieceTraj & other) const

◆ operator==() [3/3]

bool TrkDifPieceTraj::operator== ( const TrkDifPieceTraj & other) const

◆ position() [1/3]

HepPoint3D TrkDifPieceTraj::position ( double flightdist) const
virtual

Implements Trajectory.

Definition at line 417 of file TrkDifPieceTraj.cxx.

417 {
418 //
419 // First, find the right trajectory piece, then give the local position
420 //
421 double localflight( 0.0 );
422 const TrkSimpTraj* loctraj = localTrajectory( flightdist, localflight );
423 return loctraj->position( localflight );
424}

Referenced by append(), append(), append(), prepend(), prepend(), and prepend().

◆ position() [2/3]

HepPoint3D TrkDifPieceTraj::position ( double ) const
virtual

Implements Trajectory.

◆ position() [3/3]

HepPoint3D TrkDifPieceTraj::position ( double ) const
virtual

Implements Trajectory.

◆ prepend() [1/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double gfltlen,
const TrkSimpTraj & nexttraj,
double & gap )

Definition at line 260 of file TrkDifPieceTraj.cxx.

261 {
262 return prepend( glen, nexttraj.clone(), gap );
263}

Referenced by prepend(), prepend(), and TrkDifPieceTraj().

◆ prepend() [2/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double gfltlen,
const TrkSimpTraj & ,
double & gap )

◆ prepend() [3/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double gfltlen,
const TrkSimpTraj & ,
double & gap )

◆ prepend() [4/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double gfltlen,
TrkSimpTraj * nexttraj,
double & gap )

Definition at line 206 of file TrkDifPieceTraj.cxx.

206 {
207 static TrkErrCode retval;
208 retval = TrkErrCode( TrkErrCode::succeed );
209 // simple range checks
210 if ( glen <= hiRange() )
211 {
212 // resize
213 int nremoved = resize( glen, trkIn );
214 if ( nremoved > 0 )
215 {
216#ifdef MDCPATREC_WARNING
217 std::cout << "ErrMsg(warning) "
218 << " prepend removed " << nremoved << " old trajectories" << std::endl;
219#endif
220 }
221 // Compute POCA for this trajectory to the point at the end of the existing trajectory
222 HepPoint3D endpoint = position( glen );
223 HepPoint3D newend = nexttraj->position( nexttraj->hiRange() );
224 gap = newend.distance( endpoint );
225 double range[2];
226 range[0] = nexttraj->lowRange();
227 range[1] = nexttraj->hiRange();
228 double delta = max( glen - lowRange(), range[1] - range[0] );
229 if ( gap > _TOL )
230 { // Don't invoke POCA if the point is too close
231 TrkPoca endpoca( *nexttraj, nexttraj->hiRange(), endpoint, _TOL );
232 if ( endpoca.status().failure() )
233 {
234 retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
235 return retval;
236 }
237 range[1] = endpoca.flt1();
238 gap = endpoca.doca();
239 }
240 // make sure the global range stays at least as long as before
241 range[0] = range[1] - delta;
242 // resize it
243 nexttraj->setFlightRange( range );
244 // prepend the trajectory
245 _localtraj.push_front( nexttraj );
246 // prepend the new global range
247 _globalrange.push_front( glen - delta );
248 flightrange[0] = glen - delta;
249 }
250 else
251 retval = TrkErrCode( TrkErrCode::fail, 6, " cannot prepend after maximum flight range" );
252 return retval;
253}

◆ prepend() [5/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double gfltlen,
TrkSimpTraj * ,
double & gap )

◆ prepend() [6/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double gfltlen,
TrkSimpTraj * ,
double & gap )

◆ prepend() [7/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double glen,
const TrkDifPieceTraj & other,
double & gap )

Definition at line 303 of file TrkDifPieceTraj.cxx.

304 {
305 static TrkErrCode retval;
306 retval = TrkErrCode( TrkErrCode::succeed );
307 // find POCA between the trajectories.
308 double mylen = glen;
309 HepPoint3D mystart = position( mylen );
310 double otherlen = other.hiRange();
311 HepPoint3D otherend = other.position( otherlen );
312 gap = otherend.distance( mystart );
313 if ( gap > _TOL )
314 { // Don't invoke POCA if the point is too close
315 TrkPoca endpoca( other, other.hiRange(), mystart, _TOL );
316 if ( endpoca.status().failure() )
317 {
318 retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
319 return retval;
320 }
321 gap = endpoca.doca();
322 otherlen = endpoca.flt1();
323 }
324 // get the local trajectory piece at this fltlen
325 double loclen( 0 );
326 double piecegap;
327 // loop over segments in the other trajectory
328 for ( int itraj = other.trajIndex( otherlen, loclen ); itraj >= 0; itraj-- )
329 {
330 // prepend the piece from the other trajectory
331 retval = prepend( mylen, *( other._localtraj[itraj] ), piecegap );
332 if ( retval.failure() ) break;
333 // move backwards
334 mylen = lowRange();
335 }
336 return retval;
337}

◆ prepend() [8/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double ,
const TrkDifPieceTraj & ,
double & gap )

◆ prepend() [9/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( double ,
const TrkDifPieceTraj & ,
double & gap )

◆ prepend() [10/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( TrkSimpTraj * traj,
double & gap )

Definition at line 751 of file TrkDifPieceTraj.cxx.

751 {
752 static TrkErrCode retval;
753 retval = TrkErrCode( TrkErrCode::succeed );
754 // find out where this piece is relative to the existing pieces.
755 HepPoint3D end = newtraj->position( newtraj->hiRange() );
756 TrkPoca poca( *this, newtraj->hiRange(), end, _TOL );
757 if ( poca.status().success() )
758 {
759 // find the local trajectory pieces at either end
760 double local;
761 int index = trajIndex( poca.flt1(), local );
762 TrkSimpTraj* oldtraj = _localtraj[index];
763 // Make sure we're beyond the end of the existing trajectory
764 if ( index == 0 && poca.flt1() < lowRange() )
765 {
766 // we want to split the gap between the traj pieces evenly,
767 double gapstart = poca.flt1();
768 double gapend = globalDist( index, oldtraj->hiRange() );
769 double gapmid = ( gapend + gapstart ) / 2.0;
770 HepPoint3D mid = position( gapmid );
771 // approximate initial (local) fltlen for poca
772 double locmid = newtraj->hiRange() - gapstart + gapmid;
773 TrkPoca midpoca( *newtraj, locmid, mid, _TOL );
774 if ( midpoca.status().success() )
775 {
776 // create a 0-length copy of the new traj to associate with the midpoint.
777 // This insures correct coverage of the global flight range
778 TrkSimpTraj* gaptraj = (TrkSimpTraj*)( newtraj->clone() );
779 assert( gaptraj != 0 );
780 double range[2];
781 range[0] = midpoca.flt1();
782 range[1] = range[0];
783 gaptraj->setFlightRange( range );
784 // insert the trajectories
785 _localtraj.push_front( gaptraj );
786 _localtraj.push_front( newtraj );
787 // append the new global range
788 _globalrange.push_front( gapmid );
789 _globalrange.push_front( gapstart - newtraj->range() );
790 // extend the piece-trajs own range
791 flightrange[0] = _globalrange.front();
792 // measure the gap at the midpoint
793 gap = mid.distance( newtraj->position( midpoca.flt1() ) );
794 }
795 else retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
796 }
797 else retval = TrkErrCode( TrkErrCode::fail, 8, "invalid range" );
798 }
799 else retval = TrkErrCode( TrkErrCode::fail, 7, "poca failure" );
800 return retval;
801}

◆ prepend() [11/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( TrkSimpTraj * traj,
double & gap )

◆ prepend() [12/12]

const TrkErrCode & TrkDifPieceTraj::prepend ( TrkSimpTraj * traj,
double & gap )

◆ print() [1/3]

void TrkDifPieceTraj::print ( std::ostream & os) const
virtual

Reimplemented from Trajectory.

◆ print() [2/3]

void TrkDifPieceTraj::print ( std::ostream & os) const
virtual

Reimplemented from Trajectory.

◆ print() [3/3]

void TrkDifPieceTraj::print ( std::ostream & os) const
virtual

Reimplemented from Trajectory.

◆ printAll() [1/3]

void TrkDifPieceTraj::printAll ( std::ostream & os) const
virtual

Reimplemented from Trajectory.

◆ printAll() [2/3]

void TrkDifPieceTraj::printAll ( std::ostream & os) const
virtual

Reimplemented from Trajectory.

◆ printAll() [3/3]

void TrkDifPieceTraj::printAll ( std::ostream & os) const
virtual

Reimplemented from Trajectory.

◆ resize() [1/3]

int TrkDifPieceTraj::resize ( double len,
trkDirection tdir )
protected

Definition at line 537 of file TrkDifPieceTraj.cxx.

537 {
538 int nremoved( 0 );
539 TrkSimpTraj* trajpiece;
540 double oldend, locdist;
541 double lrange[2];
542 int ipiece = trajIndex( len, locdist );
543 switch ( tdir )
544 {
545 case trkIn:
546 //
547 // Reset the range. Delete trajectory pieces till we're in range.
548 // This will leave the trajectory with a starting range different from
549 // 0, but it'll still be self-consistent
550 //
551 while ( ipiece > 0 )
552 {
553 nremoved++;
554 trajpiece = _localtraj.front();
555 _localtraj.pop_front();
556 delete trajpiece;
557 oldend = _globalrange.front();
558 _globalrange.pop_front();
559 ipiece = trajIndex( len, locdist );
560 }
561 // reset the global range
562 flightrange[0] = len;
563 _globalrange[ipiece] = len;
564 // reset the local traj piece range
565 lrange[0] = locdist;
566 lrange[1] = _localtraj[ipiece]->hiRange();
567 _localtraj[ipiece]->setFlightRange( lrange );
568 break;
569 case trkOut:
570 while ( ipiece < _localtraj.size() - 1 )
571 {
572 nremoved++;
573 trajpiece = _localtraj.back();
574 _localtraj.pop_back();
575 delete trajpiece;
576 oldend = _globalrange.back();
577 _globalrange.pop_back();
578 ipiece = trajIndex( len, locdist );
579 }
580 flightrange[1] = len;
581 _globalrange[ipiece + 1] = len;
582 lrange[0] = _localtraj[ipiece]->lowRange();
583 lrange[1] = locdist;
584 _localtraj[ipiece]->setFlightRange( lrange );
585 break;
586 }
587 return nremoved;
588}

Referenced by append(), prepend(), and setFlightRange().

◆ resize() [2/3]

int TrkDifPieceTraj::resize ( double len,
trkDirection  )
protected

◆ resize() [3/3]

int TrkDifPieceTraj::resize ( double len,
trkDirection  )
protected

◆ setFlightRange() [1/3]

void TrkDifPieceTraj::setFlightRange ( double newrange[2])
virtual

Reimplemented from Trajectory.

Definition at line 619 of file TrkDifPieceTraj.cxx.

619 {
620 double oldend;
621 double lrange[2];
622 TrkSimpTraj* trajpiece;
623 //
624 // Check for pathological cases
625 //
626 if ( newrange[1] > newrange[0] && newrange[0] < flightrange[1] &&
627 newrange[1] > flightrange[0] )
628 {
629 resize( newrange[0], trkIn );
630 resize( newrange[1], trkOut );
631 }
632 else if ( newrange[1] < newrange[0] )
633 {
634#ifdef MDCPATREC_ERROR
635 std::cout << "ErrMsg(error) "
636 << "cannot resize -- invalid range" << std::endl;
637#endif
638 }
639 else
640 {
641 //
642 // Here the new range is completely discontinuous from the
643 // old. We'll just take the first (or last) traj piece,
644 // clear out everything else, and reset the ranges.
645 //
646 if ( newrange[0] > flightrange[1] )
647 {
648 while ( _localtraj.size() > 1 )
649 {
650 trajpiece = _localtraj.front();
651 _localtraj.pop_front();
652 delete trajpiece;
653 oldend = _globalrange.front();
654 _globalrange.pop_front();
655 }
656 }
657 else
658 {
659 while ( _localtraj.size() > 1 )
660 {
661 trajpiece = _localtraj.back();
662 _localtraj.pop_back();
663 delete trajpiece;
664 oldend = _globalrange.back();
665 _globalrange.pop_back();
666 }
667 }
668 lrange[0] = localDist( 0, newrange[0] );
669 lrange[1] = localDist( 0, newrange[1] );
670 flightrange[0] = newrange[0];
671 flightrange[1] = newrange[1];
672 _globalrange[0] = newrange[0];
673 _globalrange[1] = newrange[1];
674 _localtraj[0]->setFlightRange( lrange );
675 }
676}

Referenced by TrkDifPieceTraj().

◆ setFlightRange() [2/3]

void TrkDifPieceTraj::setFlightRange ( double newrange[2])
virtual

Reimplemented from Trajectory.

◆ setFlightRange() [3/3]

void TrkDifPieceTraj::setFlightRange ( double newrange[2])
virtual

Reimplemented from Trajectory.

◆ trajIndex() [1/3]

int TrkDifPieceTraj::trajIndex ( const double & global,
double & local ) const
protected

Definition at line 367 of file TrkDifPieceTraj.cxx.

367 {
368 int index( 0 ); // true when there's only 1 entry
369 if ( _localtraj.size() > 1 )
370 {
371 if ( validFlightDistance( flightdist ) )
372 {
373 // explicitly check cached value from last call
374 if ( _lastIndex >= 0 && _lastIndex < _localtraj.size() - 1 &&
375 flightdist > _globalrange[_lastIndex] && flightdist < _globalrange[_lastIndex + 1] )
376 { index = _lastIndex; }
377 else
378 {
379 //
380 // simple binary search algorithm
381 //
382 int hirange = _localtraj.size() - 1;
383 int lorange = 0;
384 index = hirange / 2;
385 int oldindex = -1;
386 while ( index != oldindex )
387 {
388 oldindex = index;
389 if ( flightdist < _globalrange[index] )
390 {
391 hirange = index;
392 index -= max( 1, ( index - lorange ) / 2 );
393 }
394 else if ( flightdist > _globalrange[index + 1] )
395 {
396 lorange = index;
397 index += max( 1, ( hirange - index ) / 2 );
398 }
399 }
400 }
401 }
402 else
403 {
404 //
405 // Return the appropriate end if the requested flightdistance is outside the
406 // global range
407 //
408 index = ( flightdist < lowRange() ? 0 : ( _localtraj.size() - 1 ) );
409 }
410 }
411 localflight = localDist( index, flightdist );
412 // cache value for next time
413 _lastIndex = index;
414 return index;
415}
bool validFlightDistance(double f, double tolerance=0.0) const

Referenced by append(), distTo1stError(), distTo2ndError(), localTrajectory(), prepend(), and resize().

◆ trajIndex() [2/3]

int TrkDifPieceTraj::trajIndex ( const double & global,
double & local ) const
protected

◆ trajIndex() [3/3]

int TrkDifPieceTraj::trajIndex ( const double & global,
double & local ) const
protected

Member Data Documentation

◆ _globalrange

◆ _lastIndex

int TrkDifPieceTraj::_lastIndex
mutableprotected

◆ _localtraj


The documentation for this class was generated from the following files: