CMS 3D CMS Logo

Public Member Functions | Private 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 Member Functions

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

Private Member Functions

reco::VertexRef chargedHadronVertex (const edm::Handle< reco::VertexCollection > &vertices, const reco::PFCandidate &pfcand) const

Private Attributes

bool enable_
 enable PFPileUp selection
edm::InputTag inputTagPFCandidates_
 PFCandidates to be analyzed.
edm::InputTag inputTagVertices_
 vertices
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

Definition at line 31 of file PFPileUp.h.


Constructor & Destructor Documentation

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

Definition at line 19 of file PFPileUp.cc.

References 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);



  produces<reco::PileUpPFCandidateCollection>();
  
}
PFPileUp::~PFPileUp ( )

Definition at line 42 of file PFPileUp.cc.

{ }

Member Function Documentation

void PFPileUp::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 46 of file PFPileUp.cc.

{ }
VertexRef PFPileUp::chargedHadronVertex ( const edm::Handle< reco::VertexCollection > &  vertices,
const reco::PFCandidate pfcand 
) const [private]

Definition at line 105 of file PFPileUp.cc.

References getHLTprescales::index, reco::PFCandidate::trackRef(), reco::Vertex::tracks_begin(), and reco::Vertex::tracks_end().

                                                                                                         {

  
  reco::TrackBaseRef trackBaseRef( pfcand.trackRef() );
  
  unsigned nFoundVertex = 0;
  size_t  iVertex = 0;
  unsigned index=0;
  typedef reco::VertexCollection::const_iterator IV;
  for(IV iv=vertices->begin(); iv!=vertices->end(); ++iv, ++index) {
//     cout<<(*iv).x()<<" "
//      <<(*iv).y()<<" "
//      <<(*iv).z()<<endl;

    const reco::Vertex& vtx = *iv;
    
    typedef reco::Vertex::trackRef_iterator IT;
    
    // loop on tracks in vertices
    for(IT iTrack=vtx.tracks_begin(); 
        iTrack!=vtx.tracks_end(); ++iTrack) {
         
      const reco::TrackBaseRef& baseRef = *iTrack;

      // one of the tracks in the vertex is the same as 
      // the track considered in the function
      if(baseRef == trackBaseRef ) {
        iVertex = index;
        nFoundVertex++;
      }         
    }
  } 

  if( nFoundVertex == 1) {
    return VertexRef( vertices, iVertex);
  }
  else if(nFoundVertex>1) assert(false);

  assert( !iVertex );

  // no vertex found with this track. 
  // keep this track
  return VertexRef();
}
void PFPileUp::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 49 of file PFPileUp.cc.

References edm::Event::getByLabel(), h, i, edm::Ref< C, T, F >::isNull(), edm::Ref< C, T, F >::key(), reco::tau::pfCandidates(), edm::Event::put(), and ExpressReco_HICollisions_FallBack::vertices.

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

  auto_ptr< reco::PileUpPFCandidateCollection > 
    pOutput( new reco::PileUpPFCandidateCollection ); 
  
  if(enable_) {

    Handle<PFCandidateCollection> pfCandidates;
    iEvent.getByLabel( inputTagPFCandidates_, pfCandidates);

  
    // get vertices 

    Handle<VertexCollection> vertices;
    iEvent.getByLabel( inputTagVertices_, vertices);
  
    for( unsigned i=0; i<pfCandidates->size(); i++ ) {
    
      // const reco::PFCandidate& cand = (*pfCandidates)[i];
      PFCandidatePtr candptr(pfCandidates, i);

      //     PFCandidateRef pfcandref(pfCandidates,i); 

      VertexRef vertexref;

      switch( candptr->particleId() ) {
      case PFCandidate::h:
        vertexref = chargedHadronVertex( vertices, *candptr );
        break;
      default:
        continue;
      } 
    
      // no associated vertex, or primary vertex
      // not pile-up
      if( vertexref.isNull() || 
          vertexref.key()==0 ) continue;

      pOutput->push_back( PileUpPFCandidate( candptr, vertexref ) );
      pOutput->back().setSourceCandidatePtr( candptr );
    }
  }
  iEvent.put( pOutput );
  
}

Member Data Documentation

bool PFPileUp::enable_ [private]

enable PFPileUp selection

Definition at line 56 of file PFPileUp.h.

PFCandidates to be analyzed.

Definition at line 50 of file PFPileUp.h.

vertices

Definition at line 53 of file PFPileUp.h.

bool PFPileUp::verbose_ [private]

verbose ?

Definition at line 59 of file PFPileUp.h.