CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector
< edm::FwdPtr
< reco::PFCandidate > > 
PFCollection
 
typedef std::vector
< reco::PFCandidate
PFCollectionByValue
 
typedef edm::View
< reco::PFCandidate
PFView
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

virtual void beginJob ()
 
 PFPileUp (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~PFPileUp ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
< reco::VertexCollection
tokenVertices_
 vertices More...
 
bool verbose_
 verbose ? More...
 

Additional Inherited Members

- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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"));
22 
24  = consumes<VertexCollection>(iConfig.getParameter<InputTag>("Vertices"));
25 
26  enable_ = iConfig.getParameter<bool>("Enable");
27 
28  verbose_ =
29  iConfig.getUntrackedParameter<bool>("verbose",false);
30 
31 
32  if ( iConfig.exists("checkClosestZVertex") ) {
33  checkClosestZVertex_ = iConfig.getParameter<bool>("checkClosestZVertex");
34  } else {
35  checkClosestZVertex_ = false;
36  }
37 
38  // Configure the algo
41 
42  //produces<reco::PFCandidateCollection>();
43  produces< PFCollection > ();
44  // produces< PFCollectionByValue > ();
45 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
Definition: PFPileUp.h:57
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:54
bool enable_
enable PFPileUp selection
Definition: PFPileUp.h:60
PFPileUpAlgo pileUpAlgo_
Definition: PFPileUp.h:51
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 ( )

Definition at line 49 of file PFPileUp.cc.

49 { }

Member Function Documentation

void PFPileUp::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 53 of file PFPileUp.cc.

53 { }
void PFPileUp::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 56 of file PFPileUp.cc.

References edm::hlt::Exception, edm::Event::getByToken(), reco::tau::pfCandidates(), edm::Handle< T >::product(), and edm::Event::put().

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

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

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 51 of file PFPileUp.h.

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

PFCandidates to be analyzed.

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.