CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1AnalysisGenerator.cc
Go to the documentation of this file.
4 #include "HepMC/GenParticle.h"
5 #include "HepMC/GenVertex.h"
7 
8 using namespace reco;
9 
11 {
12 }
13 
15 {
16 }
17 
19 {
21  e.getByLabel("genParticles", genParticles);
22  for(size_t i = 0; i < genParticles->size(); ++ i) {
23  const GenParticle & p = (*genParticles)[i];
24  int id = p.pdgId();
25  //int st = p.status();
26  if (abs(id) == 13) {
27  unsigned int nMo=p.numberOfMothers();
28 // std::cout << "id " << id << "; st " << st
29 // << "; nMo " << nMo << std::endl;
30  for(unsigned int i=0;i<nMo;++i){
31 // int thisParentID = dynamic_cast <const reco::GenParticle*>(p.mother(i))->pdgId();
32 // std::cout << " mother ID " << thisParentID << std::endl;
33  }
34  }
35 
36 //
37 // See if the parent was interesting
38  int parentID = -10000;
39  unsigned int nMo=p.numberOfMothers();
40  for(unsigned int i=0;i<nMo;++i){
41  int thisParentID = dynamic_cast
42  <const reco::GenParticle*>(p.mother(i))->pdgId();
43 //
44 // Is this a bottom hadron?
45  int hundredsIndex = abs(thisParentID)/100;
46  int thousandsIndex = abs(thisParentID)/1000;
47  if ( ((abs(thisParentID) >= 23) &&
48  (abs(thisParentID) <= 25)) ||
49  (abs(thisParentID) == 6) ||
50  (hundredsIndex == 5) ||
51  (hundredsIndex == 4) ||
52  (thousandsIndex == 5) ||
53  (thousandsIndex == 4)
54  )
55  parentID = thisParentID;
56  }
57  if ((parentID == -10000) && (nMo > 0))
58  parentID = dynamic_cast
59  <const reco::GenParticle*>(p.mother(0))->pdgId();
60 //
61 // If the parent of this particle is interesting, store all of the info
62  if ((parentID != p.pdgId()) &&
63  ((parentID > -9999)
64  || (abs(id) == 11)
65  || (abs(id) == 13)
66  || (abs(id) == 23)
67  || (abs(id) == 24)
68  || (abs(id) == 25)
69  || (abs(id) == 4)
70  || (abs(id) == 5)
71  || (abs(id) == 6))
72  )
73  {
74  generator_.id.push_back(p.pdgId());
75  generator_.status.push_back(p.status());
76  generator_.px.push_back(p.px());
77  generator_.py.push_back(p.py());
78  generator_.pz.push_back(p.pz());
79  generator_.e.push_back(p.energy());
80  generator_.parent_id.push_back(parentID);
81  }
82  }
83 
84 }
int i
Definition: DBlmapReader.cc:9
virtual double energy() const final
energy
virtual int status() const final
status word
virtual size_t numberOfMothers() const
number of mothers
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual double py() const final
y coordinate of momentum vector
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
virtual double pz() const final
z coordinate of momentum vector
virtual int pdgId() const final
PDG identifier.
virtual double px() const final
x coordinate of momentum vector
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
void Set(const edm::Event &e)