CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenParticleDecaySelector.cc
Go to the documentation of this file.
1 /* \class GenParticleDecaySelector
2  *
3  * \author Luca Lista, INFN
4  *
5  *
6  */
7 
12 
14 public:
17 private:
19  void produce(edm::Event& e, const edm::EventSetup&) override;
26  int status_;
28  std::pair<reco::GenParticleRef, reco::GenParticle*>
31 };
32 
37 
38 using namespace edm;
39 using namespace reco;
40 using namespace std;
41 
43  firstEvent_(true),
44  srcToken_(consumes<GenParticleCollection>(cfg.getParameter<InputTag>("src"))),
45  particle_(cfg.getParameter<PdtEntry>("particle")),
46  status_(cfg.getParameter<int>("status")) {
47  produces<GenParticleCollection>();
48 }
49 
51  if (firstEvent_) {particle_.setup(es); firstEvent_ = false;}
52 
54  evt.getByToken(srcToken_, genParticles);
55  auto_ptr<GenParticleCollection> decay(new GenParticleCollection);
57  for(GenParticleCollection::const_iterator g = genParticles->begin();
58  g != genParticles->end(); ++g)
59  if(g->pdgId() == particle_.pdgId() && g->status() == status_)
60  add(*decay, *g, ref);
61  evt.put(decay);
62 }
63 
64 pair<GenParticleRef, GenParticle*> GenParticleDecaySelector::add(GenParticleCollection & decay, const GenParticle & p,
65  GenParticleRefProd ref) {
66  size_t idx = decay.size();
67  GenParticleRef r(ref, idx);
68  decay.resize(idx+1);
69  const LeafCandidate & part = p;
70  GenParticle g(part);
71  size_t n = p.numberOfDaughters();
72  for(size_t i = 0; i < n; ++i) {
73  pair<GenParticleRef, GenParticle*> d = add(decay, *p.daughterRef(i), ref);
74  d.second->addMother(r);
75  g.addDaughter(d.first);
76  }
77  GenParticle & gp = decay[idx] = g;
78  return make_pair(r, &gp);
79 }
80 
81 
83 
85 
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::pair< reco::GenParticleRef, reco::GenParticle * > add(reco::GenParticleCollection &, const reco::GenParticle &, reco::GenParticleRefProd)
recursively add a new particle to the output collection
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:259
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
tuple d
Definition: ztail.py:151
GenParticleDecaySelector(const edm::ParameterSet &)
constructor
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual size_t numberOfDaughters() const
number of daughters
RefProd< PROD > getRefBeforePut()
Definition: Event.h:133
PdtEntry particle_
particle type
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
source collection name
void setup(const edm::EventSetup &)
fill data from Event Setup
Definition: PdtEntry.cc:31
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
part
Definition: HCALResponse.h:20
int pdgId() const
PDG id.
Definition: PdtEntry.cc:7
void produce(edm::Event &e, const edm::EventSetup &) override
process one event