Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef RecoMuon_MuonSeedGenerator_SETFilter_H
0002 #define RecoMuon_MuonSeedGenerator_SETFilter_H
0003 
0004 /** \class SETFilter
0005     I. Bloch, E. James, S. Stoynev
0006  */
0007 
0008 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0009 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0010 #include "TrackingTools/DetLayers/interface/NavigationDirection.h"
0011 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0012 
0013 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0014 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
0015 
0016 //#include "CLHEP/Matrix/DiagMatrix.h"
0017 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0018 #include "CLHEP/Matrix/Vector.h"
0019 #include "CLHEP/Vector/ThreeVector.h"
0020 
0021 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
0022 #include "DataFormats/Common/interface/OwnVector.h"
0023 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0024 
0025 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0026 
0027 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0028 
0029 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0030 #include "FWCore/Framework/interface/ESHandle.h"
0031 
0032 // used in the SET algorithm
0033 struct SeedCandidate {
0034   MuonTransientTrackingRecHit::MuonRecHitContainer theSet;
0035   CLHEP::Hep3Vector momentum;
0036   int charge;
0037   double weight;
0038   Trajectory::DataContainer trajectoryMeasurementsInTheSet;
0039 };
0040 
0041 class DetLayer;
0042 class Trajectory;
0043 //class MuonServiceProxy;
0044 class TrajectoryFitter;
0045 
0046 namespace edm {
0047   class ParameterSet;
0048   class EventSetup;
0049   class Event;
0050 }  // namespace edm
0051 
0052 class SETFilter {
0053 public:
0054   /// Constructor
0055   SETFilter(const edm::ParameterSet &par, const MuonServiceProxy *service);
0056 
0057   /// Destructor
0058   virtual ~SETFilter();
0059 
0060   // Operations
0061 
0062   /// Perform the inner-outward fitting
0063   void refit(const TrajectoryStateOnSurface &initialState, const DetLayer *, Trajectory &trajectory);
0064 
0065   /// the last free trajectory state
0066   FreeTrajectoryState lastUpdatedFTS() const { return *theLastUpdatedTSOS.freeTrajectoryState(); }
0067 
0068   /// the Trajectory state on the last surface of the fitting
0069   TrajectoryStateOnSurface lastUpdatedTSOS() const { return theLastUpdatedTSOS; }
0070 
0071   /// Perform the SET inner-outward fitting
0072   bool fwfit_SET(std::vector<SeedCandidate> &validSegmentsSet_in, std::vector<SeedCandidate> &validSegmentsSet_out);
0073 
0074   ///  from SeedCandidate to DataContainer only
0075   bool buildTrajectoryMeasurements(SeedCandidate *validSegmentsSet, Trajectory::DataContainer &finalCandidate);
0076 
0077   ///  transforms "segment trajectory" to "rechit container"
0078   bool transform(Trajectory::DataContainer &measurements_segments,
0079                  TransientTrackingRecHit::ConstRecHitContainer &hitContainer,
0080                  TrajectoryStateOnSurface &firstTSOS);
0081 
0082   ///  transforms "segment trajectory" to "segment container"
0083   bool transformLight(Trajectory::DataContainer &measurements_segments,
0084                       TransientTrackingRecHit::ConstRecHitContainer &hitContainer,
0085                       TrajectoryStateOnSurface &firstTSOS);
0086 
0087   void reset();
0088 
0089   /// Pass the Event to the algo at each event
0090   virtual void setEvent(const edm::Event &event);
0091 
0092   int getTotalChamberUsed() const { return totalChambers; }
0093   int getDTChamberUsed() const { return dtChambers; }
0094   int getCSCChamberUsed() const { return cscChambers; }
0095   int getRPCChamberUsed() const { return rpcChambers; }
0096 
0097   inline bool goodState() const { return totalChambers >= 2 && ((dtChambers + cscChambers) > 0); }
0098 
0099   /// return the layer used for the refit
0100   std::vector<const DetLayer *> layers() const { return theDetLayers; }
0101 
0102   /// return the last det layer
0103   const DetLayer *lastDetLayer() const { return theDetLayers.back(); }
0104 
0105   /// Return the propagation direction
0106   PropagationDirection propagationDirection() const;
0107 
0108 protected:
0109 private:
0110   /// Set the last TSOS
0111   void setLastUpdatedTSOS(TrajectoryStateOnSurface tsos) { theLastUpdatedTSOS = tsos; }
0112 
0113   /// Set the last but one TSOS
0114   void setLastButOneUpdatedTSOS(TrajectoryStateOnSurface tsos) { theLastButOneUpdatedTSOS = tsos; }
0115 
0116   /// Increment the DT,CSC,RPC counters
0117   void incrementChamberCounters(const DetLayer *layer);
0118 
0119   /// access at the propagator
0120   const Propagator *propagator() const;
0121 
0122   // chi2 functions (calculate chi2)
0123   double findChi2(double pX,
0124                   double pY,
0125                   double pZ,
0126                   const CLHEP::Hep3Vector &r3T,
0127                   SeedCandidate &muonCandidate,
0128                   TrajectoryStateOnSurface &lastUpdatedTSOS,
0129                   Trajectory::DataContainer &trajectoryMeasurementsInTheSet,
0130                   bool detailedOutput);
0131 
0132   double findMinChi2(unsigned int iSet,
0133                      const CLHEP::Hep3Vector &r3T,
0134                      SeedCandidate &muonCandidate,
0135                      std::vector<TrajectoryStateOnSurface> &lastUpdatedTSOS_Vect,
0136                      Trajectory::DataContainer &trajectoryMeasurementsInTheSet);
0137 
0138   double chi2AtSpecificStep(CLHEP::Hep3Vector &foot,
0139                             const CLHEP::Hep3Vector &r3T,
0140                             SeedCandidate &muonCandidate,
0141                             TrajectoryStateOnSurface &lastUpdatedTSOS,
0142                             Trajectory::DataContainer &trajectoryMeasurementsInTheSet,
0143                             bool detailedOutput);
0144 
0145   // find initial points for the SIMPLEX minimization
0146   std::vector<CLHEP::Hep3Vector> find3MoreStartingPoints(CLHEP::Hep3Vector &key_foot,
0147                                                          const CLHEP::Hep3Vector &r3T,
0148                                                          SeedCandidate &muonCandidate);
0149 
0150   std::pair<double, double> findParabolaMinimum(std::vector<double> &quadratic_var,
0151                                                 std::vector<double> &quadratic_chi2);
0152 
0153   // SIMPLEX minimization functions
0154   void pickElements(std::vector<double> &chi2Feet, unsigned int &high, unsigned int &second_high, unsigned int &low);
0155 
0156   CLHEP::Hep3Vector reflectFoot(std::vector<CLHEP::Hep3Vector> &feet, unsigned int key_foot, double scale);
0157 
0158   void nDimContract(std::vector<CLHEP::Hep3Vector> &feet, unsigned int low);
0159   //---- SET
0160 
0161   /// the propagator name
0162   std::string thePropagatorName;
0163 
0164   /// the propagation direction
0165   NavigationDirection theFitDirection;
0166 
0167   /// the trajectory state on the last available surface
0168   TrajectoryStateOnSurface theLastUpdatedTSOS;
0169   /// the trajectory state on the last but one available surface
0170   TrajectoryStateOnSurface theLastButOneUpdatedTSOS;
0171 
0172   /// the det layer used in the reconstruction
0173   std::vector<const DetLayer *> theDetLayers;
0174 
0175   int totalChambers;
0176   int dtChambers;
0177   int cscChambers;
0178   int rpcChambers;
0179 
0180   bool useSegmentsInTrajectory;
0181 
0182   /// used in the SET BW fit
0183   edm::ESHandle<TrajectoryFitter> theBWLightFitter;
0184   std::string theBWLightFitterName;
0185 
0186   const MuonServiceProxy *theService;
0187   //bool theOverlappingChambersFlag;
0188 };
0189 #endif