CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
reco::modulesNew::Matcher< C1, C2, S, D > Class Template Reference

#include <NewMatcher.h>

Inheritance diagram for reco::modulesNew::Matcher< C1, C2, S, D >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper reco::modulesNew::CandMatcher< S, C1, C2, D >

Public Member Functions

 Matcher (const edm::ParameterSet &cfg)
 
 ~Matcher ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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)
 

Private Types

typedef edm::Association< C2 > MatchMap
 
typedef C1::value_type T1
 
typedef C2::value_type T2
 

Private Member Functions

double matchDistance (const T1 &c1, const T2 &c2) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 
bool select (const T1 &c1, const T2 &c2) const
 

Private Attributes

distance_
 
double distMin_
 
edm::EDGetTokenT< C2 > matchedToken_
 
S select_
 
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)
 
- 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 S, typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
class reco::modulesNew::Matcher< C1, C2, S, D >

Definition at line 24 of file NewMatcher.h.

Member Typedef Documentation

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
typedef edm::Association<C2> reco::modulesNew::Matcher< C1, C2, S, D >::MatchMap
private

Definition at line 31 of file NewMatcher.h.

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
typedef C1::value_type reco::modulesNew::Matcher< C1, C2, S, D >::T1
private

Definition at line 29 of file NewMatcher.h.

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
typedef C2::value_type reco::modulesNew::Matcher< C1, C2, S, D >::T2
private

Definition at line 30 of file NewMatcher.h.

Constructor & Destructor Documentation

template<typename C1 , typename C2 , typename S , typename D >
reco::modulesNew::Matcher< C1, C2, S, D >::Matcher ( const edm::ParameterSet cfg)

Definition at line 57 of file NewMatcher.h.

57  :
58  srcToken_(consumes<C1>(cfg.template getParameter<edm::InputTag>("src"))),
59  matchedToken_(consumes<C2>(cfg.template getParameter<edm::InputTag>("matched"))),
60  distMin_(cfg.template getParameter<double>("distMin")),
61  select_(reco::modules::make<S>(cfg)),
62  distance_(reco::modules::make<D>(cfg)) {
63  produces<MatchMap>();
64  }
edm::EDGetTokenT< C1 > srcToken_
Definition: NewMatcher.h:33
edm::EDGetTokenT< C2 > matchedToken_
Definition: NewMatcher.h:34
template<typename C1 , typename C2 , typename S , typename D >
reco::modulesNew::Matcher< C1, C2, S, D >::~Matcher ( )

Definition at line 67 of file NewMatcher.h.

67 { }

Member Function Documentation

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
double reco::modulesNew::Matcher< C1, C2, S, D >::matchDistance ( const T1 c1,
const T2 c2 
) const
inlineprivate
template<typename C1 , typename C2 , typename S , typename D >
void reco::modulesNew::Matcher< C1, C2, S, D >::produce ( edm::Event evt,
const edm::EventSetup  
)
overrideprivate

Definition at line 70 of file NewMatcher.h.

References EnergyCorrector::c, reco::modulesNew::Matcher< C1, C2, S, D >::distMin_, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, plotBeamSpotDB::first, helper::MasterCollection< C1 >::get(), edm::Event::getByToken(), training_settings::idx, helper::MasterCollection< C1 >::index(), edm::helper::Filler< Map >::insert(), funct::m, funct::master(), match(), reco::modulesNew::Matcher< C1, C2, S, D >::matchDistance(), electrons_cff::matched, reco::modulesNew::Matcher< C1, C2, S, D >::matchedToken_, eostools::move(), edm::Event::put(), reco::modulesNew::Matcher< C1, C2, S, D >::select(), helper::MasterCollection< C1 >::size(), findQualityFiles::size, reco::modulesNew::Matcher< C1, C2, S, D >::srcToken_, and findQualityFiles::v.

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

70  {
71  using namespace edm;
72  using namespace std;
74  evt.getByToken(matchedToken_, matched);
75  Handle<C1> cands;
76  evt.getByToken(srcToken_, cands);
77  unique_ptr<MatchMap> matchMap(new MatchMap(matched));
78  size_t size = cands->size();
79  if( size != 0 ) {
80  typename MatchMap::Filler filler(*matchMap);
82  std::vector<int> indices(master.size(), -1);
83  for(size_t c = 0; c != size; ++ c) {
84  const T1 & cand = (*cands)[c];
85  vector<helper::MatchPair> v;
86  for(size_t m = 0; m != matched->size(); ++m) {
87  const T2 & match = (* matched)[m];
88  if (select(cand, match)) {
89  double dist = matchDistance(cand, match);
90  if (dist < distMin_) v.push_back(make_pair(m, dist));
91  }
92  }
93  if(v.size() > 0) {
94  size_t idx = master.index(c);
95  assert(idx < indices.size());
96  indices[idx] = min_element(v.begin(), v.end(), helper::SortBySecond())->first;
97  }
98  }
99  filler.insert(master.get(), indices.begin(), indices.end());
100  filler.fill();
101  }
102  evt.put(std::move(matchMap));
103  }
size
Write out results.
Master< F > master(const F &f)
Definition: FunctClone.h:68
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
edm::EDGetTokenT< C1 > srcToken_
Definition: NewMatcher.h:33
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
edm::Association< C2 > MatchMap
Definition: NewMatcher.h:31
edm::EDGetTokenT< C2 > matchedToken_
Definition: NewMatcher.h:34
bool select(const T1 &c1, const T2 &c2) const
Definition: NewMatcher.h:39
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:169
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
double matchDistance(const T1 &c1, const T2 &c2) const
Definition: NewMatcher.h:36
def move(src, dest)
Definition: eostools.py:510
template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
bool reco::modulesNew::Matcher< C1, C2, S, D >::select ( const T1 c1,
const T2 c2 
) const
inlineprivate

Member Data Documentation

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
D reco::modulesNew::Matcher< C1, C2, S, D >::distance_
private
template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
double reco::modulesNew::Matcher< C1, C2, S, D >::distMin_
private

Definition at line 35 of file NewMatcher.h.

Referenced by reco::modulesNew::Matcher< C1, C2, S, D >::produce().

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
edm::EDGetTokenT<C2> reco::modulesNew::Matcher< C1, C2, S, D >::matchedToken_
private

Definition at line 34 of file NewMatcher.h.

Referenced by reco::modulesNew::Matcher< C1, C2, S, D >::produce().

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
S reco::modulesNew::Matcher< C1, C2, S, D >::select_
private

Definition at line 42 of file NewMatcher.h.

Referenced by reco::modulesNew::Matcher< C1, C2, S, D >::select().

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
edm::EDGetTokenT<C1> reco::modulesNew::Matcher< C1, C2, S, D >::srcToken_
private

Definition at line 33 of file NewMatcher.h.

Referenced by reco::modulesNew::Matcher< C1, C2, S, D >::produce().