CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AlignmentGoodIdMuonSelector Class Reference
Inheritance diagram for AlignmentGoodIdMuonSelector:
edm::global::EDFilter<> edm::global::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AlignmentGoodIdMuonSelector (const edm::ParameterSet &)
 
 ~AlignmentGoodIdMuonSelector () override=default
 
- Public Member Functions inherited from edm::global::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=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
 
const EDFilteroperator= (const EDFilter &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

bool filter (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const bool filterEvents_
 
const double maxChi2_
 
const double maxEta_
 
const int minMatches_
 
const int minMuonHits_
 
const edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 
const bool requireGlobal_
 
const bool requireTracker_
 
const bool requireTrackerForSecondary_
 
const double secondaryEtaHigh_
 
const double secondaryEtaLow_
 
const int secondaryMinMatches_
 
const bool useSecondarySelection_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDFilterBase
typedef EDFilterBase 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
 
- 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

Definition at line 13 of file AlignmentGoodIdMuonSelector.cc.

Constructor & Destructor Documentation

◆ AlignmentGoodIdMuonSelector()

AlignmentGoodIdMuonSelector::AlignmentGoodIdMuonSelector ( const edm::ParameterSet iConfig)
explicit

Definition at line 58 of file AlignmentGoodIdMuonSelector.cc.

59  : muonToken_(consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("src"))),
60  maxEta_(iConfig.getParameter<double>("maxEta")),
61  maxChi2_(iConfig.getParameter<double>("maxChi2")),
62  minMuonHits_(iConfig.getParameter<int>("minMuonHits")),
63  minMatches_(iConfig.getParameter<int>("minMatches")),
64  requireGlobal_(iConfig.getParameter<bool>("requireGlobal")),
65  requireTracker_(iConfig.getParameter<bool>("requireTracker")),
66  filterEvents_(iConfig.getParameter<bool>("filter")),
67 
68  // Secondary selection
69  useSecondarySelection_(iConfig.getParameter<bool>("useSecondarySelection")),
70  secondaryEtaLow_(iConfig.getParameter<double>("secondaryEtaLow")),
71  secondaryEtaHigh_(iConfig.getParameter<double>("secondaryEtaHigh")),
72  secondaryMinMatches_(iConfig.getParameter<int>("secondaryMinMatches")),
73  requireTrackerForSecondary_(iConfig.getParameter<bool>("secondaryRequireTracker")) {
74  produces<reco::MuonCollection>();
75 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< reco::MuonCollection > muonToken_

◆ ~AlignmentGoodIdMuonSelector()

AlignmentGoodIdMuonSelector::~AlignmentGoodIdMuonSelector ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

void AlignmentGoodIdMuonSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 40 of file AlignmentGoodIdMuonSelector.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

40  {
42  desc.add<edm::InputTag>("src", edm::InputTag("muons"))->setComment("Input muon collection");
43  desc.add<double>("maxEta", 2.5)->setComment("|eta| cut");
44  desc.add<double>("maxChi2", 20.)->setComment("max chi2 of the global tags");
45  desc.add<int>("minMuonHits", 0.)->setComment("minimum number of valid muon hits");
46  desc.add<int>("minMatches", 1.)->setComment("minimum number of matches");
47  desc.add<bool>("requireGlobal", true)->setComment("is global muons");
48  desc.add<bool>("requireTracker", true)->setComment("is tracker muon");
49  desc.add<bool>("useSecondarySelection", false)->setComment("secondary selection");
50  desc.add<double>("secondaryEtaLow", 2.3)->setComment("min eta cut (secondary)");
51  desc.add<double>("secondaryEtaHigh", 3.0)->setComment("max eta cut (secondary)");
52  desc.add<int>("secondaryMinMatches", 0.)->setComment("minimum number of matches (secondary)");
53  desc.add<bool>("secondaryRequireTracker", true)->setComment("is tracker muon (secondary)");
54  desc.add<bool>("filter", true)->setComment("retain event only if non empty collection");
55  descriptions.addWithDefaultLabel(desc);
56 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ filter()

bool AlignmentGoodIdMuonSelector::filter ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup  
) const
overrideprivatevirtual

Implements edm::global::EDFilterBase.

Definition at line 77 of file AlignmentGoodIdMuonSelector.cc.

References funct::abs(), filterEvents_, iEvent, maxChi2_, maxEta_, minMatches_, minMuonHits_, eostools::move(), DiMuonV_cfg::muons, muonToken_, requireGlobal_, requireTracker_, requireTrackerForSecondary_, secondaryEtaHigh_, secondaryEtaLow_, secondaryMinMatches_, WZElectronSkims53X_cff::selectedMuons, and useSecondarySelection_.

77  {
79  iEvent.getByToken(muonToken_, muons);
80 
81  auto selectedMuons = std::make_unique<reco::MuonCollection>();
82 
83  for (const auto& muon : *muons) {
84  bool passPrimarySelection = true;
85 
86  // Check if globalTrack() is valid before using it
87  if (requireGlobal_) {
88  if (!muon.isGlobalMuon() || muon.globalTrack().isNull()) {
89  passPrimarySelection = false;
90  } else {
91  // Only access properties if the global track is valid
92  if (muon.globalTrack()->hitPattern().numberOfValidMuonHits() <= minMuonHits_)
93  passPrimarySelection = false;
94  if (muon.globalTrack()->normalizedChi2() >= maxChi2_)
95  passPrimarySelection = false;
96  }
97  }
98 
99  if (requireTracker_ && !muon.isTrackerMuon())
100  passPrimarySelection = false;
101  if (muon.numberOfMatches() <= minMatches_)
102  passPrimarySelection = false;
103  if (std::abs(muon.eta()) >= maxEta_)
104  passPrimarySelection = false;
105 
106  bool passSecondarySelection = false;
108  if (std::abs(muon.eta()) > secondaryEtaLow_ && std::abs(muon.eta()) < secondaryEtaHigh_ &&
109  muon.numberOfMatches() >= secondaryMinMatches_ && (!requireTrackerForSecondary_ || muon.isTrackerMuon())) {
110  passSecondarySelection = true;
111  }
112  }
113 
114  if (passPrimarySelection || passSecondarySelection) {
115  selectedMuons->push_back(muon);
116  }
117  }
118 
119  const bool passEvent = !selectedMuons->empty();
121 
122  // Decide if the event should pass based on filterEvents_ flag
123  return filterEvents_ ? passEvent : true;
124 }
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ filterEvents_

const bool AlignmentGoodIdMuonSelector::filterEvents_
private

Definition at line 30 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ maxChi2_

const double AlignmentGoodIdMuonSelector::maxChi2_
private

Definition at line 25 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ maxEta_

const double AlignmentGoodIdMuonSelector::maxEta_
private

Definition at line 24 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ minMatches_

const int AlignmentGoodIdMuonSelector::minMatches_
private

Definition at line 27 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ minMuonHits_

const int AlignmentGoodIdMuonSelector::minMuonHits_
private

Definition at line 26 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ muonToken_

const edm::EDGetTokenT<reco::MuonCollection> AlignmentGoodIdMuonSelector::muonToken_
private

Definition at line 23 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ requireGlobal_

const bool AlignmentGoodIdMuonSelector::requireGlobal_
private

Definition at line 28 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ requireTracker_

const bool AlignmentGoodIdMuonSelector::requireTracker_
private

Definition at line 29 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ requireTrackerForSecondary_

const bool AlignmentGoodIdMuonSelector::requireTrackerForSecondary_
private

Definition at line 37 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ secondaryEtaHigh_

const double AlignmentGoodIdMuonSelector::secondaryEtaHigh_
private

Definition at line 35 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ secondaryEtaLow_

const double AlignmentGoodIdMuonSelector::secondaryEtaLow_
private

Definition at line 34 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ secondaryMinMatches_

const int AlignmentGoodIdMuonSelector::secondaryMinMatches_
private

Definition at line 36 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().

◆ useSecondarySelection_

const bool AlignmentGoodIdMuonSelector::useSecondarySelection_
private

Definition at line 33 of file AlignmentGoodIdMuonSelector.cc.

Referenced by filter().