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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
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)
 
- 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 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 76 of file Matcher.h.

76  :
77  srcToken_( consumes<C1>( cfg.template getParameter<edm::InputTag>( "src" ) ) ),
78  matchedToken_( consumes<C2>( cfg.template getParameter<edm::InputTag>( "matched" ) ) ),
79  distMin_( cfg.template getParameter<double>( "distMin" ) ) {
80  produces<MatchMap>();
81  }
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 ( )

Definition at line 84 of file Matcher.h.

84 { }

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 87 of file Matcher.h.

References EnergyCorrector::c, reco::modules::MatcherBase< C1, C2, M >::distMin_, plotBeamSpotDB::first, edm::Event::getByToken(), edm::getRef(), funct::m, match(), reco::modules::MatcherBase< C1, C2, M >::matchDistance(), electronMatch_cfi::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().

87  {
88  using namespace edm;
89  using namespace std;
91  evt.getByToken( matchedToken_, matched );
92  Handle<C1> cands;
93  evt.getByToken( srcToken_, cands );
94  typedef typename MatchMap::ref_type ref_type;
95  typedef typename ref_type::key_type key_ref_type;
96  typedef typename ref_type::value_type value_ref_type;
97  unique_ptr<MatchMap> matchMap( new MatchMap( ref_type( key_ref_type( cands ),
98  value_ref_type( matched ) ) ) );
99  for( size_t c = 0; c != cands->size(); ++ c ) {
100  const T1 & cand = (*cands)[ c ];
101  vector<helper::MatchPair> v;
102  for( size_t m = 0; m != matched->size(); ++ m ) {
103  const T2 & match = ( * matched )[ m ];
104  if ( select( cand, match ) ) {
105  double dist = matchDistance( cand, match );
106  if ( dist < distMin_ ) v.push_back( make_pair( m, dist ) );
107  }
108  }
109  if ( v.size() > 0 ) {
110  size_t mMin = min_element( v.begin(), v.end(), helper::SortBySecond() )->first;
111  typedef typename MatchMap::key_type key_type;
112  typedef typename MatchMap::data_type data_type;
113  matchMap->insert( edm::getRef( cands, c ), edm::getRef( matched, mMin ) );
114  }
115  }
116  evt.put(std::move(matchMap));
117  }
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:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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:510
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().