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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 }
const TrackCollectionCloner::Tokens collectionClonerTokens
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< std::vector< reco::Muon > > token_muon
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< MVACollection > token_originalMVAVals
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ProducesCollector producesCollector()
TrackCollectionCloner collectionCloner

◆ ~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.

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

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 }
static void fill(edm::ParameterSetDescription &desc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ 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.

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

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 }
const TrackCollectionCloner::Tokens collectionClonerTokens
const edm::EDGetTokenT< std::vector< reco::Muon > > token_muon
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< MVACollection > token_originalMVAVals
reco::TrackCollection const & tracks(edm::Event &evt) const
def move(src, dest)
Definition: eostools.py:511
TrackCollectionCloner collectionCloner

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().