Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCLParticle.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// INCL++ intra-nuclear cascade model
27// Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28// Davide Mancusi, CEA
29// Alain Boudard, CEA
30// Sylvie Leray, CEA
31// Joseph Cugnon, University of Liege
32//
33// INCL++ revision: v5.1.8
34//
35#define INCLXX_IN_GEANT4_MODE 1
36
37#include "globals.hh"
38
39/*
40 * Particle.cc
41 *
42 * \date Jun 5, 2009
43 * \author Pekka Kaitaniemi
44 */
45
46#include "G4INCLParticle.hh"
48
49namespace G4INCL {
50
51 long Particle::nextID = 1;
52
54 : theZ(0), theA(0),
55 theParticipantType(TargetSpectator),
56 theType(UnknownParticle),
57 theEnergy(0.0),
58 thePropagationEnergy(&theEnergy),
59 theFrozenEnergy(theEnergy),
60 theMomentum(ThreeVector(0.,0.,0.)),
61 thePropagationMomentum(&theMomentum),
62 theFrozenMomentum(theMomentum),
63 thePosition(ThreeVector(0.,0.,0.)),
64 nCollisions(0),
65 nDecays(0),
66 thePotentialEnergy(0.0),
67 theHelicity(0.0),
68 emissionTime(0.0),
69 outOfWell(false),
70 theMass(0.)
71 {
72 ID = nextID;
73 nextID++;
74 }
75
78 : theEnergy(energy),
79 thePropagationEnergy(&theEnergy),
80 theFrozenEnergy(theEnergy),
81 theMomentum(momentum),
82 thePropagationMomentum(&theMomentum),
83 theFrozenMomentum(theMomentum),
84 thePosition(position),
85 nCollisions(0), nDecays(0),
86 thePotentialEnergy(0.), theHelicity(0.0),
87 emissionTime(0.0), outOfWell(false)
88 {
90 ID = nextID;
91 nextID++;
92 if(theEnergy <= 0.0) {
93 WARN("Particle with energy " << theEnergy << " created." << std::endl);
94 }
95 setType(t);
97 }
98
101 : thePropagationEnergy(&theEnergy),
102 theMomentum(momentum),
103 thePropagationMomentum(&theMomentum),
104 theFrozenMomentum(theMomentum),
105 thePosition(position),
106 nCollisions(0), nDecays(0),
107 thePotentialEnergy(0.), theHelicity(0.0),
108 emissionTime(0.0), outOfWell(false)
109 {
111 ID = nextID;
112 nextID++;
113 setType(t);
114 if( isResonance() ) {
115 ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
116 }
117 G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
118 theEnergy = energy;
120 }
121
123 const G4double p2 = theMomentum.mag2();
124 G4double newp2 = theEnergy*theEnergy - theMass*theMass;
125 if( newp2<0.0 ) {
126 ERROR("Particle has E^2 < m^2." << std::endl << print());
127 newp2 = 0.0;
128 theEnergy = theMass;
129 }
130
131 theMomentum *= std::sqrt(newp2/p2);
132 return theMomentum;
133 }
134
136 theEnergy = std::sqrt(theMomentum.mag2() + theMass*theMass);
137 return theEnergy;
138 }
139}
#define WARN(x)
#define ERROR(x)
double G4double
Definition: G4Types.hh:64
G4INCL::ThreeVector theMomentum
void setMass(G4double mass)
ParticipantType theParticipantType
G4double adjustEnergyFromMomentum()
Recompute the energy to match the momentum.
const ThreeVector & adjustMomentumFromEnergy()
Rescale the momentum to match the total energy.
G4double theFrozenEnergy
G4double getInvariantMass() const
Get the the particle invariant mass.
G4bool isResonance() const
Is it a resonance?
void setType(ParticleType t)
std::string print() const
G4double mag2() const