BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSParticle.cc
1 /*
2 Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3 University of London 2001 - 2018.
4 
5 This file is part of BDSIM.
6 
7 BDSIM is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published
9 by the Free Software Foundation version 3 of the License.
10 
11 BDSIM is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "BDSParticle.hh"
20 
21 #include <ostream>
22 
23 BDSParticle::BDSParticle():
24  position(0,0,0),
25  momentum(0,0,0),
26  totalEnergy(0.0),
27  T(0.0),
28  weight(1.0),
29  trackID(-1),
30  parentID(-1)
31 {;}
32 
33 BDSParticle::BDSParticle(G4double x,
34  G4double y,
35  G4double z,
36  G4double xp,
37  G4double yp,
38  G4double zp,
39  G4double totalEnergyIn,
40  G4double globalTimeIn,
41  G4double weightIn,
42  G4int trackIDIn,
43  G4int parentIDIn):
44  position(x,y,z),
45  momentum(xp,yp,zp),
46  totalEnergy(totalEnergyIn),
47  T(globalTimeIn),
48  weight(weightIn),
49  trackID(trackIDIn),
50  parentID(parentIDIn)
51 {;}
52 
53 BDSParticle::BDSParticle(G4ThreeVector pos,
54  G4ThreeVector mom,
55  G4double totalEnergyIn,
56  G4double globalTimeIn,
57  G4double weightIn,
58  G4int trackIDIn,
59  G4int parentIDIn):
60  position(pos),
61  momentum(mom),
62  totalEnergy(totalEnergyIn),
63  T(globalTimeIn),
64  weight(weightIn),
65  trackID(trackIDIn),
66  parentID(parentIDIn)
67 {;}
68 
69 std::ostream& operator<< (std::ostream& out, BDSParticle const& p)
70 {
71  out << "Total E: " << p.GetTotalEnergy() << " MeV" << G4endl;
72  out << "Position: (" << p.GetX() << ", " << p.GetY() << ", " << p.GetZ() << ")" << G4endl;
73  out << "Momentum: (" << p.GetXp() << ", " << p.GetYp() << ", " << p.GetZp() << ")" << G4endl;
74  return out;
75 }
friend std::ostream & operator<<(std::ostream &out, BDSBeamline const &bl)
output stream
Definition: BDSBeamline.cc:107
a particle definition
Definition: BDSParticle.hh:36