LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
KHitWireLine.cxx
Go to the documentation of this file.
1 
12 #include "cetlib_except/exception.h"
18 
19 namespace trkf {
20 
34  const std::shared_ptr<const Surface>& psurf)
35  : KHit(psurf), fHit(hit)
36  {
37  // Extract wire id.
38  geo::WireID wireid = hit->WireID();
39 
40  // Extract time information from hit.
41 
42  double t = hit->PeakTime();
43  double terr = hit->SigmaPeakTime();
44 
45  // Don't let the time error be less than 1./sqrt(12.) ticks.
46  // This should be removed when hit errors are fixed.
47 
48  if (terr < 1. / std::sqrt(12.)) terr = 1. / std::sqrt(12.);
49 
50  // Calculate position and error.
51 
52  double x = detProp.ConvertTicksToX(t, wireid.Plane, wireid.TPC, wireid.Cryostat);
53  double xerr = terr * detProp.GetXTicksCoefficient();
54 
55  // Check the surface (determined by wire id + drift time). If the
56  // surface pointer is null, make a new SurfWireLine surface and
57  // update the base class appropriately. Otherwise, just check
58  // that the specified surface agrees with the wire id + drift time.
59 
60  if (psurf.get() == 0) {
61  std::shared_ptr<const Surface> new_psurf(new SurfWireLine(wireid, x));
62  setMeasSurface(new_psurf);
63  }
64  else {
65  SurfWireLine check_surf(wireid, x);
66  if (!check_surf.isEqual(*psurf))
67  throw cet::exception("KHitWireLine") << "Measurement surface doesn't match hit.\n";
68  }
69 
70  setMeasPlane(wireid.Plane);
71 
72  // Update measurement vector and error matrix.
73 
74  trkf::KVector<1>::type mvec(1, 0.);
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  KHitWireLine::KHitWireLine(const geo::WireID& wireid, double x, double xerr)
95  : KHit(std::shared_ptr<const Surface>(new SurfWireLine(wireid, x)))
96  {
97  // Get plane number.
98 
99  setMeasPlane(wireid.Plane);
100 
101  // Update measurement vector and error matrix.
102  // The measured value (aka impact parameter) is always zero.
103 
104  trkf::KVector<1>::type mvec(1, 0.);
105  setMeasVector(mvec);
106 
108  merr(0, 0) = xerr * xerr;
109  setMeasError(merr);
110  }
111 
113  KVector<1>::type& pvec,
114  KSymMatrix<1>::type& perr,
115  KHMatrix<1>::type& hmatrix) const
116  {
117  // Make sure that the track surface and the measurement surface are the
118  // same. Throw an exception if they are not.
119 
120  if (!getMeasSurface()->isEqual(*tre.getSurface()))
121  throw cet::exception("KHitWireLine")
122  << "Track surface not the same as measurement surface.\n";
123 
124  // Prediction is the signed impact parameter (parameter 0).
125 
126  int size = tre.getVector().size();
127  pvec.resize(1, /* preserve */ false);
128  pvec.clear();
129  pvec(0) = tre.getVector()(0);
130 
131  perr.resize(1, /* preserve */ false);
132  perr.clear();
133  perr(0, 0) = tre.getError()(0, 0);
134 
135  // Update prediction error to include contribution from track slope.
136 
137  double pitch = art::ServiceHandle<geo::WireReadout>()->Get().Plane({0, 0, 0}).WirePitch();
138  double phi = tre.getVector()(2);
139  double cosphi = std::cos(phi);
140  double slopevar = pitch * pitch * cosphi * cosphi / 12.;
141  perr(0, 0) += slopevar;
142 
143  // Hmatrix - dr/dr = 1., all others are zero.
144 
145  hmatrix.resize(1, size, /* preserve */ false);
146  hmatrix.clear();
147  hmatrix(0, 0) = 1.;
148 
149  return true;
150  }
151 } // 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
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
virtual bool isEqual(const Surface &surf) const
Test two surfaces for equality, within tolerance.
Definition: SurfYZLine.cxx:259
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
Linear surface defined by wire id and x coordinate.
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
Encapsulate the construction of a single detector plane .
Kalman filter wire-time measurement on a SurfWireLine surface.
KHitWireLine(const detinfo::DetectorPropertiesData &detProp, const art::Ptr< recob::Hit > &hit, const std::shared_ptr< const Surface > &psurf)
Constructor from Hit.
bool subpredict(const KETrack &tre, KVector< 1 >::type &pvec, KSymMatrix< 1 >::type &perr, KHMatrix< 1 >::type &hmatrix) const override
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:96
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
Definition: Hit.h:230
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
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