LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
KHitWireLine.cxx
Go to the documentation of this file.
1 #include <stdint.h>
11 
16 #include "cetlib_except/exception.h"
17 
18 namespace trkf {
19 
32  const std::shared_ptr<const Surface>& psurf) :
33  KHit(psurf),
34  fHit(hit)
35  {
36  // Get services.
38 
39  // Extract wire id.
40  geo::WireID wireid = hit->WireID();
41 
42  // Extract time information from hit.
43 
44  double t = hit->PeakTime();
45  double terr = hit->SigmaPeakTime();
46 
47  // Don't let the time error be less than 1./sqrt(12.) ticks.
48  // This should be removed when hit errors are fixed.
49 
50  if(terr < 1./std::sqrt(12.))
51  terr = 1./std::sqrt(12.);
52 
53  // Calculate position and error.
54 
55  double x = detprop->ConvertTicksToX(t, wireid.Plane, wireid.TPC, wireid.Cryostat);
56  double xerr = terr * detprop->GetXTicksCoefficient();
57 
58  // Check the surface (determined by wire id + drift time). If the
59  // surface pointer is null, make a new SurfWireLine surface and
60  // update the base class appropriately. Otherwise, just check
61  // that the specified surface agrees with the wire id + drift time.
62 
63  if(psurf.get() == 0) {
64  std::shared_ptr<const Surface> new_psurf(new SurfWireLine(wireid, x));
65  setMeasSurface(new_psurf);
66  }
67  else {
68  SurfWireLine check_surf(wireid, x);
69  if(!check_surf.isEqual(*psurf))
70  throw cet::exception("KHitWireLine") << "Measurement surface doesn't match hit.\n";
71  }
72 
73  setMeasPlane(wireid.Plane);
74 
75  // Update measurement vector and error matrix.
76 
77  trkf::KVector<1>::type mvec(1, 0.);
78  setMeasVector(mvec);
79 
81  merr(0,0) = xerr * xerr;
82  setMeasError(merr);
83 
84  // Set the unique id from a combination of the channel number and the time.
85 
86  fID = (hit->Channel() % 200000) * 10000 + (int(std::abs(t)) % 10000);
87  }
88 
97  KHitWireLine::KHitWireLine(const geo::WireID& wireid, double x, double xerr) :
98  KHit(std::shared_ptr<const Surface>(new SurfWireLine(wireid, x)))
99  {
100  // Get services.
101 
103 
104  // Get plane number.
105 
106  setMeasPlane(wireid.Plane);
107 
108  // Update measurement vector and error matrix.
109  // The measured value (aka impact parameter) is always zero.
110 
111  trkf::KVector<1>::type mvec(1, 0.);
112  setMeasVector(mvec);
113 
115  merr(0,0) = xerr * xerr;
116  setMeasError(merr);
117  }
118 
121  {}
122 
124  KVector<1>::type& pvec,
125  KSymMatrix<1>::type& perr,
126  KHMatrix<1>::type& hmatrix) const
127  {
128  // Make sure that the track surface and the measurement surface are the same.
129  // Throw an exception if they are not.
130 
131  if(!getMeasSurface()->isEqual(*tre.getSurface()))
132  throw cet::exception("KHitWireLine") << "Track surface not the same as measurement surface.\n";
133 
134  // Prediction is the signed impact parameter (parameter 0).
135 
136  int size = tre.getVector().size();
137  pvec.resize(1, /* preserve */ false);
138  pvec.clear();
139  pvec(0) = tre.getVector()(0);
140 
141  perr.resize(1, /* preserve */ false);
142  perr.clear();
143  perr(0,0) = tre.getError()(0,0);
144 
145  // Update prediction error to include contribution from track slope.
146 
148  double pitch = geom->WirePitch();
149  double phi = tre.getVector()(2);
150  double cosphi = std::cos(phi);
151  double slopevar = pitch*pitch * cosphi*cosphi / 12.;
152  perr(0,0) += slopevar;
153 
154  // Hmatrix - dr/dr = 1., all others are zero.
155 
156  hmatrix.resize(1, size, /* preserve */ false);
157  hmatrix.clear();
158  hmatrix(0,0) = 1.;
159 
160  return true;
161  }
162 } // end namespace trkf
void setMeasSurface(const std::shared_ptr< const Surface > &psurf)
Measurement surface.
Definition: KHitBase.h:92
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
const TrackError & getError() const
Track error matrix.
Definition: KETrack.h:54
virtual ~KHitWireLine()
Destructor.
const std::shared_ptr< const Surface > & getSurface() const
Surface.
Definition: KTrack.h:55
KHitWireLine(const art::Ptr< recob::Hit > &hit, const std::shared_ptr< const Surface > &psurf)
Constructor from Hit.
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
STL namespace.
virtual bool isEqual(const Surface &surf) const
Test two surfaces for equality, within tolerance.
Definition: SurfYZLine.cxx:270
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
KMatrix< N, 5 >::type type
void setMeasVector(const typename KVector< N >::type &mvec)
Set measurement vector.
Definition: KHit.h:94
virtual double GetXTicksCoefficient(int t, int c) const =0
ublas::vector< double, ublas::bounded_array< double, N > > type
Linear surface defined by wire id and x coordinate.
void setMeasError(const typename KSymMatrix< N >::type &merr)
Set measurement error.
Definition: KHit.h:97
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Detector simulation of raw signals on wires.
int fID
Unique id.
Definition: KHitBase.h:118
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
virtual bool subpredict(const KETrack &tre, KVector< 1 >::type &pvec, KSymMatrix< 1 >::type &perr, KHMatrix< 1 >::type &hmatrix) const
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
const TrackVector & getVector() const
Track state vector.
Definition: KTrack.h:56
Kalman filter wire-time measurement on a SurfWireLine surface.
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:95
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
Definition: Hit.h:220
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
art framework interface to geometry description
const std::shared_ptr< const Surface > & getMeasSurface() const
Measurement surface.
Definition: KHitBase.h:81
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33