CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MuonFromPVSelector Class Reference
Inheritance diagram for MuonFromPVSelector:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonFromPVSelector (edm::ParameterSet const &)
 
void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double max_dxy_
 
double max_dz_
 
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 23 of file MuonFromPVSelector.cc.

Constructor & Destructor Documentation

MuonFromPVSelector::MuonFromPVSelector ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 42 of file MuonFromPVSelector.cc.

References edm::ParameterSet::getParameter(), max_dz_, v_recoMuonToken_, and v_recoVertexToken_.

43  : max_dxy_{iConfig.getParameter<double>("max_dxy")}
44  , max_dz_{iConfig.getParameter<double>("max_dz")}
45  , v_recoVertexToken_{consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("srcVertex"))}
46  , v_recoMuonToken_{consumes<std::vector<reco::Muon>>(iConfig.getParameter<edm::InputTag>("srcMuon"))}
47 {
48  produces<std::vector<reco::Muon>>();
49 }
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_

Member Function Documentation

void MuonFromPVSelector::produce ( edm::StreamID  ,
edm::Event iEvent,
edm::EventSetup const &   
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 55 of file MuonFromPVSelector.cc.

References funct::abs(), DEFINE_FWK_MODULE, edm::Event::getByToken(), goodMuons_cfi::goodMuons, max_dxy_, max_dz_, eostools::move(), electronCleaner_cfi::muons, edm::Event::put(), MetAnalyzer::pv(), v_recoMuonToken_, v_recoVertexToken_, and ecalDrivenElectronSeedsParameters_cff::vertices.

56 {
57  auto goodMuons = std::make_unique<std::vector<reco::Muon>>();
58 
60  iEvent.getByToken(v_recoVertexToken_, vertices);
61 
63  iEvent.getByToken(v_recoMuonToken_, muons);
64 
65  if (!vertices->empty()) {
66  auto const& pv = vertices->front();
67  std::copy_if(std::cbegin(*muons), std::cend(*muons), std::back_inserter(*goodMuons),
68  [&pv, this](auto const& muon){
69  return muon.innerTrack().isNonnull() &&
70  std::abs(muon.innerTrack()->dxy(pv.position())) < max_dxy_ &&
71  std::abs(muon.innerTrack()->dz(pv.position())) < max_dz_;
72  });
73  }
74 
75  iEvent.put(std::move(goodMuons));
76 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_
def pv(vc)
Definition: MetAnalyzer.py:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

double MuonFromPVSelector::max_dxy_
private

Definition at line 31 of file MuonFromPVSelector.cc.

Referenced by produce().

double MuonFromPVSelector::max_dz_
private

Definition at line 32 of file MuonFromPVSelector.cc.

Referenced by MuonFromPVSelector(), and produce().

edm::EDGetTokenT<std::vector<reco::Muon> > MuonFromPVSelector::v_recoMuonToken_
private

Definition at line 34 of file MuonFromPVSelector.cc.

Referenced by MuonFromPVSelector(), and produce().

edm::EDGetTokenT<std::vector<reco::Vertex> > MuonFromPVSelector::v_recoVertexToken_
private

Definition at line 33 of file MuonFromPVSelector.cc.

Referenced by MuonFromPVSelector(), and produce().