CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
IdealMagneticFieldRecord
magFieldToken_
 
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 ( 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  }
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_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
cms::MuonMETValueMapProducer::~MuonMETValueMapProducer ( )
inlineoverride

Definition at line 43 of file MuonMETValueMapProducer.h.

43 {}

Member Function Documentation

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)
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(), reco::Muon::globalTrack(), info(), reco::Muon::innerTrack(), reco::Muon::isGEMMuon(), reco::Muon::isGlobalMuon(), reco::Muon::isME0Muon(), reco::Muon::isRPCMuon(), reco::Muon::isTrackerMuon(), reco::Muon::outerTrack(), 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 
131  iEvent, iSetup, trackAssociator_.getFreeTrajectoryState(&magneticField, *mu_track), trackAssociatorParameters_);
132 
133  MuonMETAlgo alg;
134  alg.GetMuDepDeltas(
135  &muon, info, useTrackAssociatorPositions_, useRecHits_, useHO_, towerEtThreshold_, deltax, deltay, bfield);
136  }
static const TGPicture * info(bool iBackgroundIsBlack)
virtual TrackRef innerTrack() const
Definition: Muon.h:45
TrackDetectorAssociator trackAssociator_
bool isME0Muon() const
Definition: Muon.h:306
bool isTrackerMuon() const override
Definition: Muon.h:300
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
bool isRPCMuon() const
Definition: Muon.h:304
TrackAssociatorParameters trackAssociatorParameters_
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:48
bool isGEMMuon() const
Definition: Muon.h:305
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 &)
bool isGlobalMuon() const override
Definition: Muon.h:299
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:51
void MuonMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 80 of file MuonMETValueMapProducer.cc.

References beam_dqm_sourceclient-live_cfg::beamSpot, beamSpotToken_, decide_correction_type(), determine_deltax_deltay(), edm::Event::getByToken(), edm::EventSetup::getData(), MagneticField::inTesla(), magFieldToken_, HLT_FULL_cff::magneticField, eostools::move(), HLT_FULL_cff::muon, patZpeak::muons, muonToken_, edm::Event::put(), and PV3DBase< T, PVType, FrameType >::z().

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 
98  reco::MuonMETCorrectionData::Type muCorrType = decide_correction_type(*muon, beamSpot->position());
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)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
tuple magneticField
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
reco::MuonMETCorrectionData::Type decide_correction_type(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
T z() const
Definition: PV3DBase.h:61
def move
Definition: eostools.py:511
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
tuple muons
Definition: patZpeak.py:39
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool MuonMETValueMapProducer::should_type_MuonCandidateValuesUsed ( const reco::Muon muon,
const math::XYZPoint beamSpotPosition 
)
private

Definition at line 148 of file MuonMETValueMapProducer.cc.

References reco::LeafCandidate::eta(), reco::Muon::globalTrack(), reco::Muon::innerTrack(), isAlsoTkMu_, reco::Muon::isGlobalMuon(), reco::Muon::isTrackerMuon(), maxd0_, maxEta_, maxNormChi2_, minnHits_, minnValidStaHits_, minPt_, and reco::LeafCandidate::pt().

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  }
double pt() const final
transverse momentum
virtual TrackRef innerTrack() const
Definition: Muon.h:45
bool isTrackerMuon() const override
Definition: Muon.h:300
bool isGlobalMuon() const override
Definition: Muon.h:299
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:51
double eta() const final
momentum pseudorapidity

Member Data Documentation

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

Definition at line 73 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

bool cms::MuonMETValueMapProducer::isAlsoTkMu_
private

Definition at line 61 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

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

Definition at line 74 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::maxd0_
private

Definition at line 63 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::maxEta_
private

Definition at line 60 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::maxNormChi2_
private

Definition at line 62 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

int cms::MuonMETValueMapProducer::minnHits_
private

Definition at line 64 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

int cms::MuonMETValueMapProducer::minnValidStaHits_
private

Definition at line 65 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::minPt_
private

Definition at line 59 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

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

Definition at line 72 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::towerEtThreshold_
private

Definition at line 69 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

TrackDetectorAssociator cms::MuonMETValueMapProducer::trackAssociator_
private

Definition at line 77 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay(), and MuonMETValueMapProducer().

TrackAssociatorParameters cms::MuonMETValueMapProducer::trackAssociatorParameters_
private

Definition at line 76 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay(), and MuonMETValueMapProducer().

bool cms::MuonMETValueMapProducer::useHO_
private

Definition at line 68 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

bool cms::MuonMETValueMapProducer::useRecHits_
private

Definition at line 70 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

bool cms::MuonMETValueMapProducer::useTrackAssociatorPositions_
private

Definition at line 67 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().