LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::KHitWireLine Class Referenceabstract

#include "KHitWireLine.h"

Inheritance diagram for trkf::KHitWireLine:
trkf::KHit< 1 > trkf::KHitBase

Public Member Functions

 KHitWireLine (const detinfo::DetectorPropertiesData &detProp, const art::Ptr< recob::Hit > &hit, const std::shared_ptr< const Surface > &psurf)
 Constructor from Hit. More...
 
 KHitWireLine (const geo::WireID &wireid, double x, double xerr)
 Constructor from wire id (mainly for testing). More...
 
const art::Ptr< recob::Hit > & getHit () const
 Get original hit. More...
 
bool subpredict (const KETrack &tre, KVector< 1 >::type &pvec, KSymMatrix< 1 >::type &perr, KHMatrix< 1 >::type &hmatrix) const override
 
void setMeasVector (const typename KVector< N >::type &mvec)
 Set measurement vector. More...
 
void setMeasError (const typename KSymMatrix< N >::type &merr)
 Set measurement error. More...
 
const KVector< N >::typegetMeasVector () const
 Measurement vector. More...
 
const KSymMatrix< N >::typegetMeasError () const
 Measurement error matrix. More...
 
const KVector< N >::typegetPredVector () const
 Prediction vector. More...
 
const KSymMatrix< N >::typegetPredError () const
 Prediction matrix. More...
 
const KVector< N >::typegetResVector () const
 Residual vector. More...
 
const KSymMatrix< N >::typegetResError () const
 Residual error matrix. More...
 
const KSymMatrix< N >::typegetResInvError () const
 Residual inv. error matrix. More...
 
const KHMatrix< N >::typegetH () const
 Kalman H-matrix. More...
 
double getChisq () const
 Incremental chisquare. More...
 
bool predict (const KETrack &tre, const Propagator &prop, const KTrack *ref=0) const
 Prediction method (return false if fail). More...
 
void update (KETrack &tre) const
 Update track method. More...
 
virtual bool subpredict (const KETrack &tre, typename KVector< N >::type &pvec, typename KSymMatrix< N >::type &perr, typename KHMatrix< N >::type &hmatrix) const =0
 Calculate prediction function (return via arguments). More...
 
virtual std::ostream & Print (std::ostream &out, bool doTitle=true) const
 Printout. More...
 
const std::shared_ptr< const Surface > & getPredSurface () const
 Predition surface. More...
 
double getPredDistance () const
 Prediction distance. More...
 
const std::shared_ptr< const Surface > & getMeasSurface () const
 Measurement surface. More...
 
int getMeasPlane () const
 Measurement plane index. More...
 
int getID () const
 Unique id. More...
 
void setMeasSurface (const std::shared_ptr< const Surface > &psurf)
 Measurement surface. More...
 
void setMeasPlane (int plane)
 Measurement plane. More...
 

Protected Attributes

std::shared_ptr< const SurfacefPredSurf
 Prediction surface. More...
 
double fPredDist
 Prediction distance. More...
 
int fID
 Unique id. More...
 

Private Attributes

art::Ptr< recob::HitfHit
 

Detailed Description

Definition at line 34 of file KHitWireLine.h.

Constructor & Destructor Documentation

trkf::KHitWireLine::KHitWireLine ( const detinfo::DetectorPropertiesData detProp,
const art::Ptr< recob::Hit > &  hit,
const std::shared_ptr< const Surface > &  psurf 
)

Constructor from Hit.

Constructor.

Arguments:

hit - Hit. psurf - Measurement surface (can be null).

The measurement surface is only a suggestion. It is allowed to be specified to allow measurements to whare surfaces to save memory.

Definition at line 31 of file KHitWireLine.cxx.

References util::abs(), recob::Hit::Channel(), detinfo::DetectorPropertiesData::ConvertTicksToX(), geo::CryostatID::Cryostat, trkf::KHitBase::fID, detinfo::DetectorPropertiesData::GetXTicksCoefficient(), trkf::SurfYZLine::isEqual(), recob::Hit::PeakTime(), geo::PlaneID::Plane, trkf::KHit< 1 >::setMeasError(), trkf::KHitBase::setMeasPlane(), trkf::KHitBase::setMeasSurface(), trkf::KHit< 1 >::setMeasVector(), recob::Hit::SigmaPeakTime(), geo::TPCID::TPC, recob::Hit::WireID(), and x.

34  : KHit(psurf), fHit(hit)
35  {
36  // Extract wire id.
37  geo::WireID wireid = hit->WireID();
38 
39  // Extract time information from hit.
40 
41  double t = hit->PeakTime();
42  double terr = hit->SigmaPeakTime();
43 
44  // Don't let the time error be less than 1./sqrt(12.) ticks.
45  // This should be removed when hit errors are fixed.
46 
47  if (terr < 1. / std::sqrt(12.)) terr = 1. / std::sqrt(12.);
48 
49  // Calculate position and error.
50 
51  double x = detProp.ConvertTicksToX(t, wireid.Plane, wireid.TPC, wireid.Cryostat);
52  double xerr = terr * detProp.GetXTicksCoefficient();
53 
54  // Check the surface (determined by wire id + drift time). If the
55  // surface pointer is null, make a new SurfWireLine surface and
56  // update the base class appropriately. Otherwise, just check
57  // that the specified surface agrees with the wire id + drift time.
58 
59  if (psurf.get() == 0) {
60  std::shared_ptr<const Surface> new_psurf(new SurfWireLine(wireid, x));
61  setMeasSurface(new_psurf);
62  }
63  else {
64  SurfWireLine check_surf(wireid, x);
65  if (!check_surf.isEqual(*psurf))
66  throw cet::exception("KHitWireLine") << "Measurement surface doesn't match hit.\n";
67  }
68 
69  setMeasPlane(wireid.Plane);
70 
71  // Update measurement vector and error matrix.
72 
73  trkf::KVector<1>::type mvec(1, 0.);
74  setMeasVector(mvec);
75 
77  merr(0, 0) = xerr * xerr;
78  setMeasError(merr);
79 
80  // Set the unique id from a combination of the channel number and the time.
81 
82  fID = (hit->Channel() % 200000) * 10000 + (int(std::abs(t)) % 10000);
83  }
void setMeasSurface(const std::shared_ptr< const Surface > &psurf)
Measurement surface.
Definition: KHitBase.h:93
Float_t x
Definition: compare.C:6
art::Ptr< recob::Hit > fHit
Definition: KHitWireLine.h:54
double GetXTicksCoefficient(int t, int c) const
constexpr auto abs(T v)
Returns the absolute value of the argument.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:211
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
ublas::symmetric_matrix< double, ublas::lower, ublas::row_major, ublas::bounded_array< double, N *(N+1)/2 > > type
KHit()
Default constructor.
void setMeasVector(const typename KVector< N >::type &mvec)
Set measurement vector.
Definition: KHit.h:93
ublas::vector< double, ublas::bounded_array< double, N > > type
void setMeasError(const typename KSymMatrix< N >::type &merr)
Set measurement error.
Definition: KHit.h:96
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
int fID
Unique id.
Definition: KHitBase.h:119
double ConvertTicksToX(double ticks, int p, int t, int c) const
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:220
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:96
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
Definition: Hit.h:224
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:399
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:268
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
trkf::KHitWireLine::KHitWireLine ( const geo::WireID wireid,
double  x,
double  xerr 
)

Constructor from wire id (mainly for testing).

Constructor.

Arguments:

wireid - Wire id. x - X coordinate. xerr - X error.

Definition at line 93 of file KHitWireLine.cxx.

References geo::PlaneID::Plane, trkf::KHit< 1 >::setMeasError(), trkf::KHitBase::setMeasPlane(), and trkf::KHit< 1 >::setMeasVector().

94  : KHit(std::shared_ptr<const Surface>(new SurfWireLine(wireid, x)))
95  {
96  // Get services.
97 
99 
100  // Get plane number.
101 
102  setMeasPlane(wireid.Plane);
103 
104  // Update measurement vector and error matrix.
105  // The measured value (aka impact parameter) is always zero.
106 
107  trkf::KVector<1>::type mvec(1, 0.);
108  setMeasVector(mvec);
109 
111  merr(0, 0) = xerr * xerr;
112  setMeasError(merr);
113  }
Float_t x
Definition: compare.C:6
ublas::symmetric_matrix< double, ublas::lower, ublas::row_major, ublas::bounded_array< double, N *(N+1)/2 > > type
KHit()
Default constructor.
void setMeasVector(const typename KVector< N >::type &mvec)
Set measurement vector.
Definition: KHit.h:93
ublas::vector< double, ublas::bounded_array< double, N > > type
void setMeasError(const typename KSymMatrix< N >::type &merr)
Set measurement error.
Definition: KHit.h:96
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:96

Member Function Documentation

double trkf::KHit< N >::getChisq ( ) const
inlinevirtualinherited

Incremental chisquare.

Implements trkf::KHitBase.

Definition at line 125 of file KHit.h.

References trkf::KHit< N >::fChisq, trkf::KHit< N >::predict(), trkf::KHit< N >::Print(), trkf::KHit< N >::subpredict(), and trkf::KHit< N >::update().

125 { return fChisq; }
double fChisq
Incremental chisquare.
Definition: KHit.h:158
const KHMatrix<N>::type& trkf::KHit< N >::getH ( ) const
inlineinherited

Kalman H-matrix.

Definition at line 122 of file KHit.h.

References trkf::KHit< N >::fH.

122 { return fH; }
KHMatrix< N >::type fH
Kalman H-matrix.
Definition: KHit.h:157
const art::Ptr<recob::Hit>& trkf::KHitWireLine::getHit ( ) const
inline

Get original hit.

Definition at line 45 of file KHitWireLine.h.

45 { return fHit; }
art::Ptr< recob::Hit > fHit
Definition: KHitWireLine.h:54
int trkf::KHitBase::getID ( ) const
inlineinherited
const KSymMatrix<N>::type& trkf::KHit< N >::getMeasError ( ) const
inlineinherited

Measurement error matrix.

Definition at line 104 of file KHit.h.

References trkf::KHit< N >::fMerr.

104 { return fMerr; }
KSymMatrix< N >::type fMerr
Measurement error matrix.
Definition: KHit.h:151
int trkf::KHitBase::getMeasPlane ( ) const
inlineinherited

Measurement plane index.

Definition at line 85 of file KHitBase.h.

References trkf::KHitBase::fMeasPlane.

Referenced by trkf::KalmanFilterAlg::buildTrack(), trkf::KalmanFilterAlg::cleanTrack(), trkf::KalmanFilterAlg::extendTrack(), and trkf::KGTrack::Print().

85 { return fMeasPlane; }
int fMeasPlane
Measurement plane index.
Definition: KHitBase.h:123
const std::shared_ptr<const Surface>& trkf::KHitBase::getMeasSurface ( ) const
inlineinherited

Measurement surface.

Definition at line 82 of file KHitBase.h.

References trkf::KHitBase::fMeasSurf.

Referenced by trkf::KHit< N >::predict(), subpredict(), and trkf::KHitWireX::subpredict().

82 { return fMeasSurf; }
std::shared_ptr< const Surface > fMeasSurf
Measurement surface.
Definition: KHitBase.h:122
const KVector<N>::type& trkf::KHit< N >::getMeasVector ( ) const
inlineinherited

Measurement vector.

Definition at line 101 of file KHit.h.

References trkf::KHit< N >::fMvec.

101 { return fMvec; }
KVector< N >::type fMvec
Measurement vector.
Definition: KHit.h:150
double trkf::KHitBase::getPredDistance ( ) const
inlineinherited

Prediction distance.

Definition at line 79 of file KHitBase.h.

References trkf::KHitBase::fPredDist.

Referenced by trkf::KalmanFilterAlg::buildTrack(), and trkf::KalmanFilterAlg::extendTrack().

79 { return fPredDist; }
double fPredDist
Prediction distance.
Definition: KHitBase.h:118
const KSymMatrix<N>::type& trkf::KHit< N >::getPredError ( ) const
inlineinherited

Prediction matrix.

Definition at line 110 of file KHit.h.

References trkf::KHit< N >::fPerr.

110 { return fPerr; }
KSymMatrix< N >::type fPerr
Prediction error matrix.
Definition: KHit.h:153
const std::shared_ptr<const Surface>& trkf::KHitBase::getPredSurface ( ) const
inlineinherited

Predition surface.

Definition at line 76 of file KHitBase.h.

References trkf::KHitBase::fPredSurf.

Referenced by trkf::KHitMulti::update(), and trkf::KHit< N >::update().

76 { return fPredSurf; }
std::shared_ptr< const Surface > fPredSurf
Prediction surface.
Definition: KHitBase.h:117
const KVector<N>::type& trkf::KHit< N >::getPredVector ( ) const
inlineinherited

Prediction vector.

Definition at line 107 of file KHit.h.

References trkf::KHit< N >::fPvec.

107 { return fPvec; }
KVector< N >::type fPvec
Prediction vector.
Definition: KHit.h:152
const KSymMatrix<N>::type& trkf::KHit< N >::getResError ( ) const
inlineinherited

Residual error matrix.

Definition at line 116 of file KHit.h.

References trkf::KHit< N >::fRerr.

116 { return fRerr; }
KSymMatrix< N >::type fRerr
Residual error matrix.
Definition: KHit.h:155
const KSymMatrix<N>::type& trkf::KHit< N >::getResInvError ( ) const
inlineinherited

Residual inv. error matrix.

Definition at line 119 of file KHit.h.

References trkf::KHit< N >::fRinv.

119 { return fRinv; }
KSymMatrix< N >::type fRinv
Residual inverse error matrix.
Definition: KHit.h:156
const KVector<N>::type& trkf::KHit< N >::getResVector ( ) const
inlineinherited

Residual vector.

Definition at line 113 of file KHit.h.

References trkf::KHit< N >::fRvec.

113 { return fRvec; }
KVector< N >::type fRvec
Residual vector.
Definition: KHit.h:154
bool trkf::KHit< N >::predict ( const KETrack tre,
const Propagator prop,
const KTrack ref = 0 
) const
virtualinherited

Prediction method (return false if fail).

Prediction method.

Arguments;

tre - Track prediction. prop - Propagator. ref - Reference track.

Implements trkf::KHitBase.

virtual std::ostream& trkf::KHit< N >::Print ( std::ostream &  out,
bool  doTitle = true 
) const
virtualinherited

Printout.

Reimplemented from trkf::KHitBase.

void trkf::KHit< N >::setMeasError ( const typename KSymMatrix< N >::type merr)
inlineinherited

Set measurement error.

Definition at line 96 of file KHit.h.

References trkf::KHit< N >::fMerr.

Referenced by KHitWireLine(), and trkf::KHitWireX::KHitWireX().

96 { fMerr = merr; }
KSymMatrix< N >::type fMerr
Measurement error matrix.
Definition: KHit.h:151
void trkf::KHitBase::setMeasPlane ( int  plane)
inlineinherited

Measurement plane.

Definition at line 96 of file KHitBase.h.

References trkf::KHitBase::fMeasPlane, trkf::KHitBase::getChisq(), trkf::KHitBase::predict(), trkf::KHitBase::Print(), and trkf::KHitBase::update().

Referenced by KHitWireLine(), and trkf::KHitWireX::KHitWireX().

96 { fMeasPlane = plane; }
int fMeasPlane
Measurement plane index.
Definition: KHitBase.h:123
void trkf::KHitBase::setMeasSurface ( const std::shared_ptr< const Surface > &  psurf)
inlineinherited

Measurement surface.

Definition at line 93 of file KHitBase.h.

References trkf::KHitBase::fMeasSurf.

Referenced by KHitWireLine(), and trkf::KHitWireX::KHitWireX().

93 { fMeasSurf = psurf; }
std::shared_ptr< const Surface > fMeasSurf
Measurement surface.
Definition: KHitBase.h:122
void trkf::KHit< N >::setMeasVector ( const typename KVector< N >::type mvec)
inlineinherited

Set measurement vector.

Definition at line 93 of file KHit.h.

References trkf::KHit< N >::fMvec.

Referenced by KHitWireLine(), and trkf::KHitWireX::KHitWireX().

93 { fMvec = mvec; }
KVector< N >::type fMvec
Measurement vector.
Definition: KHit.h:150
bool trkf::KHitWireLine::subpredict ( const KETrack tre,
KVector< 1 >::type pvec,
KSymMatrix< 1 >::type perr,
KHMatrix< 1 >::type hmatrix 
) const
override

Definition at line 115 of file KHitWireLine.cxx.

References trkf::KETrack::getError(), trkf::KHitBase::getMeasSurface(), trkf::KTrack::getSurface(), trkf::KTrack::getVector(), util::size(), and geo::GeometryCore::WirePitch().

119  {
120  // Make sure that the track surface and the measurement surface are the
121  // same. Throw an exception if they are not.
122 
123  if (!getMeasSurface()->isEqual(*tre.getSurface()))
124  throw cet::exception("KHitWireLine")
125  << "Track surface not the same as measurement surface.\n";
126 
127  // Prediction is the signed impact parameter (parameter 0).
128 
129  int size = tre.getVector().size();
130  pvec.resize(1, /* preserve */ false);
131  pvec.clear();
132  pvec(0) = tre.getVector()(0);
133 
134  perr.resize(1, /* preserve */ false);
135  perr.clear();
136  perr(0, 0) = tre.getError()(0, 0);
137 
138  // Update prediction error to include contribution from track slope.
139 
141  double pitch = geom->WirePitch();
142  double phi = tre.getVector()(2);
143  double cosphi = std::cos(phi);
144  double slopevar = pitch * pitch * cosphi * cosphi / 12.;
145  perr(0, 0) += slopevar;
146 
147  // Hmatrix - dr/dr = 1., all others are zero.
148 
149  hmatrix.resize(1, size, /* preserve */ false);
150  hmatrix.clear();
151  hmatrix(0, 0) = 1.;
152 
153  return true;
154  }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
const std::shared_ptr< const Surface > & getMeasSurface() const
Measurement surface.
Definition: KHitBase.h:82
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual bool trkf::KHit< N >::subpredict ( const KETrack tre,
typename KVector< N >::type pvec,
typename KSymMatrix< N >::type perr,
typename KHMatrix< N >::type hmatrix 
) const
pure virtualinherited

Calculate prediction function (return via arguments).

void trkf::KHit< N >::update ( KETrack tre) const
virtualinherited

Update track method.

Update track method.

Arguments:

tre - Track to be updated.

Implements trkf::KHitBase.

Member Data Documentation

art::Ptr<recob::Hit> trkf::KHitWireLine::fHit
private

Definition at line 54 of file KHitWireLine.h.

int trkf::KHitBase::fID
protectedinherited

Unique id.

Definition at line 119 of file KHitBase.h.

Referenced by trkf::KHitBase::getID(), KHitWireLine(), and trkf::KHitWireX::KHitWireX().

double trkf::KHitBase::fPredDist
mutableprotectedinherited
std::shared_ptr<const Surface> trkf::KHitBase::fPredSurf
mutableprotectedinherited

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