Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:16

0001 #ifndef RecoMuon_TrackingTools_MuonTrajectoryUpdator_H
0002 #define RecoMuon_TrackingTools_MuonTrajectoryUpdator_H
0003 
0004 /** \class MuonTrajectoryUpdator
0005  *  An updator for the Muon system
0006  *  This class update a trajectory with a muon chamber measurement.
0007  *  In spite of the name, it is NOT an updator, but has one.
0008  *  A muon RecHit is a segment (for DT and CSC) or a "hit" (RPC).
0009  *  This updator is suitable both for FW and BW filtering. The difference between the two fitter are two:
0010  *  the granularity of the updating (i.e.: segment position or 1D rechit position), which can be set via
0011  *  parameter set, and the propagation direction which is embeded in the propagator set in the c'tor.
0012  *
0013  *  \author R. Bellan - INFN Torino <riccardo.bellan@cern.ch>
0014  *  \author S. Lacaprara - INFN Legnaro
0015  */
0016 
0017 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0018 #include "TrackingTools/DetLayers/interface/NavigationDirection.h"
0019 
0020 #include <functional>
0021 
0022 class Propagator;
0023 class MeasurementEstimator;
0024 class TrajectoryMeasurement;
0025 class Trajectory;
0026 class TrajectoryStateOnSurface;
0027 class TrajectoryStateUpdator;
0028 class DetLayer;
0029 
0030 namespace edm {
0031   class ParameterSet;
0032 }
0033 
0034 class MuonTrajectoryUpdator {
0035 public:
0036   /// Constructor from Propagator and Parameter set
0037   MuonTrajectoryUpdator(const edm::ParameterSet &par, NavigationDirection fitDirection);
0038 
0039   /// Constructor from Propagator, chi2 and the granularity flag
0040   MuonTrajectoryUpdator(NavigationDirection fitDirection, double chi2, int granularity);
0041 
0042   /// Destructor
0043   virtual ~MuonTrajectoryUpdator();
0044 
0045   // Operations
0046 
0047   /// update the Trajectory with the TrajectoryMeasurement
0048   virtual std::pair<bool, TrajectoryStateOnSurface> update(const TrajectoryMeasurement *measurement,
0049                                                            Trajectory &trajectory,
0050                                                            const Propagator *propagator);
0051 
0052   /// accasso at the propagator
0053   const MeasurementEstimator *estimator() const { return theEstimator; }
0054   const TrajectoryStateUpdator *measurementUpdator() const { return theUpdator; }
0055 
0056   /// get the max chi2 allowed
0057   double maxChi2() const { return theMaxChi2; }
0058 
0059   /// get the fit direction
0060   NavigationDirection fitDirection() { return theFitDirection; }
0061 
0062   /// set max chi2
0063   void setMaxChi2(double chi2) { theMaxChi2 = chi2; }
0064 
0065   /// set fit direction
0066   void setFitDirection(NavigationDirection fitDirection) { theFitDirection = fitDirection; }
0067 
0068   /// reset the theFirstTSOSFlag
0069   void makeFirstTime();
0070 
0071 protected:
0072 private:
0073   /// Propagate the state to the hit surface if it's a multi hit RecHit.
0074   /// i.e.: if "current" is a sub-rechit of the mesurement (i.e. a 1/2D RecHit)
0075   /// the state will be propagated to the surface where lies the "current" rechit
0076   TrajectoryStateOnSurface propagateState(const TrajectoryStateOnSurface &state,
0077                                           const TrajectoryMeasurement *measurement,
0078                                           const TransientTrackingRecHit::ConstRecHitPointer &current,
0079                                           const Propagator *propagator) const;
0080 
0081   ///  the max chi2 allowed
0082   double theMaxChi2;
0083 
0084   /// the granularity
0085   /// if 0 4D-segments are used both for the DT and CSC,
0086   /// if 1 2D-segments are used for the DT and the 2D-points for the CSC
0087   /// if 2 the 1D rec hit for the DT are used, while the 2D rechit for the CSC are used
0088   /// Maybe in a second step there will be more than 3 option
0089   /// i.e. max granularity for DT but not for the CSC and the viceversa
0090   int theGranularity;
0091   // FIXME: ask Tim if the CSC segments can be used, since in ORCA they wasn't.
0092 
0093   /// Ordering along increasing radius (for DT rechits)
0094   struct RadiusComparatorInOut {
0095     bool operator()(const TransientTrackingRecHit::ConstRecHitPointer &a,
0096                     const TransientTrackingRecHit::ConstRecHitPointer &b) const {
0097       return a->det()->surface().position().perp() < b->det()->surface().position().perp();
0098     }
0099   };
0100 
0101   /// Ordering along decreasing radius (for DT rechits)
0102   struct RadiusComparatorOutIn {
0103     bool operator()(const TransientTrackingRecHit::ConstRecHitPointer &a,
0104                     const TransientTrackingRecHit::ConstRecHitPointer &b) const {
0105       return a->det()->surface().position().perp() > b->det()->surface().position().perp();
0106     }
0107   };
0108 
0109   /// Ordering along increasing zed (for CSC rechits)
0110   struct ZedComparatorInOut {
0111     bool operator()(const TransientTrackingRecHit::ConstRecHitPointer &a,
0112                     const TransientTrackingRecHit::ConstRecHitPointer &b) const {
0113       return fabs(a->globalPosition().z()) < fabs(b->globalPosition().z());
0114     }
0115   };
0116 
0117   /// Ordering along decreasing zed (for CSC rechits)
0118   struct ZedComparatorOutIn {
0119     bool operator()(const TransientTrackingRecHit::ConstRecHitPointer &a,
0120                     const TransientTrackingRecHit::ConstRecHitPointer &b) const {
0121       return fabs(a->globalPosition().z()) > fabs(b->globalPosition().z());
0122     }
0123   };
0124 
0125   void sort(TransientTrackingRecHit::ConstRecHitContainer &, const DetLayer *);
0126 
0127   /// Return the trajectory measurement. It handles both the fw and the bw propagation
0128   TrajectoryMeasurement updateMeasurement(const TrajectoryStateOnSurface &propagatedTSOS,
0129                                           const TrajectoryStateOnSurface &lastUpdatedTSOS,
0130                                           const TransientTrackingRecHit::ConstRecHitPointer &recHit,
0131                                           const double &chi2,
0132                                           const DetLayer *detLayer,
0133                                           const TrajectoryMeasurement *initialMeasurement);
0134 
0135   // FIXME: change in a ESHandle
0136   MeasurementEstimator *theEstimator;
0137   TrajectoryStateUpdator *theUpdator;
0138 
0139   // The fit direction.This is the global fit direction and it could be (LOCALLY!) different w.r.t. the
0140   // propagation direction embeeded in the propagator (i.e. when it is used in the "anyDirection" mode)
0141   // This data member is not set via parameter set since it must be consistent with the RefitterParameter.
0142   NavigationDirection theFitDirection;
0143 
0144   // Parameters for the error rescaling
0145   bool theFirstTSOSFlag;
0146   bool theRescaleErrorFlag;
0147   double theRescaleFactor;
0148 
0149   // parameter to use the "bad hits"
0150   bool useInvalidHits;
0151   // exclude RPC from the fit (but allows to keep it in the muon signal confirmation)
0152   bool theRPCExFlag;
0153 };
0154 #endif