LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
KHitWireX.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  // Check the surface (determined by wire id). If the
43  // surface pointer is null, make a new SurfWireX surface and
44  // update the base class appropriately. Otherwise, just check
45  // that the specified surface agrees with the wire id.
46 
47  if(psurf.get() == 0) {
48  std::shared_ptr<const Surface> new_psurf(new SurfWireX(wireid));
49  setMeasSurface(new_psurf);
50  }
51  else {
52  SurfWireX check_surf(wireid);
53  if(!check_surf.isEqual(*psurf))
54  throw cet::exception("KHitWireX") << "Measurement surface doesn't match wire id.\n";
55  }
56 
57  setMeasPlane(hit->WireID().Plane);
58 
59  // Extract time information from hit.
60 
61  double t = hit->PeakTime();
62  double terr = hit->RMS(); //hit->SigmaPeakTime();
63 
64  // Don't let the time error be less than 1./sqrt(12.) ticks.
65  // This should be removed when hit errors are fixed.
66 
67  if(terr < 1./std::sqrt(12.))
68  terr = 1./std::sqrt(12.);
69 
70  // Calculate position and error.
71 
72  double x = detprop->ConvertTicksToX(t, hit->WireID().Plane, hit->WireID().TPC, hit->WireID().Cryostat);
73  double xerr = terr * detprop->GetXTicksCoefficient();
74 
75  // Update measurement vector and error matrix.
76 
77  trkf::KVector<1>::type mvec(1, x);
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  KHitWireX::KHitWireX(const geo::WireID& wireid, double x, double xerr) :
98  KHit(std::shared_ptr<const Surface>(new SurfWireX(wireid)))
99  {
100  // Get services.
101 
103 
104  // Get plane number.
105 
106  setMeasPlane(wireid.Plane);
107 
108  // Update measurement vector and error matrix.
109 
110  trkf::KVector<1>::type mvec(1, x);
111  setMeasVector(mvec);
112 
114  merr(0,0) = xerr * xerr;
115  setMeasError(merr);
116  }
117 
120  {}
121 
123  KVector<1>::type& pvec,
124  KSymMatrix<1>::type& perr,
125  KHMatrix<1>::type& hmatrix) const
126  {
127  // Make sure that the track surface and the measurement surface are the same.
128  // Throw an exception if they are not.
129 
130  if(!getMeasSurface()->isEqual(*tre.getSurface()))
131  throw cet::exception("KHitWireX") << "Track surface not the same as measurement surface.\n";
132 
133  // Prediction is just u track perameter and error.
134 
135  int size = tre.getVector().size();
136  pvec.resize(1, /* preserve */ false);
137  pvec.clear();
138  pvec(0) = tre.getVector()(0);
139 
140  perr.resize(1, /* preserve */ false);
141  perr.clear();
142  perr(0,0) = tre.getError()(0,0);
143 
144  // Update prediction error to include contribution from track slope.
145 
147  double pitch = geom->WirePitch();
148  double slope = tre.getVector()(2);
149  double slopevar = pitch*pitch * slope*slope / 12.;
150  perr(0,0) += slopevar;
151 
152  // Hmatrix - du/du = 1., all others are zero.
153 
154  hmatrix.resize(1, size, /* preserve */ false);
155  hmatrix.clear();
156  hmatrix(0,0) = 1.;
157 
158  return true;
159  }
160 } // 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 bool subpredict(const KETrack &tre, KVector< 1 >::type &pvec, KSymMatrix< 1 >::type &perr, KHMatrix< 1 >::type &hmatrix) const
Definition: KHitWireX.cxx:122
const std::shared_ptr< const Surface > & getSurface() const
Surface.
Definition: KTrack.h:55
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:221
Kalman filter wire-time measurement on a SurfWireX surface.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
STL namespace.
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
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
virtual ~KHitWireX()
Destructor.
Definition: KHitWireX.cxx:119
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
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
virtual bool isEqual(const Surface &surf) const
Test two surfaces for equality, within tolerance.
KHitWireX(const art::Ptr< recob::Hit > &hit, const std::shared_ptr< const Surface > &psurf)
Constructor from Hit.
Definition: KHitWireX.cxx:31
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:95
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
Planar surface defined by wire id and x-axis.
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