LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 29 of file KTrack.cxx.

int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:93
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:92
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 37 of file KTrack.cxx.

38  : fSurf(psurf), fDir(Surface::UNKNOWN), fPdgCode(0)
39  {}
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:90
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:93
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:92
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 50 of file KTrack.cxx.

54  : fSurf(psurf), fVec(vec), fDir(dir), fPdgCode(pdg)
55  {}
TrackVector fVec
Track state vector.
Definition: KTrack.h:91
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:90
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:93
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:92
TDirectory * dir
Definition: macro.C:5
trkf::KTrack::~KTrack ( )
virtual

Destructor.

Definition at line 58 of file KTrack.cxx.

58 {}

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 64 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::PropYZLine::origin_vec_prop(), trkf::PropYZPlane::origin_vec_prop(), trkf::PropXYZPlane::origin_vec_prop(), trkf::PropYZPlane::short_vec_prop(), and trkf::PropXYZPlane::short_vec_prop().

65  {
67  if (fSurf.get() != 0) result = fSurf->getDirection(fVec, fDir);
68  return result;
69  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:91
TrackDirection
Track direction enum.
Definition: Surface.h:54
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:90
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:92
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 201 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().

202  {
203  if (!isValid())
204  throw cet::exception("KTrack") << "Momentum vector requested for invalid track.\n";
206  fSurf->getMomentum(fVec, mom, dir);
207  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:91
TrackDirection
Track direction enum.
Definition: Surface.h:54
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:90
TDirectory * dir
Definition: macro.C:5
Surface::TrackDirection getDirection() const
Track direction.
Definition: KTrack.cxx:64
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool isValid() const
Test if track is valid.
Definition: KTrack.cxx:81
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 157 of file KTrack.cxx.

References fSurf, fVec, and isValid().

Referenced by trkf::KGTrack::fillTrack(), trkf::InteractGeneral::noise(), trkf::PropYZLine::origin_vec_prop(), trkf::PropXYZPlane::origin_vec_prop(), trkf::PropYZPlane::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().

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

Modifiable state vector.

Definition at line 61 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 81 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().

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

Based on pdg code.

Particle mass based on pdg code.

Definition at line 116 of file KTrack.cxx.

References util::abs(), and 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().

117  {
118  double mass = 0.;
119  int apdg = std::abs(fPdgCode);
120 
121  // Muon
122 
123  if (apdg == 13) mass = mumass;
124 
125  // Charged pion
126 
127  else if (apdg == 211)
128  mass = pimass;
129 
130  // Charged kaon
131 
132  else if (apdg == 321)
133  mass = kmass;
134 
135  // (Anti)proton
136 
137  else if (apdg == 2212)
138  mass = pmass;
139 
140  // Anything else throw exception
141 
142  else
143  throw cet::exception("KTrack") << "Mass requested for invalid pdg id = " << fPdgCode << "\n";
144 
145  // Done.
146 
147  return mass;
148  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:93
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int trkf::KTrack::PdgCode ( ) const
inline

Pdg code.

Definition at line 56 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 210 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().

211  {
212  if (doTitle) out << "KTrack:\n";
213  double xyz[3];
214  double dir[3];
215  getPosition(xyz);
216  getMomentum(dir);
217  double p = std::sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);
218  if (p != 0.) {
219  dir[0] /= p;
220  dir[1] /= p;
221  dir[2] /= p;
222  }
223  out << " Surface direction = "
224  << (fDir == Surface::FORWARD ? "FORWARD" :
225  (fDir == Surface::BACKWARD ? "BACKWARD" : "UNKNOWN"))
226  << "\n"
227  << " Pdg = " << fPdgCode << "\n"
228  << " Surface: " << *fSurf << "\n"
229  << " Track parameters:\n"
230  << " [";
231  for (unsigned int i = 0; i < fVec.size(); ++i) {
232  if (i != 0) out << ", ";
233  out << fVec(i);
234  }
235  out << "]\n";
236  out << " Position: [" << xyz[0] << ", " << xyz[1] << ", " << xyz[2] << "]\n";
237  out << " Direction: [" << dir[0] << ", " << dir[1] << ", " << dir[2] << "]\n";
238  out << " X-Latitude = " << XLatitude() << "\n";
239  out << " X-Longitude = " << XLongitude() << "\n";
240  return out;
241  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:91
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:90
double XLongitude() const
Get x-longitude.
Definition: KTrack.cxx:185
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:93
void getPosition(double xyz[3]) const
Get position of track.
Definition: KTrack.cxx:157
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:92
TDirectory * dir
Definition: macro.C:5
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:201
double XLatitude() const
Get x-latitude.
Definition: KTrack.cxx:169
void trkf::KTrack::setDirection ( Surface::TrackDirection  dir)
inline
void trkf::KTrack::setPdgCode ( int  pdg)
inline

Set pdg code.

Definition at line 67 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 169 of file KTrack.cxx.

References getMomentum().

Referenced by Print(), and setPdgCode().

170  {
171  double mom[3];
172  getMomentum(mom);
173  double ptx = std::sqrt(mom[1] * mom[1] + mom[2] * mom[2]);
174  double result = 0.;
175  if (ptx > 0. || mom[0] > 0.) result = atan2(mom[0], ptx);
176  return result;
177  }
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:201
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 185 of file KTrack.cxx.

References getMomentum().

Referenced by Print(), and setPdgCode().

186  {
187  double mom[3];
188  getMomentum(mom);
189  double result = 0.;
190  if (mom[1] != 0. || mom[2] != 0.) result = atan2(mom[1], mom[2]);
191  return result;
192  }
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:201

Member Data Documentation

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

Track direction.

Definition at line 92 of file KTrack.h.

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

int trkf::KTrack::fPdgCode
private

Pdg id. hypothesis.

Definition at line 93 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 90 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 91 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: