CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PartonSelector Class Reference

Inheritance diagram for PartonSelector:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 PartonSelector (const edm::ParameterSet &)
 ~PartonSelector ()

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::InputTag inputTagGenParticles_
bool withLeptons
bool withTop

Detailed Description

Definition at line 36 of file PartonSelector.cc.


Constructor & Destructor Documentation

PartonSelector::PartonSelector ( const edm::ParameterSet iConfig)

Definition at line 51 of file PartonSelector.cc.

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

{ 
    produces<reco::GenParticleRefVector>();
    withLeptons           = iConfig.getParameter<bool>("withLeptons"); 
    inputTagGenParticles_ = iConfig.getParameter<edm::InputTag>("src");
    if ( iConfig.exists("withTop") ) {
      withTop = iConfig.getParameter<bool>("withTop");
    } else {
      withTop = false;
    }
}
PartonSelector::~PartonSelector ( )

Definition at line 65 of file PartonSelector.cc.

{
}

Member Function Documentation

void PartonSelector::produce ( edm::Event iEvent,
const edm::EventSetup iEs 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 71 of file PartonSelector.cc.

References abs, reco::CompositeRefCandidateT< D >::daughter(), reco::flavour(), edm::Event::getByLabel(), i, m, reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::LeafCandidate::pdgId(), reco::Candidate::pdgId(), edm::Event::put(), and reco::LeafCandidate::status().

{
  
  //edm::Handle <reco::CandidateView> particles;
  edm::Handle <reco::GenParticleCollection> particles;
  iEvent.getByLabel (inputTagGenParticles_, particles );  
  edm::LogVerbatim("PartonSelector") << "=== GenParticle size:" << particles->size();
  int nPart=0; 

  auto_ptr<GenParticleRefVector> thePartons ( new GenParticleRefVector);  
  
  for (size_t m = 0; m < particles->size(); m++) {
    
    // Don't take into account first 6 particles in generator list
    if (m<6) continue;    

    const GenParticle & aParticle = (*particles)[ m ];

    bool isAParton = false;
    bool isALepton = false;
    int flavour = abs(aParticle.pdgId());
    if(flavour == 1 ||
       flavour == 2 ||
       flavour == 3 ||
       flavour == 4 ||
       flavour == 5 ||  
       (flavour == 6 && withTop) ||
       flavour == 21 ) isAParton = true;
    if(flavour == 11 ||
       flavour == 12 ||
       flavour == 13 ||
       flavour == 14 ||
       flavour == 15 ||
       flavour == 16 ) isALepton = true;


    //Add Partons status 3
    if( aParticle.status() == 3 && isAParton ) {
      thePartons->push_back( GenParticleRef( particles, m ) );
      nPart++;
    }

    //Add Partons status 2
    int nparton_daughters = 0;
    if( aParticle.numberOfDaughters() > 0 && isAParton ) {
      
      for (unsigned int i=0; i < aParticle.numberOfDaughters(); i++){
        
        int daughterFlavour = abs(aParticle.daughter(i)->pdgId());
        if( (daughterFlavour == 1 || daughterFlavour == 2 || daughterFlavour == 3 || 
             daughterFlavour == 4 || daughterFlavour == 5 || daughterFlavour == 6 || daughterFlavour == 21)) {
          nparton_daughters++;
        }

      }
      if(nparton_daughters == 0){
          nPart++;
          thePartons->push_back( GenParticleRef( particles, m ) );
      }

    }

    //Add Leptons
    // Here you have to decide what to do with taus....
    // Now all leptons, including e and mu from leptonic tau decays, are added
    if( withLeptons && aParticle.status() == 3 && isALepton ) {
      thePartons->push_back( GenParticleRef( particles, m ) );
      nPart++;
    }
  }
  
  edm::LogVerbatim("PartonSelector") << "=== GenParticle selected:" << nPart;  
  iEvent.put( thePartons );

}

Member Data Documentation

Definition at line 47 of file PartonSelector.cc.

Definition at line 45 of file PartonSelector.cc.

bool PartonSelector::withTop [private]

Definition at line 46 of file PartonSelector.cc.