CMS 3D CMS Logo

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 beginJob (const edm::EventSetup &)
 begin job
void produce (edm::Event &e, const edm::EventSetup &)
 process one event

Private Attributes

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 44 of file GenParticleDecaySelector.cc.

00044                                                                              :
00045   src_(cfg.getParameter<InputTag>("src")),
00046   particle_(cfg.getParameter<PdtEntry>("particle")),
00047   status_(cfg.getParameter<int>("status")) {
00048   produces<GenParticleCollection>();
00049 }


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 67 of file GenParticleDecaySelector.cc.

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

00068                                                                                          {
00069   size_t idx = decay.size();
00070   GenParticleRef r(ref, idx);
00071   decay.resize(idx+1);
00072   const Particle & part = p;
00073   GenParticle g(part);
00074   size_t n = p.numberOfDaughters();
00075   for(size_t i = 0; i < n; ++i) {
00076     pair<GenParticleRef, GenParticle*> d = add(decay, *p.daughterRef(i), ref);
00077     d.second->addMother(r);
00078     g.addDaughter(d.first);
00079   }
00080   GenParticle & gp = decay[idx] = g;
00081   return make_pair(r, &gp);
00082 }

void GenParticleDecaySelector::beginJob ( const edm::EventSetup es  )  [private, virtual]

begin job

Reimplemented from edm::EDProducer.

Definition at line 51 of file GenParticleDecaySelector.cc.

References particle_, and PdtEntry::setup().

00051                                                                {
00052   particle_.setup(es);
00053 }

void GenParticleDecaySelector::produce ( edm::Event e,
const edm::EventSetup  
) [private, virtual]

process one event

Implements edm::EDProducer.

Definition at line 55 of file GenParticleDecaySelector.cc.

References g, genParticles_cfi::genParticles, edm::Event::getByLabel(), edm::Event::getRefBeforePut(), particle_, PdtEntry::pdgId(), edm::Event::put(), src_, and status_.

00055                                                                           {
00056   Handle<GenParticleCollection> genParticles;
00057   evt.getByLabel(src_, genParticles);
00058   auto_ptr<GenParticleCollection> decay(new GenParticleCollection);
00059   const GenParticleRefProd ref = evt.getRefBeforePut<GenParticleCollection>();
00060   for(GenParticleCollection::const_iterator g = genParticles->begin();
00061       g != genParticles->end(); ++g)
00062     if(g->pdgId() == particle_.pdgId() && g->status() == status_)
00063       add(*decay, *g, ref);
00064   evt.put(decay);
00065 }


Member Data Documentation

PdtEntry GenParticleDecaySelector::particle_ [private]

particle type

Definition at line 26 of file GenParticleDecaySelector.cc.

Referenced by beginJob(), and produce().

edm::InputTag GenParticleDecaySelector::src_ [private]

source collection name

Definition at line 24 of file GenParticleDecaySelector.cc.

Referenced by produce().

int GenParticleDecaySelector::status_ [private]

particle status

Definition at line 28 of file GenParticleDecaySelector.cc.

Referenced by produce().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:21:22 2009 for CMSSW by  doxygen 1.5.4