Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 // 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 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 /*
38  * Particle.cc
39  *
40  * \date Jun 5, 2009
41  * \author Pekka Kaitaniemi
42  */
43 
44 #include "G4INCLParticle.hh"
45 #include "G4INCLParticleTable.hh"
46 
47 namespace G4INCL {
48 
49  G4ThreadLocal long Particle::nextID = 1;
50 
52  : theZ(0), theA(0),
53  theParticipantType(TargetSpectator),
54  theType(UnknownParticle),
55  theEnergy(0.0),
56  thePropagationEnergy(&theEnergy),
57  theFrozenEnergy(theEnergy),
58  theMomentum(ThreeVector(0.,0.,0.)),
59  thePropagationMomentum(&theMomentum),
60  theFrozenMomentum(theMomentum),
61  thePosition(ThreeVector(0.,0.,0.)),
62  nCollisions(0),
63  nDecays(0),
64  thePotentialEnergy(0.0),
65  rpCorrelated(false),
66  uncorrelatedMomentum(0.),
67  theHelicity(0.0),
68  emissionTime(0.0),
69  outOfWell(false),
70  theMass(0.)
71  {
72  ID = nextID;
73  nextID++;
74  }
75 
77  ThreeVector const &momentum, ThreeVector const &position)
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.),
87  rpCorrelated(false),
88  uncorrelatedMomentum(theMomentum.mag()),
89  theHelicity(0.0),
90  emissionTime(0.0), outOfWell(false)
91  {
93  ID = nextID;
94  nextID++;
95  if(theEnergy <= 0.0) {
96  INCL_WARN("Particle with energy " << theEnergy << " created." << std::endl);
97  }
98  setType(t);
100  }
101 
103  ThreeVector const &momentum, ThreeVector const &position)
104  : thePropagationEnergy(&theEnergy),
105  theMomentum(momentum),
106  thePropagationMomentum(&theMomentum),
107  theFrozenMomentum(theMomentum),
108  thePosition(position),
109  nCollisions(0), nDecays(0),
110  thePotentialEnergy(0.),
111  rpCorrelated(false),
112  uncorrelatedMomentum(theMomentum.mag()),
113  theHelicity(0.0),
114  emissionTime(0.0), outOfWell(false)
115  {
117  ID = nextID;
118  nextID++;
119  setType(t);
120  if( isResonance() ) {
121  INCL_ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
122  }
123  G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
124  theEnergy = energy;
126  }
127 
129  const G4double p2 = theMomentum.mag2();
130  G4double newp2 = theEnergy*theEnergy - theMass*theMass;
131  if( newp2<0.0 ) {
132  INCL_ERROR("Particle has E^2 < m^2." << std::endl << print());
133  newp2 = 0.0;
134  theEnergy = theMass;
135  }
136 
137  theMomentum *= std::sqrt(newp2/p2);
138  return theMomentum;
139  }
140 
142  theEnergy = std::sqrt(theMomentum.mag2() + theMass*theMass);
143  return theEnergy;
144  }
145 }
ParticipantType theParticipantType
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
#define INCL_WARN(x)
#define G4ThreadLocal
Definition: tls.hh:52
G4double mag2() const
G4double getInvariantMass() const
Get the the particle invariant mass.
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
void setType(ParticleType t)
G4INCL::ThreeVector theMomentum
double G4double
Definition: G4Types.hh:76
G4double theFrozenEnergy
const ThreeVector & adjustMomentumFromEnergy()
Rescale the momentum to match the total energy.