CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
pat::MatcherUsingTracks Class Reference

Matcher of reconstructed objects to other reconstructed objects using the tracks inside them. More...

Inheritance diagram for pat::MatcherUsingTracks:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MatcherUsingTracks (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~MatcherUsingTracks () 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
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

Private Member Functions

template<typename T >
void storeValueMap (edm::Event &iEvent, const edm::Handle< edm::View< reco::Candidate > > &handle, const std::vector< T > &values, const std::string &label) const
 Store extra information in a ValueMap. More...
 

Private Attributes

MatcherUsingTracksAlgorithm algo_
 The real workhorse. More...
 
bool dontFailOnMissingInput_
 Some extra configurables. More...
 
edm::EDGetTokenT< edm::View< reco::Candidate > > matchedToken_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
 Labels for input collections. More...
 
bool writeExtraPATOutput_
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Matcher of reconstructed objects to other reconstructed objects using the tracks inside them.

Author
Giovanni Petrucciani
Version
Id
MatcherUsingTracks.cc,v 1.5 2010/07/12 20:56:11 gpetrucc Exp

Definition at line 32 of file MatcherUsingTracks.cc.

Constructor & Destructor Documentation

◆ MatcherUsingTracks()

pat::MatcherUsingTracks::MatcherUsingTracks ( const edm::ParameterSet iConfig)
explicit

Definition at line 61 of file MatcherUsingTracks.cc.

64  algo_(iConfig),
65  dontFailOnMissingInput_(iConfig.existsAs<bool>("dontFailOnMissingInput")
66  ? iConfig.getParameter<bool>("dontFailOnMissingInput")
67  : false),
69  iConfig.existsAs<bool>("writeExtraPATOutput") ? iConfig.getParameter<bool>("writeExtraPATOutput") : false) {
70  // this is the basic output (edm::Association is not generic)
71  produces<edm::ValueMap<reco::CandidatePtr> >();
73  // this is the crazy stuff to get the same with UserData
74  produces<edm::OwnVector<pat::UserData> >();
75  produces<edm::ValueMap<edm::Ptr<pat::UserData> > >();
76  }
77  // this is the extra stuff
78  if (algo_.hasMetrics()) {
79  produces<edm::ValueMap<float> >("deltaR");
80  produces<edm::ValueMap<float> >("deltaEta");
81  produces<edm::ValueMap<float> >("deltaPhi");
82  produces<edm::ValueMap<float> >("deltaLocalPos");
83  produces<edm::ValueMap<float> >("deltaPtRel");
84  if (algo_.hasChi2()) {
85  produces<edm::ValueMap<float> >("chi2");
86  }
87  } else {
88  produces<edm::ValueMap<int> >("matched");
89  }
90 }

References algo_, and writeExtraPATOutput_.

◆ ~MatcherUsingTracks()

pat::MatcherUsingTracks::~MatcherUsingTracks ( )
inlineoverride

Definition at line 35 of file MatcherUsingTracks.cc.

35 {}

Member Function Documentation

◆ produce()

void pat::MatcherUsingTracks::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 92 of file MatcherUsingTracks.cc.

92  {
93  using namespace edm;
94  using namespace std;
95 
96  algo_.init(iSetup);
97 
99 
100  iEvent.getByToken(srcToken_, src);
101  iEvent.getByToken(matchedToken_, matched);
102 
103  // declare loop variables and some intermediate stuff
105  int isrc, nsrc = src->size();
106 
107  // working and output variables
108  vector<int> match(nsrc, -1);
109  vector<float> deltaRs(nsrc, 999);
110  vector<float> deltaEtas(nsrc, 999);
111  vector<float> deltaPhis(nsrc, 999);
112  vector<float> deltaPtRel(nsrc, 999);
113  vector<float> deltaLocalPos(nsrc, 999);
114  vector<float> chi2(nsrc, 999999);
115 
116  // don't try matching if the input collection is missing and the module is configured to fail silently
117  if (!(matched.failedToGet() && dontFailOnMissingInput_)) {
118  // loop on the source collection, and request for the match
119  for (itsrc = src->begin(), edsrc = src->end(), isrc = 0; itsrc != edsrc; ++itsrc, ++isrc) {
120  match[isrc] = algo_.match(*itsrc,
121  *matched,
122  deltaRs[isrc],
123  deltaEtas[isrc],
124  deltaPhis[isrc],
125  deltaLocalPos[isrc],
126  deltaPtRel[isrc],
127  chi2[isrc]);
128  }
129  }
130 
131  std::vector<reco::CandidatePtr> ptrs(nsrc);
132  for (isrc = 0; isrc < nsrc; ++isrc) {
133  if (match[isrc] != -1) {
134  ptrs[isrc] = matched->ptrAt(match[isrc]);
135  }
136  }
137  storeValueMap<reco::CandidatePtr>(iEvent, src, ptrs, "");
138 
139  if (writeExtraPATOutput_) {
140  auto outUDVect = std::make_unique<edm::OwnVector<pat::UserData> >();
141  std::vector<int> idxUD(nsrc, -1);
142  for (isrc = 0; isrc < nsrc; ++isrc) {
143  if (match[isrc] != -1) {
144  outUDVect->push_back(pat::UserData::make(ptrs[isrc]));
145  idxUD[isrc] = outUDVect->size() - 1;
146  }
147  }
149  std::vector<edm::Ptr<pat::UserData> > ptrUD(nsrc);
150  for (isrc = 0; isrc < nsrc; ++isrc) {
151  if (idxUD[isrc] != -1)
152  ptrUD[isrc] = edm::Ptr<pat::UserData>(doneUDVect, idxUD[isrc]);
153  }
154  storeValueMap<edm::Ptr<pat::UserData> >(iEvent, src, ptrUD, "");
155  }
156 
157  if (algo_.hasMetrics()) {
158  storeValueMap<float>(iEvent, src, deltaRs, "deltaR");
159  storeValueMap<float>(iEvent, src, deltaEtas, "deltaEta");
160  storeValueMap<float>(iEvent, src, deltaPhis, "deltaPhi");
161  storeValueMap<float>(iEvent, src, deltaLocalPos, "deltaLocalPos");
162  storeValueMap<float>(iEvent, src, deltaPtRel, "deltaPtRel");
163  if (algo_.hasChi2()) {
164  storeValueMap<float>(iEvent, src, chi2, "chi2");
165  }
166  } else {
167  std::vector<int> ismatched(nsrc, 0);
168  for (isrc = 0; isrc < nsrc; ++isrc) {
169  ismatched[isrc] = (match[isrc] != -1);
170  }
171  storeValueMap<int>(iEvent, src, ismatched, "matched");
172  }
173 }

References hltPixelTracks_cff::chi2, iEvent, pat::UserData::make(), match(), muonTagProbeFilters_cff::matched, eostools::move(), and TrackRefitter_38T_cff::src.

◆ storeValueMap()

template<typename T >
void pat::MatcherUsingTracks::storeValueMap ( edm::Event iEvent,
const edm::Handle< edm::View< reco::Candidate > > &  handle,
const std::vector< T > &  values,
const std::string &  label 
) const
private

Store extra information in a ValueMap.

Definition at line 176 of file MatcherUsingTracks.cc.

179  {
180  using namespace edm;
181  using namespace std;
182  unique_ptr<ValueMap<T> > valMap(new ValueMap<T>());
183  typename edm::ValueMap<T>::Filler filler(*valMap);
184  filler.insert(handle, values.begin(), values.end());
185  filler.fill();
186  iEvent.put(std::move(valMap), label);
187 }

References trigObjTnPSource_cfi::filler, patZpeak::handle, iEvent, label, eostools::move(), and contentValuesCheck::values.

Member Data Documentation

◆ algo_

MatcherUsingTracksAlgorithm pat::MatcherUsingTracks::algo_
private

The real workhorse.

Definition at line 45 of file MatcherUsingTracks.cc.

Referenced by MatcherUsingTracks().

◆ dontFailOnMissingInput_

bool pat::MatcherUsingTracks::dontFailOnMissingInput_
private

Some extra configurables.

Definition at line 48 of file MatcherUsingTracks.cc.

◆ matchedToken_

edm::EDGetTokenT<edm::View<reco::Candidate> > pat::MatcherUsingTracks::matchedToken_
private

Definition at line 42 of file MatcherUsingTracks.cc.

◆ srcToken_

edm::EDGetTokenT<edm::View<reco::Candidate> > pat::MatcherUsingTracks::srcToken_
private

Labels for input collections.

Definition at line 41 of file MatcherUsingTracks.cc.

◆ writeExtraPATOutput_

bool pat::MatcherUsingTracks::writeExtraPATOutput_
private

Definition at line 49 of file MatcherUsingTracks.cc.

Referenced by MatcherUsingTracks().

muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
pat::MatcherUsingTracks::dontFailOnMissingInput_
bool dontFailOnMissingInput_
Some extra configurables.
Definition: MatcherUsingTracks.cc:48
patZpeak.handle
handle
Definition: patZpeak.py:23
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::MatcherUsingTracks::srcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
Labels for input collections.
Definition: MatcherUsingTracks.cc:41
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
edm::Handle
Definition: AssociativeIterator.h:50
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
pat::MatcherUsingTracks::algo_
MatcherUsingTracksAlgorithm algo_
The real workhorse.
Definition: MatcherUsingTracks.cc:45
edm::View
Definition: CaloClusterFwd.h:14
pat::MatcherUsingTracks::writeExtraPATOutput_
bool writeExtraPATOutput_
Definition: MatcherUsingTracks.cc:49
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::Ptr
Definition: AssociationVector.h:31
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
pat::UserData::make
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
edm::ValueMap
Definition: ValueMap.h:107
pat::MatcherUsingTracks::matchedToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > matchedToken_
Definition: MatcherUsingTracks.cc:42
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::helper::Filler
Definition: ValueMap.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11