All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
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.

29  :
31  fPdgCode(0)
32  {}
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 40 of file KTrack.cxx.

40  :
41  fSurf(psurf),
43  fPdgCode(0)
44  {}
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 55 of file KTrack.cxx.

58  :
59  fSurf(psurf),
60  fVec(vec),
61  fDir(dir),
62  fPdgCode(pdg)
63  {}
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
var pdg
Definition: selectors.fcl:14
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
tuple dir
Definition: dropbox.py:28
trkf::KTrack::~KTrack ( )
virtual

Destructor.

Definition at line 66 of file KTrack.cxx.

67  {}

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 73 of file KTrack.cxx.

74  {
76  if(fSurf.get() != 0)
77  result = fSurf->getDirection(fVec, fDir);
78  return result;
79  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
TrackDirection
Track direction enum.
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 218 of file KTrack.cxx.

219  {
220  if(!isValid())
221  throw cet::exception("KTrack") << "Momentum vector requested for invalid track.\n";
223  fSurf->getMomentum(fVec, mom, dir);
224  }
TrackVector fVec
Track state vector.
Definition: KTrack.h:94
TrackDirection
Track direction enum.
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
tuple dir
Definition: dropbox.py:28
Surface::TrackDirection getDirection() const
Track direction.
Definition: KTrack.cxx:73
bool isValid() const
Test if track is valid.
Definition: KTrack.cxx:91
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 171 of file KTrack.cxx.

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

Surface.

Definition at line 55 of file KTrack.h.

const TrackVector& trkf::KTrack::getVector ( ) const
inline

Track state vector.

Definition at line 56 of file KTrack.h.

TrackVector& trkf::KTrack::getVector ( )
inline

Modifiable state vector.

Definition at line 63 of file KTrack.h.

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 91 of file KTrack.cxx.

92  {
93  bool result = true;
94 
95  // Check for valid direction.
96 
98  result = false;
99 
100  // Check for non-null surface pointer (for safety, should be redundant
101  // with previous check.
102 
103  if(result && fSurf.get() == 0)
104  result = false;
105 
106  // Check for track parameters containing invalid floating point
107  // values.
108 
109  if(result) {
110  for(unsigned int i=0; i<fVec.size(); ++i) {
111  if(!std::isfinite(fVec(i))) {
112  result = false;
113  break;
114  }
115  }
116  }
117 
118  // Surface-dependent check on track validity.
119 
120  if(result && !fSurf->isTrackValid(fVec))
121  result = false;
122 
123  // Done.
124 
125  return result;
126  }
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:73
double trkf::KTrack::Mass ( ) const

Based on pdg code.

Particle mass based on pdg code.

Definition at line 129 of file KTrack.cxx.

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

Pdg code.

Definition at line 58 of file KTrack.h.

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 227 of file KTrack.cxx.

228  {
229  if(doTitle)
230  out << "KTrack:\n";
231  double xyz[3];
232  double dir[3];
233  getPosition(xyz);
234  getMomentum(dir);
235  double p = std::sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]);
236  if(p != 0.) {
237  dir[0] /= p;
238  dir[1] /= p;
239  dir[2] /= p;
240  }
241  out << " Surface direction = " << (fDir == Surface::FORWARD ?
242  "FORWARD" :
243  ( fDir == Surface::BACKWARD ?
244  "BACKWARD" : "UNKNOWN" )) << "\n"
245  << " Pdg = " << fPdgCode << "\n"
246  << " Surface: " << *fSurf << "\n"
247  << " Track parameters:\n"
248  << " [";
249  for(unsigned int i = 0; i < fVec.size(); ++i) {
250  if(i != 0)
251  out << ", ";
252  out << fVec(i);
253  }
254  out << "]\n";
255  out << " Position: [" << xyz[0] << ", " << xyz[1] << ", " << xyz[2] << "]\n";
256  out << " Direction: [" << dir[0] << ", " << dir[1] << ", " << dir[2] << "]\n";
257  out << " X-Latitude = " << XLatitude() << "\n";
258  out << " X-Longitude = " << XLongitude() << "\n";
259  return out;
260  }
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:201
pdgs p
Definition: selectors.fcl:22
int fPdgCode
Pdg id. hypothesis.
Definition: KTrack.h:96
void getPosition(double xyz[3]) const
Get position of track.
Definition: KTrack.cxx:171
Surface::TrackDirection fDir
Track direction.
Definition: KTrack.h:95
tuple dir
Definition: dropbox.py:28
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:218
double XLatitude() const
Get x-latitude.
Definition: KTrack.cxx:184
void trkf::KTrack::setDirection ( Surface::TrackDirection  dir)
inline

Set direction.

Definition at line 68 of file KTrack.h.

void trkf::KTrack::setPdgCode ( int  pdg)
inline

Set pdg code.

Definition at line 69 of file KTrack.h.

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

Set surface.

Definition at line 66 of file KTrack.h.

66 {fSurf = psurf;}
std::shared_ptr< const Surface > fSurf
Track surface.
Definition: KTrack.h:93
void trkf::KTrack::setVector ( const TrackVector vec)
inline

Set state vector.

Definition at line 67 of file KTrack.h.

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 184 of file KTrack.cxx.

185  {
186  double mom[3];
187  getMomentum(mom);
188  double ptx = std::sqrt(mom[1]*mom[1] + mom[2]*mom[2]);
189  double result = 0.;
190  if(ptx > 0. || mom[0] > 0.)
191  result = atan2(mom[0], ptx);
192  return result;
193  }
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:218
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 201 of file KTrack.cxx.

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

Member Data Documentation

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

Track direction.

Definition at line 95 of file KTrack.h.

int trkf::KTrack::fPdgCode
private

Pdg id. hypothesis.

Definition at line 96 of file KTrack.h.

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

Track surface.

Definition at line 93 of file KTrack.h.

TrackVector trkf::KTrack::fVec
private

Track state vector.

Definition at line 94 of file KTrack.h.


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