LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GenParticle.cc
Go to the documentation of this file.
1 //
2 // A minimal class to hold information about generated particles.
3 //
4 
6 #include <ostream>
7 
9  : _pdgId(PDGCode::invalid), _parent(), _children(), _position(), _momentum(), _status(undefined)
10 {}
11 
14  CLHEP::Hep3Vector const& position,
15  CLHEP::HepLorentzVector const& momentum,
17  : _pdgId(pdgId)
18  , _parent(parent)
19  , _children()
20  , _position(position)
21  , _momentum(momentum)
22  , _status(status)
23 {}
24 
25 void
27 {
28  _children.push_back(child);
29 }
30 
31 std::ostream&
32 artg4tk::operator<<(std::ostream& ost, const artg4tk::GenParticle& genp)
33 {
34  ost << "[ "
35  << "pdg: " << genp.pdgId() << " "
36  << "Position: " << genp.position() << " "
37  << "4-momentum " << genp.momentum() << " "
38  << "status: " << genp.status() << " "
39  << "parent: ";
40  if (genp.parent().id() == art::ProductID()) {
41  ost << "none ";
42  } else {
43  ost << genp.parent().id() << " " << genp.parent().key() << " ";
44  }
45  ost << " children: ";
46 
47  if (genp.children().empty()) {
48  ost << "none";
49  } else {
50  ost << "( ";
51  for (auto const& child : genp.children()) {
52  ost << " " << child.id() << "." << child.key();
53  }
54  ost << " )";
55  }
56  ost << " ]";
57  return ost;
58 }
CLHEP::Hep3Vector const & position() const
Definition: GenParticle.hh:55
std::ostream & operator<<(std::ostream &ost, const GenParticle &genp)
Definition: GenParticle.cc:32
art::Ptr< GenParticle > const & parent() const
Definition: GenParticle.hh:40
art::Ptr< GenParticle > const & child(size_t i) const
Definition: GenParticle.hh:50
PDGCode::type _pdgId
Definition: GenParticle.hh:84
status_type _status
Definition: GenParticle.hh:94
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
PDGCode::type pdgId() const
Definition: GenParticle.hh:35
bool empty() const
Definition: PtrVector.h:330
CLHEP::HepLorentzVector const & momentum() const
Definition: GenParticle.hh:60
children_type const & children() const
Definition: GenParticle.hh:45
CLHEP::HepLorentzVector _momentum
Definition: GenParticle.hh:92
art::Ptr< GenParticle > _parent
Definition: GenParticle.hh:87
status_type status() const
Definition: GenParticle.hh:65
Definition: fwd.h:26
children_type _children
Definition: GenParticle.hh:88
CLHEP::Hep3Vector _position
Definition: GenParticle.hh:91
void addChild(art::Ptr< GenParticle > const &child)
Definition: GenParticle.cc:26