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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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, 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_
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 39 of file MuonMETValueMapProducer.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file MuonMETValueMapProducer.cc.

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

59  : minPt_(iConfig.getParameter<double>("minPt"))
60  , maxEta_(iConfig.getParameter<double>("maxEta"))
61  , isAlsoTkMu_(iConfig.getParameter<bool>("isAlsoTkMu"))
62  , maxNormChi2_(iConfig.getParameter<double>("maxNormChi2"))
63  , maxd0_(iConfig.getParameter<double>("maxd0"))
64  , minnHits_(iConfig.getParameter<int>("minnHits"))
65  , minnValidStaHits_(iConfig.getParameter<int>("minnValidStaHits"))
66  , useTrackAssociatorPositions_(iConfig.getParameter<bool>("useTrackAssociatorPositions"))
67  , useHO_(iConfig.getParameter<bool>("useHO"))
68  , towerEtThreshold_(iConfig.getParameter<double>("towerEtThreshold"))
69  , useRecHits_(iConfig.getParameter<bool>("useRecHits"))
70 {
71  muonToken_ = consumes<edm::View<reco::Muon> >(iConfig.getParameter<edm::InputTag>("muonInputTag"));
72  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
73 
74  edm::ParameterSet trackAssociatorParams = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
75  edm::ConsumesCollector iC = consumesCollector();
76  trackAssociatorParameters_.loadParameters(trackAssociatorParams, iC);
78 
79  produces<edm::ValueMap<reco::MuonMETCorrectionData> >("muCorrData");
80 }
T getParameter(std::string const &) const
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_
cms::MuonMETValueMapProducer::~MuonMETValueMapProducer ( )
inlineoverride

Member Function Documentation

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

Definition at line 143 of file MuonMETValueMapProducer.cc.

References should_type_MuonCandidateValuesUsed().

Referenced by produce(), and ~MuonMETValueMapProducer().

144 {
145  if(should_type_MuonCandidateValuesUsed(muon, beamSpotPosition))
146  return reco::MuonMETCorrectionData::Type::MuonCandidateValuesUsed;
147 
148  return reco::MuonMETCorrectionData::Type::NotUsed;
149 }
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,
edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Definition at line 123 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(), and ~MuonMETValueMapProducer().

124 {
125  reco::TrackRef mu_track;
126  if(muon.isGlobalMuon()) mu_track = muon.globalTrack();
127  else if(muon.isTrackerMuon()||muon.isRPCMuon()||muon.isGEMMuon()||muon.isME0Muon()) mu_track = muon.innerTrack();
128  else mu_track = muon.outerTrack();
129 
131  trackAssociator_.getFreeTrajectoryState(iSetup, *mu_track),
133 
134  MuonMETAlgo alg;
135  alg.GetMuDepDeltas(&muon, info,
138  deltax, deltay, bfield);
139 
140 }
static const TGPicture * info(bool iBackgroundIsBlack)
virtual TrackRef innerTrack() const
Definition: Muon.h:48
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
TrackDetectorAssociator trackAssociator_
bool isME0Muon() const
Definition: Muon.h:279
bool isTrackerMuon() const override
Definition: Muon.h:273
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:101
bool isRPCMuon() const
Definition: Muon.h:277
bool isGlobalMuon() const override
Definition: Muon.h:272
TrackAssociatorParameters trackAssociatorParameters_
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
bool isGEMMuon() const
Definition: Muon.h:278
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54
void MuonMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 83 of file MuonMETValueMapProducer.cc.

References ecalDrivenElectronSeedsParameters_cff::beamSpot, beamSpotToken_, decide_correction_type(), determine_deltax_deltay(), edm::EventSetup::get(), edm::Event::getByToken(), MagneticField::inTesla(), seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, eostools::move(), metsig::muon, nano_cff::muons, muonToken_, reco::BeamSpot::position(), edm::Event::put(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ~MuonMETValueMapProducer().

84 {
86  iEvent.getByToken(muonToken_, muons);
87 
89  iEvent.getByToken(beamSpotToken_, beamSpot);
90 
92  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
93 
94  double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
95 
96  std::vector<reco::MuonMETCorrectionData> muCorrDataList;
97 
98  for(edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon)
99  {
100  double deltax = 0.0;
101  double deltay = 0.0;
102  determine_deltax_deltay(deltax, deltay, *muon, bfield, iEvent, iSetup);
103 
105 
106  reco::MuonMETCorrectionData muMETCorrData(muCorrType, deltax, deltay);
107  muCorrDataList.push_back(muMETCorrData);
108 
109  }
110 
111  auto valueMapMuCorrData = std::make_unique<edm::ValueMap<reco::MuonMETCorrectionData>>();
112 
113  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*valueMapMuCorrData);
114 
115  dataFiller.insert(muons, muCorrDataList.begin(), muCorrDataList.end());
116  dataFiller.fill();
117 
118  iEvent.put(std::move(valueMapMuCorrData), "muCorrData");
119 
120 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
reco::MuonMETCorrectionData::Type decide_correction_type(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
T z() const
Definition: PV3DBase.h:64
void determine_deltax_deltay(double &deltax, double &deltay, const reco::Muon &muon, double bfield, edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const T & get() const
Definition: EventSetup.h:59
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const Point & position() const
position
Definition: BeamSpot.h:62
def move(src, dest)
Definition: eostools.py:510
bool MuonMETValueMapProducer::should_type_MuonCandidateValuesUsed ( const reco::Muon muon,
const math::XYZPoint beamSpotPosition 
)
private

Definition at line 152 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(), and ~MuonMETValueMapProducer().

153 {
154  if(!muon.isGlobalMuon()) return false;
155  if(!muon.isTrackerMuon() && isAlsoTkMu_) return false;
156  reco::TrackRef globTk = muon.globalTrack();
157  reco::TrackRef siTk = muon.innerTrack();
158 
159  if(muon.pt() < minPt_ || fabs(muon.eta()) > maxEta_) return false;
160  if(globTk->chi2()/globTk->ndof() > maxNormChi2_) return false;
161  if(fabs(globTk->dxy(beamSpotPosition)) > fabs(maxd0_)) return false;
162  if(siTk->numberOfValidHits() < minnHits_) return false;
163  if(globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_) return false;
164  return true;
165 }
double eta() const final
momentum pseudorapidity
virtual TrackRef innerTrack() const
Definition: Muon.h:48
double pt() const final
transverse momentum
bool isTrackerMuon() const override
Definition: Muon.h:273
bool isGlobalMuon() const override
Definition: Muon.h:272
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54

Member Data Documentation

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

Definition at line 66 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

bool cms::MuonMETValueMapProducer::isAlsoTkMu_
private

Definition at line 54 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::maxd0_
private

Definition at line 56 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::maxEta_
private

Definition at line 53 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::maxNormChi2_
private

Definition at line 55 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

int cms::MuonMETValueMapProducer::minnHits_
private

Definition at line 57 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

int cms::MuonMETValueMapProducer::minnValidStaHits_
private

Definition at line 58 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

double cms::MuonMETValueMapProducer::minPt_
private

Definition at line 52 of file MuonMETValueMapProducer.h.

Referenced by should_type_MuonCandidateValuesUsed().

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

Definition at line 65 of file MuonMETValueMapProducer.h.

Referenced by MuonMETValueMapProducer(), and produce().

double cms::MuonMETValueMapProducer::towerEtThreshold_
private

Definition at line 62 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

TrackDetectorAssociator cms::MuonMETValueMapProducer::trackAssociator_
private

Definition at line 69 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay(), and MuonMETValueMapProducer().

TrackAssociatorParameters cms::MuonMETValueMapProducer::trackAssociatorParameters_
private

Definition at line 68 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay(), and MuonMETValueMapProducer().

bool cms::MuonMETValueMapProducer::useHO_
private

Definition at line 61 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

bool cms::MuonMETValueMapProducer::useRecHits_
private

Definition at line 63 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().

bool cms::MuonMETValueMapProducer::useTrackAssociatorPositions_
private

Definition at line 60 of file MuonMETValueMapProducer.h.

Referenced by determine_deltax_deltay().