CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HLTMuonTrackSelector Class Reference

#include <HLTMuonTrackSelector.h>

Inheritance diagram for HLTMuonTrackSelector:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

using MVACollection = std::vector< float >
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 HLTMuonTrackSelector (const edm::ParameterSet &)
 
 ~HLTMuonTrackSelector () override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

TrackCollectionCloner collectionCloner
 
const TrackCollectionCloner::Tokens collectionClonerTokens
 
const bool flag_copyMVA
 
const edm::EDGetTokenT< std::vector< reco::Muon > > token_muon
 
const edm::EDGetTokenT< MVACollectiontoken_originalMVAVals
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 30 of file HLTMuonTrackSelector.h.

Member Typedef Documentation

◆ MVACollection

using HLTMuonTrackSelector::MVACollection = std::vector<float>

Definition at line 35 of file HLTMuonTrackSelector.h.

Constructor & Destructor Documentation

◆ HLTMuonTrackSelector()

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

Definition at line 21 of file HLTMuonTrackSelector.cc.

22  : collectionCloner(producesCollector(), iConfig, true),
24  token_muon(consumes<vector<reco::Muon> >(iConfig.getParameter<edm::InputTag>("muon"))),
25  token_originalMVAVals(consumes<MVACollection>(iConfig.getParameter<edm::InputTag>("originalMVAVals"))),
26  flag_copyMVA(iConfig.getParameter<bool>("copyMVA")) {
27  produces<MVACollection>("MVAValues");
28 }

◆ ~HLTMuonTrackSelector()

HLTMuonTrackSelector::~HLTMuonTrackSelector ( )
override

Definition at line 30 of file HLTMuonTrackSelector.cc.

30 {}

Member Function Documentation

◆ fillDescriptions()

void HLTMuonTrackSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 32 of file HLTMuonTrackSelector.cc.

32  {
34  desc.add<edm::InputTag>("track", edm::InputTag());
35  desc.add<edm::InputTag>("muon", edm::InputTag());
36  desc.add<edm::InputTag>("originalMVAVals", edm::InputTag());
37  desc.add<bool>("copyMVA", false);
38  TrackCollectionCloner::fill(desc); // -- add copyExtras and copyTrajectories
39  descriptions.add("HLTMuonTrackSelector", desc);
40 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, TrackCollectionCloner::fill(), and HLT_FULL_cff::InputTag.

◆ produce()

void HLTMuonTrackSelector::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 42 of file HLTMuonTrackSelector.cc.

42  {
44 
45  // -- load tracks
47  auto nTrack = originalTracks.size();
48 
49  // -- load muons
50  edm::Handle<vector<reco::Muon> > handle_muon;
51  iEvent.getByToken(token_muon, handle_muon);
52  auto nMuon = handle_muon->size();
53 
54  // -- load MVA values if necessary
55  edm::Handle<MVACollection> handle_originalMVAVals;
56  if (flag_copyMVA) {
57  iEvent.getByToken(token_originalMVAVals, handle_originalMVAVals);
58  assert((*handle_originalMVAVals).size() == nTrack);
59  }
60 
61  // -- containers for selected track informations
62  std::vector<unsigned int> selectedIter;
63  auto selectedMVAVals = std::make_unique<MVACollection>();
64 
65  auto nSelected = 0U;
66 
68  // -- matching -- //
70 
71  // -- iteration over muons
72  for (auto i_mu = 0U; i_mu < nMuon; ++i_mu) {
73  // -- avoids crashing in case the muon is SA only.
74  const reco::Muon& muon(handle_muon->at(i_mu));
75  TrackRef muonTrackRef = (muon.innerTrack().isNonnull()) ? muon.innerTrack() : muon.muonBestTrack();
76 
77  double muonPt = muonTrackRef->pt();
78  double muonEta = muonTrackRef->eta();
79  double muonPhi = muonTrackRef->phi();
80 
81  double smallestDPt = 1e30;
82  unsigned int smallestDPtIter = 9999U;
83 
84  // -- iteration over tracks
85  for (auto i_trk = 0U; i_trk < nTrack; ++i_trk) {
86  auto const& track = originalTracks[i_trk];
87 
88  double trackPt = track.pt();
89  double trackEta = track.eta();
90  double trackPhi = track.phi();
91 
92  if (deltaR(trackEta, trackPhi, muonEta, muonPhi) < 0.1) {
93  double dPt = fabs(trackPt - muonPt);
94 
95  if (dPt < smallestDPt) {
96  smallestDPt = dPt;
97  smallestDPtIter = i_trk;
98  }
99  }
100  } // -- end of track iteration
101 
102  // -- if at least one track is matched
103  if (smallestDPtIter != 9999U) {
104  selectedIter.push_back(smallestDPtIter);
105  if (flag_copyMVA)
106  selectedMVAVals->push_back((*handle_originalMVAVals)[smallestDPtIter]);
107  ++nSelected;
108  }
109 
110  } // -- end of muon iteration
111 
112  assert(producer.selTracks_->empty());
113 
114  // -- produces tracks and associated informations
115  producer(collectionClonerTokens, selectedIter);
116  assert(producer.selTracks_->size() == nSelected);
117 
118  if (flag_copyMVA)
119  iEvent.put(std::move(selectedMVAVals), "MVAValues");
120 }

References cms::cuda::assert(), collectionCloner, collectionClonerTokens, PbPb_ZMuSkimMuonDPG_cff::deltaR, flag_copyMVA, iEvent, eostools::move(), HLT_FULL_cff::muon, HLTObjectMonitor_cfi::muonEta, HLTObjectMonitor_cfi::muonPhi, HLTObjectMonitor_cfi::muonPt, packedPFCandidates_cfi::originalTracks, RawToDigi_Repacked_cff::producer, token_muon, token_originalMVAVals, HLT_FULL_cff::track, reco::btau::trackEta, reco::btau::trackPhi, listHistos::trackPt, TrackCollectionTokens::tracks(), and mitigatedMETSequence_cff::U.

Member Data Documentation

◆ collectionCloner

TrackCollectionCloner HLTMuonTrackSelector::collectionCloner
private

Definition at line 42 of file HLTMuonTrackSelector.h.

Referenced by produce().

◆ collectionClonerTokens

const TrackCollectionCloner::Tokens HLTMuonTrackSelector::collectionClonerTokens
private

Definition at line 43 of file HLTMuonTrackSelector.h.

Referenced by produce().

◆ flag_copyMVA

const bool HLTMuonTrackSelector::flag_copyMVA
private

Definition at line 47 of file HLTMuonTrackSelector.h.

Referenced by produce().

◆ token_muon

const edm::EDGetTokenT<std::vector<reco::Muon> > HLTMuonTrackSelector::token_muon
private

Definition at line 45 of file HLTMuonTrackSelector.h.

Referenced by produce().

◆ token_originalMVAVals

const edm::EDGetTokenT<MVACollection> HLTMuonTrackSelector::token_originalMVAVals
private

Definition at line 46 of file HLTMuonTrackSelector.h.

Referenced by produce().

HLTObjectMonitor_cfi.muonPt
muonPt
Definition: HLTObjectMonitor_cfi.py:82
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
TrackCollectionCloner::Producer
Definition: TrackCollectionCloner.h:52
HLTMuonTrackSelector::token_muon
const edm::EDGetTokenT< std::vector< reco::Muon > > token_muon
Definition: HLTMuonTrackSelector.h:45
HLTObjectMonitor_cfi.muonEta
muonEta
Definition: HLTObjectMonitor_cfi.py:92
muon
Definition: MuonCocktails.h:17
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RawToDigi_Repacked_cff.producer
producer
Definition: RawToDigi_Repacked_cff.py:6
cms::cuda::assert
assert(be >=bs)
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:46
reco::btau::trackEta
Definition: TaggingVariable.h:42
HLTMuonTrackSelector::token_originalMVAVals
const edm::EDGetTokenT< MVACollection > token_originalMVAVals
Definition: HLTMuonTrackSelector.h:46
HLTMuonTrackSelector::collectionCloner
TrackCollectionCloner collectionCloner
Definition: HLTMuonTrackSelector.h:42
edm::Handle
Definition: AssociativeIterator.h:50
reco::Muon
Definition: Muon.h:27
edm::Ref< TrackCollection >
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
TrackCollectionCloner::fill
static void fill(edm::ParameterSetDescription &desc)
Definition: TrackCollectionCloner.cc:3
TrackCollectionTokens::tracks
reco::TrackCollection const & tracks(edm::Event &evt) const
Definition: TrackCollectionTokens.h:26
reco::btau::trackPhi
Definition: TaggingVariable.h:43
HLTObjectMonitor_cfi.muonPhi
muonPhi
Definition: HLTObjectMonitor_cfi.py:102
iEvent
int iEvent
Definition: GenABIO.cc:224
HLTMuonTrackSelector::collectionClonerTokens
const TrackCollectionCloner::Tokens collectionClonerTokens
Definition: HLTMuonTrackSelector.h:43
packedPFCandidates_cfi.originalTracks
originalTracks
Definition: packedPFCandidates_cfi.py:7
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
edm::ProducerBase::producesCollector
ProducesCollector producesCollector()
Definition: ProducerBase.cc:105
listHistos.trackPt
trackPt
Definition: listHistos.py:120
edm::InputTag
Definition: InputTag.h:15
HLTMuonTrackSelector::flag_copyMVA
const bool flag_copyMVA
Definition: HLTMuonTrackSelector.h:47