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::EDProducer 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::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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)
 

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::Event &, const edm::EventSetup &) 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::EDProducer
typedef EDProducer 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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

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

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.

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.

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

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
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

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
template<typename C1 , typename C2 , typename M >
void reco::modules::MatcherBase< C1, C2, M >::produce ( edm::Event evt,
const edm::EventSetup  
)
overrideprivate

Definition at line 82 of file Matcher.h.

References HltBtagPostValidation_cff::c, HLT_2018_cff::cands, reco::modules::MatcherBase< C1, C2, M >::distMin_, dqmdumpme::first, edm::Event::getByToken(), edm::getRef(), visualization-live-secondInstance_cfg::m, match(), reco::modules::MatcherBase< C1, C2, M >::matchDistance(), muonTagProbeFilters_cff::matched, reco::modules::MatcherBase< C1, C2, M >::matchedToken_, eostools::move(), edm::Event::put(), reco::modules::MatcherBase< C1, C2, M >::select(), reco::modules::MatcherBase< C1, C2, M >::srcToken_, and findQualityFiles::v.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

82  {
83  using namespace edm;
84  using namespace std;
86  evt.getByToken(matchedToken_, matched);
88  evt.getByToken(srcToken_, cands);
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
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
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
virtual bool select(const T1 &, const T2 &) const =0
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

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.

Referenced by reco::modules::MatcherBase< C1, C2, M >::produce().

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.

Referenced by reco::modules::MatcherBase< C1, C2, M >::produce().

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.

Referenced by reco::modules::MatcherBase< C1, C2, M >::produce().