Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:56

0001 #ifndef RecoTracker_TkTrackingRegions_AreaSeededTrackingRegionsBuilder_h
0002 #define RecoTracker_TkTrackingRegions_AreaSeededTrackingRegionsBuilder_h
0003 
0004 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
0005 
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 #include "FWCore/Framework/interface/ConsumesCollector.h"
0010 #include "FWCore/Utilities/interface/VecArray.h"
0011 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0012 #include "DataFormats/VertexReco/interface/Vertex.h"
0013 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0014 
0015 #include "MagneticField/Engine/interface/MagneticField.h"
0016 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0017 
0018 #include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
0019 #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
0020 
0021 #include "TrackingSeedCandidates.h"
0022 class AreaSeededTrackingRegionsBuilder {
0023 public:
0024   using Origin = std::pair<GlobalPoint, float>;  // (origin, half-length in z)
0025   using Origins = std::vector<Origin>;
0026 
0027   class Area {
0028   public:
0029     Area() {}
0030 
0031     // phimin and phimax, and hence xmin+xmax and ymin+ymax are
0032     // ordered by which way one goes around the unit circle, so it may
0033     // happen that actually phimax < phimin
0034     Area(float rmin, float rmax, float phimin, float phimax, float zmin, float zmax) : m_zmin(zmin), m_zmax(zmax) {
0035       auto cosphimin = std::cos(phimin);
0036       auto sinphimin = std::sin(phimin);
0037       auto cosphimax = std::cos(phimax);
0038       auto sinphimax = std::sin(phimax);
0039 
0040       m_x_rmin_phimin = rmin * cosphimin;
0041       m_x_rmin_phimax = rmin * cosphimax;
0042       m_x_rmax_phimin = rmax * cosphimin;
0043       m_x_rmax_phimax = rmax * cosphimax;
0044 
0045       m_y_rmin_phimin = rmin * sinphimin;
0046       m_y_rmin_phimax = rmin * sinphimax;
0047       m_y_rmax_phimin = rmax * sinphimin;
0048       m_y_rmax_phimax = rmax * sinphimax;
0049     }
0050 
0051     float x_rmin_phimin() const { return m_x_rmin_phimin; }
0052     float x_rmin_phimax() const { return m_x_rmin_phimax; }
0053     float x_rmax_phimin() const { return m_x_rmax_phimin; }
0054     float x_rmax_phimax() const { return m_x_rmax_phimax; }
0055     float y_rmin_phimin() const { return m_y_rmin_phimin; }
0056     float y_rmin_phimax() const { return m_y_rmin_phimax; }
0057     float y_rmax_phimin() const { return m_y_rmax_phimin; }
0058     float y_rmax_phimax() const { return m_y_rmax_phimax; }
0059 
0060     float zmin() const { return m_zmin; }
0061     float zmax() const { return m_zmax; }
0062 
0063   private:
0064     // all of these are in global coordinates
0065     float m_x_rmin_phimin = 0;
0066     float m_x_rmin_phimax = 0;
0067     float m_x_rmax_phimin = 0;
0068     float m_x_rmax_phimax = 0;
0069 
0070     float m_y_rmin_phimin = 0;
0071     float m_y_rmin_phimax = 0;
0072     float m_y_rmax_phimin = 0;
0073     float m_y_rmax_phimax = 0;
0074 
0075     float m_zmin = 0;
0076     float m_zmax = 0;
0077   };
0078 
0079   class Builder {
0080   public:
0081     explicit Builder(const AreaSeededTrackingRegionsBuilder* conf,
0082                      const MagneticField* field,
0083                      const MultipleScatteringParametrisationMaker* msmaker)
0084         : m_conf(conf), m_field(field), m_msmaker(msmaker) {}
0085     ~Builder() = default;
0086 
0087     void setMeasurementTracker(const MeasurementTrackerEvent* mte) { m_measurementTracker = mte; }
0088     void setCandidates(const TrackingSeedCandidates::Objects cands) { candidates = cands; }
0089 
0090     std::vector<std::unique_ptr<TrackingRegion> > regions(const Origins& origins, const std::vector<Area>& areas) const;
0091     std::unique_ptr<TrackingRegion> region(const Origin& origin, const std::vector<Area>& areas) const;
0092     std::unique_ptr<TrackingRegion> region(const Origin& origin, const edm::VecArray<Area, 2>& areas) const;
0093 
0094   private:
0095     template <typename T>
0096     std::unique_ptr<TrackingRegion> regionImpl(const Origin& origin, const T& areas) const;
0097 
0098     const AreaSeededTrackingRegionsBuilder* m_conf = nullptr;
0099     const MeasurementTrackerEvent* m_measurementTracker = nullptr;
0100     const MagneticField* m_field = nullptr;
0101     const MultipleScatteringParametrisationMaker* m_msmaker = nullptr;
0102     TrackingSeedCandidates::Objects candidates;
0103   };
0104 
0105   AreaSeededTrackingRegionsBuilder(const edm::ParameterSet& regPSet, edm::ConsumesCollector&& iC)
0106       : AreaSeededTrackingRegionsBuilder(regPSet, iC) {}
0107   AreaSeededTrackingRegionsBuilder(const edm::ParameterSet& regPSet, edm::ConsumesCollector& iC);
0108   ~AreaSeededTrackingRegionsBuilder() = default;
0109 
0110   static void fillDescriptions(edm::ParameterSetDescription& desc);
0111 
0112   Builder beginEvent(const edm::Event& e, const edm::EventSetup& es) const;
0113 
0114 private:
0115   std::vector<Area> m_areas;
0116   TrackingSeedCandidates candidates_;
0117   float m_extraPhi;
0118   float m_extraEta;
0119   float m_ptMin;
0120   float m_originRadius;
0121   bool m_precise;
0122   edm::EDGetTokenT<MeasurementTrackerEvent> token_measurementTracker;
0123   RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker;
0124   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> token_field;
0125   edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> token_msmaker;
0126   bool m_searchOpt;
0127 };
0128 
0129 #endif