CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::MuonMETValueMapProducer Class Reference

#include <MuonMETValueMapProducer.h>

Inheritance diagram for cms::MuonMETValueMapProducer:
edm::stream::EDProducer<>

Public Member Functions

 MuonMETValueMapProducer (const edm::ParameterSet &)
 
 ~MuonMETValueMapProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

reco::MuonMETCorrectionData::Type decide_correction_type (const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
 
void determine_deltax_deltay (double &deltax, double &deltay, const reco::Muon &muon, double bfield, const MagneticField &magneticField, edm::Event &iEvent, const edm::EventSetup &iSetup)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
bool should_type_MuonCandidateValuesUsed (const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
bool isAlsoTkMu_
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagFieldToken_
 
double maxd0_
 
double maxEta_
 
double maxNormChi2_
 
int minnHits_
 
int minnValidStaHits_
 
double minPt_
 
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
 
double towerEtThreshold_
 
TrackDetectorAssociator trackAssociator_
 
TrackAssociatorParameters trackAssociatorParameters_
 
bool useHO_
 
bool useRecHits_
 
bool useTrackAssociatorPositions_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 40 of file MuonMETValueMapProducer.h.

Constructor & Destructor Documentation

◆ MuonMETValueMapProducer()

MuonMETValueMapProducer::MuonMETValueMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 55 of file MuonMETValueMapProducer.cc.

References beamSpotToken_, edm::ParameterSet::getParameter(), TrackAssociatorParameters::loadParameters(), magFieldToken_, muonToken_, trackAssociator_, trackAssociatorParameters_, and TrackDetectorAssociator::useDefaultPropagator().

56  : minPt_(iConfig.getParameter<double>("minPt")),
57  maxEta_(iConfig.getParameter<double>("maxEta")),
58  isAlsoTkMu_(iConfig.getParameter<bool>("isAlsoTkMu")),
59  maxNormChi2_(iConfig.getParameter<double>("maxNormChi2")),
60  maxd0_(iConfig.getParameter<double>("maxd0")),
61  minnHits_(iConfig.getParameter<int>("minnHits")),
62  minnValidStaHits_(iConfig.getParameter<int>("minnValidStaHits")),
63  useTrackAssociatorPositions_(iConfig.getParameter<bool>("useTrackAssociatorPositions")),
64  useHO_(iConfig.getParameter<bool>("useHO")),
65  towerEtThreshold_(iConfig.getParameter<double>("towerEtThreshold")),
66  useRecHits_(iConfig.getParameter<bool>("useRecHits")) {
67  muonToken_ = consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muonInputTag"));
68  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
69  magFieldToken_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
70 
71  edm::ParameterSet trackAssociatorParams = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
72  edm::ConsumesCollector iC = consumesCollector();
73  trackAssociatorParameters_.loadParameters(trackAssociatorParams, iC);
75 
76  produces<edm::ValueMap<reco::MuonMETCorrectionData>>("muCorrData");
77  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
void useDefaultPropagator()
use the default propagator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
TrackDetectorAssociator trackAssociator_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
TrackAssociatorParameters trackAssociatorParameters_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_

◆ ~MuonMETValueMapProducer()

cms::MuonMETValueMapProducer::~MuonMETValueMapProducer ( )
inlineoverride

Definition at line 43 of file MuonMETValueMapProducer.h.

43 {}

Member Function Documentation

◆ decide_correction_type()

reco::MuonMETCorrectionData::Type MuonMETValueMapProducer::decide_correction_type ( const reco::Muon muon,
const math::XYZPoint beamSpotPosition 
)
private

Definition at line 139 of file MuonMETValueMapProducer.cc.

References should_type_MuonCandidateValuesUsed().

Referenced by produce().

140  {
141  if (should_type_MuonCandidateValuesUsed(muon, beamSpotPosition))
142  return reco::MuonMETCorrectionData::Type::MuonCandidateValuesUsed;
143 
144  return reco::MuonMETCorrectionData::Type::NotUsed;
145  }
bool should_type_MuonCandidateValuesUsed(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)

◆ determine_deltax_deltay()

void MuonMETValueMapProducer::determine_deltax_deltay ( double &  deltax,
double &  deltay,
const reco::Muon muon,
double  bfield,
const MagneticField magneticField,
edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Definition at line 115 of file MuonMETValueMapProducer.cc.

References TrackDetectorAssociator::associate(), TrackDetectorAssociator::getFreeTrajectoryState(), MuonMETAlgo::GetMuDepDeltas(), iEvent, info(), HLT_2024v14_cff::magneticField, towerEtThreshold_, trackAssociator_, trackAssociatorParameters_, useHO_, useRecHits_, and useTrackAssociatorPositions_.

Referenced by produce().

121  {
122  reco::TrackRef mu_track;
123  if (muon.isGlobalMuon())
124  mu_track = muon.globalTrack();
125  else if (muon.isTrackerMuon() || muon.isRPCMuon() || muon.isGEMMuon() || muon.isME0Muon())
126  mu_track = muon.innerTrack();
127  else
128  mu_track = muon.outerTrack();
129 
132 
133  MuonMETAlgo alg;
134  alg.GetMuDepDeltas(
136  }
static const TGPicture * info(bool iBackgroundIsBlack)
TrackDetectorAssociator trackAssociator_
void GetMuDepDeltas(const reco::Muon *inputMuon, TrackDetMatchInfo &info, bool useTrackAssociatorPositions, bool useRecHits, bool useHO, double towerEtThreshold, double &deltax, double &deltay, double Bfield)
Definition: MuonMETAlgo.cc:96
int iEvent
Definition: GenABIO.cc:224
TrackAssociatorParameters trackAssociatorParameters_
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)

◆ produce()

void MuonMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 80 of file MuonMETValueMapProducer.cc.

References pwdgSkimBPark_cfi::beamSpot, beamSpotToken_, decide_correction_type(), determine_deltax_deltay(), edm::EventSetup::getData(), iEvent, magFieldToken_, HLT_2024v14_cff::magneticField, eostools::move(), HLT_2024v14_cff::muon, DiMuonV_cfg::muons, and muonToken_.

80  {
82  iEvent.getByToken(muonToken_, muons);
83 
85  iEvent.getByToken(beamSpotToken_, beamSpot);
86 
88 
89  double bfield = magneticField.inTesla(GlobalPoint(0., 0., 0.)).z();
90 
91  std::vector<reco::MuonMETCorrectionData> muCorrDataList;
92 
93  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
94  double deltax = 0.0;
95  double deltay = 0.0;
96  determine_deltax_deltay(deltax, deltay, *muon, bfield, magneticField, iEvent, iSetup);
97 
99 
100  reco::MuonMETCorrectionData muMETCorrData(muCorrType, deltax, deltay);
101  muCorrDataList.push_back(muMETCorrData);
102  }
103 
104  auto valueMapMuCorrData = std::make_unique<edm::ValueMap<reco::MuonMETCorrectionData>>();
105 
106  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*valueMapMuCorrData);
107 
108  dataFiller.insert(muons, muCorrDataList.begin(), muCorrDataList.end());
109  dataFiller.fill();
110 
111  iEvent.put(std::move(valueMapMuCorrData), "muCorrData");
112  }
void determine_deltax_deltay(double &deltax, double &deltay, const reco::Muon &muon, double bfield, const MagneticField &magneticField, edm::Event &iEvent, const edm::EventSetup &iSetup)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
reco::MuonMETCorrectionData::Type decide_correction_type(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
def move(src, dest)
Definition: eostools.py:511

◆ should_type_MuonCandidateValuesUsed()

bool MuonMETValueMapProducer::should_type_MuonCandidateValuesUsed ( const reco::Muon muon,
const math::XYZPoint beamSpotPosition 
)
private

Definition at line 148 of file MuonMETValueMapProducer.cc.

References isAlsoTkMu_, maxd0_, maxEta_, maxNormChi2_, minnHits_, minnValidStaHits_, and minPt_.

Referenced by decide_correction_type().

149  {
150  if (!muon.isGlobalMuon())
151  return false;
152  if (!muon.isTrackerMuon() && isAlsoTkMu_)
153  return false;
154  reco::TrackRef globTk = muon.globalTrack();
155  reco::TrackRef siTk = muon.innerTrack();
156 
157  if (muon.pt() < minPt_ || fabs(muon.eta()) > maxEta_)
158  return false;
159  if (globTk->chi2() / globTk->ndof() > maxNormChi2_)
160  return false;
161  if (fabs(globTk->dxy(beamSpotPosition)) > fabs(maxd0_))
162  return false;
163  if (siTk->numberOfValidHits() < minnHits_)
164  return false;
165  if (globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_)
166  return false;
167  return true;
168  }

Member Data Documentation

◆ beamSpotToken_

edm::EDGetTokenT<reco::BeamSpot> cms::MuonMETValueMapProducer::beamSpotToken_
private

Definition at line 73 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

◆ isAlsoTkMu_

bool cms::MuonMETValueMapProducer::isAlsoTkMu_
private

Definition at line 61 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ magFieldToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> cms::MuonMETValueMapProducer::magFieldToken_
private

Definition at line 74 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

◆ maxd0_

double cms::MuonMETValueMapProducer::maxd0_
private

Definition at line 63 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ maxEta_

double cms::MuonMETValueMapProducer::maxEta_
private

Definition at line 60 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ maxNormChi2_

double cms::MuonMETValueMapProducer::maxNormChi2_
private

Definition at line 62 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ minnHits_

int cms::MuonMETValueMapProducer::minnHits_
private

Definition at line 64 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ minnValidStaHits_

int cms::MuonMETValueMapProducer::minnValidStaHits_
private

Definition at line 65 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ minPt_

double cms::MuonMETValueMapProducer::minPt_
private

Definition at line 59 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

◆ muonToken_

edm::EDGetTokenT<edm::View<reco::Muon> > cms::MuonMETValueMapProducer::muonToken_
private

Definition at line 72 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

◆ towerEtThreshold_

double cms::MuonMETValueMapProducer::towerEtThreshold_
private

Definition at line 69 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

◆ trackAssociator_

TrackDetectorAssociator cms::MuonMETValueMapProducer::trackAssociator_
private

Definition at line 77 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay(), and MuonMETValueMapProducer().

◆ trackAssociatorParameters_

TrackAssociatorParameters cms::MuonMETValueMapProducer::trackAssociatorParameters_
private

Definition at line 76 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay(), and MuonMETValueMapProducer().

◆ useHO_

bool cms::MuonMETValueMapProducer::useHO_
private

Definition at line 68 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

◆ useRecHits_

bool cms::MuonMETValueMapProducer::useRecHits_
private

Definition at line 70 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

◆ useTrackAssociatorPositions_

bool cms::MuonMETValueMapProducer::useTrackAssociatorPositions_
private

Definition at line 67 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().