Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-09 23:33:53

0001 #ifndef RecoMuon_L2MuonSeedCreator_Phase2L2MuonSeedCreator_H
0002 #define RecoMuon_L2MuonSeedCreator_Phase2L2MuonSeedCreator_H
0003 
0004 /** \class Phase2L2MuonSeedCreator
0005  * 
0006  *  Standalone Muon seeds for Phase-2
0007  *  This class takes in input the full L1 Tracker Muon collection
0008  *  and the collections of (DT/CSC) segments in the muon chambers.
0009  *  For each L1 Tracker Muon, the stubs used to produce it are 
0010  *  matched with segments in the muon chambers looking, in order,
0011  *  at deltaPhi, number of hits, and deltaTheta. All matched segments
0012  *  are added to the seed, together with the pT information from the
0013  *  tracker muon itself. Specifically for the barrel region and in 
0014  *  stations where no stub is found, a simple extrapolation is 
0015  *  attempted from nearby stations with a match (e.g no stub found in 
0016  *  station 2, attempt to match segments extrapolating from station
0017  *  1, 3, and 4 in this order).
0018  * 
0019  *  The logic allows a single-step extension to seed displaced muons
0020  *  (currently not implemented)
0021  * 
0022  *  \author Luca Ferragina (INFN BO), 2024
0023  */
0024 
0025 #include "DataFormats/MuonSeed/interface/L2MuonTrajectorySeed.h"
0026 #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
0027 
0028 #include "FWCore/Framework/interface/stream/EDProducer.h"
0029 #include "FWCore/Framework/interface/ESHandle.h"
0030 #include "FWCore/Framework/interface/Frameworkfwd.h"
0031 #include "FWCore/Framework/interface/ConsumesCollector.h"
0032 #include "FWCore/Framework/interface/EventSetup.h"
0033 #include "FWCore/Framework/interface/Event.h"
0034 #include "FWCore/Framework/interface/MakerMacros.h"
0035 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0036 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0037 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0038 #include "FWCore/Utilities/interface/ESGetToken.h"
0039 #include "FWCore/Utilities/interface/InputTag.h"
0040 
0041 #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h"
0042 #include "DataFormats/CSCRecHit/interface/CSCSegment.h"
0043 #include "DataFormats/DTRecHit/interface/DTRecSegment4D.h"
0044 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0045 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0046 
0047 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0048 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0049 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0050 
0051 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0052 #include "RecoMuon/MeasurementDet/interface/MuonDetLayerMeasurements.h"
0053 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0054 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
0055 #include "MagneticField/Engine/interface/MagneticField.h"
0056 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0057 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
0058 
0059 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0060 
0061 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0062 
0063 #include <map>
0064 #include <utility>
0065 
0066 class RecHit;
0067 class Plane;
0068 class GeomDet;
0069 class MagneticField;
0070 class MuonTransientTrackingRecHit;
0071 
0072 enum Type { barrel, overlap, endcap };
0073 
0074 class Phase2L2MuonSeedCreator : public edm::stream::EDProducer<> {
0075 public:
0076   typedef MuonTransientTrackingRecHit::MuonRecHitContainer SegmentContainer;
0077 
0078   // Constructor
0079   explicit Phase2L2MuonSeedCreator(const edm::ParameterSet& pset);
0080 
0081   // Destructor
0082   ~Phase2L2MuonSeedCreator() override = default;
0083 
0084   // Operations
0085   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0086   void produce(edm::Event&, const edm::EventSetup&) override;
0087 
0088 private:
0089   // Tokens
0090   const edm::EDGetTokenT<l1t::TrackerMuonCollection> l1TkMuCollToken_;
0091   const edm::EDGetTokenT<CSCSegmentCollection> cscSegmentCollToken_;
0092   const edm::EDGetTokenT<DTRecSegment4DCollection> dtSegmentCollToken_;
0093 
0094   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeometryToken_;
0095   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeometryToken_;
0096   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
0097 
0098   // Miminum and maximum pt momentum of a track
0099   const double minMomentum_;
0100   const double maxMomentum_;
0101 
0102   // Parameters to match L1 stubs to DT/CSC segments
0103   const double matchingPhiWindow_;
0104   const double matchingThetaWindow_;
0105 
0106   // Parameters to extrapolate matches in nearby stations
0107   const double extrapolationDeltaPhiClose_;
0108   const double extrapolationDeltaPhiFar_;
0109 
0110   const double maxEtaBarrel_;   // barrel with |eta| < 0.7
0111   const double maxEtaOverlap_;  // overlap with |eta| < 1.3, endcap after that
0112 
0113   // Handles
0114   edm::ESHandle<CSCGeometry> cscGeometry_;
0115   edm::ESHandle<DTGeometry> dtGeometry_;
0116 
0117   std::unique_ptr<MuonServiceProxy> service_;
0118   std::unique_ptr<MeasurementEstimator> estimator_;
0119 
0120   const std::string propagatorName_;
0121 
0122   // In DT station 4 the top and bottom sectors are made of two chambers
0123   // due to material requirements. Online is not split:
0124   // Online sector 4 == offline sector 4 or 10, Online sector 10 == offline sector 10 or 14
0125   const std::vector<DTChamberId> matchingIds(const DTChamberId& stubId) const;
0126 
0127   // Match online-level CSCDetIds with offline
0128   const std::vector<CSCDetId> matchingIds(const CSCDetId& stubId) const;
0129 
0130   // Logic to match L1 stubs to DT segments
0131   const std::pair<int, int> matchingStubSegment(const DTChamberId& stubId,
0132                                                 const l1t::MuonStubRef stub,
0133                                                 const DTRecSegment4DCollection& segments,
0134                                                 const float l1TkMuTheta) const;
0135 
0136   // Logic to match L1 stubs to CSC segments
0137   const std::pair<int, int> matchingStubSegment(const CSCDetId& stubId,
0138                                                 const l1t::MuonStubRef stub,
0139                                                 const CSCSegmentCollection& segments,
0140                                                 const float l1TkMuTheta) const;
0141 
0142   // Logic to extrapolate from nearby stations in the barrel
0143   const std::pair<int, int> extrapolateToNearbyStation(const int endingStation,
0144                                                        const std::map<DTChamberId, std::pair<int, int>>& matchesInBarrel,
0145                                                        const DTRecSegment4DCollection& segments) const;
0146 
0147   const std::pair<int, int> extrapolateMatch(const int bestStartingSegIndex,
0148                                              const int endingStation,
0149                                              const DTRecSegment4DCollection& segments) const;
0150 };
0151 #endif