CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Private Member Functions | Private Attributes
reco::modules::MatcherBase< C1, C2, M > Class Template Referenceabstract

#include <Matcher.h>

Inheritance diagram for reco::modules::MatcherBase< C1, C2, M >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper reco::modules::Matcher< C1, C2, S, D, M >

Public Member Functions

 MatcherBase (const edm::ParameterSet &)
 
 ~MatcherBase () 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
 
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)
 

Protected Types

typedef M MatchMap
 
typedef C1::value_type T1
 
typedef C2::value_type T2
 

Private Member Functions

virtual double matchDistance (const T1 &, const T2 &) const =0
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
virtual bool select (const T1 &, const T2 &) const =0
 

Private Attributes

double distMin_
 
edm::EDGetTokenT< C2 > matchedToken_
 
edm::EDGetTokenT< C1 > srcToken_
 

Additional Inherited Members

- 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
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
class reco::modules::MatcherBase< C1, C2, M >

Definition at line 21 of file Matcher.h.

Member Typedef Documentation

◆ MatchMap

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
typedef M reco::modules::MatcherBase< C1, C2, M >::MatchMap
protected

Definition at line 29 of file Matcher.h.

◆ T1

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
typedef C1::value_type reco::modules::MatcherBase< C1, C2, M >::T1
protected

Definition at line 27 of file Matcher.h.

◆ T2

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
typedef C2::value_type reco::modules::MatcherBase< C1, C2, M >::T2
protected

Definition at line 28 of file Matcher.h.

Constructor & Destructor Documentation

◆ MatcherBase()

template<typename C1 , typename C2 , typename M >
reco::modules::MatcherBase< C1, C2, M >::MatcherBase ( const edm::ParameterSet cfg)

Definition at line 71 of file Matcher.h.

72  : srcToken_(consumes<C1>(cfg.template getParameter<edm::InputTag>("src"))),
73  matchedToken_(consumes<C2>(cfg.template getParameter<edm::InputTag>("matched"))),
74  distMin_(cfg.template getParameter<double>("distMin")) {
75  produces<MatchMap>();
76  }
edm::EDGetTokenT< C1 > srcToken_
Definition: Matcher.h:33
edm::EDGetTokenT< C2 > matchedToken_
Definition: Matcher.h:34

◆ ~MatcherBase()

template<typename C1 , typename C2 , typename M >
reco::modules::MatcherBase< C1, C2, M >::~MatcherBase ( )
override

Definition at line 79 of file Matcher.h.

79 {}

Member Function Documentation

◆ matchDistance()

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
virtual double reco::modules::MatcherBase< C1, C2, M >::matchDistance ( const T1 ,
const T2  
) const
privatepure virtual

◆ produce()

template<typename C1 , typename C2 , typename M >
void reco::modules::MatcherBase< C1, C2, M >::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup  
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 82 of file Matcher.h.

References HltBtagPostValidation_cff::c, HLT_2023v12_cff::cands, dqmdumpme::first, edm::Event::getByToken(), edm::getRef(), visualization-live-secondInstance_cfg::m, muonTagProbeFilters_cff::matched, eostools::move(), edm::Event::put(), singleTopDQM_cfi::select, and findQualityFiles::v.

82  {
83  using namespace edm;
84  using namespace std;
89  typedef typename MatchMap::ref_type ref_type;
90  typedef typename ref_type::key_type key_ref_type;
91  typedef typename ref_type::value_type value_ref_type;
92  unique_ptr<MatchMap> matchMap(new MatchMap(ref_type(key_ref_type(cands), value_ref_type(matched))));
93  for (size_t c = 0; c != cands->size(); ++c) {
94  const T1& cand = (*cands)[c];
95  vector<helper::MatchPair> v;
96  for (size_t m = 0; m != matched->size(); ++m) {
97  const T2& match = (*matched)[m];
98  if (select(cand, match)) {
99  double dist = matchDistance(cand, match);
100  if (dist < distMin_)
101  v.push_back(make_pair(m, dist));
102  }
103  }
104  if (!v.empty()) {
105  size_t mMin = min_element(v.begin(), v.end(), helper::SortBySecond())->first;
106  typedef typename MatchMap::key_type key_type;
107  typedef typename MatchMap::data_type data_type;
108  matchMap->insert(edm::getRef(cands, c), edm::getRef(matched, mMin));
109  }
110  }
111  evt.put(std::move(matchMap));
112  }
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
virtual bool select(const T1 &, const T2 &) const =0
::ecal::reco::ComputationScalarType data_type
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
edm::EDGetTokenT< C1 > srcToken_
Definition: Matcher.h:33
virtual double matchDistance(const T1 &, const T2 &) const =0
C1::value_type T1
Definition: Matcher.h:27
C2::value_type T2
Definition: Matcher.h:28
edm::EDGetTokenT< C2 > matchedToken_
Definition: Matcher.h:34
HLT enums.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
def move(src, dest)
Definition: eostools.py:511

◆ select()

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
virtual bool reco::modules::MatcherBase< C1, C2, M >::select ( const T1 ,
const T2  
) const
privatepure virtual

Member Data Documentation

◆ distMin_

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
double reco::modules::MatcherBase< C1, C2, M >::distMin_
private

Definition at line 35 of file Matcher.h.

◆ matchedToken_

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
edm::EDGetTokenT<C2> reco::modules::MatcherBase< C1, C2, M >::matchedToken_
private

Definition at line 34 of file Matcher.h.

◆ srcToken_

template<typename C1, typename C2, typename M = edm::AssociationMap<edm::OneToOne<C1, C2> >>
edm::EDGetTokenT<C1> reco::modules::MatcherBase< C1, C2, M >::srcToken_
private

Definition at line 33 of file Matcher.h.