CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
GreedyMuonPFCandidateFilter Class Reference
Inheritance diagram for GreedyMuonPFCandidateFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GreedyMuonPFCandidateFilter (const edm::ParameterSet &)
 
 ~GreedyMuonPFCandidateFilter () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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

void beginJob () override
 
void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const bool debug_
 
const double eOverPMax_
 
const bool taggingMode_
 
const edm::EDGetTokenT< reco::PFCandidateCollectiontokenPFCandidates_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter 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::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 25 of file GreedyMuonPFCandidateFilter.cc.

Constructor & Destructor Documentation

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

Definition at line 56 of file GreedyMuonPFCandidateFilter.cc.

58  : tokenPFCandidates_ (consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidates") ) )
59  , eOverPMax_ (iConfig.getParameter<double>("eOverPMax") )
60  , debug_ ( iConfig.getParameter<bool>("debug") )
61  , taggingMode_ (iConfig.getParameter<bool>("taggingMode") )
62 {
63  produces<bool>();
64  produces<reco::PFCandidateCollection>("muons");
65 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::PFCandidateCollection > tokenPFCandidates_
GreedyMuonPFCandidateFilter::~GreedyMuonPFCandidateFilter ( )
override

Definition at line 68 of file GreedyMuonPFCandidateFilter.cc.

69 {
70 
71  // do anything here that needs to be done at desctruction time
72  // (e.g. close files, deallocate resources etc.)
73 
74 }

Member Function Documentation

void GreedyMuonPFCandidateFilter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 136 of file GreedyMuonPFCandidateFilter.cc.

137 {
138 }
void GreedyMuonPFCandidateFilter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 142 of file GreedyMuonPFCandidateFilter.cc.

References DEFINE_FWK_MODULE.

142  {
143 }
bool GreedyMuonPFCandidateFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 83 of file GreedyMuonPFCandidateFilter.cc.

References gather_cfg::cout, debug_, eOverPMax_, edm::Event::getByToken(), mps_fire::i, PFMuonAlgo::isIsolatedMuon(), eostools::move(), reco::PFCandidate::mu, reco::PFCandidate::muonRef(), reco::LeafCandidate::p(), reco::PFCandidate::particleId(), patMuonMerger_cfi::pfCandidates, edm::Event::put(), reco::PFCandidate::rawEcalEnergy(), reco::PFCandidate::rawHcalEnergy(), taggingMode_, and tokenPFCandidates_.

84 {
85  using namespace std;
86  using namespace edm;
87 
89  iEvent.getByToken(tokenPFCandidates_,pfCandidates);
90 
91  bool foundMuon = false;
92 
93  auto pOutputCandidateCollection = std::make_unique<reco::PFCandidateCollection>();
94 
95  for( unsigned i=0; i<pfCandidates->size(); i++ ) {
96 
97  const reco::PFCandidate & cand = (*pfCandidates)[i];
98 
99 // if( cand.particleId() != 3 ) // not a muon
100  if( cand.particleId() != reco::PFCandidate::mu ) // not a muon
101  continue;
102 
103  if(!PFMuonAlgo::isIsolatedMuon( cand.muonRef() ) ) // muon is not isolated
104  continue;
105 
106  double totalCaloEnergy = cand.rawEcalEnergy() + cand.rawHcalEnergy();
107  double eOverP = totalCaloEnergy/cand.p();
108 
109  if( eOverP < eOverPMax_ )
110  continue;
111 
112  foundMuon = true;
113 
114  pOutputCandidateCollection->push_back( cand );
115 
116  if( debug_ ) {
117  cout<<cand<<" HCAL E="<<endl;
118  cout<<"\t"<<"ECAL energy "<<cand.rawEcalEnergy()<<endl;
119  cout<<"\t"<<"HCAL energy "<<cand.rawHcalEnergy()<<endl;
120  cout<<"\t"<<"E/p "<<eOverP<<endl;
121  }
122  }
123 
124  iEvent.put(std::move(pOutputCandidateCollection), "muons");
125 
126  bool pass = !foundMuon;
127 
128  iEvent.put(std::make_unique<bool>(pass));
129 
130  return taggingMode_ || pass;
131 
132 }
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:137
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:225
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const edm::EDGetTokenT< reco::PFCandidateCollection > tokenPFCandidates_
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:459
double p() const final
magnitude of momentum vector
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
HLT enums.
virtual ParticleType particleId() const
Definition: PFCandidate.h:374
def move(src, dest)
Definition: eostools.py:511
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:235

Member Data Documentation

const bool GreedyMuonPFCandidateFilter::debug_
private

Definition at line 40 of file GreedyMuonPFCandidateFilter.cc.

Referenced by filter().

const double GreedyMuonPFCandidateFilter::eOverPMax_
private

Definition at line 38 of file GreedyMuonPFCandidateFilter.cc.

Referenced by filter().

const bool GreedyMuonPFCandidateFilter::taggingMode_
private

Definition at line 42 of file GreedyMuonPFCandidateFilter.cc.

Referenced by filter().

const edm::EDGetTokenT<reco::PFCandidateCollection> GreedyMuonPFCandidateFilter::tokenPFCandidates_
private

Definition at line 35 of file GreedyMuonPFCandidateFilter.cc.

Referenced by filter().