LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
KHitWireX.cxx
Go to the documentation of this file.
1 
12 #include "cetlib_except/exception.h"
17 
18 namespace trkf {
19 
33  const std::shared_ptr<const Surface>& psurf)
34  : KHit(psurf), fHit(hit)
35  {
36  // Extract wire id.
37  geo::WireID wireid = hit->WireID();
38 
39  // Check the surface (determined by wire id). If the
40  // surface pointer is null, make a new SurfWireX surface and
41  // update the base class appropriately. Otherwise, just check
42  // that the specified surface agrees with the wire id.
43 
44  if (psurf.get() == 0) {
45  std::shared_ptr<const Surface> new_psurf(new SurfWireX(wireid));
46  setMeasSurface(new_psurf);
47  }
48  else {
49  SurfWireX check_surf(wireid);
50  if (!check_surf.isEqual(*psurf))
51  throw cet::exception("KHitWireX") << "Measurement surface doesn't match wire id.\n";
52  }
53 
54  setMeasPlane(hit->WireID().Plane);
55 
56  // Extract time information from hit.
57 
58  double t = hit->PeakTime();
59  double terr = hit->RMS(); // hit->SigmaPeakTime();
60 
61  // Don't let the time error be less than 1./sqrt(12.) ticks.
62  // This should be removed when hit errors are fixed.
63 
64  if (terr < 1. / std::sqrt(12.)) terr = 1. / std::sqrt(12.);
65 
66  // Calculate position and error.
67 
68  double x =
69  detProp.ConvertTicksToX(t, hit->WireID().Plane, hit->WireID().TPC, hit->WireID().Cryostat);
70  double xerr = terr * detProp.GetXTicksCoefficient();
71 
72  // Update measurement vector and error matrix.
73 
74  trkf::KVector<1>::type mvec(1, x);
75  setMeasVector(mvec);
76 
78  merr(0, 0) = xerr * xerr;
79  setMeasError(merr);
80 
81  // Set the unique id from a combination of the channel number and the time.
82 
83  fID = (hit->Channel() % 200000) * 10000 + (int(std::abs(t)) % 10000);
84  }
85 
94  KHitWireX::KHitWireX(const geo::WireID& wireid, double x, double xerr)
95  : KHit(std::shared_ptr<const Surface>(new SurfWireX(wireid)))
96  {
97  // Get plane number.
98 
99  setMeasPlane(wireid.Plane);
100 
101  // Update measurement vector and error matrix.
102 
103  trkf::KVector<1>::type mvec(1, x);
104  setMeasVector(mvec);
105 
107  merr(0, 0) = xerr * xerr;
108  setMeasError(merr);
109  }
110 
112  KVector<1>::type& pvec,
113  KSymMatrix<1>::type& perr,
114  KHMatrix<1>::type& hmatrix) const
115  {
116  // Make sure that the track surface and the measurement surface are the
117  // same. Throw an exception if they are not.
118 
119  if (!getMeasSurface()->isEqual(*tre.getSurface()))
120  throw cet::exception("KHitWireX") << "Track surface not the same as measurement surface.\n";
121 
122  // Prediction is just u track perameter and error.
123 
124  int size = tre.getVector().size();
125  pvec.resize(1, /* preserve */ false);
126  pvec.clear();
127  pvec(0) = tre.getVector()(0);
128 
129  perr.resize(1, /* preserve */ false);
130  perr.clear();
131  perr(0, 0) = tre.getError()(0, 0);
132 
133  // Update prediction error to include contribution from track slope.
134 
135  double pitch = art::ServiceHandle<geo::WireReadout>()->Get().Plane({0, 0, 0}).WirePitch();
136  double slope = tre.getVector()(2);
137  double slopevar = pitch * pitch * slope * slope / 12.;
138  perr(0, 0) += slopevar;
139 
140  // Hmatrix - du/du = 1., all others are zero.
141 
142  hmatrix.resize(1, size, /* preserve */ false);
143  hmatrix.clear();
144  hmatrix(0, 0) = 1.;
145 
146  return true;
147  }
148 } // end namespace trkf
void setMeasSurface(const std::shared_ptr< const Surface > &psurf)
Measurement surface.
Definition: KHitBase.h:93
Float_t x
Definition: compare.C:6
const TrackError & getError() const
Track error matrix.
Definition: KETrack.h:52
const std::shared_ptr< const Surface > & getSurface() const
Surface.
Definition: KTrack.h:53
double GetXTicksCoefficient(int t, int c) const
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:234
Kalman filter wire-time measurement on a SurfWireX surface.
constexpr auto abs(T v)
Returns the absolute value of the argument.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:195
STL namespace.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:290
ublas::symmetric_matrix< double, ublas::lower, ublas::row_major, ublas::bounded_array< double, N *(N+1)/2 > > type
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void setMeasVector(const typename KVector< N >::type &mvec)
Set measurement vector.
Definition: KHit.h:93
ublas::vector< double, ublas::bounded_array< double, N > > type
KHitWireX(const detinfo::DetectorPropertiesData &detProp, const art::Ptr< recob::Hit > &hit, const std::shared_ptr< const Surface > &psurf)
Constructor from Hit.
Definition: KHitWireX.cxx:31
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:373
Detector simulation of raw signals on wires.
int fID
Unique id.
Definition: KHitBase.h:119
double ConvertTicksToX(double ticks, int p, int t, int c) const
KMatrix< N, 5 >::type type
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:226
const TrackVector & getVector() const
Track state vector.
Definition: KTrack.h:54
virtual bool isEqual(const Surface &surf) const
Test two surfaces for equality, within tolerance.
Encapsulate the construction of a single detector plane .
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:96
bool subpredict(const KETrack &tre, KVector< 1 >::type &pvec, KSymMatrix< 1 >::type &perr, KHMatrix< 1 >::type &hmatrix) const override
Definition: KHitWireX.cxx:111
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:315
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:278
Planar surface defined by wire id and x-axis.
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