CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
MuonTrackingRegionByPtBuilder Class Reference

#include <MuonTrackingRegionByPtBuilder.h>

Inheritance diagram for MuonTrackingRegionByPtBuilder:
TrackingRegionProducer

Public Member Functions

 MuonTrackingRegionByPtBuilder (const edm::ParameterSet &par, edm::ConsumesCollector &iC)
 Constructor. More...
 
 MuonTrackingRegionByPtBuilder (const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
 
std::unique_ptr< RectangularEtaPhiTrackingRegionregion (const reco::TrackRef &) const
 Define tracking region. More...
 
std::unique_ptr< RectangularEtaPhiTrackingRegionregion (const reco::Track &t) const
 
std::unique_ptr< RectangularEtaPhiTrackingRegionregion (const reco::Track &, const edm::Event &, const edm::EventSetup &) const
 
std::vector< std::unique_ptr< TrackingRegion > > regions (const edm::Event &, const edm::EventSetup &) const override
 Create Region of Interest. More...
 
void setEvent (const edm::Event &, const edm::EventSetup &)
 Pass the Event to the algo at each event. More...
 
 ~MuonTrackingRegionByPtBuilder () override=default
 Destructor. More...
 
- Public Member Functions inherited from TrackingRegionProducer
virtual ~TrackingRegionProducer ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 Add Fill Descriptions. More...
 

Private Member Functions

void build (const edm::ParameterSet &, edm::ConsumesCollector &)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordbfieldToken
 
std::vector< double > deltaEtas_
 
std::vector< double > deltaPhis_
 
edm::EDGetTokenT< reco::TrackCollectioninputCollectionToken
 
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecordmsmakerToken
 
std::vector< double > ptRanges_
 
double theDeltaR
 
const edm::EventtheEvent
 
const edm::EventSetuptheEventSetup
 
double theHalfZ
 
int theMaxRegions
 
edm::EDGetTokenT< MeasurementTrackerEventtheMeasurementTrackerToken
 
double theNsigmaDz
 
RectangularEtaPhiTrackingRegion::UseMeasurementTracker theOnDemand
 
bool thePrecise
 
double thePtMin
 
bool useFixedPt
 
bool useFixedZ
 
bool useVertex
 
edm::EDGetTokenT< reco::VertexCollectionvertexCollectionToken
 

Detailed Description

Definition at line 26 of file MuonTrackingRegionByPtBuilder.h.

Constructor & Destructor Documentation

◆ MuonTrackingRegionByPtBuilder() [1/2]

MuonTrackingRegionByPtBuilder::MuonTrackingRegionByPtBuilder ( const edm::ParameterSet par,
edm::ConsumesCollector iC 
)
inlineexplicit

Constructor.

Definition at line 29 of file MuonTrackingRegionByPtBuilder.h.

References build().

29 { build(par, iC); }
void build(const edm::ParameterSet &, edm::ConsumesCollector &)

◆ MuonTrackingRegionByPtBuilder() [2/2]

MuonTrackingRegionByPtBuilder::MuonTrackingRegionByPtBuilder ( const edm::ParameterSet par,
edm::ConsumesCollector &&  iC 
)
inlineexplicit

Definition at line 30 of file MuonTrackingRegionByPtBuilder.h.

References build().

30 { build(par, iC); }
void build(const edm::ParameterSet &, edm::ConsumesCollector &)

◆ ~MuonTrackingRegionByPtBuilder()

MuonTrackingRegionByPtBuilder::~MuonTrackingRegionByPtBuilder ( )
overridedefault

Destructor.

Member Function Documentation

◆ build()

void MuonTrackingRegionByPtBuilder::build ( const edm::ParameterSet par,
edm::ConsumesCollector iC 
)
private

Definition at line 28 of file MuonTrackingRegionByPtBuilder.cc.

References beamSpotToken, bfieldToken, edm::ConsumesCollector::consumes(), deltaEtas_, deltaPhis_, edm::ConsumesCollector::esConsumes(), edm::ParameterSet::getParameter(), inputCollectionToken, RectangularEtaPhiTrackingRegion::intToUseMeasurementTracker(), RectangularEtaPhiTrackingRegion::kNever, msmakerToken, ptRanges_, theDeltaR, theHalfZ, theMaxRegions, theMeasurementTrackerToken, theNsigmaDz, theOnDemand, thePrecise, thePtMin, useFixedPt, useFixedZ, useVertex, and vertexCollectionToken.

Referenced by MuonTrackingRegionByPtBuilder().

28  {
29  // Adjust errors on dz
30  theNsigmaDz = par.getParameter<double>("Rescale_Dz");
31 
32  // Flag to switch to use Vertices instead of BeamSpot
33  useVertex = par.getParameter<bool>("UseVertex");
34 
35  // Flag to use fixed limits for Eta, Phi, Z, pT
36  useFixedZ = par.getParameter<bool>("Z_fixed");
37  useFixedPt = par.getParameter<bool>("Pt_fixed");
38 
39  // Minimum value for pT
40  thePtMin = par.getParameter<double>("Pt_min");
41 
42  // The static region size along the Z direction
43  theHalfZ = par.getParameter<double>("DeltaZ");
44 
45  // The transverse distance of the region from the BS/PV
46  theDeltaR = par.getParameter<double>("DeltaR");
47 
48  // Parameterized ROIs depending on the pt
49  ptRanges_ = par.getParameter<std::vector<double>>("ptRanges");
50  if (ptRanges_.size() < 2) {
51  edm::LogError("MuonTrackingRegionByPtBuilder") << "Size of ptRanges does not be less than 2." << std::endl;
52  }
53 
54  deltaEtas_ = par.getParameter<std::vector<double>>("deltaEtas");
55  if (deltaEtas_.size() != ptRanges_.size() - 1) {
56  edm::LogError("MuonTrackingRegionByPtBuilder")
57  << "Size of deltaEtas does not match number of pt bins." << std::endl;
58  }
59 
60  deltaPhis_ = par.getParameter<std::vector<double>>("deltaPhis");
61  if (deltaPhis_.size() != ptRanges_.size() - 1) {
62  edm::LogError("MuonTrackingRegionByPtBuilder")
63  << "Size of deltaPhis does not match number of pt bins." << std::endl;
64  }
65 
66  // Maximum number of regions to build when looping over Muons
67  theMaxRegions = par.getParameter<int>("maxRegions");
68 
69  // Flag to use precise??
70  thePrecise = par.getParameter<bool>("precise");
71 
72  // perigee reference point
76  iC.consumes<MeasurementTrackerEvent>(par.getParameter<edm::InputTag>("MeasurementTrackerName"));
77  }
78 
79  // Vertex collection and Beam Spot
82 
83  // Input muon collection
85 
86  bfieldToken = iC.esConsumes();
87  if (thePrecise) {
88  msmakerToken = iC.esConsumes();
89  }
90 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
Log< level::Error, false > LogError
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > msmakerToken
edm::EDGetTokenT< reco::TrackCollection > inputCollectionToken
RectangularEtaPhiTrackingRegion::UseMeasurementTracker theOnDemand
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerToken
static UseMeasurementTracker intToUseMeasurementTracker(int value)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bfieldToken

◆ fillDescriptions()

void MuonTrackingRegionByPtBuilder::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Add Fill Descriptions.

Definition at line 219 of file MuonTrackingRegionByPtBuilder.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and edm::ConfigurationDescriptions::setComment().

219  {
221  desc.add<double>("DeltaR", 0.2);
222  desc.add<edm::InputTag>("beamSpot", edm::InputTag(""));
223  desc.add<int>("OnDemand", -1);
224  desc.add<edm::InputTag>("vertexCollection", edm::InputTag(""));
225  desc.add<edm::InputTag>("MeasurementTrackerName", edm::InputTag(""));
226  desc.add<bool>("UseVertex", false);
227  desc.add<double>("Rescale_Dz", 3.0);
228  desc.add<bool>("Pt_fixed", false);
229  desc.add<bool>("Z_fixed", true);
230  desc.add<double>("Pt_min", 1.5);
231  desc.add<double>("DeltaZ", 15.9);
232  desc.add<std::vector<double>>("ptRanges", {0., 1.e9});
233  desc.add<std::vector<double>>("deltaEtas", {0.2});
234  desc.add<std::vector<double>>("deltaPhis", {0.15});
235  desc.add<int>("maxRegions", 1);
236  desc.add<bool>("precise", true);
237  desc.add<edm::InputTag>("input", edm::InputTag(""));
238  descriptions.add("MuonTrackingRegionByPtBuilder", desc);
239 
240  descriptions.setComment(
241  "Build a TrackingRegion around a standalone muon. Options to define region around beamspot or primary vertex and "
242  "dynamic regions are included.");
243 }
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ region() [1/3]

std::unique_ptr< RectangularEtaPhiTrackingRegion > MuonTrackingRegionByPtBuilder::region ( const reco::TrackRef track) const

Define tracking region.

Definition at line 114 of file MuonTrackingRegionByPtBuilder.cc.

References HLT_2024v14_cff::track.

Referenced by region(), and regions().

115  {
116  return region(*track);
117 }
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.

◆ region() [2/3]

std::unique_ptr<RectangularEtaPhiTrackingRegion> MuonTrackingRegionByPtBuilder::region ( const reco::Track t) const
inline

Definition at line 40 of file MuonTrackingRegionByPtBuilder.h.

References region(), submitPVValidationJobs::t, theEvent, and theEventSetup.

40  {
41  return region(t, *theEvent, *theEventSetup);
42  }
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.

◆ region() [3/3]

std::unique_ptr< RectangularEtaPhiTrackingRegion > MuonTrackingRegionByPtBuilder::region ( const reco::Track staTrack,
const edm::Event ev,
const edm::EventSetup es 
) const

Definition at line 130 of file MuonTrackingRegionByPtBuilder.cc.

References funct::abs(), beamSpotToken, bfieldToken, cms::cuda::bs, deltaEtas_, deltaPhis_, eleIsoSequence_cff::deltaR, l1tTrackerHTMiss_cfi::deltaZ, makeMEIFBenchmarkPlots::ev, edm::EventSetup::getData(), reco::Track::innerMomentum(), edm::EDGetTokenT< T >::isUninitialized(), LogDebug, WZElectronSkims53X_cff::max, HLTSiStripMonitoring_cff::measurementTracker, PV_cfg::minPt, reco::TrackBase::momentum(), msmakerToken, reco::TrackBase::p(), edm::Handle< T >::product(), DiDispStaMuonMonitor_cfi::pt, reco::TrackBase::pt(), ptRanges_, region(), theDeltaR, theHalfZ, theMeasurementTrackerToken, theNsigmaDz, theOnDemand, thePrecise, thePtMin, pfDeepBoostedJetPreprocessParams_cfi::upper_bound, useFixedPt, useFixedZ, useVertex, spclusmultinvestigator_cfi::vertexCollection, vertexCollectionToken, and L1BJetProducer_cff::vtx.

131  {
132  // get track momentum/direction at vertex
133  const math::XYZVector& mom = staTrack.momentum();
134  GlobalVector dirVector(mom.x(), mom.y(), mom.z());
135  double pt = staTrack.pt();
136 
137  // Fix for StandAlone tracks with low momentum
138  const math::XYZVector& innerMomentum = staTrack.innerMomentum();
139  GlobalVector forSmallMomentum(innerMomentum.x(), innerMomentum.y(), innerMomentum.z());
140  if (staTrack.p() <= 1.5) {
141  pt = std::abs(forSmallMomentum.perp());
142  }
143 
144  // initial vertex position - in the following it is replaced with beamspot/vertexing
145  GlobalPoint vertexPos(0.0, 0.0, 0.0);
146  // standard 15.9, if useVertex than use error from vertex
147  double deltaZ = theHalfZ;
148 
149  // retrieve beam spot information
151  bool bsHandleFlag = ev.getByToken(beamSpotToken, bs);
152 
153  // check the validity, otherwise vertexing
154  if (bsHandleFlag && bs.isValid() && !useVertex) {
155  vertexPos = GlobalPoint(bs->x0(), bs->y0(), bs->z0());
156  deltaZ = useFixedZ ? theHalfZ : bs->sigmaZ() * theNsigmaDz;
157  } else {
158  // get originZPos from list of reconstructed vertices (first or all)
160  bool vtxHandleFlag = ev.getByToken(vertexCollectionToken, vertexCollection);
161  // check if there exists at least one reconstructed vertex
162  if (vtxHandleFlag && !vertexCollection->empty()) {
163  // use the first vertex in the collection and assume it is the primary event vertex
164  reco::VertexCollection::const_iterator vtx = vertexCollection->begin();
165  if (!vtx->isFake() && vtx->isValid()) {
166  vertexPos = GlobalPoint(vtx->x(), vtx->y(), vtx->z());
167  deltaZ = useFixedZ ? theHalfZ : vtx->zError() * theNsigmaDz;
168  }
169  }
170  }
171 
172  // set delta eta and delta phi depending on the pt
173  auto region_dEta = deltaEtas_.at(0);
174  auto region_dPhi = deltaPhis_.at(0);
175  if (pt < ptRanges_.back()) {
176  auto lowEdge = std::upper_bound(ptRanges_.begin(), ptRanges_.end(), pt);
177  region_dEta = deltaEtas_.at(lowEdge - ptRanges_.begin() - 1);
178  region_dPhi = deltaPhis_.at(lowEdge - ptRanges_.begin() - 1);
179  }
180 
181  float deltaR = theDeltaR;
182  double minPt = useFixedPt ? thePtMin : std::max(thePtMin, pt * 0.6);
183 
187  ev.getByToken(theMeasurementTrackerToken, hmte);
188  measurementTracker = hmte.product();
189  }
190 
191  const auto& bfield = es.getData(bfieldToken);
192  const MultipleScatteringParametrisationMaker* msmaker = nullptr;
193  if (thePrecise) {
194  msmaker = &es.getData(msmakerToken);
195  }
196 
197  auto region = std::make_unique<RectangularEtaPhiTrackingRegion>(dirVector,
198  vertexPos,
199  minPt,
200  deltaR,
201  deltaZ,
202  region_dEta,
203  region_dPhi,
204  bfield,
205  msmaker,
206  thePrecise,
207  theOnDemand,
209 
210  LogDebug("MuonTrackingRegionByPtBuilder")
211  << "the region parameters are:\n"
212  << "\n dirVector: " << dirVector << "\n vertexPos: " << vertexPos << "\n minPt: " << minPt
213  << "\n deltaR:" << deltaR << "\n deltaZ:" << deltaZ << "\n region_dEta:" << region_dEta
214  << "\n region_dPhi:" << region_dPhi << "\n on demand parameter: " << static_cast<int>(theOnDemand);
215 
216  return region;
217 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
T const * product() const
Definition: Handle.h:70
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:98
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
minPt
Definition: PV_cfg.py:223
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken
double pt() const
track transverse momentum
Definition: TrackBase.h:637
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > msmakerToken
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
RectangularEtaPhiTrackingRegion::UseMeasurementTracker theOnDemand
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerToken
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bfieldToken
#define LogDebug(id)

◆ regions()

std::vector< std::unique_ptr< TrackingRegion > > MuonTrackingRegionByPtBuilder::regions ( const edm::Event ev,
const edm::EventSetup es 
) const
overridevirtual

Create Region of Interest.

Implements TrackingRegionProducer.

Definition at line 95 of file MuonTrackingRegionByPtBuilder.cc.

References makeMEIFBenchmarkPlots::ev, inputCollectionToken, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, region(), mps_fire::result, theMaxRegions, and DiMuonV_cfg::tracks.

96  {
97  std::vector<std::unique_ptr<TrackingRegion>> result;
98 
100  ev.getByToken(inputCollectionToken, tracks);
101 
102  int nRegions = 0;
103  for (auto it = tracks->cbegin(), ed = tracks->cend(); it != ed && nRegions < theMaxRegions; ++it) {
104  result.push_back(region(*it, ev, es));
105  nRegions++;
106  }
107 
108  return result;
109 }
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
edm::EDGetTokenT< reco::TrackCollection > inputCollectionToken

◆ setEvent()

void MuonTrackingRegionByPtBuilder::setEvent ( const edm::Event event,
const edm::EventSetup es 
)

Pass the Event to the algo at each event.

Definition at line 122 of file MuonTrackingRegionByPtBuilder.cc.

References edmPickEvents::event, theEvent, and theEventSetup.

122  {
123  theEvent = &event;
124  theEventSetup = &es;
125 }

Member Data Documentation

◆ beamSpotToken

edm::EDGetTokenT<reco::BeamSpot> MuonTrackingRegionByPtBuilder::beamSpotToken
private

Definition at line 78 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ bfieldToken

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> MuonTrackingRegionByPtBuilder::bfieldToken
private

Definition at line 81 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ deltaEtas_

std::vector<double> MuonTrackingRegionByPtBuilder::deltaEtas_
private

Definition at line 73 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ deltaPhis_

std::vector<double> MuonTrackingRegionByPtBuilder::deltaPhis_
private

Definition at line 74 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ inputCollectionToken

edm::EDGetTokenT<reco::TrackCollection> MuonTrackingRegionByPtBuilder::inputCollectionToken
private

Definition at line 80 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and regions().

◆ msmakerToken

edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> MuonTrackingRegionByPtBuilder::msmakerToken
private

Definition at line 82 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ ptRanges_

std::vector<double> MuonTrackingRegionByPtBuilder::ptRanges_
private

Definition at line 72 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ theDeltaR

double MuonTrackingRegionByPtBuilder::theDeltaR
private

Definition at line 69 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ theEvent

const edm::Event* MuonTrackingRegionByPtBuilder::theEvent
private

Definition at line 56 of file MuonTrackingRegionByPtBuilder.h.

Referenced by region(), and setEvent().

◆ theEventSetup

const edm::EventSetup* MuonTrackingRegionByPtBuilder::theEventSetup
private

Definition at line 57 of file MuonTrackingRegionByPtBuilder.h.

Referenced by region(), and setEvent().

◆ theHalfZ

double MuonTrackingRegionByPtBuilder::theHalfZ
private

Definition at line 70 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ theMaxRegions

int MuonTrackingRegionByPtBuilder::theMaxRegions
private

Definition at line 64 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and regions().

◆ theMeasurementTrackerToken

edm::EDGetTokenT<MeasurementTrackerEvent> MuonTrackingRegionByPtBuilder::theMeasurementTrackerToken
private

Definition at line 77 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ theNsigmaDz

double MuonTrackingRegionByPtBuilder::theNsigmaDz
private

Definition at line 66 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ theOnDemand

RectangularEtaPhiTrackingRegion::UseMeasurementTracker MuonTrackingRegionByPtBuilder::theOnDemand
private

Definition at line 76 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ thePrecise

bool MuonTrackingRegionByPtBuilder::thePrecise
private

Definition at line 62 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ thePtMin

double MuonTrackingRegionByPtBuilder::thePtMin
private

Definition at line 68 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ useFixedPt

bool MuonTrackingRegionByPtBuilder::useFixedPt
private

Definition at line 61 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ useFixedZ

bool MuonTrackingRegionByPtBuilder::useFixedZ
private

Definition at line 60 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ useVertex

bool MuonTrackingRegionByPtBuilder::useVertex
private

Definition at line 59 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().

◆ vertexCollectionToken

edm::EDGetTokenT<reco::VertexCollection> MuonTrackingRegionByPtBuilder::vertexCollectionToken
private

Definition at line 79 of file MuonTrackingRegionByPtBuilder.h.

Referenced by build(), and region().