CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

GenParticleDecaySelector Class Reference

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

List of all members.

Public Member Functions

 GenParticleDecaySelector (const edm::ParameterSet &)
 constructor

Private Member Functions

std::pair
< reco::GenParticleRef,
reco::GenParticle * > 
add (reco::GenParticleCollection &, const reco::GenParticle &, reco::GenParticleRefProd)
 recursively add a new particle to the output collection
void produce (edm::Event &e, const edm::EventSetup &)
 process one event

Private Attributes

bool firstEvent_
PdtEntry particle_
 particle type
edm::InputTag src_
 source collection name
int status_
 particle status

Detailed Description

Definition at line 14 of file GenParticleDecaySelector.cc.


Constructor & Destructor Documentation

GenParticleDecaySelector::GenParticleDecaySelector ( const edm::ParameterSet cfg)

constructor

Definition at line 43 of file GenParticleDecaySelector.cc.

                                                                             :
  firstEvent_(true),
  src_(cfg.getParameter<InputTag>("src")),
  particle_(cfg.getParameter<PdtEntry>("particle")),
  status_(cfg.getParameter<int>("status")) {
  produces<GenParticleCollection>();
}

Member Function Documentation

pair< GenParticleRef, GenParticle * > GenParticleDecaySelector::add ( reco::GenParticleCollection decay,
const reco::GenParticle p,
reco::GenParticleRefProd  ref 
) [private]

recursively add a new particle to the output collection

Definition at line 65 of file GenParticleDecaySelector.cc.

References reco::CompositeRefCandidateT< D >::addDaughter(), reco::CompositeRefCandidateT< D >::daughterRef(), g, i, n, reco::CompositeRefCandidateT< D >::numberOfDaughters(), AlCaHLTBitMon_ParallelJobs::p, and alignCSCRings::r.

Referenced by produce().

                                                                                         {
  size_t idx = decay.size();
  GenParticleRef r(ref, idx);
  decay.resize(idx+1);
  const LeafCandidate & part = p;
  GenParticle g(part);
  size_t n = p.numberOfDaughters();
  for(size_t i = 0; i < n; ++i) {
    pair<GenParticleRef, GenParticle*> d = add(decay, *p.daughterRef(i), ref);
    d.second->addMother(r);
    g.addDaughter(d.first);
  }
  GenParticle & gp = decay[idx] = g;
  return make_pair(r, &gp);
}
void GenParticleDecaySelector::produce ( edm::Event e,
const edm::EventSetup es 
) [private, virtual]

process one event

Implements edm::EDProducer.

Definition at line 51 of file GenParticleDecaySelector.cc.

References add(), firstEvent_, g, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), edm::Event::getRefBeforePut(), particle_, PdtEntry::pdgId(), edm::Event::put(), PdtEntry::setup(), src_, and status_.

                                                                             {
  if (firstEvent_) {particle_.setup(es); firstEvent_ = false;}

  Handle<GenParticleCollection> genParticles;
  evt.getByLabel(src_, genParticles);
  auto_ptr<GenParticleCollection> decay(new GenParticleCollection);
  const GenParticleRefProd ref = evt.getRefBeforePut<GenParticleCollection>();
  for(GenParticleCollection::const_iterator g = genParticles->begin();
      g != genParticles->end(); ++g)
    if(g->pdgId() == particle_.pdgId() && g->status() == status_)
      add(*decay, *g, ref);
  evt.put(decay);
}

Member Data Documentation

Definition at line 21 of file GenParticleDecaySelector.cc.

Referenced by produce().

particle type

Definition at line 25 of file GenParticleDecaySelector.cc.

Referenced by produce().

source collection name

Definition at line 23 of file GenParticleDecaySelector.cc.

Referenced by produce().

particle status

Definition at line 27 of file GenParticleDecaySelector.cc.

Referenced by produce().