TrackPropagator.h
Go to the documentation of this file.
1 #ifndef TRACKPROPAGATOR_H
2 #define TRACKPROPAGATOR_H
3 
4 ////////////////////////////////////////////////////////////////////////
5 /// \file TrackPropagator.h
6 /// \brief Interface to propagate a Track to the specific point
7 ///
8 /// \version $Id: $
9 /// \author eldwan.brianne@desy.de
10 ////////////////////////////////////////////////////////////////////////
11 
12 #include "TMath.h"
13 
14 #include <cmath>
15 #include <algorithm>
16 #include <iostream>
17 
18 namespace gar {
19  namespace rec {
20  class Track;
21  }
22 }
23 
24 namespace util {
26 
27  public:
28  //No constructor
29  TrackPropagator() = delete;
30  //No copy constructor
31  TrackPropagator(const TrackPropagator&) = delete;
32  //No destructor
33  ~TrackPropagator() = delete;
34 
35 
36 
37 
38 
39  /** IMPORTANT: Make sure that you have a consistent set of coordinate
40  systems in the arguments passed to all these methods. As a rule,
41  track parameters are expressed in the coordinate system implicitly
42  defined by the geometry gdml file specified in the ---.fcl file. But
43  in writing algorithms that check if some track extrapolates out to some
44  point or whatever, you might be thinking in another coordinate system,
45  e.g. one where the center of the MPD is at (0, 0, 0). That would be
46  an error. Consider trying instead something like
47 
48  int result = util::TrackPropagator::PropagateToCylinder(trk->TrackParEnd(), trk->End(),
49  fGeo->GetECALInnerBarrelRadius(),fGeo->TPCYCent(),fGeo->TPCZCent(), xyz_intersection,
50  fGeo->GetECALEndcapStartX() );
51 
52  where fGeo is an
53 
54  const gar::geo::GeometryCore* fGeo = gar::providerFrom<geo::GeometryGAr>();
55  */
56 
57 
58 
59 
60 
61  /** Finds two intersections of a helix with an infinite cylinder of radius
62  rCyl, centered at yCyl, zCyl and parallel to the x axis, storing the
63  "closest" intersection in retXYZ1, meaning that the value of phi at the
64  intersection is closest to what it is at Xpoint. The other intersection is
65  returned in retXYZ2. Status codes: 0 is success; 1,2, 3 and 4 are
66  rno-intersection conditions. If the helix cylinder and given cylinder
67  are disjoint, returns 1; if one is entirely inside the other,
68  status is 2; if the cylinders have a common axes, status is 3. Status
69  code 4 results when the track has zero curvature and the line does not
70  intersect the cylinder. If the intersections are found, and Xmax > 0, this
71  function checks if the selected intersection is outside the range [-Xmax,+Xmax]
72  and returns status code 5 if either of them are. In this case the return
73  value retXYZ is still valid. retXYZ must be float[3] in the calling code;
74  trackpar and Xpoint are as in PropagateToX and DistXYZ. */
75 
76  static int PropagateToCylinder(const float* trackpar, const float* Xpoint,
77  const float rCyl, const float yCyl, const float zCyl, float* retXYZ1,
78  float* retXYZ2, const float Xmax=0.0, const float epsilon = 2.0e-5);
79 
80 
81 
82  /** Finds the point on the track in 3d, given the x value. You might call it like this:
83 
84  TrackPropagator::PropagateToX(Track::TrackParBeg(),Track::Vertex(),float,float[3])
85 
86  where the first float is the x input and the float[3] will be the computed (x,y,z)
87  point. Or, you may call it like this:
88 
89  TrackPropagator::PropagateToX(Track::TrackParEnd(),Track::End(),float,float[3],250.0)
90 
91  but don't mix the ends! Track::Vertex() is used to give the Xo for the parameters
92  of Track::TrackParBeg() and Track::End() specifies the Xo where the track
93  parameters of Track::TrackParEnd() are valid.
94 
95  Return values are 0 for good finish, 1 for straight track; if Rmax > 0 , returns
96  2 if y^2 + z^2 > Rmax^2 -- means you might want to use PropagateToCylinder
97  */
98  static int PropagateToX(const float* trackpar, const float* Xpoint, const float x,
99  float* retXYZ, const float Rmax=0.0 );
100 
101 
102 
103 
104 
105  /** Finds the distance from the point xyz to this track. You may call it so:
106 
107  util::TrackPropagator::DistXYZ( Track::TrackParBeg(), Track::Vertex(), float[3], &float)
108 
109  where the float[3] is the input (x,y,z) point and last float will be the computed
110  distance. Or, you may call it like this:
111 
112  util::TrackPropagator::DistXYZ( Track::TrackParEnd(), Track::End(), float[3], &float)
113 
114  but don't mix the ends! The 2nd argument is an initial guess for the iteration to
115  the point of closest approach.
116 
117  Return values are 0 for good finish, 1 for straight track, or 2 for track
118  parallel to the x axis; but the computed distance is OK for all return values.
119  */
120  static int DistXYZ(const float* trackpar, const float* Xpoint,
121  const float* xyz, float& retDist);
122 
123 
124 
125 
126 
127  /** Two methods for direction of track at an arbitrary x or phi.
128  Differs from Track::FindDirectionFromTrackParameters in that that method
129  only finds directions at the two ends of the track and has a different
130  sign convention. One evaluates at a value of x and the
131  other evaluates at a specific value of phi. You may call them like so:
132 
133  util::TrackPropagator::DirectionX (Track::TrackParBeg(),Track::Vertex(), float&,float[3])
134  util::TrackPropagator::DirectionPar(Track::TrackParBeg(),Track::Vertex(), float&,float[3])
135 
136  where Track::Vertex() would specify the Xo where the track parameters of
137  the first argument are valid. The float& is either the x or phi value at
138  which the direction is wanted and the float[3] will be the returned unit
139  direction vector.
140 
141  The return value is 0 for good return; DirectionX can return 1 for zero
142  curvature.
143  */
144  static int DirectionX (const float* trackpar, const float* Xpoint,
145  float& xEval, float* retXYZ);
146  static int DirectionPhi(const float* trackpar, const float* Xpoint,
147  float& phiEval, float* retXYZ);
148 
149 
150 
151 
152 
153  private:
154  // Used by DistXYZ:
155  static float d2(float xt,float yt,float zt, float x0,float yc,float zc,
156  float r, float s, float phi,float phi0);
157  };
158 
159 } //namespace util
160 
161 #endif
rec
Definition: tracks.py:88
Namespace for general, non-LArSoft-specific utilities.
const double e
General GArSoft Utilities.
list x
Definition: train.py:276
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
static QCString * s
Definition: config.cpp:1042