Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:20

0001 #ifndef Alignment_ReferenceTrajectories_ReferenceTrajectory_H
0002 #define Alignment_ReferenceTrajectories_ReferenceTrajectory_H
0003 
0004 /**
0005  * Author     : Gero Flucke (based on code by Edmund Widl replacing ORCA's TkReferenceTrack)
0006  * date       : 2006/09/17
0007  * last update: $Date: 2012/06/20 12:07:28 $
0008  * by         : $Author: flucke $
0009  *
0010  *  Class implementing the reference trajectory of a single charged
0011  *  particle, i.e. a helix with 5 parameters. Given the
0012  *  TrajectoryStateOnSurface at the first hit and the list of all hits
0013  *  the local measurements, derivatives etc. as described in (and
0014  *  accessed via) ReferenceTrajectoryBase are calculated.
0015  * 
0016  *  The covariance-matrix of the measurements may include effects of
0017  *  multiple-scattering or energy-loss effects or both. This can be
0018  *  defined in the constructor via the variable 'materialEffects
0019  *  (cf. ReferenceTrajectoryBase):
0020  *
0021  *  materialEffects =  none/multipleScattering/energyLoss/combined
0022  *
0023  *  Correct multiple scattering treatment, even if ignoring the off-diagonal
0024  *  elements of the covariance matrix, can be achieved with 
0025  *  (cf. documentaion of ReferenceTrajectoryBase):
0026  *
0027  *  materialEffects = BrokenLines[Coarse]/BrokenLinesFine/BreakPoints
0028  *
0029  *  By default, the mass is assumed to be the muon-mass, but can be
0030  *  changed via a constructor argument.
0031  *
0032  * LIMITATIONS:
0033  *  Only broken lines and break points parameterisations take into account 
0034  *  material effects of invalid hits.
0035  *
0036  */
0037 
0038 #include "Alignment/ReferenceTrajectories/interface/ReferenceTrajectoryBase.h"
0039 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0040 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0041 #include "TrackingTools/TrajectoryState/interface/SurfaceSideDefinition.h"
0042 
0043 #include "GblTrajectory.h"
0044 
0045 class TrajectoryStateOnSurface;
0046 class MagneticField;
0047 class MaterialEffectsUpdator;
0048 class Plane;
0049 class BeamSpotTransientTrackingRecHit;
0050 
0051 namespace reco {
0052   class BeamSpot;
0053 }
0054 
0055 class ReferenceTrajectory : public ReferenceTrajectoryBase {
0056 public:
0057   typedef SurfaceSideDefinition::SurfaceSide SurfaceSide;
0058 
0059   /**Constructor with Tsos at first hit (in physical order) and list of hits 
0060      [if (hitsAreReverse) ==> order of hits is in opposite direction compared
0061      to the flight of particle, but note that ReferenceTrajectory::recHits()
0062      returns the hits always in order of flight],
0063      the material effects to be considered and a particle mass,
0064      the magnetic field and beamSpot of the event are needed for propagations etc.
0065    */
0066   ReferenceTrajectory(const TrajectoryStateOnSurface &referenceTsos,
0067                       const TransientTrackingRecHit::ConstRecHitContainer &recHits,
0068                       const MagneticField *magField,
0069                       const reco::BeamSpot &beamSpot,
0070                       const ReferenceTrajectoryBase::Config &config);
0071 
0072   ~ReferenceTrajectory() override {}
0073 
0074   ReferenceTrajectory *clone() const override { return new ReferenceTrajectory(*this); }
0075 
0076 protected:
0077   // ReferenceTrajectory(unsigned int nPar, unsigned int nHits, MaterialEffects materialEffects);
0078   ReferenceTrajectory(unsigned int nPar, unsigned int nHits, const ReferenceTrajectoryBase::Config &config);
0079 
0080   /** internal method to calculate members
0081    */
0082   virtual bool construct(const TrajectoryStateOnSurface &referenceTsos,
0083                          const TransientTrackingRecHit::ConstRecHitContainer &recHits,
0084                          const MagneticField *magField,
0085                          const reco::BeamSpot &beamSpot);
0086 
0087   /** internal method to get apropriate updator
0088    */
0089   MaterialEffectsUpdator *createUpdator(MaterialEffects materialEffects, double mass) const;
0090 
0091   /** internal method to calculate jacobian
0092    */
0093   virtual bool propagate(const Plane &previousSurface,
0094                          const TrajectoryStateOnSurface &previousTsos,
0095                          const Plane &newSurface,
0096                          TrajectoryStateOnSurface &newTsos,
0097                          AlgebraicMatrix &newJacobian,
0098                          AlgebraicMatrix &newCurvlinJacobian,
0099                          double &nextStep,
0100                          const MagneticField *magField) const;
0101 
0102   /** internal method to fill measurement and error matrix for hit iRow/2
0103    */
0104   virtual void fillMeasurementAndError(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr,
0105                                        unsigned int iRow,
0106                                        const TrajectoryStateOnSurface &updatedTsos);
0107 
0108   /** internal method to fill derivatives for hit iRow/2
0109    */
0110   virtual void fillDerivatives(const AlgebraicMatrix &projection,
0111                                const AlgebraicMatrix &fullJacobian,
0112                                unsigned int iRow);
0113 
0114   /** internal method to fill the trajectory positions for hit iRow/2
0115    */
0116   virtual void fillTrajectoryPositions(const AlgebraicMatrix &projection,
0117                                        const AlgebraicVector &mixedLocalParams,
0118                                        unsigned int iRow);
0119 
0120   /** internal method to add material effects to measurments covariance matrix
0121    */
0122   virtual bool addMaterialEffectsCov(const std::vector<AlgebraicMatrix> &allJacobians,
0123                                      const std::vector<AlgebraicMatrix> &allProjections,
0124                                      const std::vector<AlgebraicSymMatrix> &allCurvChanges,
0125                                      const std::vector<AlgebraicSymMatrix> &allDeltaParaCovs);
0126 
0127   /** internal method to add material effects using break points
0128    */
0129   virtual bool addMaterialEffectsBp(const std::vector<AlgebraicMatrix> &allJacobians,
0130                                     const std::vector<AlgebraicMatrix> &allProjections,
0131                                     const std::vector<AlgebraicSymMatrix> &allCurvChanges,
0132                                     const std::vector<AlgebraicSymMatrix> &allDeltaParaCovs,
0133                                     const std::vector<AlgebraicMatrix> &allLocalToCurv);
0134 
0135   /** internal methods to add material effects using broken lines (fine version)
0136    */
0137   virtual bool addMaterialEffectsBrl(const std::vector<AlgebraicMatrix> &allJacobians,
0138                                      const std::vector<AlgebraicMatrix> &allProjections,
0139                                      const std::vector<AlgebraicSymMatrix> &allCurvChanges,
0140                                      const std::vector<AlgebraicSymMatrix> &allDeltaParaCovs,
0141                                      const std::vector<AlgebraicMatrix> &allLocalToCurv,
0142                                      const GlobalTrajectoryParameters &gtp);
0143   /** internal methods to add material effects using broken lines (coarse version)
0144    */
0145   virtual bool addMaterialEffectsBrl(const std::vector<AlgebraicMatrix> &allProjections,
0146                                      const std::vector<AlgebraicSymMatrix> &allDeltaParaCovs,
0147                                      const std::vector<AlgebraicMatrix> &allLocalToCurv,
0148                                      const std::vector<double> &allSteps,
0149                                      const GlobalTrajectoryParameters &gtp,
0150                                      const double minStep = 1.0);
0151 
0152   /** internal methods to add material effects using broken lines (fine version, local system)
0153    */
0154   virtual bool addMaterialEffectsLocalGbl(const std::vector<AlgebraicMatrix> &allJacobians,
0155                                           const std::vector<AlgebraicMatrix> &allProjections,
0156                                           const std::vector<AlgebraicSymMatrix> &allCurvatureChanges,
0157                                           const std::vector<AlgebraicSymMatrix> &allDeltaParameterCovs);
0158 
0159   /** internal methods to add material effects using broken lines (fine version, curvilinear system)
0160    */
0161   virtual bool addMaterialEffectsCurvlinGbl(const std::vector<AlgebraicMatrix> &allJacobians,
0162                                             const std::vector<AlgebraicMatrix> &allProjections,
0163                                             const std::vector<AlgebraicSymMatrix> &allCurvChanges,
0164                                             const std::vector<AlgebraicSymMatrix> &allDeltaParaCovs,
0165                                             const std::vector<AlgebraicMatrix> &allLocalToCurv);
0166 
0167   /// Don't care for propagation direction 'anyDirection' - in that case the material effects
0168   /// are anyway not updated ...
0169   inline SurfaceSide surfaceSide(const PropagationDirection dir) const {
0170     return (dir == alongMomentum) ? SurfaceSideDefinition::beforeSurface : SurfaceSideDefinition::afterSurface;
0171   }
0172 
0173   /** first (generic) helper to get the projection matrix
0174    */
0175   AlgebraicMatrix getHitProjectionMatrix(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const;
0176 
0177   /** second helper (templated on the dimension) to get the projection matrix
0178    */
0179   template <unsigned int N>
0180   AlgebraicMatrix getHitProjectionMatrixT(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const;
0181 
0182 private:
0183   template <typename Derived>
0184   void clhep2eigen(const AlgebraicVector &in, Eigen::MatrixBase<Derived> &out);
0185   template <typename Derived>
0186   void clhep2eigen(const AlgebraicMatrix &in, Eigen::MatrixBase<Derived> &out);
0187   template <typename Derived>
0188   void clhep2eigen(const AlgebraicSymMatrix &in, Eigen::MatrixBase<Derived> &out);
0189 
0190   const double mass_;
0191   const MaterialEffects materialEffects_;
0192   const PropagationDirection propDir_;
0193   const bool useBeamSpot_;
0194   const bool includeAPEs_;
0195   const bool allowZeroMaterial_;
0196 };
0197 
0198 #endif