Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:59

0001 #ifndef MeasurementDet_MuonDetLayerMeasurements_H
0002 #define MeasurementDet_MuonDetLayerMeasurements_H
0003 
0004 /** \class MuonDetLayerMeasurements
0005  *  The class to access recHits and TrajectoryMeasurements from DetLayer.  
0006  *
0007  *  \author C. Liu, R. Bellan, N. Amapane
0008  *  \modified by C. Calabria to include GEMs
0009  *  \modified by D. Nash to include ME0s
0010  *
0011  *  \modified by C. Calabria & A. Sharma to include GEMs
0012  *
0013  */
0014 
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0017 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0018 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0019 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0020 //#include "TrackingTools/ementDet/interface/TrajectoryMeasurement.h"
0021 #include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h"
0022 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0023 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0024 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
0025 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0026 #include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
0027 
0028 #include "FWCore/Utilities/interface/InputTag.h"
0029 #include "FWCore/Framework/interface/ConsumesCollector.h"
0030 
0031 #include <vector>
0032 
0033 class DetLayer;
0034 class GeomDet;
0035 class TrajectoryMeasurement;
0036 
0037 //FIXME: these typedefs MUST GO inside the scope of MuonDetLayerMeasurements
0038 typedef std::vector<TrajectoryMeasurement> MeasurementContainer;
0039 typedef std::pair<const GeomDet*, TrajectoryStateOnSurface> DetWithState;
0040 
0041 class MuonDetLayerMeasurements {
0042 public:
0043   typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
0044 
0045   MuonDetLayerMeasurements(edm::InputTag dtlabel,
0046                            edm::InputTag csclabel,
0047                            edm::InputTag rpclabel,
0048                            edm::InputTag gemlabel,
0049                            edm::InputTag me0label,
0050                            edm::ConsumesCollector& iC,
0051                            bool enableDT = true,
0052                            bool enableCSC = true,
0053                            bool enableRPC = true,
0054                            bool enableGEM = true,
0055                            bool enableME0 = true);
0056 
0057   virtual ~MuonDetLayerMeasurements();
0058 
0059   // for a given det and state.  Not clear when the fastMeasurements below
0060   //  should be used, since it isn't passed a GeomDet
0061   MeasurementContainer measurements(const DetLayer* layer,
0062                                     const GeomDet* det,
0063                                     const TrajectoryStateOnSurface& stateOnDet,
0064                                     const MeasurementEstimator& est,
0065                                     const edm::Event& iEvent);
0066 
0067   /// returns TMeasurements in a DetLayer compatible with the TSOS.
0068   MeasurementContainer measurements(const DetLayer* layer,
0069                                     const TrajectoryStateOnSurface& startingState,
0070                                     const Propagator& prop,
0071                                     const MeasurementEstimator& est,
0072                                     const edm::Event& iEvent);
0073 
0074   /// faster version in case the TrajectoryState on the surface of the GeomDet is already available
0075   MeasurementContainer fastMeasurements(const DetLayer* layer,
0076                                         const TrajectoryStateOnSurface& theStateOnDet,
0077                                         const TrajectoryStateOnSurface& startingState,
0078                                         const Propagator& prop,
0079                                         const MeasurementEstimator& est,
0080                                         const edm::Event& iEvent);
0081 
0082   /// returns TMeasurements in a DetLayer compatible with the TSOS.
0083   MeasurementContainer measurements(const DetLayer* layer,
0084                                     const TrajectoryStateOnSurface& startingState,
0085                                     const Propagator& prop,
0086                                     const MeasurementEstimator& est);
0087 
0088   /// faster version in case the TrajectoryState on the surface of the GeomDet is already available
0089   MeasurementContainer fastMeasurements(const DetLayer* layer,
0090                                         const TrajectoryStateOnSurface& theStateOnDet,
0091                                         const TrajectoryStateOnSurface& startingState,
0092                                         const Propagator& prop,
0093                                         const MeasurementEstimator& est);
0094 
0095   std::vector<TrajectoryMeasurementGroup> groupedMeasurements(const DetLayer* layer,
0096                                                               const TrajectoryStateOnSurface& startingState,
0097                                                               const Propagator& prop,
0098                                                               const MeasurementEstimator& est,
0099                                                               const edm::Event& iEvent);
0100 
0101   std::vector<TrajectoryMeasurementGroup> groupedMeasurements(const DetLayer* layer,
0102                                                               const TrajectoryStateOnSurface& startingState,
0103                                                               const Propagator& prop,
0104                                                               const MeasurementEstimator& est);
0105 
0106   void setEvent(const edm::Event&);
0107 
0108   /// returns the rechits which are on the layer
0109   MuonRecHitContainer recHits(const DetLayer* layer, const edm::Event& iEvent);
0110 
0111   /// returns the rechits which are on the layer
0112   MuonRecHitContainer recHits(const DetLayer* layer);
0113 
0114 private:
0115   /// obtain TrackingRecHits from a DetLayer
0116   MuonRecHitContainer recHits(const GeomDet*, const edm::Event& iEvent);
0117 
0118   /// check that the event is set, and throw otherwise
0119   void checkEvent() const;
0120 
0121   edm::EDGetTokenT<DTRecSegment4DCollection> dtToken_;
0122   edm::EDGetTokenT<CSCSegmentCollection> cscToken_;
0123   edm::EDGetTokenT<RPCRecHitCollection> rpcToken_;
0124   edm::EDGetTokenT<GEMRecHitCollection> gemToken_;
0125   edm::EDGetTokenT<ME0SegmentCollection> me0Token_;
0126 
0127   bool enableDTMeasurement;
0128   bool enableCSCMeasurement;
0129   bool enableRPCMeasurement;
0130   bool enableGEMMeasurement;
0131   bool enableME0Measurement;
0132 
0133   // caches that should get filled once per event
0134   edm::Handle<DTRecSegment4DCollection> theDTRecHits;
0135   edm::Handle<CSCSegmentCollection> theCSCRecHits;
0136   edm::Handle<RPCRecHitCollection> theRPCRecHits;
0137   edm::Handle<GEMRecHitCollection> theGEMRecHits;
0138   edm::Handle<ME0SegmentCollection> theME0RecHits;
0139 
0140   void checkDTRecHits();
0141   void checkCSCRecHits();
0142   void checkRPCRecHits();
0143   void checkGEMRecHits();
0144   void checkME0RecHits();
0145 
0146   // keeps track of which event the cache holds
0147   edm::Event::CacheIdentifier_t theDTEventCacheID;
0148   edm::Event::CacheIdentifier_t theCSCEventCacheID;
0149   edm::Event::CacheIdentifier_t theRPCEventCacheID;
0150   edm::Event::CacheIdentifier_t theGEMEventCacheID;
0151   edm::Event::CacheIdentifier_t theME0EventCacheID;
0152 
0153   const edm::Event* theEvent;
0154 };
0155 #endif