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::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

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

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::StreamID, edm::Event &, const edm::EventSetup &) const 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::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 S, typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
class reco::modulesNew::Matcher< C1, C2, S, D >

Definition at line 23 of file NewMatcher.h.

Member Typedef Documentation

◆ MatchMap

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.

◆ T1

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.

◆ T2

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

◆ Matcher()

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

Definition at line 51 of file NewMatcher.h.

52  : srcToken_(consumes<C1>(cfg.template getParameter<edm::InputTag>("src"))),
53  matchedToken_(consumes<C2>(cfg.template getParameter<edm::InputTag>("matched"))),
54  distMin_(cfg.template getParameter<double>("distMin")),
55  select_(reco::modules::make<S>(cfg)),
56  distance_(reco::modules::make<D>(cfg)) {
57  produces<MatchMap>();
58  }
edm::EDGetTokenT< C1 > srcToken_
Definition: NewMatcher.h:33
edm::EDGetTokenT< C2 > matchedToken_
Definition: NewMatcher.h:34

◆ ~Matcher()

template<typename C1 , typename C2 , typename S , typename D >
reco::modulesNew::Matcher< C1, C2, S, D >::~Matcher ( )
override

Definition at line 61 of file NewMatcher.h.

61 {}

Member Function Documentation

◆ matchDistance()

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

◆ produce()

template<typename C1 , typename C2 , typename S , typename D >
void reco::modulesNew::Matcher< C1, C2, S, D >::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup  
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 64 of file NewMatcher.h.

References cms::cuda::assert(), HltBtagPostValidation_cff::c, HLT_2024v14_cff::cands, trigObjTnPSource_cfi::filler, dqmdumpme::first, edm::Event::getByToken(), heavyIonCSV_trainingSettings::idx, dqmdumpme::indices, visualization-live-secondInstance_cfg::m, volumeBasedMagneticField_160812_cfi::master, muonTagProbeFilters_cff::matched, eostools::move(), edm::Event::put(), singleTopDQM_cfi::select, and findQualityFiles::v.

64  {
65  using namespace edm;
66  using namespace std;
71  unique_ptr<MatchMap> matchMap(new MatchMap(matched));
72  size_t size = cands->size();
73  if (size != 0) {
74  typename MatchMap::Filler filler(*matchMap);
75  ::helper::MasterCollection<C1> master(cands, evt);
76  std::vector<int> indices(master.size(), -1);
77  for (size_t c = 0; c != size; ++c) {
78  const T1& cand = (*cands)[c];
79  vector<helper::MatchPair> v;
80  for (size_t m = 0; m != matched->size(); ++m) {
81  const T2& match = (*matched)[m];
82  if (select(cand, match)) {
83  double dist = matchDistance(cand, match);
84  if (dist < distMin_)
85  v.push_back(make_pair(m, dist));
86  }
87  }
88  if (!v.empty()) {
89  size_t idx = master.index(c);
90  assert(idx < indices.size());
91  indices[idx] = min_element(v.begin(), v.end(), helper::SortBySecond())->first;
92  }
93  }
94  filler.insert(master.get(), indices.begin(), indices.end());
95  filler.fill();
96  }
97  evt.put(std::move(matchMap));
98  }
size
Write out results.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< C1 > srcToken_
Definition: NewMatcher.h:33
edm::Association< C2 > MatchMap
Definition: NewMatcher.h:31
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
edm::EDGetTokenT< C2 > matchedToken_
Definition: NewMatcher.h:34
assert(be >=bs)
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:162
double matchDistance(const T1 &c1, const T2 &c2) const
Definition: NewMatcher.h:36
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
bool select(const T1 &c1, const T2 &c2) const
Definition: NewMatcher.h:37
def move(src, dest)
Definition: eostools.py:511

◆ select()

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

◆ distance_

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

◆ distMin_

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.

◆ matchedToken_

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.

◆ select_

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 38 of file NewMatcher.h.

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

◆ srcToken_

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.