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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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=default
 
- 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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 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 22 of file HLTMuonTrackSelector.cc.

23  : collectionCloner(producesCollector(), iConfig, true),
25  token_muon(consumes<vector<reco::Muon> >(iConfig.getParameter<edm::InputTag>("muon"))),
26  token_originalMVAVals(consumes<MVACollection>(iConfig.getParameter<edm::InputTag>("originalMVAVals"))),
27  flag_copyMVA(iConfig.getParameter<bool>("copyMVA")) {
28  produces<MVACollection>("MVAValues");
29 }
const TrackCollectionCloner::Tokens collectionClonerTokens
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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 ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 31 of file HLTMuonTrackSelector.cc.

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

31  {
33  desc.add<edm::InputTag>("track", edm::InputTag());
34  desc.add<edm::InputTag>("muon", edm::InputTag());
35  desc.add<edm::InputTag>("originalMVAVals", edm::InputTag());
36  desc.add<bool>("copyMVA", false);
37  TrackCollectionCloner::fill(desc); // -- add copyExtras and copyTrajectories
38  descriptions.add("HLTMuonTrackSelector", desc);
39 }
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 41 of file HLTMuonTrackSelector.cc.

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

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