Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4InuclParticle.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id$
27//
28// 20100409 M. Kelsey -- Drop unused string argument from ctors.
29// 20110721 M. Kelsey -- Add model ID as optional ctor argument (so subclasses
30// don't have to call SetModel()).
31// 20110922 M. Kelsey -- Add stream argument to printParticle() => print()
32
33#include <cmath>
34
35#include "G4InuclParticle.hh"
36#include "G4ios.hh"
37#include "G4SystemOfUnits.hh"
38
39// Internal constructor only usable by subclasses
41 const G4LorentzVector& mom,
43 : modelId(model) {
44 setDefinition(pd);
45 setMomentum(mom);
46}
47
48
49// Assignment operator for use with std::sort()
51 pDP = right.pDP;
52 modelId = right.modelId;
53
54 return *this;
55}
56
57
58// Set particle definition allowing for null pointer to erase DynPart content
60 if (pd) pDP.SetDefinition(pd);
61 else {
62 static const G4DynamicParticle empty; // To zero out everything
63 pDP = empty;
64 }
65}
66
67
68// WARNING! Bertini code doesn't do four-vectors; repair mass before use!
70 G4double mass = getMass();
71 if (std::fabs(mass-mom.m()) <= 1e-5)
72 pDP.Set4Momentum(mom*GeV/MeV); // From Bertini to G4 units
73 else
74 pDP.SetMomentum(mom.vect()*GeV/MeV); // Don't change current mass!
75}
76
77
78// Proper stream output (just calls print())
79
80std::ostream& operator<<(std::ostream& os, const G4InuclParticle& part) {
81 part.print(os);
82 return os;
83}
84
85void G4InuclParticle::print(std::ostream& os) const {
87 os << " px " << mom.px() << " py " << mom.py() << " pz " << mom.pz()
88 << " pmod " << mom.rho() << " E " << mom.e()
89 << " creator model " << modelId;
90}
91
std::ostream & operator<<(std::ostream &os, const G4InuclParticle &part)
double G4double
Definition: G4Types.hh:64
Hep3Vector vect() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void Set4Momentum(const G4LorentzVector &momentum)
void SetMomentum(const G4ThreeVector &momentum)
virtual void print(std::ostream &os) const
G4InuclParticle & operator=(const G4InuclParticle &right)
G4double getMass() const
G4LorentzVector getMomentum() const
void setMomentum(const G4LorentzVector &mom)
void setDefinition(G4ParticleDefinition *pd)