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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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
 
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
 
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< vector< reco::Muon > > token_muon
 
const edm::EDGetTokenT< MVACollectiontoken_originalMVAVals
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 33 of file HLTMuonTrackSelector.h.

Member Typedef Documentation

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

Definition at line 38 of file HLTMuonTrackSelector.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file HLTMuonTrackSelector.cc.

19  : collectionCloner(producesCollector(), iConfig, true),
21  token_muon(consumes<vector<reco::Muon> >(iConfig.getParameter<edm::InputTag>("muon"))),
22  token_originalMVAVals(consumes<MVACollection>(iConfig.getParameter<edm::InputTag>("originalMVAVals"))),
23  flag_copyMVA(iConfig.getParameter<bool>("copyMVA")) {
24  produces<MVACollection>("MVAValues");
25 }
T getParameter(std::string const &) const
const TrackCollectionCloner::Tokens collectionClonerTokens
const edm::EDGetTokenT< 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 ( )
override

Definition at line 27 of file HLTMuonTrackSelector.cc.

27 {}

Member Function Documentation

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

Definition at line 29 of file HLTMuonTrackSelector.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), TrackCollectionCloner::fill(), and HLT_2018_cff::InputTag.

29  {
31  desc.add<edm::InputTag>("track", edm::InputTag());
32  desc.add<edm::InputTag>("muon", edm::InputTag());
33  desc.add<edm::InputTag>("originalMVAVals", edm::InputTag());
34  desc.add<bool>("copyMVA", false);
35  TrackCollectionCloner::fill(desc); // -- add copyExtras and copyTrajectories
36  descriptions.add("HLTMuonTrackSelector", desc);
37 }
static void fill(edm::ParameterSetDescription &desc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HLTMuonTrackSelector::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 39 of file HLTMuonTrackSelector.cc.

References collectionCloner, collectionClonerTokens, DEFINE_FWK_MODULE, PbPb_ZMuSkimMuonDPG_cff::deltaR, flag_copyMVA, edm::Event::getByToken(), eostools::move(), HLT_2018_cff::muon, HLTObjectMonitor_cfi::muonEta, HLTObjectMonitor_cfi::muonPhi, HLTObjectMonitor_cfi::muonPt, packedPFCandidates_cfi::originalTracks, RawToDigi_Repacked_cff::producer, edm::Event::put(), TrackCollectionCloner::Producer::selTracks_, token_muon, token_originalMVAVals, HLT_2018_cff::track, reco::btau::trackEta, reco::btau::trackPhi, listHistos::trackPt, TrackCollectionTokens::tracks(), and mitigatedMETSequence_cff::U.

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

TrackCollectionCloner HLTMuonTrackSelector::collectionCloner
private

Definition at line 45 of file HLTMuonTrackSelector.h.

Referenced by produce().

const TrackCollectionCloner::Tokens HLTMuonTrackSelector::collectionClonerTokens
private

Definition at line 46 of file HLTMuonTrackSelector.h.

Referenced by produce().

const bool HLTMuonTrackSelector::flag_copyMVA
private

Definition at line 50 of file HLTMuonTrackSelector.h.

Referenced by produce().

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

Definition at line 48 of file HLTMuonTrackSelector.h.

Referenced by produce().

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

Definition at line 49 of file HLTMuonTrackSelector.h.

Referenced by produce().