Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // Alain Boudard, CEA-Saclay, France
28 // Joseph Cugnon, University of Liege, Belgium
29 // Jean-Christophe David, CEA-Saclay, France
30 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
31 // Sylvie Leray, CEA-Saclay, France
32 // Davide Mancusi, CEA-Saclay, France
33 //
34 #define INCLXX_IN_GEANT4_MODE 1
35 
36 #include "globals.hh"
37 
38 /*
39  * Particle.cc
40  *
41  * \date Jun 5, 2009
42  * \author Pekka Kaitaniemi
43  */
44 
45 #include "G4INCLParticle.hh"
46 #include "G4INCLParticleTable.hh"
47 
48 namespace G4INCL {
49 
50  G4ThreadLocal long Particle::nextID = 1;
51 
53  : theZ(0), theA(0),
54  theParticipantType(TargetSpectator),
55  theType(UnknownParticle),
56  theEnergy(0.0),
57  thePropagationEnergy(&theEnergy),
58  theFrozenEnergy(theEnergy),
59  theMomentum(ThreeVector(0.,0.,0.)),
60  thePropagationMomentum(&theMomentum),
61  theFrozenMomentum(theMomentum),
62  thePosition(ThreeVector(0.,0.,0.)),
63  nCollisions(0),
64  nDecays(0),
65  thePotentialEnergy(0.0),
66  rpCorrelated(false),
67  uncorrelatedMomentum(0.),
68  theHelicity(0.0),
69  emissionTime(0.0),
70  outOfWell(false),
71  theMass(0.)
72  {
73  ID = nextID;
74  nextID++;
75  }
76 
78  ThreeVector const &momentum, ThreeVector const &position)
79  : theEnergy(energy),
80  thePropagationEnergy(&theEnergy),
81  theFrozenEnergy(theEnergy),
82  theMomentum(momentum),
83  thePropagationMomentum(&theMomentum),
84  theFrozenMomentum(theMomentum),
85  thePosition(position),
86  nCollisions(0), nDecays(0),
87  thePotentialEnergy(0.),
88  rpCorrelated(false),
89  uncorrelatedMomentum(theMomentum.mag()),
90  theHelicity(0.0),
91  emissionTime(0.0), outOfWell(false)
92  {
94  ID = nextID;
95  nextID++;
96  if(theEnergy <= 0.0) {
97  INCL_WARN("Particle with energy " << theEnergy << " created." << '\n');
98  }
99  setType(t);
101  }
102 
104  ThreeVector const &momentum, ThreeVector const &position)
105  : thePropagationEnergy(&theEnergy),
106  theMomentum(momentum),
107  thePropagationMomentum(&theMomentum),
108  theFrozenMomentum(theMomentum),
109  thePosition(position),
110  nCollisions(0), nDecays(0),
111  thePotentialEnergy(0.),
112  rpCorrelated(false),
113  uncorrelatedMomentum(theMomentum.mag()),
114  theHelicity(0.0),
115  emissionTime(0.0), outOfWell(false)
116  {
118  ID = nextID;
119  nextID++;
120  setType(t);
121  if( isResonance() ) {
122  INCL_ERROR("Cannot create resonance without specifying its momentum four-vector." << '\n');
123  }
124  G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
125  theEnergy = energy;
127  }
128 
130  const G4double p2 = theMomentum.mag2();
131  G4double newp2 = theEnergy*theEnergy - theMass*theMass;
132  if( newp2<0.0 ) {
133  INCL_ERROR("Particle has E^2 < m^2." << '\n' << print());
134  newp2 = 0.0;
135  theEnergy = theMass;
136  }
137 
138  theMomentum *= std::sqrt(newp2/p2);
139  return theMomentum;
140  }
141 
143  theEnergy = std::sqrt(theMomentum.mag2() + theMass*theMass);
144  return theEnergy;
145  }
146 
148  for(const_iterator i=begin(), e=end(); i!=e; ++i) {
149  (*i)->rotatePositionAndMomentum(angle, axis);
150  }
151  }
152 
153  void ParticleList::rotatePosition(const G4double angle, const ThreeVector &axis) const {
154  for(const_iterator i=begin(), e=end(); i!=e; ++i) {
155  (*i)->rotatePosition(angle, axis);
156  }
157  }
158 
159  void ParticleList::rotateMomentum(const G4double angle, const ThreeVector &axis) const {
160  for(const_iterator i=begin(), e=end(); i!=e; ++i) {
161  (*i)->rotateMomentum(angle, axis);
162  }
163  }
164 
165  void ParticleList::boost(const ThreeVector &b) const {
166  for(const_iterator i=begin(), e=end(); i!=e; ++i) {
167  (*i)->boost(b);
168  }
169  }
170 }
ParticipantType theParticipantType
void rotatePosition(const G4double angle, const ThreeVector &axis) const
void setMass(G4double mass)
G4bool isResonance() const
Is it a resonance?
#define INCL_ERROR(x)
G4double adjustEnergyFromMomentum()
Recompute the energy to match the momentum.
std::string print() const
static G4double angle[DIM]
#define INCL_WARN(x)
#define G4ThreadLocal
Definition: tls.hh:89
G4double mag2() const
G4double getInvariantMass() const
Get the the particle invariant mass.
void boost(const ThreeVector &b) const
G4double energy(const ThreeVector &p, const G4double m)
void setType(ParticleType t)
void rotatePositionAndMomentum(const G4double angle, const ThreeVector &axis) const
G4INCL::ThreeVector theMomentum
double G4double
Definition: G4Types.hh:76
G4double theFrozenEnergy
void rotateMomentum(const G4double angle, const ThreeVector &axis) const
const ThreeVector & adjustMomentumFromEnergy()
Rescale the momentum to match the total energy.