Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:51

0001 #ifndef _TRACKER_GLOBALTRAJECTORYPARAMETERS_H_
0002 #define _TRACKER_GLOBALTRAJECTORYPARAMETERS_H_
0003 
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0006 #include "DataFormats/TrajectoryState/interface/TrackCharge.h"
0007 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
0008 
0009 class MagneticField;
0010 /** Class providing access to a set of relevant parameters of a trajectory
0011  *  in the global, Cartesian frame. The basic data members used to calculate
0012  *  these parameters are the charge and global position and momentum.
0013  */
0014 
0015 class GlobalTrajectoryParameters {
0016 public:
0017   // construct
0018   GlobalTrajectoryParameters()
0019       : theField(nullptr), theX(), theP(), theCharge(0) {}  // we must initialize cache to non-NAN to avoid FPE
0020 
0021   /** Constructing class from global position, global momentum and charge.
0022    */
0023 
0024   GlobalTrajectoryParameters(const GlobalPoint& aX,
0025                              const GlobalVector& aP,
0026                              TrackCharge aCharge,
0027                              const MagneticField* fieldProvider)
0028       : theField(fieldProvider), theX(aX), theP(aP), theCharge(aCharge) {
0029     setCache();
0030   }
0031 
0032   GlobalTrajectoryParameters(const GlobalPoint& aX,
0033                              const GlobalVector& aP,
0034                              TrackCharge aCharge,
0035                              const MagneticField* fieldProvider,
0036                              GlobalVector fieldValue)
0037       : theField(fieldProvider), theX(aX), theP(aP), cachedMagneticField(fieldValue), theCharge(aCharge) {}
0038 
0039   /** Constructing class from global position, direction (unit length) 
0040    *  and transverse curvature. The fourth int argument is dummy, 
0041    *  it serves only to distinguish
0042    *  this constructor from the one above.
0043    */
0044   GlobalTrajectoryParameters(const GlobalPoint& aX,
0045                              const GlobalVector& direction,
0046                              float transverseCurvature,
0047                              int,
0048                              const MagneticField* fieldProvider);
0049 
0050   GlobalTrajectoryParameters(const GlobalPoint& aX,
0051                              const GlobalVector& direction,
0052                              float transverseCurvature,
0053                              int,
0054                              const MagneticField* fieldProvider,
0055                              GlobalVector fieldValue);
0056 
0057   /** Global position.
0058    */
0059 
0060   GlobalPoint position() const { return theX; }
0061 
0062   /** Global momentum.
0063    */
0064 
0065   GlobalVector momentum() const { return theP; }
0066 
0067   GlobalVector direction() const { return theP.unit(); }
0068 
0069   /** Charge q of particle, either +1 or -1.
0070    */
0071 
0072   TrackCharge charge() const { return theCharge; }
0073 
0074   /** Charge divided by (magnitude of) momentum, i.e. q/p.
0075    */
0076 
0077   float signedInverseMomentum() const { return theCharge / theP.mag(); }
0078 
0079   /** Charge divided by transverse momentum, i.e. q/p_T.
0080    */
0081 
0082   float signedInverseTransverseMomentum() const { return theCharge / theP.perp(); }
0083 
0084   /** Transverse curvature kappa (which is the inverse radius of curvature in the transverse plane) 
0085    *  in cm^{-1}. Sign convention is such that positive kappa means
0086    *  counterclockwise rotation of the track with respect to the global z-axis.
0087    */
0088 
0089   float transverseCurvature() const {
0090     return -2.99792458e-3f * signedInverseTransverseMomentum() * cachedMagneticField.z();
0091   }
0092 
0093   /** Vector whose first three elements are the global position coordinates and
0094    *  whose last three elements are the global momentum coordinates.
0095    */
0096 
0097   AlgebraicVector6 vector() const {
0098     return AlgebraicVector6(theX.x(), theX.y(), theX.z(), theP.x(), theP.y(), theP.z());
0099   }
0100 
0101   GlobalVector magneticFieldInInverseGeV(const GlobalPoint& x) const;
0102   GlobalVector magneticFieldInInverseGeV() const { return 2.99792458e-3f * cachedMagneticField; }
0103 
0104   GlobalVector magneticFieldInTesla() const { return cachedMagneticField; }
0105 
0106   const MagneticField& magneticField() const { return *theField; }
0107 
0108 private:
0109   void setCache();
0110 
0111 private:
0112   const MagneticField* theField;
0113   GlobalPoint theX;
0114   GlobalVector theP;
0115   GlobalVector cachedMagneticField;
0116   signed char theCharge;
0117 };
0118 
0119 #endif