PandaRoot
genfit2/trackReps/include/RKTrackRep.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 #ifndef genfit_RKTrackRep_h
25 #define genfit_RKTrackRep_h
26 
27 #include "AbsTrackRep.h"
28 #include "StateOnPlane.h"
29 #include "RKTools.h"
30 #include "StepLimits.h"
31 
32 namespace genfit {
33 
37 struct RKStep {
38  MatStep matStep_; // material properties and stepsize
39  M1x7 state7_; // 7D state vector
41 
42  RKStep() { memset(state7_, 0x00, 7 * sizeof(double)); }
43 };
44 
48 struct ExtrapStep {
49  M7x7 jac7_; // 5D jacobian of transport
50  M7x7 noise7_; // 5D noise matrix
51 
53  {
54  memset(jac7_, 0, sizeof(M7x7));
55  memset(noise7_, 0, sizeof(M7x7));
56  }
57 };
58 
66 class RKTrackRep : public AbsTrackRep {
67 
68  public:
69  RKTrackRep();
70  RKTrackRep(int pdgCode, char propDir = 0);
71 
72  virtual ~RKTrackRep();
73 
74  virtual AbsTrackRep *clone() const { return new RKTrackRep(*this); }
75 
76  virtual double extrapolateToPlane(StateOnPlane &state, const SharedPlanePtr &plane, bool stopAtBoundary = false, bool calcJacobianNoise = false) const;
77 
79 
80  virtual double
81  extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary = false, bool calcJacobianNoise = false) const;
82 
83  virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point, bool stopAtBoundary = false, bool calcJacobianNoise = false) const
84  {
85  return extrapToPoint(state, point, nullptr, stopAtBoundary, calcJacobianNoise);
86  }
87 
88  virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point,
89  const TMatrixDSym &G, // weight matrix (metric)
90  bool stopAtBoundary = false, bool calcJacobianNoise = false) const
91  {
92  return extrapToPoint(state, point, &G, stopAtBoundary, calcJacobianNoise);
93  }
94 
95  virtual double extrapolateToCylinder(StateOnPlane &state, double radius, const TVector3 &linePoint = TVector3(0., 0., 0.), const TVector3 &lineDirection = TVector3(0., 0., 1.),
96  bool stopAtBoundary = false, bool calcJacobianNoise = false) const;
97 
98  virtual double
99  extrapolateToSphere(StateOnPlane &state, double radius, const TVector3 &point = TVector3(0., 0., 0.), bool stopAtBoundary = false, bool calcJacobianNoise = false) const;
100 
101  virtual double extrapolateBy(StateOnPlane &state, double step, bool stopAtBoundary = false, bool calcJacobianNoise = false) const;
102 
103  unsigned int getDim() const { return 5; }
104 
105  virtual TVector3 getPos(const StateOnPlane &state) const;
106 
107  virtual TVector3 getMom(const StateOnPlane &state) const;
108  virtual void getPosMom(const StateOnPlane &state, TVector3 &pos, TVector3 &mom) const;
109 
110  virtual double getMomMag(const StateOnPlane &state) const;
111  virtual double getMomVar(const MeasuredStateOnPlane &state) const;
112 
113  virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane &state) const;
114  virtual void getPosMomCov(const MeasuredStateOnPlane &state, TVector3 &pos, TVector3 &mom, TMatrixDSym &cov) const;
115  virtual double getCharge(const StateOnPlane &state) const;
116  virtual double getQop(const StateOnPlane &state) const { return state.getState()(0); }
117  double getSpu(const StateOnPlane &state) const;
118  double getTime(const StateOnPlane &state) const;
119 
120  virtual void getForwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const;
121 
122  virtual void getBackwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const;
123 
124  std::vector<genfit::MatStep> getSteps() const;
125 
126  virtual double getRadiationLenght() const;
127 
128  virtual void setPosMom(StateOnPlane &state, const TVector3 &pos, const TVector3 &mom) const;
129  virtual void setPosMom(StateOnPlane &state, const TVectorD &state6) const;
130  virtual void setPosMomErr(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TVector3 &posErr, const TVector3 &momErr) const;
131  virtual void setPosMomCov(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) const;
132  virtual void setPosMomCov(MeasuredStateOnPlane &state, const TVectorD &state6, const TMatrixDSym &cov6x6) const;
133 
134  virtual void setChargeSign(StateOnPlane &state, double charge) const;
135  virtual void setQop(StateOnPlane &state, double qop) const { state.getState()(0) = qop; }
136 
137  void setSpu(StateOnPlane &state, double spu) const;
138  void setTime(StateOnPlane &state, double time) const;
139 
141 
148  double RKPropagate(M1x7 &state7, M7x7 *jacobian, M1x3 &SA, double S, bool varField = true, bool calcOnlyLastRowOfJ = false) const;
149 
150  virtual bool isSameType(const AbsTrackRep *other);
151  virtual bool isSame(const AbsTrackRep *other);
152 
153  private:
154  void initArrays() const;
155 
156  virtual double extrapToPoint(StateOnPlane &state, const TVector3 &point,
157  const TMatrixDSym *G = nullptr, // weight matrix (metric)
158  bool stopAtBoundary = false, bool calcJacobianNoise = false) const;
159 
160  void getState7(const StateOnPlane &state, M1x7 &state7) const;
161  void getState5(StateOnPlane &state, const M1x7 &state7) const; // state7 must already lie on plane of state!
162 
163  void transformPM7(const MeasuredStateOnPlane &state, M7x7 &out7x7) const;
164 
165  void calcJ_pM_5x7(M5x7 &J_pM, const TVector3 &U, const TVector3 &V, const M1x3 &pTilde, double spu) const;
166 
167  void transformPM6(const MeasuredStateOnPlane &state, M6x6 &out6x6) const;
168 
169  void transformM7P(const M7x7 &in7x7, const M1x7 &state7,
170  MeasuredStateOnPlane &state) const; // plane must already be set!
171 
172  void calcJ_Mp_7x5(M7x5 &J_Mp, const TVector3 &U, const TVector3 &V, const TVector3 &W, const M1x3 &A) const;
173 
174  void calcForwardJacobianAndNoise(const M1x7 &startState7, const DetPlane &startPlane, const M1x7 &destState7, const DetPlane &destPlane) const;
175 
176  void transformM6P(const M6x6 &in6x6, const M1x7 &state7,
177  MeasuredStateOnPlane &state) const; // plane and charge must already be set!
178 
180 
189  bool RKutta(const M1x4 &SU, const DetPlane &plane, double charge, double mass, M1x7 &state7, M7x7 *jacobianT, M1x7 *J_MMT_unprojected_lastRow,
190  double &coveredDistance, // signed
191  double &flightTime, bool &checkJacProj, M7x7 &noiseProjection, StepLimits &limits, bool onlyOneStep = false, bool calcOnlyLastRowOfJ = false) const;
192 
193  double estimateStep(const M1x7 &state7, const M1x4 &SU, const DetPlane &plane, const double &charge, double &relMomLoss, StepLimits &limits) const;
194 
195  TVector3 pocaOnLine(const TVector3 &linePoint, const TVector3 &lineDirection, const TVector3 &point) const;
196 
198 
206  double Extrap(const DetPlane &startPlane, // plane where Extrap starts
207  const DetPlane &destPlane, // plane where Extrap has to extrapolate to
208  double charge, double mass, bool &isAtBoundary, M1x7 &state7, double &flightTime, bool fillExtrapSteps, TMatrixDSym *cov = nullptr, bool onlyOneStep = false,
209  bool stopAtBoundary = false, double maxStep = 1.E99) const;
210 
211  void checkCache(const StateOnPlane &state, const SharedPlanePtr *plane) const;
212 
213  double momMag(const M1x7 &state7) const;
214 
215  mutable StateOnPlane lastStartState_;
216  mutable StateOnPlane lastEndState_;
217  mutable std::vector<RKStep> RKSteps_;
218  mutable int RKStepsFXStart_;
219  mutable int RKStepsFXStop_;
220  mutable std::vector<ExtrapStep> ExtrapSteps_;
221 
222  mutable TMatrixD fJacobian_;
223  mutable TMatrixDSym fNoise_;
224 
225  mutable bool useCache_;
226  mutable unsigned int cachePos_;
227 
228  // auxiliary variables and arrays
229  // needed in Extrap()
230  mutable StepLimits limits_;
231  mutable M7x7 noiseArray_;
232  mutable M7x7 noiseProjection_;
233  mutable M7x7 J_MMT_;
234 
235  public:
236  ClassDef(RKTrackRep, 1)
237 };
238 
239 } /* End of namespace genfit */
242 #endif // genfit_RKTrackRep_h
const TVectorD & getState() const
Definition: StateOnPlane.h:57
Detector plane.
Definition: DetPlane.h:60
Simple struct containing MaterialProperties and stepsize in the material.
Definition: AbsTrackRep.h:41
Helper to store different limits on the stepsize for the RKTRackRep.
Definition: StepLimits.h:52
double M6x6[6 *6]
Definition: RKTools.h:38
Abstract base class for a track representation.
Definition: AbsTrackRep.h:62
double M1x4[1 *4]
Definition: RKTools.h:34
StateOnPlane with additional covariance matrix.
virtual AbsTrackRep * clone() const
Clone the trackRep.
double M7x5[7 *5]
Definition: RKTools.h:42
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:44
double M1x7[1 *7]
Definition: RKTools.h:36
double M5x7[5 *7]
Definition: RKTools.h:44
virtual void setQop(StateOnPlane &state, double qop) const
Set charge/momentum.
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
virtual double getQop(const StateOnPlane &state) const
Get charge over momentum.
double M1x3[1 *3]
Definition: RKTools.h:33
virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point, const TMatrixDSym &G, bool stopAtBoundary=false, bool calcJacobianNoise=false) const
Extrapolates the state to the POCA to a point in the metric of G, and returns the extrapolation lengt...
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and...
AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u&#39;, v&#39;, u, v) ...
double M7x7[7 *7]
Definition: RKTools.h:39
virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false) const
Extrapolates the state to the POCA to a point, and returns the extrapolation length and...
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
unsigned int getDim() const
Get the dimension of the state vector used by the track representation.
Matrix inversion tools.
Definition: AbsBField.h:28