Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:04

0001 #ifndef RecoTracker_TkTrackingRegions_AreaSeededTrackingRegionsProducer_h
0002 #define RecoTracker_TkTrackingRegions_AreaSeededTrackingRegionsProducer_h
0003 
0004 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
0005 
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0011 #include "FWCore/Framework/interface/ConsumesCollector.h"
0012 #include "DataFormats/Common/interface/Handle.h"
0013 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0014 #include "DataFormats/VertexReco/interface/Vertex.h"
0015 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0016 #include "DataFormats/Math/interface/PtEtaPhiMass.h"
0017 
0018 #include "VertexBeamspotOrigins.h"
0019 #include "AreaSeededTrackingRegionsBuilder.h"
0020 
0021 #include <array>
0022 #include <limits>
0023 
0024 /** class AreaSeededTrackingRegionsProducer
0025  *
0026  * eta-phi TrackingRegions producer in directions defined by z-phi area-based objects of interest
0027  * from the "input" parameters.
0028  *
0029  * Four operational modes are supported ("mode" parameter):
0030  *
0031  *   BeamSpotFixed:
0032  *     origin is defined by the beam spot
0033  *     z-half-length is defined by a fixed zErrorBeamSpot parameter
0034  *   BeamSpotSigma:
0035  *     origin is defined by the beam spot
0036  *     z-half-length is defined by nSigmaZBeamSpot * beamSpot.sigmaZ
0037  *   VerticesFixed:
0038  *     origins are defined by vertices from VertexCollection (use maximum MaxNVertices of them)
0039  *     z-half-length is defined by a fixed zErrorVertex parameter
0040  *   VerticesSigma:
0041  *     origins are defined by vertices from VertexCollection (use maximum MaxNVertices of them)
0042  *     z-half-length is defined by nSigmaZVertex * vetex.zError
0043  *
0044  *   If, while using one of the "Vertices" modes, there's no vertices in an event, we fall back into
0045  *   either BeamSpotSigma or BeamSpotFixed mode, depending on the positiveness of nSigmaZBeamSpot.
0046  *
0047  */
0048 class AreaSeededTrackingRegionsProducer {
0049 public:
0050   typedef enum { BEAM_SPOT_FIXED, BEAM_SPOT_SIGMA, VERTICES_FIXED, VERTICES_SIGMA } Mode;
0051 
0052   AreaSeededTrackingRegionsProducer(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC)
0053       : m_origins(conf.getParameter<edm::ParameterSet>("RegionPSet"), iC),
0054         m_builder(conf.getParameter<edm::ParameterSet>("RegionPSet"), iC) {
0055     edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
0056     for (const auto& area : regPSet.getParameter<std::vector<edm::ParameterSet> >("areas")) {
0057       m_areas.emplace_back(area.getParameter<double>("rmin"),
0058                            area.getParameter<double>("rmax"),
0059                            area.getParameter<double>("phimin"),
0060                            area.getParameter<double>("phimax"),
0061                            area.getParameter<double>("zmin"),
0062                            area.getParameter<double>("zmax"));
0063     }
0064     if (m_areas.empty())
0065       throw cms::Exception("Configuration") << "Empty 'areas' parameter.";
0066   }
0067 
0068   ~AreaSeededTrackingRegionsProducer() = default;
0069 
0070   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0071     edm::ParameterSetDescription desc;
0072 
0073     edm::ParameterSetDescription descAreas;
0074     descAreas.add<double>("rmin", 0.0);
0075     descAreas.add<double>("rmax", 0.0);
0076     descAreas.add<double>("zmin", 0.0);
0077     descAreas.add<double>("zmax", 0.0);
0078     descAreas.add<double>("phimin", 0.0);
0079     descAreas.add<double>("phimax", 0.0);
0080     std::vector<edm::ParameterSet> vDefaults;
0081     desc.addVPSet("areas", descAreas, vDefaults);
0082 
0083     VertexBeamspotOrigins::fillDescriptions(desc);
0084     AreaSeededTrackingRegionsBuilder::fillDescriptions(desc);
0085 
0086     // Only for backwards-compatibility
0087     edm::ParameterSetDescription descRegion;
0088     descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
0089 
0090     descriptions.add("areaSeededTrackingRegion", descRegion);
0091   }
0092 
0093   std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& e, const edm::EventSetup& es) const {
0094     auto origins = m_origins.origins(e);
0095     auto builder = m_builder.beginEvent(e, es);
0096     return builder.regions(origins, m_areas);
0097   }
0098 
0099 private:
0100   VertexBeamspotOrigins m_origins;
0101   AreaSeededTrackingRegionsBuilder m_builder;
0102   std::vector<AreaSeededTrackingRegionsBuilder::Area> m_areas;
0103 };
0104 
0105 #endif