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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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::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.

18  :
19 collectionCloner ( *this, 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 {
25  produces<MVACollection>("MVAValues");
26 }
T getParameter(std::string const &) const
const TrackCollectionCloner::Tokens collectionClonerTokens
const edm::EDGetTokenT< MVACollection > token_originalMVAVals
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::EDGetTokenT< vector< reco::Muon > > token_muon
TrackCollectionCloner collectionCloner
HLTMuonTrackSelector::~HLTMuonTrackSelector ( )
override

Definition at line 28 of file HLTMuonTrackSelector.cc.

28 { }

Member Function Documentation

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

Definition at line 30 of file HLTMuonTrackSelector.cc.

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

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

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

41  {
43 
44  // -- load tracks
45  auto const & originalTracks = collectionClonerTokens.tracks(iEvent);
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 
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 ) 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< MVACollection > token_originalMVAVals
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
reco::TrackCollection const & tracks(edm::Event &evt) const
const edm::EDGetTokenT< vector< reco::Muon > > token_muon
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().