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 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 ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

const bool debug_
 
const double eOverPMax_
 
const bool taggingMode_
 
const edm::EDGetTokenT
< reco::PFCandidateCollection
tokenPFCandidates_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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 &)
 
- 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

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 ( )

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 137 of file GreedyMuonPFCandidateFilter.cc.

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

Reimplemented from edm::EDFilter.

Definition at line 143 of file GreedyMuonPFCandidateFilter.cc.

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

Implements edm::EDFilter.

Definition at line 83 of file GreedyMuonPFCandidateFilter.cc.

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

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

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().