CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
pat::MatcherByPulls< T > Class Template Reference

#include <MuonAnalysis/MuonAssociators/src/MatcherByPulls.cc>

Inheritance diagram for pat::MatcherByPulls< T >:
edm::stream::EDProducer<>

Public Member Functions

 MatcherByPulls (const edm::ParameterSet &)
 
 ~MatcherByPulls () override
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

MatcherByPullsAlgorithm algo_
 
edm::EDGetTokenT< std::vector< reco::GenParticle > > matchedToken_
 The MC objects to match against. More...
 
StringCutObjectSelector< reco::GenParticlemcSel_
 Preselection cut on MC objects. More...
 
edm::EDGetTokenT< edm::View< T > > srcToken_
 The RECO objects. More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T>
class pat::MatcherByPulls< T >

Description: Matches RecoCandidates to (Gen)Particles by looking at the pulls fo the track parameters. Produces as output an edm::Association to GenParticles, and a ValueMap with the pull values.

Implementation: uses MatcherByPullsAlgorithm the module is in the pat namespace, but it doesn't have any PAT dependency.

Definition at line 47 of file MatcherByPulls.cc.

Constructor & Destructor Documentation

◆ MatcherByPulls()

template<typename T >
pat::MatcherByPulls< T >::MatcherByPulls ( const edm::ParameterSet iConfig)
explicit

Definition at line 76 of file MatcherByPulls.cc.

77  : srcToken_(consumes<edm::View<T> >(iConfig.getParameter<edm::InputTag>("src"))),
78  matchedToken_(consumes<std::vector<reco::GenParticle> >(iConfig.getParameter<edm::InputTag>("matched"))),
79  mcSel_(iConfig.getParameter<std::string>("matchedSelector")),
80  algo_(iConfig) {
81  produces<edm::Association<std::vector<reco::GenParticle> > >();
82  produces<edm::ValueMap<float> >("pulls");
83 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::View< T > > srcToken_
The RECO objects.
StringCutObjectSelector< reco::GenParticle > mcSel_
Preselection cut on MC objects.
edm::EDGetTokenT< std::vector< reco::GenParticle > > matchedToken_
The MC objects to match against.
MatcherByPullsAlgorithm algo_

◆ ~MatcherByPulls()

template<typename T >
pat::MatcherByPulls< T >::~MatcherByPulls ( )
override

Definition at line 86 of file MatcherByPulls.cc.

86 {}

Member Function Documentation

◆ produce()

template<typename T >
void pat::MatcherByPulls< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 97 of file MatcherByPulls.cc.

References HLT_2024v12_cff::cands, edm::helper::Filler< Map >::fill(), mps_fire::i, iEvent, edm::helper::Filler< Map >::insert(), visualization-live-secondInstance_cfg::m, oniaPATMuonsWithTrigger_cff::matches, eostools::move(), dqmiodumpmetadata::n, TrackRefitter_38T_cff::src, and HcalDetIdTransform::transform().

97  {
98  typedef std::vector<reco::GenParticle> MCColl;
101  iEvent.getByToken(srcToken_, src);
102  iEvent.getByToken(matchedToken_, cands);
103 
104  std::vector<uint8_t> candGood(cands->size(), 1);
105  std::transform(cands->begin(), cands->end(), candGood.begin(), mcSel_);
106 
107  std::vector<int> matches(src->size(), -1);
108  std::vector<float> pulls(src->size(), 1e39);
109  for (size_t i = 0, n = src->size(); i < n; ++i) {
110  const T& tk = (*src)[i];
111  std::pair<int, float> m = algo_.match(tk, *cands, candGood);
112  matches[i] = m.first;
113  pulls[i] = m.second;
114  }
115 
116  typedef edm::Association<MCColl> MCAsso;
117  std::unique_ptr<MCAsso> matchesMap(new MCAsso(edm::RefProd<MCColl>(cands)));
118  MCAsso::Filler matchesFiller(*matchesMap);
119  matchesFiller.insert(src, matches.begin(), matches.end());
120  matchesFiller.fill();
121  iEvent.put(std::move(matchesMap));
122 
123  std::unique_ptr<edm::ValueMap<float> > pullsMap(new edm::ValueMap<float>());
124  edm::ValueMap<float>::Filler pullsFiller(*pullsMap);
125  pullsFiller.insert(src, pulls.begin(), pulls.end());
126  pullsFiller.fill();
127  iEvent.put(std::move(pullsMap), "pulls");
128 }
edm::EDGetTokenT< edm::View< T > > srcToken_
The RECO objects.
StringCutObjectSelector< reco::GenParticle > mcSel_
Preselection cut on MC objects.
int iEvent
Definition: GenABIO.cc:224
std::pair< bool, float > match(const reco::Track &tk, const reco::Candidate &mc, const AlgebraicSymMatrix55 &invertedCovariance) const
edm::EDGetTokenT< std::vector< reco::GenParticle > > matchedToken_
The MC objects to match against.
MatcherByPullsAlgorithm algo_
long double T
def move(src, dest)
Definition: eostools.py:511
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

◆ algo_

template<typename T >
MatcherByPullsAlgorithm pat::MatcherByPulls< T >::algo_
private

Definition at line 64 of file MatcherByPulls.cc.

◆ matchedToken_

template<typename T >
edm::EDGetTokenT<std::vector<reco::GenParticle> > pat::MatcherByPulls< T >::matchedToken_
private

The MC objects to match against.

Definition at line 59 of file MatcherByPulls.cc.

◆ mcSel_

template<typename T >
StringCutObjectSelector<reco::GenParticle> pat::MatcherByPulls< T >::mcSel_
private

Preselection cut on MC objects.

Definition at line 62 of file MatcherByPulls.cc.

◆ srcToken_

template<typename T >
edm::EDGetTokenT<edm::View<T> > pat::MatcherByPulls< T >::srcToken_
private

The RECO objects.

Definition at line 56 of file MatcherByPulls.cc.