Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:47

0001 #ifndef MuonAnalysis_MuonAssociators_interface_PropagateToMuon_h
0002 #define MuonAnalysis_MuonAssociators_interface_PropagateToMuon_h
0003 //
0004 //
0005 
0006 /**
0007   \class    PropagateToMuon PropagateToMuon.h "MuonAnalysis/MuonAssociators/interface/PropagateToMuon.h" 
0008 
0009   \brief Propagate an object (usually a track) to the second (default) or first muon station.
0010 
0011 */
0012 
0013 #include "DataFormats/Candidate/interface/Candidate.h"
0014 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
0015 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
0016 #include "DataFormats/TrackReco/interface/Track.h"
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/Framework/interface/ConsumesCollector.h"
0019 #include "MagneticField/Engine/interface/MagneticField.h"
0020 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0021 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0022 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0023 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0024 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0025 #include "MuonAnalysis/MuonAssociators/interface/trackStateEnums.h"
0026 
0027 class IdealMagneticFieldRecord;
0028 class TrackingComponentsRecord;
0029 class MuonRecoGeometryRecord;
0030 
0031 class PropagateToMuon {
0032 public:
0033   explicit PropagateToMuon() {}
0034   explicit PropagateToMuon(edm::ESHandle<MagneticField>,
0035                            edm::ESHandle<Propagator>,
0036                            edm::ESHandle<Propagator>,
0037                            edm::ESHandle<Propagator>,
0038                            edm::ESHandle<MuonDetLayerGeometry>,
0039                            bool,
0040                            bool,
0041                            bool,
0042                            WhichTrack,
0043                            WhichState,
0044                            bool,
0045                            bool);
0046   ~PropagateToMuon() {}
0047 
0048   /// Extrapolate reco::Track to the muon station 2, return an invalid TSOS if it fails
0049   TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const { return extrapolate(startingState(tk)); }
0050 
0051   /// Extrapolate reco::Candidate to the muon station 2, return an invalid TSOS if it fails
0052   TrajectoryStateOnSurface extrapolate(const reco::Candidate &tk) const { return extrapolate(startingState(tk)); }
0053 
0054   /// Extrapolate a SimTrack to the muon station 2, return an invalid TSOS if it fails; needs the SimVertices too, to know where to start from
0055   /// Note: it will throw an exception if the SimTrack has no vertex.
0056   //  don't ask me why SimVertexContainer is in edm namespace
0057   TrajectoryStateOnSurface extrapolate(const SimTrack &tk, const edm::SimVertexContainer &vtxs) const {
0058     return extrapolate(startingState(tk, vtxs));
0059   }
0060 
0061   /// Extrapolate a FreeTrajectoryState to the muon station 2, return an invalid TSOS if it fails
0062   TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &state) const;
0063 
0064 private:
0065   // needed services for track propagation
0066   edm::ESHandle<MagneticField> magfield_;
0067   edm::ESHandle<Propagator> propagator_, propagatorAny_, propagatorOpposite_;
0068   edm::ESHandle<MuonDetLayerGeometry> muonGeometry_;
0069 
0070   bool useSimpleGeometry_;
0071 
0072   bool useMB2_;
0073 
0074   /// Fallback to ME1 if propagation to ME2 fails
0075   bool fallbackToME1_;
0076 
0077   /// Labels for input collections
0078   WhichTrack whichTrack_;
0079   WhichState whichState_;
0080 
0081   /// for cosmics, some things change: the along-opposite is not in-out, nor the innermost/outermost states are in-out really
0082   bool cosmicPropagation_;
0083 
0084   bool useMB2InOverlap_;
0085 
0086   // simplified geometry for track propagation
0087   const BoundCylinder *barrelCylinder_;
0088   const BoundDisk *endcapDiskPos_[3], *endcapDiskNeg_[3];
0089   double barrelHalfLength_;
0090   std::pair<float, float> endcapRadii_[3];
0091 
0092   /// Starting state for the propagation
0093   FreeTrajectoryState startingState(const reco::Candidate &reco) const;
0094 
0095   /// Starting state for the propagation
0096   FreeTrajectoryState startingState(const reco::Track &tk) const;
0097 
0098   /// Starting state for the propagation
0099   FreeTrajectoryState startingState(const SimTrack &tk, const edm::SimVertexContainer &vtxs) const;
0100 
0101   /// Get the best TSOS on one of the chambres of this DetLayer, or an invalid TSOS if none match
0102   TrajectoryStateOnSurface getBestDet(const TrajectoryStateOnSurface &tsos, const DetLayer *station) const;
0103 };
0104 
0105 #endif