CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
modules::MuonCleanerBySegmentsT< T > Class Template Reference

Removes duplicates from a muon collection using segment references. More...

Inheritance diagram for modules::MuonCleanerBySegmentsT< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool isBetterMuon (const T &mu1, const T &mu2) const
 
template<>
bool isSameMuon (const pat::Muon &mu1, const pat::Muon &mu2) const
 
template<>
bool isSameMuon (const pat::Muon &mu1, const pat::Muon &mu2) const
 
bool isSameMuon (const T &mu1, const T &mu2) const
 
 MuonCleanerBySegmentsT (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~MuonCleanerBySegmentsT () 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 Types

typedef std::pair< const reco::Muon *, const reco::Muon * > MuonPointerPair
 Cut on the pair of objects together. More...
 

Private Attributes

StringCutObjectSelector< MuonPointerPair, true > bestMuonSelector_
 
bool defaultBestMuon_
 Use default criteria to choose the best muon. More...
 
StringCutObjectSelector< Tpassthrough_
 Always-accept cut. More...
 
StringCutObjectSelector< Tpreselection_
 Preselection cut. More...
 
double sharedFraction_
 Fraction of shared segments. More...
 
edm::EDGetTokenT< edm::View< T > > srcToken_
 Tokens for input collections. More...
 

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

template<typename T>
class modules::MuonCleanerBySegmentsT< T >

Removes duplicates from a muon collection using segment references.

      This module removes duplicates from a muon collection using segment references.

      All muons that don't pass the preselection are discarded first

      Then, for each pair of muons that share at least a given fraction of segments,
      the worse one is flagged as ghost.

      Finally, all muons that are not flagged as ghosts, or which pass a 'passthrough' selection,
      are saved in the output.
Author
Giovanni Petrucciani
Version
Id
MuonCleanerBySegments.cc,v 1.1 2012/08/11 13:00:50 gpetrucc Exp

Definition at line 38 of file MuonCleanerBySegments.cc.

Member Typedef Documentation

◆ MuonPointerPair

template<typename T >
typedef std::pair<const reco::Muon *, const reco::Muon *> modules::MuonCleanerBySegmentsT< T >::MuonPointerPair
private

Cut on the pair of objects together.

Definition at line 67 of file MuonCleanerBySegments.cc.

Constructor & Destructor Documentation

◆ MuonCleanerBySegmentsT()

template<typename T >
modules::MuonCleanerBySegmentsT< T >::MuonCleanerBySegmentsT ( const edm::ParameterSet iConfig)
explicit

Definition at line 76 of file MuonCleanerBySegments.cc.

78  preselection_(iConfig.existsAs<std::string>("preselection") ? iConfig.getParameter<std::string>("preselection")
79  : ""),
80  passthrough_(iConfig.existsAs<std::string>("passthrough") ? iConfig.getParameter<std::string>("passthrough")
81  : "0"),
82  sharedFraction_(iConfig.getParameter<double>("fractionOfSharedSegments")),
83  defaultBestMuon_(!iConfig.existsAs<std::string>("customArbitration")),
84  bestMuonSelector_(defaultBestMuon_ ? std::string("") : iConfig.getParameter<std::string>("customArbitration")) {
85  // this is the basic output (edm::Association is not generic)
86  produces<std::vector<T> >();
87 }

◆ ~MuonCleanerBySegmentsT()

template<typename T >
modules::MuonCleanerBySegmentsT< T >::~MuonCleanerBySegmentsT ( )
inlineoverride

Definition at line 41 of file MuonCleanerBySegments.cc.

41 {}

Member Function Documentation

◆ isBetterMuon()

template<typename T >
bool modules::MuonCleanerBySegmentsT< T >::isBetterMuon ( const T mu1,
const T mu2 
) const

Definition at line 136 of file MuonCleanerBySegments.cc.

136  {
137  if (!defaultBestMuon_) {
138  MuonPointerPair pair = {&mu1, &mu2};
139  return bestMuonSelector_(pair);
140  }
141  if (mu2.track().isNull())
142  return true;
143  if (mu1.track().isNull())
144  return false;
145  if (mu1.isPFMuon() != mu2.isPFMuon())
146  return mu1.isPFMuon();
147  if (mu1.isGlobalMuon() != mu2.isGlobalMuon())
148  return mu1.isGlobalMuon();
149  if (mu1.charge() == mu2.charge() && deltaR2(mu1, mu2) < 0.0009) {
150  return mu1.track()->ptError() / mu1.track()->pt() < mu2.track()->ptError() / mu2.track()->pt();
151  } else {
152  int nm1 = mu1.numberOfMatches(reco::Muon::SegmentArbitration);
153  int nm2 = mu2.numberOfMatches(reco::Muon::SegmentArbitration);
154  return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
155  }
156 }

References HLTMuonOfflineAnalyzer_cfi::deltaR2, and reco::Muon::SegmentArbitration.

◆ isSameMuon() [1/3]

template<>
bool modules::MuonCleanerBySegmentsT< pat::Muon >::isSameMuon ( const pat::Muon mu1,
const pat::Muon mu2 
) const

◆ isSameMuon() [2/3]

template<>
bool modules::MuonCleanerBySegmentsT< pat::Muon >::isSameMuon ( const pat::Muon mu1,
const pat::Muon mu2 
) const

Definition at line 159 of file MuonCleanerBySegments.cc.

159  {
160  return (&mu1 == &mu2) || (mu1.originalObjectRef() == mu2.originalObjectRef()) ||
161  (mu1.reco::Muon::innerTrack().isNonnull() ? mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack()
162  : mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
163 }

References pat::PATObject< ObjectType >::originalObjectRef().

◆ isSameMuon() [3/3]

template<typename T >
bool modules::MuonCleanerBySegmentsT< T >::isSameMuon ( const T mu1,
const T mu2 
) const
inline

Definition at line 45 of file MuonCleanerBySegments.cc.

45  {
46  return (&mu1 == &mu2) ||
47  (mu1.reco::Muon::innerTrack().isNonnull() ? mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack()
48  : mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
49  }

◆ produce()

template<typename T >
void modules::MuonCleanerBySegmentsT< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 90 of file MuonCleanerBySegments.cc.

90  {
91  using namespace edm;
92  using namespace std;
93 
95  unique_ptr<vector<T> > out(new vector<T>());
96 
97  iEvent.getByToken(srcToken_, src);
98  unsigned int nsrc = src->size();
99  out->reserve(nsrc);
100  std::vector<int> good(nsrc, true);
101  for (unsigned int i = 0; i < nsrc; ++i) {
102  const T &mu1 = (*src)[i];
103  if (!preselection_(mu1))
104  good[i] = false;
105  if (!good[i])
106  continue;
107  int nSegments1 = mu1.numberOfMatches(reco::Muon::SegmentArbitration);
108  for (unsigned int j = i + 1; j < nsrc; ++j) {
109  const T &mu2 = (*src)[j];
110  if (isSameMuon(mu1, mu2))
111  continue;
112  if (!good[j] || !preselection_(mu2))
113  continue;
114  int nSegments2 = mu2.numberOfMatches(reco::Muon::SegmentArbitration);
115  if (nSegments2 == 0 || nSegments1 == 0)
116  continue;
117  double sf = muon::sharedSegments(mu1, mu2) / std::min<double>(nSegments1, nSegments2);
118  if (sf > sharedFraction_) {
119  if (isBetterMuon(mu1, mu2)) {
120  good[j] = false;
121  } else {
122  good[i] = false;
123  }
124  }
125  }
126  }
127  for (unsigned int i = 0; i < nsrc; ++i) {
128  const T &mu1 = (*src)[i];
129  if (good[i] || passthrough_(mu1))
130  out->push_back(mu1);
131  }
132  iEvent.put(std::move(out));
133 }

References mps_fire::i, iEvent, dqmiolumiharvest::j, eostools::move(), MillePedeFileConverter_cfg::out, reco::Muon::SegmentArbitration, muon::sharedSegments(), and TrackRefitter_38T_cff::src.

Member Data Documentation

◆ bestMuonSelector_

template<typename T >
StringCutObjectSelector<MuonPointerPair, true> modules::MuonCleanerBySegmentsT< T >::bestMuonSelector_
private

Definition at line 68 of file MuonCleanerBySegments.cc.

◆ defaultBestMuon_

template<typename T >
bool modules::MuonCleanerBySegmentsT< T >::defaultBestMuon_
private

Use default criteria to choose the best muon.

Definition at line 65 of file MuonCleanerBySegments.cc.

◆ passthrough_

template<typename T >
StringCutObjectSelector<T> modules::MuonCleanerBySegmentsT< T >::passthrough_
private

Always-accept cut.

Definition at line 59 of file MuonCleanerBySegments.cc.

◆ preselection_

template<typename T >
StringCutObjectSelector<T> modules::MuonCleanerBySegmentsT< T >::preselection_
private

Preselection cut.

Definition at line 57 of file MuonCleanerBySegments.cc.

◆ sharedFraction_

template<typename T >
double modules::MuonCleanerBySegmentsT< T >::sharedFraction_
private

Fraction of shared segments.

Definition at line 62 of file MuonCleanerBySegments.cc.

◆ srcToken_

template<typename T >
edm::EDGetTokenT<edm::View<T> > modules::MuonCleanerBySegmentsT< T >::srcToken_
private

Tokens for input collections.

Definition at line 54 of file MuonCleanerBySegments.cc.

mps_fire.i
i
Definition: mps_fire.py:428
reco::Muon::SegmentArbitration
Definition: Muon.h:189
modules::MuonCleanerBySegmentsT::isBetterMuon
bool isBetterMuon(const T &mu1, const T &mu2) const
Definition: MuonCleanerBySegments.cc:136
edm
HLT enums.
Definition: AlignableModifier.h:19
modules::MuonCleanerBySegmentsT::MuonPointerPair
std::pair< const reco::Muon *, const reco::Muon * > MuonPointerPair
Cut on the pair of objects together.
Definition: MuonCleanerBySegments.cc:67
modules::MuonCleanerBySegmentsT::srcToken_
edm::EDGetTokenT< edm::View< T > > srcToken_
Tokens for input collections.
Definition: MuonCleanerBySegments.cc:54
modules::MuonCleanerBySegmentsT::passthrough_
StringCutObjectSelector< T > passthrough_
Always-accept cut.
Definition: MuonCleanerBySegments.cc:59
modules::MuonCleanerBySegmentsT::isSameMuon
bool isSameMuon(const T &mu1, const T &mu2) const
Definition: MuonCleanerBySegments.cc:45
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
edm::Handle
Definition: AssociativeIterator.h:50
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pat::PATObject::originalObjectRef
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:539
edm::View
Definition: CaloClusterFwd.h:14
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
modules::MuonCleanerBySegmentsT::defaultBestMuon_
bool defaultBestMuon_
Use default criteria to choose the best muon.
Definition: MuonCleanerBySegments.cc:65
iEvent
int iEvent
Definition: GenABIO.cc:224
modules::MuonCleanerBySegmentsT::bestMuonSelector_
StringCutObjectSelector< MuonPointerPair, true > bestMuonSelector_
Definition: MuonCleanerBySegments.cc:68
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
muon::sharedSegments
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
Definition: MuonSelectors.cc:978
modules::MuonCleanerBySegmentsT::sharedFraction_
double sharedFraction_
Fraction of shared segments.
Definition: MuonCleanerBySegments.cc:62
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
T
long double T
Definition: Basic3DVectorLD.h:48
modules::MuonCleanerBySegmentsT::preselection_
StringCutObjectSelector< T > preselection_
Preselection cut.
Definition: MuonCleanerBySegments.cc:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15