CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PFPileUp Class Reference

Identifies pile-up candidates from a collection of PFCandidates, and produces the corresponding collection of PileUpCandidates. More...

#include <PFPileUp.h>

Inheritance diagram for PFPileUp:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector< edm::FwdPtr< reco::PFCandidate > > PFCollection
 
typedef std::vector< reco::PFCandidatePFCollectionByValue
 
typedef edm::View< reco::PFCandidatePFView
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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
 

Public Member Functions

 PFPileUp (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PFPileUp () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool checkClosestZVertex_
 use the closest z vertex if a track is not in a vertex More...
 
bool enable_
 enable PFPileUp selection More...
 
PFPileUpAlgo pileUpAlgo_
 
edm::EDGetTokenT< PFCollectiontokenPFCandidates_
 PFCandidates to be analyzed. More...
 
edm::EDGetTokenT< PFViewtokenPFCandidatesView_
 fall-back token More...
 
edm::EDGetTokenT< reco::VertexCollectiontokenVertices_
 vertices More...
 
bool verbose_
 verbose ? More...
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
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

Identifies pile-up candidates from a collection of PFCandidates, and produces the corresponding collection of PileUpCandidates.

Author
Colin Bernet
Date
february 2008 Florian Beaudette 30/03/2012

Definition at line 34 of file PFPileUp.h.

Member Typedef Documentation

Definition at line 37 of file PFPileUp.h.

Definition at line 39 of file PFPileUp.h.

Definition at line 38 of file PFPileUp.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file PFPileUp.cc.

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

18  {
19 
21  = consumes<PFCollection>(iConfig.getParameter<InputTag>("PFCandidates"));
23  = mayConsume<PFView>(iConfig.getParameter<InputTag>("PFCandidates"));
24 
26  = consumes<VertexCollection>(iConfig.getParameter<InputTag>("Vertices"));
27 
28  enable_ = iConfig.getParameter<bool>("Enable");
29 
30  verbose_ =
31  iConfig.getUntrackedParameter<bool>("verbose",false);
32 
33 
34  if ( iConfig.exists("checkClosestZVertex") ) {
35  checkClosestZVertex_ = iConfig.getParameter<bool>("checkClosestZVertex");
36  } else {
37  checkClosestZVertex_ = false;
38  }
39 
40  // Configure the algo
43 
44  //produces<reco::PFCandidateCollection>();
45  produces< PFCollection > ();
46  // produces< PFCollectionByValue > ();
47 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
Definition: PFPileUp.h:57
edm::EDGetTokenT< PFView > tokenPFCandidatesView_
fall-back token
Definition: PFPileUp.h:54
bool exists(std::string const &parameterName) const
checks if a parameter exists
void setCheckClosestZVertex(bool val)
Definition: PFPileUpAlgo.h:31
bool verbose_
verbose ?
Definition: PFPileUp.h:63
edm::EDGetTokenT< PFCollection > tokenPFCandidates_
PFCandidates to be analyzed.
Definition: PFPileUp.h:52
bool enable_
enable PFPileUp selection
Definition: PFPileUp.h:60
PFPileUpAlgo pileUpAlgo_
Definition: PFPileUp.h:49
bool checkClosestZVertex_
use the closest z vertex if a track is not in a vertex
Definition: PFPileUp.h:66
void setVerbose(bool verbose)
Definition: PFPileUpAlgo.h:29
PFPileUp::~PFPileUp ( )
override

Definition at line 51 of file PFPileUp.cc.

51 { }

Member Function Documentation

void PFPileUp::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 55 of file PFPileUp.cc.

References Exception, edm::Event::getByToken(), eostools::move(), slimmedMuons_cfi::pfCandidates, edm::Handle< T >::product(), edm::Event::put(), and electrons_cff::vertices.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

56  {
57 
58 // LogDebug("PFPileUp")<<"START event: "<<iEvent.id().event()
59 // <<" in run "<<iEvent.id().run()<<endl;
60 
61 
62  // get PFCandidates
63 
64  unique_ptr< PFCollection >
65  pOutput( new PFCollection );
66 
67  unique_ptr< PFCollectionByValue >
68  pOutputByValue ( new PFCollectionByValue );
69 
70  if(enable_) {
71 
72 
73  // get vertices
75  iEvent.getByToken( tokenVertices_, vertices);
76 
77  // get PF Candidates
79  PFCollection const * pfCandidatesRef = nullptr;
80  PFCollection usedIfNoFwdPtrs;
81  bool getFromFwdPtr = iEvent.getByToken( tokenPFCandidates_, pfCandidates);
82  if ( getFromFwdPtr ) {
83  pfCandidatesRef = pfCandidates.product();
84  }
85  // Maintain backwards-compatibility.
86  // If there is no vector of FwdPtr<PFCandidate> found, then
87  // make a dummy vector<FwdPtr<PFCandidate> > for the PFPileupAlgo,
88  // set the pointer "pfCandidatesRef" to point to it, and
89  // then we can pass it to the PFPileupAlgo.
90  else {
91  Handle<PFView> pfView;
92  bool getFromView = iEvent.getByToken( tokenPFCandidatesView_, pfView );
93  if ( ! getFromView ) {
94  throw cms::Exception("PFPileUp is misconfigured. This needs to be either vector<FwdPtr<PFCandidate> >, or View<PFCandidate>");
95  }
96  for ( edm::View<reco::PFCandidate>::const_iterator viewBegin = pfView->begin(),
97  viewEnd = pfView->end(), iview = viewBegin;
98  iview != viewEnd; ++iview ) {
99  usedIfNoFwdPtrs.push_back( edm::FwdPtr<reco::PFCandidate>( pfView->ptrAt(iview-viewBegin), pfView->ptrAt(iview-viewBegin) ) );
100  }
101  pfCandidatesRef = &usedIfNoFwdPtrs;
102  }
103 
104  if ( pfCandidatesRef == nullptr ) {
105  throw cms::Exception("Something went dreadfully wrong with PFPileUp. pfCandidatesRef should never be zero, so this is a logic error.");
106  }
107 
108 
109 
110  pileUpAlgo_.process(*pfCandidatesRef,*vertices);
111  pOutput->insert(pOutput->end(),pileUpAlgo_.getPFCandidatesFromPU().begin(),pileUpAlgo_.getPFCandidatesFromPU().end());
112 
113  // for ( PFCollection::const_iterator byValueBegin = pileUpAlgo_.getPFCandidatesFromPU().begin(),
114  // byValueEnd = pileUpAlgo_.getPFCandidatesFromPU().end(), ibyValue = byValueBegin;
115  // ibyValue != byValueEnd; ++ibyValue ) {
116  // pOutputByValue->push_back( **ibyValue );
117  // }
118 
119  } // end if enabled
120  // outsize of the loop to fill the collection anyway even when disabled
121  iEvent.put(std::move(pOutput));
122  // iEvent.put(std::move(pOutputByValue));
123 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
Definition: PFPileUp.h:57
edm::EDGetTokenT< PFView > tokenPFCandidatesView_
fall-back token
Definition: PFPileUp.h:54
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
Ptr< value_type > ptrAt(size_type i) const
const_iterator begin() const
std::vector< reco::PFCandidate > PFCollectionByValue
Definition: PFPileUp.h:39
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCollection
Definition: PFPileUp.h:37
edm::EDGetTokenT< PFCollection > tokenPFCandidates_
PFCandidates to be analyzed.
Definition: PFPileUp.h:52
bool enable_
enable PFPileUp selection
Definition: PFPileUp.h:60
T const * product() const
Definition: Handle.h:81
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void process(const PFCollection &pfCandidates, const reco::VertexCollection &vertices)
Definition: PFPileUpAlgo.cc:5
PFPileUpAlgo pileUpAlgo_
Definition: PFPileUp.h:49
const_iterator end() const
const PFCollection & getPFCandidatesFromPU() const
Definition: PFPileUpAlgo.h:33
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

bool PFPileUp::checkClosestZVertex_
private

use the closest z vertex if a track is not in a vertex

Definition at line 66 of file PFPileUp.h.

bool PFPileUp::enable_
private

enable PFPileUp selection

Definition at line 60 of file PFPileUp.h.

PFPileUpAlgo PFPileUp::pileUpAlgo_
private

Definition at line 49 of file PFPileUp.h.

edm::EDGetTokenT<PFCollection> PFPileUp::tokenPFCandidates_
private

PFCandidates to be analyzed.

Definition at line 52 of file PFPileUp.h.

edm::EDGetTokenT<PFView> PFPileUp::tokenPFCandidatesView_
private

fall-back token

Definition at line 54 of file PFPileUp.h.

edm::EDGetTokenT<reco::VertexCollection> PFPileUp::tokenVertices_
private

vertices

Definition at line 57 of file PFPileUp.h.

bool PFPileUp::verbose_
private

verbose ?

Definition at line 63 of file PFPileUp.h.