test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonMETValueMapProducer (const edm::ParameterSet &)
 
 ~MuonMETValueMapProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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)
 
virtual 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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::EDConsumerBase::consumesCollector(), 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");
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_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
cms::MuonMETValueMapProducer::~MuonMETValueMapProducer ( )
inline

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 143 of file MuonMETValueMapProducer.cc.

References should_type_MuonCandidateValuesUsed().

Referenced by produce().

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::isGlobalMuon(), reco::Muon::isTrackerMuon(), reco::Muon::outerTrack(), towerEtThreshold_, trackAssociator_, trackAssociatorParameters_, useHO_, useRecHits_, and useTrackAssociatorPositions_.

Referenced by produce().

124 {
125  reco::TrackRef mu_track;
126  if(muon.isGlobalMuon()) mu_track = muon.globalTrack();
127  else if(muon.isTrackerMuon()) 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
bool isTrackerMuon() const
Definition: Muon.h:219
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
bool isGlobalMuon() const
Definition: Muon.h:218
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:101
TrackAssociatorParameters trackAssociatorParameters_
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
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 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 83 of file MuonMETValueMapProducer.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, beamSpotToken_, decide_correction_type(), determine_deltax_deltay(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), metsig::muon, patZpeak::muons, muonToken_, and edm::Event::put().

84 {
86  iEvent.getByToken(muonToken_, muons);
87 
89  iEvent.getByToken(beamSpotToken_, beamSpot);
90 
91  edm::ESHandle<MagneticField> magneticField;
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 
104  reco::MuonMETCorrectionData::Type muCorrType = decide_correction_type(*muon, beamSpot->position());
105 
106  reco::MuonMETCorrectionData muMETCorrData(muCorrType, deltax, deltay);
107  muCorrDataList.push_back(muMETCorrData);
108 
109  }
110 
111  std::auto_ptr<edm::ValueMap<reco::MuonMETCorrectionData> > valueMapMuCorrData(new 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(valueMapMuCorrData, "muCorrData");
119 
120 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
void determine_deltax_deltay(double &deltax, double &deltay, const reco::Muon &muon, double bfield, edm::Event &iEvent, const edm::EventSetup &iSetup)
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
tuple muons
Definition: patZpeak.py:38
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().

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  if(muon.pt() < minPt_ || fabs(muon.eta()) > maxEta_) return false;
159  if(globTk->chi2()/globTk->ndof() > maxNormChi2_) return false;
160  if(fabs(globTk->dxy(beamSpotPosition)) > fabs(maxd0_)) return false;
161  if(siTk->numberOfValidHits() < minnHits_) return false;
162  if(globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_) return false;
163  return true;
164 }
virtual float pt() const
transverse momentum
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool isTrackerMuon() const
Definition: Muon.h:219
bool isGlobalMuon() const
Definition: Muon.h:218
virtual float eta() const
momentum pseudorapidity
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().