Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-10 10:03:10

0001 #ifndef TrackProducerBase_h
0002 #define TrackProducerBase_h
0003 
0004 /** \class TrackProducerBase
0005  *  Base Class To Produce Tracks
0006  *
0007  *  \author cerati
0008  */
0009 
0010 #include "AlgoProductTraits.h"
0011 
0012 #include "FWCore/Framework/interface/ConsumesCollector.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 
0020 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0021 #include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"
0022 
0023 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0024 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
0025 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0026 #include "DataFormats/TrackerRecHit2D/interface/ClusterRemovalInfo.h"
0027 #include <RecoTracker/MeasurementDet/interface/MeasurementTracker.h>
0028 
0029 #include <tuple>
0030 
0031 class Propagator;
0032 class TrajectoryStateUpdator;
0033 class MeasurementEstimator;
0034 class TrackerGeometry;
0035 class TrajectoryFitter;
0036 class TransientTrackingRecHitBuilder;
0037 class NavigationSchool;
0038 class TrackerDigiGeometryRecord;
0039 class IdealMagneticFieldRecord;
0040 class TransientRecHitRecord;
0041 class TrackingComponentsRecord;
0042 class NavigationSchoolRecord;
0043 class CkfComponentsRecord;
0044 
0045 template <class T>
0046 class TrackProducerBase : public AlgoProductTraits<T> {
0047 public:
0048   using Base = AlgoProductTraits<T>;
0049   using TrackView = typename Base::TrackView;
0050   using TrackCollection = typename Base::TrackCollection;
0051   using AlgoProductCollection = typename Base::AlgoProductCollection;
0052 
0053 public:
0054   /// Constructor
0055   TrackProducerBase(bool trajectoryInEvent = false) : trajectoryInEvent_(trajectoryInEvent) {}
0056 
0057   /// Destructor
0058   virtual ~TrackProducerBase() noexcept(false);
0059 
0060   /// Get needed services from the Event Setup
0061   virtual void getFromES(const edm::EventSetup&,
0062                          edm::ESHandle<TrackerGeometry>&,
0063                          edm::ESHandle<MagneticField>&,
0064                          edm::ESHandle<TrajectoryFitter>&,
0065                          edm::ESHandle<Propagator>&,
0066                          edm::ESHandle<MeasurementTracker>&,
0067                          edm::ESHandle<TransientTrackingRecHitBuilder>&);
0068 
0069   /// Get TrackCandidateCollection from the Event (needed by TrackProducer)
0070   virtual void getFromEvt(edm::Event&, edm::Handle<TrackCandidateCollection>&, reco::BeamSpot&);
0071   /// Get TrackCollection from the Event (needed by TrackRefitter)
0072   virtual void getFromEvt(edm::Event&, edm::Handle<TrackView>&, reco::BeamSpot&);
0073 
0074   /// Method where the procduction take place. To be implemented in concrete classes
0075   virtual void produce(edm::Event&, const edm::EventSetup&) = 0;
0076 
0077   /// Call this method in inheriting class' constructor
0078   void initTrackProducerBase(const edm::ParameterSet& conf, edm::ConsumesCollector cc, const edm::EDGetToken& src);
0079 
0080   /// set the aliases of produced collections
0081   void setAlias(std::string alias) {
0082     alias.erase(alias.size() - 6, alias.size());
0083     alias_ = alias;
0084   }
0085 
0086   void setSecondHitPattern(Trajectory* traj,
0087                            T& track,
0088                            const Propagator* prop,
0089                            const MeasurementTrackerEvent* measTk,
0090                            const TrackerTopology* ttopo);
0091 
0092   const edm::ParameterSet& getConf() const { return conf_; }
0093 
0094 protected:
0095   edm::ParameterSet conf_;
0096   edm::EDGetToken src_;
0097 
0098 protected:
0099   std::string alias_;
0100   bool trajectoryInEvent_;
0101   edm::OrphanHandle<TrackCollection> rTracks_;
0102   edm::EDGetTokenT<reco::BeamSpot> bsSrc_;
0103   edm::EDGetTokenT<MeasurementTrackerEvent> mteSrc_;
0104 
0105   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackGeomSrc_;
0106   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> mfSrc_;
0107   edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> fitterSrc_;
0108   edm::ESGetToken<Propagator, TrackingComponentsRecord> propagatorSrc_;
0109   edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> builderSrc_;
0110   edm::ESGetToken<MeasurementTracker, CkfComponentsRecord> measTkSrc_;
0111   edm::ESGetToken<NavigationSchool, NavigationSchoolRecord> schoolSrc_;
0112 
0113   edm::ESHandle<NavigationSchool> theSchool;
0114   bool useSchool_ = false;
0115 };
0116 
0117 #include "RecoTracker/TrackProducer/interface/TrackProducerBase.icc"
0118 
0119 #endif