CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
bool isSameMuon (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
 
 MuonCleanerBySegmentsT (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~MuonCleanerBySegmentsT ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::InputTag src_
 Labels for input collections. More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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.2 2013/02/27 20:42:45 wmtan Exp

Definition at line 41 of file MuonCleanerBySegments.cc.

Member Typedef Documentation

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 70 of file MuonCleanerBySegments.cc.

Constructor & Destructor Documentation

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

Definition at line 80 of file MuonCleanerBySegments.cc.

80  :
81  src_(iConfig.getParameter<edm::InputTag>("src")),
82  preselection_(iConfig.existsAs<std::string>("preselection") ? iConfig.getParameter<std::string>("preselection") : ""),
83  passthrough_(iConfig.existsAs<std::string>("passthrough") ? iConfig.getParameter<std::string>("passthrough") : "0"),
84  sharedFraction_(iConfig.getParameter<double>("fractionOfSharedSegments")),
85  defaultBestMuon_(!iConfig.existsAs<std::string>("customArbitration")),
86  bestMuonSelector_(defaultBestMuon_ ? std::string("") : iConfig.getParameter<std::string>("customArbitration"))
87 {
88  // this is the basic output (edm::Association is not generic)
89  produces<std::vector<T> >();
90 }
T getParameter(std::string const &) const
double sharedFraction_
Fraction of shared segments.
StringCutObjectSelector< T > preselection_
Preselection cut.
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
StringCutObjectSelector< T > passthrough_
Always-accept cut.
edm::InputTag src_
Labels for input collections.
StringCutObjectSelector< MuonPointerPair, true > bestMuonSelector_
bool defaultBestMuon_
Use default criteria to choose the best muon.
template<typename T >
virtual modules::MuonCleanerBySegmentsT< T >::~MuonCleanerBySegmentsT ( )
inlinevirtual

Definition at line 44 of file MuonCleanerBySegments.cc.

44 { }

Member Function Documentation

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

Definition at line 135 of file MuonCleanerBySegments.cc.

References Geom::deltaR2(), and reco::Muon::SegmentArbitration.

135  {
136  if (!defaultBestMuon_) {
137  MuonPointerPair pair = { &mu1, &mu2 };
138  return bestMuonSelector_(pair);
139  }
140  if (mu2.track().isNull()) return true;
141  if (mu1.track().isNull()) return false;
142  if (mu1.isPFMuon() != mu2.isPFMuon()) return mu1.isPFMuon();
143  if (mu1.isGlobalMuon() != mu2.isGlobalMuon()) return mu1.isGlobalMuon();
144  if (mu1.charge() == mu2.charge() && deltaR2(mu1,mu2) < 0.0009) {
145  return mu1.track()->ptError()/mu1.track()->pt() < mu2.track()->ptError()/mu2.track()->pt();
146  } else {
147  int nm1 = mu1.numberOfMatches(reco::Muon::SegmentArbitration);
148  int nm2 = mu2.numberOfMatches(reco::Muon::SegmentArbitration);
149  return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
150  }
151 }
std::pair< const reco::Muon *, const reco::Muon * > MuonPointerPair
Cut on the pair of objects together.
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
StringCutObjectSelector< MuonPointerPair, true > bestMuonSelector_
bool defaultBestMuon_
Use default criteria to choose the best muon.
template<typename T >
bool modules::MuonCleanerBySegmentsT< T >::isSameMuon ( const T mu1,
const T mu2 
) const
inline

Definition at line 48 of file MuonCleanerBySegments.cc.

48  {
49  return (& mu1 == & mu2) ||
50  (mu1.reco::Muon::innerTrack().isNonnull() ?
51  mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
52  mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
53  }
template<>
bool modules::MuonCleanerBySegmentsT< pat::Muon >::isSameMuon ( const pat::Muon mu1,
const pat::Muon mu2 
) const
template<>
bool modules::MuonCleanerBySegmentsT< pat::Muon >::isSameMuon ( const pat::Muon mu1,
const pat::Muon mu2 
) const

Definition at line 155 of file MuonCleanerBySegments.cc.

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

155  {
156  return (& mu1 == & mu2) ||
157  (mu1.originalObjectRef() == mu2.originalObjectRef()) ||
158  (mu1.reco::Muon::innerTrack().isNonnull() ?
159  mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
160  mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
161 }
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:482
template<typename T >
void modules::MuonCleanerBySegmentsT< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 94 of file MuonCleanerBySegments.cc.

References edm::Event::getByLabel(), i, j, dbtoconf::out, edm::Event::put(), reco::Muon::SegmentArbitration, muon::sharedSegments(), and alcazmumu_cfi::src.

94  {
95  using namespace edm;
96  using namespace std;
97 
99  auto_ptr<vector<T> > out(new vector<T>());
100 
101  iEvent.getByLabel(src_, src);
102  unsigned int nsrc = src->size();
103  out->reserve(nsrc);
104  std::vector<int> good(nsrc, true);
105  for (unsigned int i = 0; i < nsrc; ++i) {
106  const T &mu1 = (*src)[i];
107  if (!preselection_(mu1)) good[i] = false;
108  if (!good[i]) continue;
109  int nSegments1 = mu1.numberOfMatches(reco::Muon::SegmentArbitration);
110  for (unsigned int j = i+1; j < nsrc; ++j) {
111  const T &mu2 = (*src)[j];
112  if (isSameMuon(mu1,mu2)) continue;
113  if (!good[j] || !preselection_(mu2)) continue;
114  int nSegments2 = mu2.numberOfMatches(reco::Muon::SegmentArbitration);
115  if (nSegments2 == 0 || nSegments1 == 0) continue;
116  double sf = muon::sharedSegments(mu1,mu2)/std::min<double>(nSegments1,nSegments2);
117  if (sf > sharedFraction_) {
118  if (isBetterMuon(mu1,mu2)) {
119  good[j] = false;
120  } else {
121  good[i] = false;
122  }
123  }
124  }
125  }
126  for (unsigned int i = 0; i < nsrc; ++i) {
127  const T &mu1 = (*src)[i];
128  if (good[i] || passthrough_(mu1)) out->push_back(mu1);
129  }
130  iEvent.put(out);
131 }
int i
Definition: DBlmapReader.cc:9
double sharedFraction_
Fraction of shared segments.
StringCutObjectSelector< T > preselection_
Preselection cut.
StringCutObjectSelector< T > passthrough_
Always-accept cut.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
bool isSameMuon(const T &mu1, const T &mu2) const
int j
Definition: DBlmapReader.cc:9
edm::InputTag src_
Labels for input collections.
bool isBetterMuon(const T &mu1, const T &mu2) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
tuple out
Definition: dbtoconf.py:99
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
long double T

Member Data Documentation

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

Definition at line 71 of file MuonCleanerBySegments.cc.

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

Use default criteria to choose the best muon.

Definition at line 68 of file MuonCleanerBySegments.cc.

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

Always-accept cut.

Definition at line 62 of file MuonCleanerBySegments.cc.

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

Preselection cut.

Definition at line 60 of file MuonCleanerBySegments.cc.

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

Fraction of shared segments.

Definition at line 65 of file MuonCleanerBySegments.cc.

template<typename T >
edm::InputTag modules::MuonCleanerBySegmentsT< T >::src_
private

Labels for input collections.

Definition at line 57 of file MuonCleanerBySegments.cc.