LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
InteractGeneral.cxx
Go to the documentation of this file.
1 
11 #include <cmath>
14 #include "cetlib_except/exception.h"
15 
16 namespace trkf {
17 
25  Interactor(tcut),
26  fInteract(tcut),
27  fProp(-1., false)
28  {}
29 
32  {}
33 
53  bool InteractGeneral::noise(const KTrack& trk, double s, TrackError& noise_matrix) const
54  {
55  // Get track position and direction.
56 
57  double xyz[3];
58  double mom[3];
59  trk.getPosition(xyz);
60  trk.getMomentum(mom);
61 
62  // Generate a SurfXYZPlane with origin at current track position, and
63  // normal to current track direction.
64 
65  std::shared_ptr<Surface> psurf(new SurfXYZPlane(xyz[0], xyz[1], xyz[2],
66  mom[0], mom[1], mom[2]));
67 
68  // Propagate track to newly created surface (zero-distance propagation).
69 
70  TrackMatrix prop_matrix;
71  KTrack temp_trk = trk;
72  boost::optional<double> result = fProp.short_vec_prop(temp_trk, psurf, Propagator::UNKNOWN,
73  false, &prop_matrix);
74 
75  // Return failure if propagation did not succeed.
76 
77  if(!result)
78  return false;
79 
80  // Calculate noise on plane surface.
81 
82  TrackError plane_noise(5);
83  fInteract.noise(temp_trk, s, plane_noise);
84 
85  // Transform noise matrix to original surface using inverse of propagation matrix.
86 
87  invert(prop_matrix);
88  TrackMatrix temp = prod(plane_noise, trans(prop_matrix));
89  TrackMatrix temp2 = prod(prop_matrix, temp);
90  noise_matrix = ublas::symmetric_adaptor<TrackMatrix>(temp2);
91 
92  // Done (success).
93 
94  return true;
95  }
96 } // end namespace trkf
Float_t s
Definition: plot.C:23
Interactor for planar surfaces.
General planar surface.
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
virtual bool noise(const KTrack &trk, double s, TrackError &noise_matrix) const
Calculate noise matrix.
virtual bool noise(const KTrack &trk, double s, TrackError &noise_matrix) const
Calculate noise matrix.
virtual ~InteractGeneral()
Destructor.
boost::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &surf, Propagator::PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const
Propagate without error.
Definition: PropAny.cxx:58
void getPosition(double xyz[3]) const
Get position of track.
Definition: KTrack.cxx:170
bool invert(ublas::matrix< T, L, A > &m)
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:217
PropAny fProp
Propagator.
InteractGeneral(double tcut)
Constructor.
InteractPlane fInteract
Plane interactor.