![]() |
|
|||
File indexing completed on 2025-08-05 08:18:21
0001 /* Copyright 2008-2010, Technische Universitaet Muenchen, 0002 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch 0003 0004 This file is part of GENFIT. 0005 0006 GENFIT is free software: you can redistribute it and/or modify 0007 it under the terms of the GNU Lesser General Public License as published 0008 by the Free Software Foundation, either version 3 of the License, or 0009 (at your option) any later version. 0010 0011 GENFIT is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU Lesser General Public License for more details. 0015 0016 You should have received a copy of the GNU Lesser General Public License 0017 along with GENFIT. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 /** @addtogroup genfit 0020 * @{ 0021 */ 0022 0023 #ifndef genfit_AbsTrackRep_h 0024 #define genfit_AbsTrackRep_h 0025 0026 #include "SharedPlanePtr.h" 0027 //#include "MaterialInfo.h" 0028 #include "Material.h" 0029 0030 #include <TVector3.h> 0031 #include <TObject.h> 0032 #include <TVectorD.h> 0033 #include <TMatrixD.h> 0034 #include <TMatrixDSym.h> 0035 0036 0037 namespace genfit { 0038 0039 /** 0040 * @brief Simple struct containing MaterialProperties and stepsize in the material. 0041 */ 0042 struct MatStep { 0043 Material material_; 0044 double stepSize_; 0045 0046 MatStep() { 0047 stepSize_ = 0; 0048 } 0049 0050 }; 0051 0052 class StateOnPlane; 0053 class MeasuredStateOnPlane; 0054 class AbsMeasurement; 0055 0056 /** 0057 * @brief Abstract base class for a track representation 0058 * 0059 * Provides functionality to extrapolate a StateOnPlane to another DetPlane, 0060 * to the POCA to a line or a point, or a cylinder or sphere. 0061 * Defines a set of parameters describing the track. 0062 * StateOnPlane objects are always defined with a track parameterization of a specific AbsTrackRep. 0063 * The AbsTrackRep provides functionality to translate from the internal representation of a state 0064 * into cartesian position and momentum (and covariance) and vice versa. 0065 */ 0066 class AbsTrackRep : public TObject { 0067 0068 public: 0069 0070 AbsTrackRep(); 0071 AbsTrackRep(int pdgCode, char propDir = 0); 0072 0073 virtual ~AbsTrackRep() {;} 0074 0075 //! Clone the trackRep. 0076 virtual AbsTrackRep* clone() const = 0; 0077 0078 /** 0079 * @brief Extrapolates the state to plane, and returns the extrapolation length 0080 * and, via reference, the extrapolated state. 0081 * 0082 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0083 * 0084 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0085 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0086 */ 0087 virtual double extrapolateToPlane( 0088 StateOnPlane& state, 0089 const genfit::SharedPlanePtr& plane, 0090 bool stopAtBoundary = false, 0091 bool calcJacobianNoise = false) const = 0; 0092 0093 /** 0094 * @brief Extrapolates the state to the POCA to a line, and returns the extrapolation length 0095 * and, via reference, the extrapolated state. 0096 * 0097 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0098 * 0099 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0100 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0101 */ 0102 virtual double extrapolateToLine(StateOnPlane& state, 0103 const TVector3& linePoint, 0104 const TVector3& lineDirection, 0105 bool stopAtBoundary = false, 0106 bool calcJacobianNoise = false) const = 0; 0107 0108 /** 0109 * @brief Resembles the interface of GFAbsTrackRep in old versions of genfit 0110 * 0111 * This interface to extrapolateToLine is intended to resemble the 0112 * interface of GFAbsTrackRep in old versions of genfit and is 0113 * implemented by default via the preceding function. 0114 * 0115 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0116 * 0117 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0118 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0119 */ 0120 virtual double extrapolateToLine(StateOnPlane& state, 0121 const TVector3& point1, 0122 const TVector3& point2, 0123 TVector3& poca, 0124 TVector3& dirInPoca, 0125 TVector3& poca_onwire, 0126 bool stopAtBoundary = false, 0127 bool calcJacobianNoise = false) const { 0128 TVector3 wireDir(point2 - point1); 0129 wireDir = wireDir.Unit(); 0130 double retval = this->extrapolateToLine(state, point1, wireDir, stopAtBoundary, calcJacobianNoise); 0131 poca = this->getPos(state); 0132 dirInPoca = this->getMom(state); 0133 dirInPoca = dirInPoca.Unit(); 0134 0135 poca_onwire = point1 + wireDir*((poca - point1)*wireDir); 0136 0137 return retval; 0138 } 0139 0140 /** 0141 * @brief Extrapolates the state to the POCA to a point, and returns the extrapolation length 0142 * and, via reference, the extrapolated state. 0143 * 0144 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0145 * 0146 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0147 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0148 */ 0149 virtual double extrapolateToPoint(StateOnPlane& state, 0150 const TVector3& point, 0151 bool stopAtBoundary = false, 0152 bool calcJacobianNoise = false) const = 0; 0153 0154 /** 0155 * @brief Extrapolates the state to the POCA to a point in the metric of G, and returns the extrapolation length 0156 * and, via reference, the extrapolated state. 0157 * 0158 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0159 * 0160 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0161 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0162 */ 0163 virtual double extrapolateToPoint(StateOnPlane& state, 0164 const TVector3& point, 0165 const TMatrixDSym& G, // weight matrix (metric) 0166 bool stopAtBoundary = false, 0167 bool calcJacobianNoise = false) const = 0; 0168 0169 /** 0170 * @brief Extrapolates the state to the cylinder surface, and returns the extrapolation length 0171 * and, via reference, the extrapolated state. 0172 * 0173 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0174 * 0175 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0176 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0177 */ 0178 virtual double extrapolateToCylinder(StateOnPlane& state, 0179 double radius, 0180 const TVector3& linePoint = TVector3(0.,0.,0.), 0181 const TVector3& lineDirection = TVector3(0.,0.,1.), 0182 bool stopAtBoundary = false, 0183 bool calcJacobianNoise = false) const = 0; 0184 0185 /** 0186 * @brief Extrapolates the state to the cone surface, and returns the extrapolation length 0187 * and, via reference, the extrapolated state. 0188 * 0189 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0190 * 0191 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0192 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0193 */ 0194 virtual double extrapolateToCone(StateOnPlane& state, 0195 double radius, 0196 const TVector3& linePoint = TVector3(0.,0.,0.), 0197 const TVector3& lineDirection = TVector3(0.,0.,1.), 0198 bool stopAtBoundary = false, 0199 bool calcJacobianNoise = false) const = 0; 0200 0201 /** 0202 * @brief Extrapolates the state to the sphere surface, and returns the extrapolation length 0203 * and, via reference, the extrapolated state. 0204 * 0205 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0206 * 0207 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0208 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0209 */ 0210 virtual double extrapolateToSphere(StateOnPlane& state, 0211 double radius, 0212 const TVector3& point = TVector3(0.,0.,0.), 0213 bool stopAtBoundary = false, 0214 bool calcJacobianNoise = false) const = 0; 0215 0216 /** 0217 * @brief Extrapolates the state by step (cm) and returns the extrapolation length 0218 * and, via reference, the extrapolated state. 0219 * 0220 * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. 0221 * 0222 * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. 0223 * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. 0224 */ 0225 virtual double extrapolateBy(StateOnPlane& state, 0226 double step, 0227 bool stopAtBoundary = false, 0228 bool calcJacobianNoise = false) const = 0; 0229 0230 //! extrapolate to an AbsMeasurement 0231 double extrapolateToMeasurement(StateOnPlane& state, 0232 const AbsMeasurement* measurement, 0233 bool stopAtBoundary = false, 0234 bool calcJacobianNoise = false) const; 0235 0236 //! Get the dimension of the state vector used by the track representation. 0237 virtual unsigned int getDim() const = 0; 0238 0239 //! Get the cartesian position of a state. 0240 virtual TVector3 getPos(const StateOnPlane& state) const = 0; 0241 0242 //! Get the cartesian momentum vector of a state. 0243 virtual TVector3 getMom(const StateOnPlane& state) const = 0; 0244 0245 //! Get the direction vector of a state. 0246 TVector3 getDir(const StateOnPlane& state) const {return getMom(state).Unit();} 0247 0248 //! Get cartesian position and momentum vector of a state. 0249 virtual void getPosMom(const StateOnPlane& state, TVector3& pos, TVector3& mom) const = 0; 0250 0251 //! Get cartesian position and direction vector of a state. 0252 void getPosDir(const StateOnPlane& state, TVector3& pos, TVector3& dir) const {getPosMom(state, pos, dir); dir.SetMag(1.);} 0253 0254 //! Get the 6D state vector (x, y, z, p_x, p_y, p_z). 0255 virtual TVectorD get6DState(const StateOnPlane& state) const; 0256 0257 //! Get the 6D covariance. 0258 virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane& state) const = 0; 0259 0260 //! Translates MeasuredStateOnPlane into 3D position, momentum and 6x6 covariance. 0261 virtual void getPosMomCov(const MeasuredStateOnPlane& state, TVector3& pos, TVector3& mom, TMatrixDSym& cov) const = 0; 0262 0263 //! Translates MeasuredStateOnPlane into 6D state vector (x, y, z, p_x, p_y, p_z) and 6x6 covariance. 0264 virtual void get6DStateCov(const MeasuredStateOnPlane& state, TVectorD& stateVec, TMatrixDSym& cov) const; 0265 0266 //! get the magnitude of the momentum in GeV. 0267 virtual double getMomMag(const StateOnPlane& state) const = 0; 0268 //! get the variance of the absolute value of the momentum . 0269 virtual double getMomVar(const MeasuredStateOnPlane& state) const = 0; 0270 0271 //! Get the pdg code. 0272 int getPDG() const {return pdgCode_;} 0273 0274 //! Get the charge of the particle of the pdg code 0275 double getPDGCharge() const; 0276 0277 /** 0278 * @brief Get the (fitted) charge of a state. 0279 * This is not always equal the pdg charge (e.g. if the charge sign was flipped during the fit). 0280 */ 0281 virtual double getCharge(const StateOnPlane& state) const = 0; 0282 //! Get charge over momentum. 0283 virtual double getQop(const StateOnPlane& state) const = 0; 0284 //! Get tha particle mass in GeV/c^2 0285 double getMass(const StateOnPlane& state) const; 0286 0287 //! Get propagation direction. (-1, 0, 1) -> (backward, auto, forward). 0288 char getPropDir() const {return propDir_;} 0289 0290 //! Get the jacobian and noise matrix of the last extrapolation. 0291 virtual void getForwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const = 0; 0292 0293 //! Get the jacobian and noise matrix of the last extrapolation if it would have been done in opposite direction. 0294 virtual void getBackwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const = 0; 0295 0296 //! Get stepsizes and material properties of crossed materials of the last extrapolation. 0297 virtual std::vector<genfit::MatStep> getSteps() const = 0; 0298 0299 //! Get the accumulated X/X0 (path / radiation length) of the material crossed in the last extrapolation. 0300 virtual double getRadiationLenght() const = 0; 0301 0302 //! Get the time corresponding to the StateOnPlane. Extrapolation 0303 // should keep this up to date with the time of flight. 0304 virtual double getTime(const StateOnPlane&) const = 0; 0305 0306 /** 0307 * @brief Calculate Jacobian of transportation numerically. 0308 * Slow but accurate. Can be used to validate (semi)analytic calculations. 0309 */ 0310 void calcJacobianNumerically(const genfit::StateOnPlane& origState, 0311 const genfit::SharedPlanePtr destPlane, 0312 TMatrixD& jacobian) const; 0313 0314 //! try to multiply pdg code with -1. (Switch from particle to anti-particle and vice versa). 0315 bool switchPDGSign(); 0316 0317 //! Set position and momentum of state. 0318 virtual void setPosMom(StateOnPlane& state, const TVector3& pos, const TVector3& mom) const = 0; 0319 //! Set position and momentum of state. 0320 virtual void setPosMom(StateOnPlane& state, const TVectorD& state6) const = 0; 0321 //! Set position and momentum and error of state. 0322 virtual void setPosMomErr(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TVector3& posErr, const TVector3& momErr) const = 0; 0323 //! Set position, momentum and covariance of state. 0324 virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TMatrixDSym& cov6x6) const = 0; 0325 //! Set position, momentum and covariance of state. 0326 virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVectorD& state6, const TMatrixDSym& cov6x6) const = 0; 0327 0328 //! Set the sign of the charge according to charge. 0329 virtual void setChargeSign(StateOnPlane& state, double charge) const = 0; 0330 //! Set charge/momentum. 0331 virtual void setQop(StateOnPlane& state, double qop) const = 0; 0332 //! Set time at which the state was defined 0333 virtual void setTime(StateOnPlane& state, double time) const = 0; 0334 0335 //! Set propagation direction. (-1, 0, 1) -> (backward, auto, forward). 0336 void setPropDir(int dir) { 0337 if (dir>0) propDir_ = 1; 0338 else if (dir<0) propDir_ = -1; 0339 else propDir_ = 0; 0340 }; 0341 0342 //! Switch propagation direction. Has no effect if propDir_ is set to 0. 0343 void switchPropDir(){propDir_ = -1*propDir_;} 0344 0345 //! check if other is of same type (e.g. RKTrackRep). 0346 virtual bool isSameType(const AbsTrackRep* other) = 0; 0347 0348 //! check if other is of same type (e.g. RKTrackRep) and has same pdg code. 0349 virtual bool isSame(const AbsTrackRep* other) = 0; 0350 0351 virtual void setDebugLvl(unsigned int lvl = 1) {debugLvl_ = lvl;} 0352 0353 virtual void Print(const Option_t* = "") const; 0354 0355 protected: 0356 0357 //! protect from calling copy c'tor from outside the class. Use #clone() if you want a copy! 0358 AbsTrackRep(const AbsTrackRep&); 0359 //! protect from calling assignment operator from outside the class. Use #clone() instead! 0360 AbsTrackRep& operator=(const AbsTrackRep&); 0361 0362 0363 //! Particle code 0364 int pdgCode_; 0365 //! propagation direction (-1, 0, 1) -> (backward, auto, forward) 0366 char propDir_; 0367 0368 unsigned int debugLvl_; 0369 0370 public: 0371 ClassDef(AbsTrackRep,1) 0372 0373 }; 0374 0375 } /* End of namespace genfit */ 0376 /** @} */ 0377 0378 #endif // genfit_AbsTrackRep_h
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |