Geant4  9.6.p02
 All Classes 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  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  theHelicity(0.0),
66  emissionTime(0.0),
67  outOfWell(false),
68  theMass(0.)
69  {
70  ID = nextID;
71  nextID++;
72  }
73 
76  : theEnergy(energy),
77  thePropagationEnergy(&theEnergy),
78  theFrozenEnergy(theEnergy),
79  theMomentum(momentum),
80  thePropagationMomentum(&theMomentum),
81  theFrozenMomentum(theMomentum),
82  thePosition(position),
83  nCollisions(0), nDecays(0),
84  thePotentialEnergy(0.), theHelicity(0.0),
85  emissionTime(0.0), outOfWell(false)
86  {
88  ID = nextID;
89  nextID++;
90  if(theEnergy <= 0.0) {
91  WARN("Particle with energy " << theEnergy << " created." << std::endl);
92  }
93  setType(t);
95  }
96 
99  : thePropagationEnergy(&theEnergy),
100  theMomentum(momentum),
101  thePropagationMomentum(&theMomentum),
102  theFrozenMomentum(theMomentum),
103  thePosition(position),
104  nCollisions(0), nDecays(0),
105  thePotentialEnergy(0.), theHelicity(0.0),
106  emissionTime(0.0), outOfWell(false)
107  {
109  ID = nextID;
110  nextID++;
111  setType(t);
112  if( isResonance() ) {
113  ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
114  }
115  G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
116  theEnergy = energy;
118  }
119 
121  const G4double p2 = theMomentum.mag2();
122  G4double newp2 = theEnergy*theEnergy - theMass*theMass;
123  if( newp2<0.0 ) {
124  ERROR("Particle has E^2 < m^2." << std::endl << print());
125  newp2 = 0.0;
126  theEnergy = theMass;
127  }
128 
129  theMomentum *= std::sqrt(newp2/p2);
130  return theMomentum;
131  }
132 
134  theEnergy = std::sqrt(theMomentum.mag2() + theMass*theMass);
135  return theEnergy;
136  }
137 }