Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef RecoMTD_MeasurementDet_MTDDetLayerMeasurements_H
0002 #define RecoMTD_MeasurementDet_MTDDetLayerMeasurements_H
0003 
0004 /** \class MTDDetLayerMeasurements
0005  *  The class to access recHits and TrajectoryMeasurements from DetLayer.  
0006  *
0007  *  \author B. Tannenwald 
0008  *  Adapted from RecoMuon version.
0009  *
0010  */
0011 
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0014 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0015 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0016 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0017 #include "TrackingTools/TransientTrackingRecHit/interface/GenericTransientTrackingRecHit.h"
0018 #include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h"
0019 #include "DataFormats/TrackerRecHit2D/interface/MTDTrackingRecHit.h"
0020 
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022 #include "FWCore/Framework/interface/ConsumesCollector.h"
0023 
0024 #include <vector>
0025 
0026 class DetLayer;
0027 class GeomDet;
0028 class TrajectoryMeasurement;
0029 
0030 class MTDDetLayerMeasurements {
0031 public:
0032   typedef std::vector<TrajectoryMeasurement> MeasurementContainer;
0033   typedef std::pair<const GeomDet*, TrajectoryStateOnSurface> DetWithState;
0034   typedef std::vector<GenericTransientTrackingRecHit::RecHitPointer> MTDRecHitContainer;
0035 
0036   MTDDetLayerMeasurements(const edm::InputTag& mtdlabel, edm::ConsumesCollector& iC);
0037 
0038   virtual ~MTDDetLayerMeasurements();
0039 
0040   // for a given det and state.  Not clear when the fastMeasurements below
0041   //  should be used, since it isn't passed a GeomDet
0042   MeasurementContainer measurements(const DetLayer* layer,
0043                                     const GeomDet* det,
0044                                     const TrajectoryStateOnSurface& stateOnDet,
0045                                     const MeasurementEstimator& est,
0046                                     const edm::Event& iEvent);
0047 
0048   /// returns TMeasurements in a DetLayer compatible with the TSOS.
0049   MeasurementContainer measurements(const DetLayer* layer,
0050                                     const TrajectoryStateOnSurface& startingState,
0051                                     const Propagator& prop,
0052                                     const MeasurementEstimator& est,
0053                                     const edm::Event& iEvent);
0054 
0055   /// faster version in case the TrajectoryState on the surface of the GeomDet is already available
0056   MeasurementContainer fastMeasurements(const DetLayer* layer,
0057                                         const TrajectoryStateOnSurface& theStateOnDet,
0058                                         const TrajectoryStateOnSurface& startingState,
0059                                         const Propagator& prop,
0060                                         const MeasurementEstimator& est,
0061                                         const edm::Event& iEvent);
0062 
0063   /// returns TMeasurements in a DetLayer compatible with the TSOS.
0064   MeasurementContainer measurements(const DetLayer* layer,
0065                                     const TrajectoryStateOnSurface& startingState,
0066                                     const Propagator& prop,
0067                                     const MeasurementEstimator& est);
0068 
0069   /// faster version in case the TrajectoryState on the surface of the GeomDet is already available
0070   MeasurementContainer fastMeasurements(const DetLayer* layer,
0071                                         const TrajectoryStateOnSurface& theStateOnDet,
0072                                         const TrajectoryStateOnSurface& startingState,
0073                                         const Propagator& prop,
0074                                         const MeasurementEstimator& est);
0075 
0076   std::vector<TrajectoryMeasurementGroup> groupedMeasurements(const DetLayer* layer,
0077                                                               const TrajectoryStateOnSurface& startingState,
0078                                                               const Propagator& prop,
0079                                                               const MeasurementEstimator& est,
0080                                                               const edm::Event& iEvent);
0081 
0082   std::vector<TrajectoryMeasurementGroup> groupedMeasurements(const DetLayer* layer,
0083                                                               const TrajectoryStateOnSurface& startingState,
0084                                                               const Propagator& prop,
0085                                                               const MeasurementEstimator& est);
0086 
0087   void setEvent(const edm::Event&);
0088 
0089   /// returns the rechits which are on the layer
0090   MTDRecHitContainer recHits(const DetLayer* layer, const edm::Event& iEvent);
0091 
0092   /// returns the rechits which are on the layer
0093   MTDRecHitContainer recHits(const DetLayer* layer);
0094 
0095 private:
0096   /// obtain TrackingRecHits from a DetLayer
0097   MTDRecHitContainer recHits(const GeomDet*, const edm::Event& iEvent);
0098 
0099   /// check that the event is set, and throw otherwise
0100   void checkEvent() const;
0101 
0102   // sort functions for containers provided by measurements methods
0103   template <class T>
0104   T sortResult(T&);
0105 
0106   edm::EDGetTokenT<MTDTrackingRecHit> theMTDToken;
0107 
0108   // caches that should get filled once per event
0109   edm::Handle<edmNew::DetSetVector<MTDTrackingRecHit>> theMTDRecHits;
0110 
0111   void checkMTDRecHits();
0112 
0113   // keeps track of which event the cache holds
0114   edm::Event::CacheIdentifier_t theMTDEventCacheID;
0115 
0116   const edm::Event* theEvent;
0117 };
0118 #endif