Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:27

0001 #ifndef _COMMONRECO_ANALYTICALPROPAGATOR_H_
0002 #define _COMMONRECO_ANALYTICALPROPAGATOR_H_
0003 
0004 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0005 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0006 #include "FWCore/Utilities/interface/Visibility.h"
0007 
0008 #include <cmath>
0009 #include <cfloat>
0010 
0011 class Surface;
0012 class Cylinder;
0013 class Plane;
0014 class HelixPlaneCrossing;
0015 class MagneticField;
0016 
0017 /** (Mostly) analytical helix propagation to cylindrical or planar surfaces.
0018  *  Based on GtfGeometricalPropagator with successive replacement of components
0019  *  (currently: propagation to arbitrary plane).
0020  */
0021 
0022 class AnalyticalPropagator final : public Propagator {
0023 public:
0024   AnalyticalPropagator(const MagneticField* field,
0025                        PropagationDirection dir = alongMomentum,
0026                        float maxDPhi = 1.6,
0027                        bool isOld = true)
0028       : Propagator(dir),
0029         theMaxDPhi2(maxDPhi * maxDPhi),
0030         theMaxDBzRatio(0.5),
0031         theField(field),
0032         isOldPropagationType(isOld) {}
0033 
0034   ~AnalyticalPropagator() override {}
0035 
0036   //
0037   // use base class methods where necessary:
0038   // - propagation from TrajectoryStateOnSurface
0039   //     (will use propagation from FreeTrajectoryState)
0040   // - propagation to general Surface
0041   //     (will use specialised methods for planes or cylinders)
0042   //
0043   using Propagator::propagate;
0044   using Propagator::propagateWithPath;
0045 
0046 private:
0047   /// propagation to plane with path length
0048   std::pair<TrajectoryStateOnSurface, double> propagateWithPath(const FreeTrajectoryState& fts,
0049                                                                 const Plane& plane) const override;
0050 
0051   /// propagation to cylinder with path length
0052   std::pair<TrajectoryStateOnSurface, double> propagateWithPath(const FreeTrajectoryState& fts,
0053                                                                 const Cylinder& cylinder) const override;
0054 
0055 public:
0056   /** limitation of change in transverse direction
0057    *  (to avoid loops).
0058    */
0059   bool setMaxDirectionChange(float phiMax) override {
0060     theMaxDPhi2 = phiMax * phiMax;
0061     return true;
0062   }
0063 
0064   AnalyticalPropagator* clone() const override { return new AnalyticalPropagator(*this); }
0065 
0066   /** Set the maximum relative change in Bz (Bz_at_end-Bz_at_start)/Bz_at_start
0067    * for a single propagation. The default is no limit.
0068    * NB: this propagator assumes constant, non-zero magnetic field parallel to the z-axis!
0069    **/
0070   void setMaxRelativeChangeInBz(const float maxDBz) { theMaxDBzRatio = maxDBz; }
0071 
0072 private:
0073   /// propagation of errors (if needed) and generation of a new TSOS
0074   std::pair<TrajectoryStateOnSurface, double> propagatedStateWithPath(const FreeTrajectoryState& fts,
0075                                                                       const Surface& surface,
0076                                                                       const GlobalTrajectoryParameters& gtp,
0077                                                                       const double& s) const dso_internal;
0078 
0079   /// parameter propagation to cylinder (returns position, momentum and path length)
0080   bool propagateParametersOnCylinder(const FreeTrajectoryState& fts,
0081                                      const Cylinder& cylinder,
0082                                      GlobalPoint& x,
0083                                      GlobalVector& p,
0084                                      double& s) const dso_internal;
0085 
0086   /// parameter propagation to plane (returns position, momentum and path length)
0087   bool propagateParametersOnPlane(const FreeTrajectoryState& fts,
0088                                   const Plane& plane,
0089                                   GlobalPoint& x,
0090                                   GlobalVector& p,
0091                                   double& s) const dso_internal;
0092 
0093   /// straight line parameter propagation to a plane
0094   bool propagateWithLineCrossing(const GlobalPoint&, const GlobalVector&, const Plane&, GlobalPoint&, double&) const
0095       dso_internal;
0096   /// straight line parameter propagation to a cylinder
0097   bool propagateWithLineCrossing(const GlobalPoint&, const GlobalVector&, const Cylinder&, GlobalPoint&, double&) const
0098       dso_internal;
0099   /// helix parameter propagation to a plane using HelixPlaneCrossing
0100   bool propagateWithHelixCrossing(
0101       HelixPlaneCrossing&, const Plane&, const float, GlobalPoint&, GlobalVector&, double& s) const dso_internal;
0102 
0103   const MagneticField* magneticField() const override { return theField; }
0104 
0105 private:
0106   typedef std::pair<TrajectoryStateOnSurface, double> TsosWP;
0107   float theMaxDPhi2;
0108   float theMaxDBzRatio;
0109   const MagneticField* theField;
0110   bool isOldPropagationType;
0111 };
0112 
0113 #endif