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 Member Functions | Private Attributes
PFMuonCaloCleaner Class Reference

#include <PFMuonCaloCleaner.h>

Inheritance diagram for PFMuonCaloCleaner:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFMuonCaloCleaner (const edm::ParameterSet &)
 
 ~PFMuonCaloCleaner ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 Types

typedef std::map< uint32_t, float > detIdToFloatMap
 

Private Member Functions

void fillEnergyDepositMap (const reco::Muon *, const edm::View< reco::PFCandidate > &, detIdToFloatMap &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

double dRmatch_
 
edm::InputTag srcPFCandidates_
 
edm::InputTag srcSelectedMuons_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 17 of file PFMuonCaloCleaner.h.

Member Typedef Documentation

typedef std::map<uint32_t, float> PFMuonCaloCleaner::detIdToFloatMap
private

Definition at line 26 of file PFMuonCaloCleaner.h.

Constructor & Destructor Documentation

PFMuonCaloCleaner::PFMuonCaloCleaner ( const edm::ParameterSet cfg)
explicit

Definition at line 23 of file PFMuonCaloCleaner.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and verbosity_.

24  : srcSelectedMuons_(cfg.getParameter<edm::InputTag>("selectedMuons")),
25  srcPFCandidates_(cfg.getParameter<edm::InputTag>("pfCandidates")),
26  dRmatch_(cfg.getParameter<double>("dRmatch"))
27 {
28  // maps of detId to energy deposit attributed to muon
29  produces<detIdToFloatMap>("energyDepositsMuPlus");
30  produces<detIdToFloatMap>("energyDepositsMuMinus");
31 
32  verbosity_ = ( cfg.exists("verbosity") ) ?
33  cfg.getParameter<int>("verbosity") : 0;
34 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag srcPFCandidates_
edm::InputTag srcSelectedMuons_
PFMuonCaloCleaner::~PFMuonCaloCleaner ( )
inline

Definition at line 21 of file PFMuonCaloCleaner.h.

21 {}

Member Function Documentation

void PFMuonCaloCleaner::fillEnergyDepositMap ( const reco::Muon muon,
const edm::View< reco::PFCandidate > &  pfCandidates,
detIdToFloatMap energyDepositMap 
)
private

Definition at line 72 of file PFMuonCaloCleaner.cc.

References edm::OwnVector< T, P >::begin(), edm::View< T >::begin(), gather_cfg::cout, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, dRmatch_, edm::OwnVector< T, P >::end(), edm::View< T >::end(), reco::LeafCandidate::eta(), Exception, customizeTrackingMonitorSeedNumber::idx, trackerHitRTTI::isMatched(), edm::InputTag::label(), reco::PFCandidate::mu, reco::LeafCandidate::p4(), reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), srcSelectedMuons_, and verbosity_.

Referenced by produce().

73 {
74  if ( !muon )
75  throw cms::Exception("InvalidData")
76  << "Collection 'selectedMuons' = " << srcSelectedMuons_.label() << " is not of valid type !!\n";
77 
78  bool isMatched = false;
79  for ( edm::View<reco::PFCandidate>::const_iterator pfCandidate = pfCandidates.begin();
80  pfCandidate != pfCandidates.end(); ++pfCandidate ) {
81  if ( pfCandidate->particleId() == reco::PFCandidate::mu ) {
82  double dR = deltaR(pfCandidate->p4(), muon->p4());
83  if ( dR < dRmatch_ ) {
84  // NOTE: particleFlow sequence needs to be rerun for Zmumu event
85  // in order to recreate the links from PFCandidates->PFBlocks->PFClusters->PFRecHitFractions
86  // (not stored in AOD/RECO event content)
87  const reco::PFCandidate::ElementsInBlocks& pfBlocks = pfCandidate->elementsInBlocks();
88  for ( reco::PFCandidate::ElementsInBlocks::const_iterator pfBlock = pfBlocks.begin();
89  pfBlock != pfBlocks.end(); ++pfBlock ) {
90  const edm::OwnVector<reco::PFBlockElement>& pfBlockElements = pfBlock->first->elements();
91  for ( edm::OwnVector<reco::PFBlockElement>::const_iterator pfBlockElement = pfBlockElements.begin();
92  pfBlockElement != pfBlockElements.end(); ++pfBlockElement ) {
93  if ( pfBlockElement->clusterRef().isNonnull() ) {
94  reco::PFClusterRef pfCluster = pfBlockElement->clusterRef();
95  const std::vector<reco::PFRecHitFraction>& pfRecHitFractions = pfCluster->recHitFractions();
96  for ( std::vector<reco::PFRecHitFraction>::const_iterator pfRecHitFraction = pfRecHitFractions.begin();
97  pfRecHitFraction != pfRecHitFractions.end(); ++pfRecHitFraction ) {
98  const reco::PFRecHitRef& pfRecHit = pfRecHitFraction->recHitRef();
99  energyDepositMap[pfRecHit->detId()] += pfRecHitFraction->fraction();
100  }
101  }
102  }
103  }
104  isMatched = true;
105  }
106  }
107  }
108  if ( !isMatched ) {
109  edm::LogWarning("PFMuonCaloCleaner")
110  << "Failed to match Muon to PFCandidate: Pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << " !!" << std::endl;
111  if ( verbosity_ ) {
112  int idx = 0;
113  for ( edm::View<reco::PFCandidate>::const_iterator pfCandidate = pfCandidates.begin();
114  pfCandidate != pfCandidates.end(); ++pfCandidate ) {
115  std::cout << "PFCandidate #" << idx << " (" << getPFCandidateType(pfCandidate->particleId()) << "):"
116  << " Pt = " << pfCandidate->pt() << ", eta = " << pfCandidate->eta() << ", phi = " << pfCandidate->phi() << std::endl;
117  ++idx;
118  }
119  }
120  }
121 }
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:386
iterator begin()
Definition: OwnVector.h:234
const_iterator begin() const
bool isMatched(TrackingRecHit const &hit)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
iterator end()
Definition: OwnVector.h:239
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::string const & label() const
Definition: InputTag.h:43
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::InputTag srcSelectedMuons_
void PFMuonCaloCleaner::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 36 of file PFMuonCaloCleaner.cc.

References fillEnergyDepositMap(), edm::Event::getByLabel(), getSelMuons(), getTheMuMinus(), getTheMuPlus(), edm::RefToBase< T >::isNonnull(), reco::tau::pfCandidates(), edm::Event::put(), srcPFCandidates_, and srcSelectedMuons_.

37 {
38  std::auto_ptr<detIdToFloatMap> energyDepositMuPlus(new detIdToFloatMap());
39  std::auto_ptr<detIdToFloatMap> energyDepositMuMinus(new detIdToFloatMap());
40 
41  std::vector<reco::CandidateBaseRef > selMuons = getSelMuons(evt, srcSelectedMuons_);
42  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
43  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
44 
45  typedef edm::View<reco::PFCandidate> PFCandidateView;
47  evt.getByLabel(srcPFCandidates_, pfCandidates);
48 
49  if ( muPlus.isNonnull() ) fillEnergyDepositMap(dynamic_cast<const reco::Muon*>(&*muPlus), *pfCandidates, *energyDepositMuPlus);
50  if ( muMinus.isNonnull() ) fillEnergyDepositMap(dynamic_cast<const reco::Muon*>(&*muMinus), *pfCandidates, *energyDepositMuMinus);
51 
52  evt.put(energyDepositMuPlus, "energyDepositsMuPlus");
53  evt.put(energyDepositMuMinus, "energyDepositsMuMinus");
54 }
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
void fillEnergyDepositMap(const reco::Muon *, const edm::View< reco::PFCandidate > &, detIdToFloatMap &)
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:330
edm::InputTag srcPFCandidates_
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
std::map< uint32_t, float > detIdToFloatMap
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
edm::InputTag srcSelectedMuons_

Member Data Documentation

double PFMuonCaloCleaner::dRmatch_
private

Definition at line 31 of file PFMuonCaloCleaner.h.

Referenced by fillEnergyDepositMap().

edm::InputTag PFMuonCaloCleaner::srcPFCandidates_
private

Definition at line 30 of file PFMuonCaloCleaner.h.

Referenced by produce().

edm::InputTag PFMuonCaloCleaner::srcSelectedMuons_
private

Definition at line 29 of file PFMuonCaloCleaner.h.

Referenced by fillEnergyDepositMap(), and produce().

int PFMuonCaloCleaner::verbosity_
private

Definition at line 33 of file PFMuonCaloCleaner.h.

Referenced by fillEnergyDepositMap(), and PFMuonCaloCleaner().