LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
trkf::KTrack Class Reference

#include "KTrack.h"

Inheritance diagram for trkf::KTrack:
trkf::KETrack trkf::KFitTrack trkf::KHitsTrack trkf::KHitTrack

Public Member Functions

 KTrack ()
 Enum. More...
 
 KTrack (const std::shared_ptr< const Surface > &psurf)
 Constructor - specify surface only. More...
 
 KTrack (std::shared_ptr< const Surface > psurf, const TrackVector &vec, Surface::TrackDirection dir=Surface::UNKNOWN, int pdg=0)
 Constructor - surface + track parameters. More...
 
virtual ~KTrack ()
 Destructor. More...
 
const std::shared_ptr< const Surface > & getSurface () const
 Surface. More...
 
const TrackVectorgetVector () const
 Track state vector. More...
 
Surface::TrackDirection getDirection () const
 Track direction. More...
 
int PdgCode () const
 Pdg code. More...
 
double Mass () const
 Based on pdg code. More...
 
TrackVectorgetVector ()
 Modifiable state vector. More...
 
void setSurface (const std::shared_ptr< const Surface > &psurf)
 Set surface. More...
 
void setVector (const TrackVector &vec)
 Set state vector. More...
 
void setDirection (Surface::TrackDirection dir)
 Set direction. More...
 
void setPdgCode (int pdg)
 Set pdg code. More...
 
bool isValid () const
 Test if track is valid. More...
 
void getPosition (double xyz[3]) const
 Get position of track. More...
 
void getMomentum (double mom[3]) const
 Get momentum vector of track. More...
 
double XLatitude () const
 Get x-latitude. More...
 
double XLongitude () const
 Get x-longitude. More...
 
virtual std::ostream & Print (std::ostream &out, bool doTitle=true) const
 Printout. More...
 

Private Attributes

std::shared_ptr< const SurfacefSurf
 Track surface. More...
 
TrackVector fVec
 Track state vector. More...
 
Surface::TrackDirection fDir
 Track direction. More...
 
int fPdgCode
 Pdg id. hypothesis. More...
 

Detailed Description

Definition at line 32 of file KTrack.h.

Constructor & Destructor Documentation

trkf::KTrack::KTrack ( )

Enum.

Default constructor.

Definition at line 28 of file KTrack.cxx.

28  :
30  fPdgCode(0)
31  {}
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
trkf::KTrack::KTrack ( const std::shared_ptr< const Surface > &  psurf)

Constructor - specify surface only.

Constructor - specify surface only.

Arguments:

psurf - Surface pointer.

Definition at line 39 of file KTrack.cxx.

39  :
40  fSurf(psurf),
42  fPdgCode(0)
43  {}
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
trkf::KTrack::KTrack ( std::shared_ptr< const Surface psurf,
const TrackVector vec,
Surface::TrackDirection  dir = Surface::UNKNOWN,
int  pdg = 0 
)

Constructor - surface + track parameters.

Constructor - surface + track parameters.

Arguments:

psurf - Surface pointer. vec - Track state vector. dir - Track direction. pdg - Pdg code.

Definition at line 54 of file KTrack.cxx.

57  :
58  fSurf(psurf),
59  fVec(vec),
60  fDir(dir),
61  fPdgCode(pdg)
62  {}
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
TDirectory * dir
Definition: macro.C:5
trkf::KTrack::~KTrack ( )
virtual

Destructor.

Definition at line 65 of file KTrack.cxx.

66  {}

Member Function Documentation

Surface::TrackDirection trkf::KTrack::getDirection ( ) const

Track direction.

Track direction accessor. Track direction implied by track parameters has precedence over track direction attribute. If the surface pointer is null, return UNKNOWN.

Definition at line 72 of file KTrack.cxx.

References fDir, fSurf, fVec, and trkf::Surface::UNKNOWN.

Referenced by getMomentum(), getVector(), isValid(), trkf::Propagator::lin_prop(), trkf::InteractPlane::noise(), trkf::PropYZPlane::origin_vec_prop(), trkf::PropXYZPlane::origin_vec_prop(), trkf::PropYZLine::origin_vec_prop(), trkf::PropYZPlane::short_vec_prop(), and trkf::PropXYZPlane::short_vec_prop().

73  {
75  if(fSurf.get() != 0)
76  result = fSurf->getDirection(fVec, fDir);
77  return result;
78  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
TrackDirection
Track direction enum.
Definition: Surface.h:56
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
void trkf::KTrack::getMomentum ( double  mom[3]) const

Get momentum vector of track.

Get momentum vector of track. Throw an exception if track is not valid.

Arguments:

mom - Momentum vector of track.

Definition at line 217 of file KTrack.cxx.

References dir, fSurf, fVec, getDirection(), and isValid().

Referenced by trkf::KGTrack::fillTrack(), trkf::InteractGeneral::noise(), Print(), trkf::KGTrack::Print(), trkf::Track3DKalmanHitAlg::qualityCutsOnSeedTrack(), setPdgCode(), trkf::Propagator::vec_prop(), XLatitude(), and XLongitude().

218  {
219  if(!isValid())
220  throw cet::exception("KTrack") << "Momentum vector requested for invalid track.\n";
222  fSurf->getMomentum(fVec, mom, dir);
223  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
TrackDirection
Track direction enum.
Definition: Surface.h:56
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
TDirectory * dir
Definition: macro.C:5
Surface::TrackDirection getDirection() const
Track direction.
Definition: KTrack.cxx:72
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool isValid() const
Test if track is valid.
Definition: KTrack.cxx:90
void trkf::KTrack::getPosition ( double  xyz[3]) const

Get position of track.

Get position of track. Throw an exception if track is not valid.

Arguments:

xyz - Position vector.

Definition at line 170 of file KTrack.cxx.

References fSurf, fVec, and isValid().

Referenced by trkf::KGTrack::fillTrack(), trkf::InteractGeneral::noise(), trkf::PropYZLine::origin_vec_prop(), trkf::PropYZPlane::origin_vec_prop(), trkf::PropXYZPlane::origin_vec_prop(), Print(), trkf::KGTrack::Print(), setPdgCode(), trkf::PropYZLine::short_vec_prop(), trkf::PropYZPlane::short_vec_prop(), trkf::PropXYZPlane::short_vec_prop(), and trkf::Propagator::vec_prop().

171  {
172  if(!isValid())
173  throw cet::exception("KTrack") << "Position requested for invalid track.\n";
174  fSurf->getPosition(fVec, xyz);
175  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool isValid() const
Test if track is valid.
Definition: KTrack.cxx:90
TrackVector& trkf::KTrack::getVector ( )
inline

Modifiable state vector.

Definition at line 63 of file KTrack.h.

References fVec.

bool trkf::KTrack::isValid ( ) const

Test if track is valid.

Test if track is valid.

A default-constructed or partially-constructed track, is invalid by virtue of having an unknown propagation direction or a null surface pointer.

Tracks can become invaliddynamically for other reasons. This method also does the following checks: a) Check for invalid floating point values (inf and nan). b) Surface-dependent checks via virtual method Surface::isTrackValid.

Definition at line 90 of file KTrack.cxx.

References fSurf, fVec, getDirection(), geo::vect::isfinite(), and trkf::Surface::UNKNOWN.

Referenced by trkf::KGTrack::addTrack(), trkf::KalmanFilterAlg::buildTrack(), trkf::KETrack::combineTrack(), trkf::KalmanFilterAlg::extendTrack(), getMomentum(), getPosition(), trkf::Propagator::lin_prop(), trkf::PropYZLine::origin_vec_prop(), trkf::PropXYZPlane::origin_vec_prop(), trkf::PropYZPlane::origin_vec_prop(), trkf::KETrack::PointingError(), setPdgCode(), and trkf::KalmanFilterAlg::smoothTrack().

91  {
92  bool result = true;
93 
94  // Check for valid direction.
95 
97  result = false;
98 
99  // Check for non-null surface pointer (for safety, should be redundant
100  // with previous check.
101 
102  if(result && fSurf.get() == 0)
103  result = false;
104 
105  // Check for track parameters containing invalid floating point
106  // values.
107 
108  if(result) {
109  for(unsigned int i=0; i<fVec.size(); ++i) {
110  if(!std::isfinite(fVec(i))) {
111  result = false;
112  break;
113  }
114  }
115  }
116 
117  // Surface-dependent check on track validity.
118 
119  if(result && !fSurf->isTrackValid(fVec))
120  result = false;
121 
122  // Done.
123 
124  return result;
125  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
bool isfinite(Vector const &v)
Returns whether all components of the vector are finite.
Surface::TrackDirection getDirection() const
Track direction.
Definition: KTrack.cxx:72
double trkf::KTrack::Mass ( ) const

Based on pdg code.

Particle mass based on pdg code.

Definition at line 128 of file KTrack.cxx.

References fPdgCode.

Referenced by trkf::KalmanFilterAlg::fitMomentumMS(), trkf::InteractPlane::noise(), PdgCode(), trkf::PropYZLine::short_vec_prop(), trkf::PropXYZPlane::short_vec_prop(), trkf::PropYZPlane::short_vec_prop(), and trkf::Propagator::vec_prop().

129  {
130  double mass = 0.;
131  int apdg = std::abs(fPdgCode);
132 
133  // Muon
134 
135  if(apdg == 13)
136  mass = mumass;
137 
138  // Charged pion
139 
140  else if(apdg == 211)
141  mass = pimass;
142 
143  // Charged kaon
144 
145  else if(apdg == 321)
146  mass = kmass;
147 
148  // (Anti)proton
149 
150  else if(apdg == 2212)
151  mass = pmass;
152 
153  // Anything else throw exception
154 
155  else
156  throw cet::exception("KTrack") << "Mass requested for invalid pdg id = " << fPdgCode << "\n";
157 
158  // Done.
159 
160  return mass;
161  }
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int trkf::KTrack::PdgCode ( ) const
inline

Pdg code.

Definition at line 58 of file KTrack.h.

References fPdgCode, and Mass().

std::ostream & trkf::KTrack::Print ( std::ostream &  out,
bool  doTitle = true 
) const
virtual

Printout.

Reimplemented in trkf::KFitTrack, trkf::KETrack, trkf::KHitsTrack, and trkf::KHitTrack.

Definition at line 226 of file KTrack.cxx.

References trkf::Surface::BACKWARD, dir, fDir, trkf::Surface::FORWARD, fPdgCode, fSurf, fVec, getMomentum(), getPosition(), XLatitude(), and XLongitude().

Referenced by trkf::operator<<(), trkf::KETrack::Print(), and setPdgCode().

227  {
228  if(doTitle)
229  out << "KTrack:\n";
230  double xyz[3];
231  double dir[3];
232  getPosition(xyz);
233  getMomentum(dir);
234  double p = std::sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]);
235  if(p != 0.) {
236  dir[0] /= p;
237  dir[1] /= p;
238  dir[2] /= p;
239  }
240  out << " Surface direction = " << (fDir == Surface::FORWARD ?
241  "FORWARD" :
242  ( fDir == Surface::BACKWARD ?
243  "BACKWARD" : "UNKNOWN" )) << "\n"
244  << " Pdg = " << fPdgCode << "\n"
245  << " Surface: " << *fSurf << "\n"
246  << " Track parameters:\n"
247  << " [";
248  for(unsigned int i = 0; i < fVec.size(); ++i) {
249  if(i != 0)
250  out << ", ";
251  out << fVec(i);
252  }
253  out << "]\n";
254  out << " Position: [" << xyz[0] << ", " << xyz[1] << ", " << xyz[2] << "]\n";
255  out << " Direction: [" << dir[0] << ", " << dir[1] << ", " << dir[2] << "]\n";
256  out << " X-Latitude = " << XLatitude() << "\n";
257  out << " X-Longitude = " << XLongitude() << "\n";
258  return out;
259  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
double XLongitude() const
Get x-longitude.
Definition: KTrack.cxx:200
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
void getPosition(double xyz[3]) const
Get position of track.
Definition: KTrack.cxx:170
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
TDirectory * dir
Definition: macro.C:5
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:217
double XLatitude() const
Get x-latitude.
Definition: KTrack.cxx:183
void trkf::KTrack::setDirection ( Surface::TrackDirection  dir)
inline
void trkf::KTrack::setPdgCode ( int  pdg)
inline

Set pdg code.

Definition at line 69 of file KTrack.h.

References fPdgCode, getMomentum(), getPosition(), isValid(), Print(), XLatitude(), and XLongitude().

void trkf::KTrack::setSurface ( const std::shared_ptr< const Surface > &  psurf)
inline
double trkf::KTrack::XLatitude ( ) const

Get x-latitude.

Get x-latitude.

The x-latitude is the latitude defined with respect to the x-axis. The x-latitude is zero of the track is traveling parallel to the wire planes.

Definition at line 183 of file KTrack.cxx.

References getMomentum().

Referenced by Print(), and setPdgCode().

184  {
185  double mom[3];
186  getMomentum(mom);
187  double ptx = std::sqrt(mom[1]*mom[1] + mom[2]*mom[2]);
188  double result = 0.;
189  if(ptx > 0. || mom[0] > 0.)
190  result = atan2(mom[0], ptx);
191  return result;
192  }
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:217
double trkf::KTrack::XLongitude ( ) const

Get x-longitude.

Get x-longitude.

The x-longitude is the longitude defined with respect to the y- and z-axes. The x-longitude is zero of the track is parallel to the z-axis in the yz-plane.

Definition at line 200 of file KTrack.cxx.

References getMomentum().

Referenced by Print(), and setPdgCode().

201  {
202  double mom[3];
203  getMomentum(mom);
204  double result = 0.;
205  if(mom[1] != 0. || mom[2] != 0.)
206  result = atan2(mom[1], mom[2]);
207  return result;
208  }
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:217

Member Data Documentation

Surface::TrackDirection trkf::KTrack::fDir
private

Track direction.

Definition at line 95 of file KTrack.h.

Referenced by getDirection(), Print(), and setDirection().

int trkf::KTrack::fPdgCode
private

Pdg id. hypothesis.

Definition at line 96 of file KTrack.h.

Referenced by Mass(), PdgCode(), Print(), and setPdgCode().

std::shared_ptr<const Surface> trkf::KTrack::fSurf
private

Track surface.

Definition at line 93 of file KTrack.h.

Referenced by getDirection(), getMomentum(), getPosition(), getSurface(), isValid(), Print(), and setSurface().

TrackVector trkf::KTrack::fVec
private

Track state vector.

Definition at line 94 of file KTrack.h.

Referenced by getDirection(), getMomentum(), getPosition(), getVector(), isValid(), Print(), and setVector().


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