CMS 3D CMS Logo

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::ProductRegistryHelper

List of all members.

Public Types

typedef std::vector
< edm::FwdPtr
< reco::PFCandidate > > 
PFCollection
typedef std::vector
< reco::PFCandidate
PFCollectionByValue
typedef edm::View
< reco::PFCandidate
PFView

Public Member Functions

virtual void beginJob ()
 PFPileUp (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~PFPileUp ()

Private Attributes

bool checkClosestZVertex_
 use the closest z vertex if a track is not in a vertex
bool enable_
 enable PFPileUp selection
edm::InputTag inputTagPFCandidates_
 PFCandidates to be analyzed.
edm::InputTag inputTagVertices_
 vertices
PFPileUpAlgo pileUpAlgo_
bool verbose_
 verbose ?

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

                                                 {
  
  inputTagPFCandidates_ 
    = iConfig.getParameter<InputTag>("PFCandidates");

  inputTagVertices_ 
    = iConfig.getParameter<InputTag>("Vertices");

  enable_ = iConfig.getParameter<bool>("Enable");

  verbose_ = 
    iConfig.getUntrackedParameter<bool>("verbose",false);


  if ( iConfig.exists("checkClosestZVertex") ) {
    checkClosestZVertex_ = iConfig.getParameter<bool>("checkClosestZVertex");
  } else {
    checkClosestZVertex_ = false;
  }

  // Configure the algo
  pileUpAlgo_.setVerbose(verbose_);
  pileUpAlgo_.setCheckClosestZVertex(checkClosestZVertex_);
  
  //produces<reco::PFCandidateCollection>();
  produces< PFCollection > ();
  produces< PFCollectionByValue > ();
}
PFPileUp::~PFPileUp ( )

Definition at line 49 of file PFPileUp.cc.

{ }

Member Function Documentation

void PFPileUp::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 53 of file PFPileUp.cc.

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

Implements edm::EDProducer.

Definition at line 56 of file PFPileUp.cc.

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

                                                    {
  
//   LogDebug("PFPileUp")<<"START event: "<<iEvent.id().event()
//                       <<" in run "<<iEvent.id().run()<<endl;
  
   
  // get PFCandidates

  auto_ptr< PFCollection > 
    pOutput( new PFCollection ); 

  auto_ptr< PFCollectionByValue >
    pOutputByValue ( new PFCollectionByValue );
  
  if(enable_) {

  
    // get vertices 
    Handle<VertexCollection> vertices;
    iEvent.getByLabel( inputTagVertices_, vertices);
  
    // get PF Candidates
    Handle<PFCollection> pfCandidates;
    PFCollection const * pfCandidatesRef = 0;
    PFCollection usedIfNoFwdPtrs;
    bool getFromFwdPtr = iEvent.getByLabel( inputTagPFCandidates_, pfCandidates);
    if ( getFromFwdPtr ) {
      pfCandidatesRef = pfCandidates.product();
    }
    // Maintain backwards-compatibility.
    // If there is no vector of FwdPtr<PFCandidate> found, then
    // make a dummy vector<FwdPtr<PFCandidate> > for the PFPileupAlgo, 
    // set the pointer "pfCandidatesRef" to point to it, and
    // then we can pass it to the PFPileupAlgo. 
    else {
      Handle<PFView> pfView;
      bool getFromView = iEvent.getByLabel( inputTagPFCandidates_, pfView );
      if ( ! getFromView ) {
        throw cms::Exception("PFPileUp is misconfigured. This needs to be either vector<FwdPtr<PFCandidate> >, or View<PFCandidate>");
      }
      for ( edm::View<reco::PFCandidate>::const_iterator viewBegin = pfView->begin(),
              viewEnd = pfView->end(), iview = viewBegin;
            iview != viewEnd; ++iview ) {
        usedIfNoFwdPtrs.push_back( edm::FwdPtr<reco::PFCandidate>( pfView->ptrAt(iview-viewBegin), pfView->ptrAt(iview-viewBegin)  ) );
      }
      pfCandidatesRef = &usedIfNoFwdPtrs;
    }

    if ( pfCandidatesRef == 0 ) {
      throw cms::Exception("Something went dreadfully wrong with PFPileUp. pfCandidatesRef should never be zero, so this is a logic error.");
    }

    

    pileUpAlgo_.process(*pfCandidatesRef,*vertices);
    pOutput->insert(pOutput->end(),pileUpAlgo_.getPFCandidatesFromPU().begin(),pileUpAlgo_.getPFCandidatesFromPU().end());

    for ( PFCollection::const_iterator byValueBegin = pileUpAlgo_.getPFCandidatesFromPU().begin(),
            byValueEnd = pileUpAlgo_.getPFCandidatesFromPU().end(), ibyValue = byValueBegin;
          ibyValue != byValueEnd; ++ibyValue ) {
      pOutputByValue->push_back( **ibyValue );
    }

  } // end if enabled
  // outsize of the loop to fill the collection anyway even when disabled
  iEvent.put( pOutput );
  iEvent.put( pOutputByValue );
}

Member Data Documentation

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.

PFCandidates to be analyzed.

Definition at line 54 of file PFPileUp.h.

vertices

Definition at line 57 of file PFPileUp.h.

Definition at line 51 of file PFPileUp.h.

bool PFPileUp::verbose_ [private]

verbose ?

Definition at line 63 of file PFPileUp.h.