Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/particles/management/src/G4DynamicParticle.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/management/src/G4DynamicParticle.cc (Version 11.3.0) and /particles/management/src/G4DynamicParticle.cc (Version 10.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4DynamicParticle class implementation      << 
 27 //                                                 26 //
 28 // History:                                    <<  27 // $Id: G4DynamicParticle.cc 81373 2014-05-27 13:06:32Z gcosmo $
 29 // - 2 December 1995, G.Cosmo - first design,  <<  28 //
 30 // - 29 January 1996, M.Asai - first implement <<  29 // 
 31 // - 1996 - 2007,     H.Kurashige - revisions. <<  30 // --------------------------------------------------------------
 32 // - 15 March 2019,   M.Novak - log-kinetic en <<  31 //  GEANT 4 class implementation file 
 33 //                    on demand if its stored  <<  32 //
 34 //-------------------------------------------- <<  33 //  History: first implementation, based on object model of
                                                   >>  34 //  2nd December 1995, G.Cosmo
                                                   >>  35 //      ---------------- G4DynamicParticle  ----------------
                                                   >>  36 //      first implementation by Makoto Asai, 29 January 1996
                                                   >>  37 //      revised by G.Cosmo, 29 February 1996
                                                   >>  38 //      revised by H.Kurashige 06 May 1996
                                                   >>  39 //      revised by Hisaya Kurashige, 27 July 1996
                                                   >>  40 //         modify thePreAssignedDecayProducts
                                                   >>  41 //         add   void SetMomentum(G4ThreeVector &momentum)
                                                   >>  42 //         add   void Set4Momentum(G4LorentzVector &momentum)
                                                   >>  43 //         add   G4DynamicParticle(G4ParticleDefinition * aParticleDefinition,
                                                   >>  44 //                                 G4LorentzVector &p4vector)
                                                   >>  45 //      revised by Hisaya Kurashige, 19 Oct 1996
                                                   >>  46 //         add    theKillProcess
                                                   >>  47 //         add    ProperTime
                                                   >>  48 //      revised by Hisaya Kurashige, 26 Mar 1997
                                                   >>  49 //         modify destructor
                                                   >>  50 //      revised by Hisaya Kurashige, 05 June 1997
                                                   >>  51 //         modify DumpInfo()
                                                   >>  52 //      revised by Hisaya Kurashige, 5  June 1998
                                                   >>  53 //         remove    theKillProcess
                                                   >>  54 //      revised by Hisaya Kurashige, 5  Mar 2001
                                                   >>  55 //         fixed  SetDefinition()
                                                   >>  56 //      revised by V.Ivanchenko,    12 June 2003
                                                   >>  57 //         fixed problem of massless particles
                                                   >>  58 //      revised by V.Ivanchenko,    18 June 2003
                                                   >>  59 //         take into account the case of virtual photons
                                                   >>  60 //      revised by M.Kelsey         12 May 2010
                                                   >>  61 //     ensure that all constructors initialize all data members
                                                   >>  62 //--------------------------------------------------------------
 35                                                    63 
 36 #include "G4DynamicParticle.hh"                    64 #include "G4DynamicParticle.hh"
 37                                                <<  65 #include "G4PhysicalConstants.hh"
                                                   >>  66 #include "G4SystemOfUnits.hh"
 38 #include "G4DecayProducts.hh"                      67 #include "G4DecayProducts.hh"
 39 #include "G4IonTable.hh"                       << 
 40 #include "G4LorentzVector.hh"                      68 #include "G4LorentzVector.hh"
 41 #include "G4ParticleDefinition.hh"                 69 #include "G4ParticleDefinition.hh"
                                                   >>  70 #include "G4ParticleTable.hh"
                                                   >>  71 #include "G4IonTable.hh"
 42 #include "G4PrimaryParticle.hh"                    72 #include "G4PrimaryParticle.hh"
 43                                                    73 
 44 G4Allocator<G4DynamicParticle>*& pDynamicParti <<  74 G4ThreadLocal G4Allocator<G4DynamicParticle> *pDynamicParticleAllocator = 0;
 45 {                                              << 
 46   G4ThreadLocalStatic G4Allocator<G4DynamicPar << 
 47   return _instance;                            << 
 48 }                                              << 
 49                                                    75 
 50 static const G4double EnergyMomentumRelationAl <<  76 static const G4double EnergyMomentumRelationAllowance = keV;
 51 static const G4double EnergyMRA2 =             << 
 52   EnergyMomentumRelationAllowance * EnergyMome << 
 53                                                << 
 54 G4DynamicParticle::G4DynamicParticle()         << 
 55   : theMomentumDirection(0.0, 0.0, 1.0), thePo << 
 56 {}                                             << 
 57                                                << 
 58 G4DynamicParticle::G4DynamicParticle(const G4P << 
 59                                      const G4T << 
 60                                      G4double  << 
 61   : theMomentumDirection(aMomentumDirection),  << 
 62     thePolarization(0.0, 0.0, 0.0),            << 
 63     theParticleDefinition(aParticleDefinition) << 
 64     theKineticEnergy(aKineticEnergy),          << 
 65     theDynamicalMass(aParticleDefinition->GetP << 
 66     theDynamicalCharge(aParticleDefinition->Ge << 
 67     theDynamicalSpin(aParticleDefinition->GetP << 
 68     theDynamicalMagneticMoment(aParticleDefini << 
 69 {}                                             << 
 70                                                << 
 71 G4DynamicParticle::G4DynamicParticle(const G4P << 
 72                                      const G4T << 
 73                                      G4double  << 
 74   : theMomentumDirection(aMomentumDirection),  << 
 75     thePolarization(0.0, 0.0, 0.0),            << 
 76     theParticleDefinition(aParticleDefinition) << 
 77     theKineticEnergy(aKineticEnergy),          << 
 78     theDynamicalMass(aParticleDefinition->GetP << 
 79     theDynamicalCharge(aParticleDefinition->Ge << 
 80     theDynamicalSpin(aParticleDefinition->GetP << 
 81     theDynamicalMagneticMoment(aParticleDefini << 
 82 {                                              << 
 83   if (std::abs(theDynamicalMass - dynamicalMas << 
 84     if (dynamicalMass > EnergyMomentumRelation << 
 85       theDynamicalMass = dynamicalMass;        << 
 86     else                                       << 
 87       theDynamicalMass = 0.0;                  << 
 88   }                                            << 
 89 }                                              << 
 90                                                    77 
 91 G4DynamicParticle::G4DynamicParticle(const G4P <<  78 ////////////////////
 92                                      const G4T <<  79 G4DynamicParticle::G4DynamicParticle():
 93   : thePolarization(0.0, 0.0, 0.0),            <<  80        theMomentumDirection(0.0,0.0,1.0),
 94     theParticleDefinition(aParticleDefinition) <<  81        theParticleDefinition(0),
 95     theDynamicalMass(aParticleDefinition->GetP <<  82        theKineticEnergy(0.0),
 96     theDynamicalCharge(aParticleDefinition->Ge <<  83        theProperTime(0.0),
 97     theDynamicalSpin(aParticleDefinition->GetP <<  84        theDynamicalMass(0.0),
 98     theDynamicalMagneticMoment(aParticleDefini <<  85        theDynamicalCharge(0.0),
                                                   >>  86        theDynamicalSpin(0.0),
                                                   >>  87        theDynamicalMagneticMoment(0.0),
                                                   >>  88        theElectronOccupancy(0),
                                                   >>  89                    thePreAssignedDecayProducts(0),
                                                   >>  90                    thePreAssignedDecayTime(-1.0),
                                                   >>  91        verboseLevel(1),
                                                   >>  92        primaryParticle(0),
                                                   >>  93                    thePDGcode(0)
                                                   >>  94 {
                                                   >>  95 }
                                                   >>  96 
                                                   >>  97 ////////////////////
                                                   >>  98 // -- constructors ----
                                                   >>  99 ////////////////////
                                                   >> 100 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
                                                   >> 101              const G4ThreeVector& aMomentumDirection,
                                                   >> 102              G4double aKineticEnergy):
                                                   >> 103        theMomentumDirection(aMomentumDirection),
                                                   >> 104        theParticleDefinition(aParticleDefinition),
                                                   >> 105        theKineticEnergy(aKineticEnergy),
                                                   >> 106        theProperTime(0.0),
                                                   >> 107        theDynamicalMass(aParticleDefinition->GetPDGMass()),
                                                   >> 108        theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
                                                   >> 109        theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
                                                   >> 110        theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
                                                   >> 111        theElectronOccupancy(0),
                                                   >> 112                    thePreAssignedDecayProducts(0),
                                                   >> 113                    thePreAssignedDecayTime(-1.0),
                                                   >> 114        verboseLevel(1),
                                                   >> 115        primaryParticle(0),
                                                   >> 116                    thePDGcode(0)
                                                   >> 117 {
                                                   >> 118 }
                                                   >> 119 
                                                   >> 120 ////////////////////
                                                   >> 121 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
                                                   >> 122              const G4ThreeVector& aMomentumDirection,
                                                   >> 123              G4double aKineticEnergy,
                                                   >> 124                                      const G4double dynamicalMass):
                                                   >> 125        theMomentumDirection(aMomentumDirection),
                                                   >> 126        theParticleDefinition(aParticleDefinition),
                                                   >> 127        theKineticEnergy(aKineticEnergy),
                                                   >> 128        theProperTime(0.0),
                                                   >> 129        theDynamicalMass(dynamicalMass),
                                                   >> 130        theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
                                                   >> 131        theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
                                                   >> 132        theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
                                                   >> 133        theElectronOccupancy(0),
                                                   >> 134                    thePreAssignedDecayProducts(0),
                                                   >> 135                    thePreAssignedDecayTime(-1.0),
                                                   >> 136        verboseLevel(1),
                                                   >> 137        primaryParticle(0),
                                                   >> 138                    thePDGcode(0)
                                                   >> 139 {
                                                   >> 140 }
                                                   >> 141 
                                                   >> 142 ////////////////////
                                                   >> 143 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
                                                   >> 144                                      const G4ThreeVector& aParticleMomentum):
                                                   >> 145        theParticleDefinition(aParticleDefinition),
                                                   >> 146        theKineticEnergy(0.0),
                                                   >> 147              theProperTime(0.0),
                                                   >> 148        theDynamicalMass(aParticleDefinition->GetPDGMass()),
                                                   >> 149        theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
                                                   >> 150        theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
                                                   >> 151        theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
                                                   >> 152        theElectronOccupancy(0),
                                                   >> 153                    thePreAssignedDecayProducts(0),
                                                   >> 154                    thePreAssignedDecayTime(-1.0),
                                                   >> 155        verboseLevel(1),
                                                   >> 156        primaryParticle(0),
                                                   >> 157                    thePDGcode(0)
 99 {                                                 158 {
100   SetMomentum(aParticleMomentum);  // 3-dim mo    159   SetMomentum(aParticleMomentum);  // 3-dim momentum is given
101 }                                                 160 }
102                                                   161 
103 G4DynamicParticle::G4DynamicParticle(const G4P << 162 
104                                      const G4L << 163 ////////////////////
105   : thePolarization(0.0, 0.0, 0.0),            << 164 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
106     theParticleDefinition(aParticleDefinition) << 165              const G4LorentzVector   &aParticleMomentum):
107     theDynamicalMass(aParticleDefinition->GetP << 166        theParticleDefinition(aParticleDefinition),
108     theDynamicalCharge(aParticleDefinition->Ge << 167        theKineticEnergy(0.0),
109     theDynamicalSpin(aParticleDefinition->GetP << 168        theProperTime(0.0),
110     theDynamicalMagneticMoment(aParticleDefini << 169        theDynamicalMass(aParticleDefinition->GetPDGMass()),
111 {                                              << 170        theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
112   Set4Momentum(aParticleMomentum);  // 4-momen << 171        theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
113 }                                              << 172        theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
114                                                << 173        theElectronOccupancy(0),
115 G4DynamicParticle::G4DynamicParticle(const G4P << 174                    thePreAssignedDecayProducts(0),
116                                      G4double  << 175                    thePreAssignedDecayTime(-1.0),
117   : thePolarization(0.0, 0.0, 0.0),            << 176        verboseLevel(1),
118     theParticleDefinition(aParticleDefinition) << 177        primaryParticle(0),
119     theDynamicalMass(aParticleDefinition->GetP << 178                    thePDGcode(0)
120     theDynamicalCharge(aParticleDefinition->Ge << 179 {
121     theDynamicalSpin(aParticleDefinition->GetP << 180   Set4Momentum(aParticleMomentum);  // 4-momentum vector (Lorentz vector) is given
122     theDynamicalMagneticMoment(aParticleDefini << 181 }
                                                   >> 182 
                                                   >> 183 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
                                                   >> 184                                      G4double totalEnergy,
                                                   >> 185              const G4ThreeVector &aParticleMomentum):
                                                   >> 186                    theParticleDefinition(aParticleDefinition),
                                                   >> 187        theKineticEnergy(0.0),
                                                   >> 188                    theProperTime(0.0),
                                                   >> 189        theDynamicalMass(aParticleDefinition->GetPDGMass()),
                                                   >> 190        theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
                                                   >> 191        theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
                                                   >> 192        theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
                                                   >> 193        theElectronOccupancy(0),
                                                   >> 194                    thePreAssignedDecayProducts(0),
                                                   >> 195                    thePreAssignedDecayTime(-1.0),
                                                   >> 196        verboseLevel(1),
                                                   >> 197        primaryParticle(0),
                                                   >> 198                    thePDGcode(0)
123 {                                                 199 {
124   // total energy and 3-dim momentum are given    200   // total energy and 3-dim momentum are given
125   G4double pModule2 = aParticleMomentum.mag2()    201   G4double pModule2 = aParticleMomentum.mag2();
126   if (pModule2 > 0.0) {                        << 202   if (pModule2>0.0) {
127     G4double mass2 = totalEnergy * totalEnergy << 203     G4double mass2 = totalEnergy*totalEnergy - pModule2;
128     G4double PDGmass2 = (aParticleDefinition-> << 204     if(mass2 < EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance) {
129     SetMomentumDirection(aParticleMomentum.uni << 
130     if (mass2 < EnergyMRA2) {                  << 
131       theDynamicalMass = 0.;                      205       theDynamicalMass = 0.;
                                                   >> 206       SetMomentumDirection(aParticleMomentum.unit());
132       SetKineticEnergy(totalEnergy);              207       SetKineticEnergy(totalEnergy);
                                                   >> 208     } else {
                                                   >> 209       theDynamicalMass = std::sqrt(mass2);
                                                   >> 210       SetMomentum(aParticleMomentum);
133     }                                             211     }
134     else {                                     << 212   } else {
135       if (std::abs(PDGmass2 - mass2) > EnergyM << 213     SetMomentumDirection(1.0,0.0,0.0);
136         theDynamicalMass = std::sqrt(mass2);   << 
137         SetKineticEnergy(totalEnergy - theDyna << 
138       }                                        << 
139       else {                                   << 
140         SetKineticEnergy(totalEnergy - theDyna << 
141       }                                        << 
142     }                                          << 
143   }                                            << 
144   else {                                       << 
145     SetMomentumDirection(1.0, 0.0, 0.0);       << 
146     SetKineticEnergy(0.0);                        214     SetKineticEnergy(0.0);
147   }                                               215   }
148 }                                                 216 }
149                                                   217 
150 G4DynamicParticle::G4DynamicParticle(const G4D << 218 ////////////////////
151   : theMomentumDirection(right.theMomentumDire << 219 G4DynamicParticle::G4DynamicParticle(const G4DynamicParticle &right):
152     thePolarization(right.thePolarization),    << 220   theMomentumDirection(right.theMomentumDirection),
153     theParticleDefinition(right.theParticleDef << 221   theParticleDefinition(right.theParticleDefinition),
154     // Don't copy preassignedDecayProducts     << 222   thePolarization(right.thePolarization),
155     primaryParticle(right.primaryParticle),    << 223   theKineticEnergy(right.theKineticEnergy),
156     theKineticEnergy(right.theKineticEnergy),  << 224   theProperTime(0.0),
157     theLogKineticEnergy(right.theLogKineticEne << 225   theDynamicalMass(right.theDynamicalMass),
158     theBeta(right.theBeta),                    << 226   theDynamicalCharge(right.theDynamicalCharge),
159     theProperTime(right.theProperTime),        << 227   theDynamicalSpin(right.theDynamicalSpin),
160     theDynamicalMass(right.theDynamicalMass),  << 228   theDynamicalMagneticMoment(right.theDynamicalMagneticMoment),
161     theDynamicalCharge(right.theDynamicalCharg << 229   theElectronOccupancy(0),
162     theDynamicalSpin(right.theDynamicalSpin),  << 230   thePreAssignedDecayProducts(0), // Do not copy preassignedDecayProducts
163     theDynamicalMagneticMoment(right.theDynami << 231   thePreAssignedDecayTime(-1.0),
164                                                << 232   verboseLevel(right.verboseLevel),
165     verboseLevel(right.verboseLevel),          << 233   primaryParticle(right.primaryParticle),
166     thePDGcode(right.thePDGcode)               << 234   thePDGcode(right.thePDGcode)
167 {                                              << 235 {
168   if (right.theElectronOccupancy != nullptr) { << 236   if (right.theElectronOccupancy != 0) {
169     theElectronOccupancy = new G4ElectronOccup << 237       theElectronOccupancy =
                                                   >> 238   new G4ElectronOccupancy(*right.theElectronOccupancy);
170   }                                               239   }
171 }                                                 240 }
172                                                   241 
173 G4DynamicParticle::G4DynamicParticle(G4Dynamic << 242 ////////////////////
174   : theMomentumDirection(from.theMomentumDirec << 243 // -- destructor ----
175     thePolarization(from.thePolarization),     << 244 ////////////////////
176     theParticleDefinition(from.theParticleDefi << 
177     theElectronOccupancy(from.theElectronOccup << 
178     // Don't move preassignedDecayProducts     << 
179     primaryParticle(from.primaryParticle),     << 
180     theKineticEnergy(from.theKineticEnergy),   << 
181     theLogKineticEnergy(from.theLogKineticEner << 
182     theBeta(from.theBeta),                     << 
183     theProperTime(from.theProperTime),         << 
184     theDynamicalMass(from.theDynamicalMass),   << 
185     theDynamicalCharge(from.theDynamicalCharge << 
186     theDynamicalSpin(from.theDynamicalSpin),   << 
187     theDynamicalMagneticMoment(from.theDynamic << 
188                                                << 
189     verboseLevel(from.verboseLevel),           << 
190     thePDGcode(from.thePDGcode)                << 
191 {                                              << 
192   // Release the data from the source object   << 
193   from.theParticleDefinition = nullptr;        << 
194   from.theElectronOccupancy = nullptr;         << 
195   from.thePreAssignedDecayProducts = nullptr;  << 
196   from.primaryParticle = nullptr;              << 
197 }                                              << 
198                                                << 
199 G4DynamicParticle::~G4DynamicParticle()           245 G4DynamicParticle::~G4DynamicParticle()
200 {                                                 246 {
201   delete thePreAssignedDecayProducts;          << 247   //  delete thePreAssignedDecayProducts
202   thePreAssignedDecayProducts = nullptr;       << 248   if (thePreAssignedDecayProducts != 0) delete thePreAssignedDecayProducts;
                                                   >> 249   thePreAssignedDecayProducts = 0;
203                                                   250 
204   delete theElectronOccupancy;                 << 251   if (theElectronOccupancy != 0) delete theElectronOccupancy;
205   theElectronOccupancy = nullptr;              << 252   theElectronOccupancy =0;
206 }                                                 253 }
207                                                   254 
208 G4DynamicParticle& G4DynamicParticle::operator << 255 
                                                   >> 256 ////////////////////
                                                   >> 257 // -- operators ----
                                                   >> 258 ////////////////////
                                                   >> 259 G4DynamicParticle & G4DynamicParticle::operator=(const G4DynamicParticle &right)
209 {                                                 260 {
210   if (this != &right) {                           261   if (this != &right) {
211     theMomentumDirection = right.theMomentumDi    262     theMomentumDirection = right.theMomentumDirection;
212     theParticleDefinition = right.theParticleD    263     theParticleDefinition = right.theParticleDefinition;
213     thePolarization = right.thePolarization;      264     thePolarization = right.thePolarization;
214     theKineticEnergy = right.theKineticEnergy;    265     theKineticEnergy = right.theKineticEnergy;
215     theProperTime = right.theProperTime;          266     theProperTime = right.theProperTime;
216                                                   267 
217     theDynamicalMass = right.theDynamicalMass;    268     theDynamicalMass = right.theDynamicalMass;
218     theDynamicalCharge = right.theDynamicalCha    269     theDynamicalCharge = right.theDynamicalCharge;
219     theDynamicalSpin = right.theDynamicalSpin;    270     theDynamicalSpin = right.theDynamicalSpin;
220     theDynamicalMagneticMoment = right.theDyna    271     theDynamicalMagneticMoment = right.theDynamicalMagneticMoment;
221                                                   272 
222     delete theElectronOccupancy;               << 273     if (theElectronOccupancy != 0) delete theElectronOccupancy;
223     if (right.theElectronOccupancy != nullptr) << 274     if (right.theElectronOccupancy != 0){
224       theElectronOccupancy = new G4ElectronOcc << 275       theElectronOccupancy =
225     }                                          << 276              new G4ElectronOccupancy(*right.theElectronOccupancy);
226     else {                                     << 277     } else {
227       theElectronOccupancy = nullptr;          << 278       theElectronOccupancy = 0;
228     }                                             279     }
229                                                   280 
230     // thePreAssignedDecayProducts must not be    281     // thePreAssignedDecayProducts must not be copied.
231     thePreAssignedDecayProducts = nullptr;     << 282     thePreAssignedDecayProducts = 0;
232     thePreAssignedDecayTime = -1.0;               283     thePreAssignedDecayTime = -1.0;
233                                                   284 
234     verboseLevel = right.verboseLevel;            285     verboseLevel = right.verboseLevel;
235                                                   286 
236     // Primary particle information must be pr    287     // Primary particle information must be preserved
237     //*** primaryParticle = right.primaryParti    288     //*** primaryParticle = right.primaryParticle;
238                                                   289 
239     thePDGcode = right.thePDGcode;                290     thePDGcode = right.thePDGcode;
240   }                                               291   }
241   return *this;                                   292   return *this;
242 }                                                 293 }
243                                                   294 
244 G4DynamicParticle& G4DynamicParticle::operator << 295 ////////////////////
245 {                                              << 296 void G4DynamicParticle::SetDefinition(const G4ParticleDefinition * aParticleDefinition)
246   if (this != &from) {                         << 
247     theMomentumDirection = from.theMomentumDir << 
248     thePolarization = from.thePolarization;    << 
249     theKineticEnergy = from.theKineticEnergy;  << 
250     theProperTime = from.theProperTime;        << 
251                                                << 
252     theDynamicalMass = from.theDynamicalMass;  << 
253     theDynamicalCharge = from.theDynamicalChar << 
254     theDynamicalSpin = from.theDynamicalSpin;  << 
255     theDynamicalMagneticMoment = from.theDynam << 
256                                                << 
257     delete theElectronOccupancy;               << 
258     theElectronOccupancy = from.theElectronOcc << 
259     from.theElectronOccupancy = nullptr;       << 
260                                                << 
261     // thePreAssignedDecayProducts must not be << 
262     thePreAssignedDecayProducts = nullptr;     << 
263     from.thePreAssignedDecayProducts = nullptr << 
264     thePreAssignedDecayTime = -1.0;            << 
265                                                << 
266     theParticleDefinition = from.theParticleDe << 
267     from.theParticleDefinition = nullptr;      << 
268                                                << 
269     verboseLevel = from.verboseLevel;          << 
270                                                << 
271     primaryParticle = from.primaryParticle;    << 
272     from.primaryParticle = nullptr;            << 
273                                                << 
274     thePDGcode = from.thePDGcode;              << 
275   }                                            << 
276   return *this;                                << 
277 }                                              << 
278                                                << 
279 void G4DynamicParticle::SetDefinition(const G4 << 
280 {                                                 297 {
281   // remove preassigned decay                     298   // remove preassigned decay
282   if (thePreAssignedDecayProducts != nullptr)  << 299   if (thePreAssignedDecayProducts != 0) {
283 #ifdef G4VERBOSE                                  300 #ifdef G4VERBOSE
284     if (verboseLevel > 0) {                    << 301     if (verboseLevel>0) {
285       G4cout << " G4DynamicParticle::SetDefini    302       G4cout << " G4DynamicParticle::SetDefinition()::"
286              << "!!! Pre-assigned decay produc    303              << "!!! Pre-assigned decay products is attached !!!! " << G4endl;
287       G4cout << "!!! New Definition is " << aP << 304       G4cout << "!!! New Definition is " << aParticleDefinition->GetParticleName() 
288              << G4endl;                        << 305        << " !!! " << G4endl;
289       G4cout << "!!! Pre-assigned decay produc    306       G4cout << "!!! Pre-assigned decay products will be deleted !!!! " << G4endl;
290     }                                             307     }
291 #endif                                            308 #endif
292     delete thePreAssignedDecayProducts;           309     delete thePreAssignedDecayProducts;
293   }                                               310   }
294   thePreAssignedDecayProducts = nullptr;       << 311   thePreAssignedDecayProducts = 0;
295                                                   312 
296   theParticleDefinition = aParticleDefinition;    313   theParticleDefinition = aParticleDefinition;
297                                                   314 
298   // set Dynamic mass/charge                   << 315   // set Dynamic mass/chrge
299   SetMass(theParticleDefinition->GetPDGMass()) << 316   theDynamicalMass = theParticleDefinition->GetPDGMass();
300   theDynamicalCharge = theParticleDefinition->    317   theDynamicalCharge = theParticleDefinition->GetPDGCharge();
301   theDynamicalSpin = theParticleDefinition->Ge    318   theDynamicalSpin = theParticleDefinition->GetPDGSpin();
302   theDynamicalMagneticMoment = theParticleDefi    319   theDynamicalMagneticMoment = theParticleDefinition->GetPDGMagneticMoment();
303                                                   320 
304   // Set electron orbits                          321   // Set electron orbits
305   if (theElectronOccupancy != nullptr) {       << 322   if (theElectronOccupancy != 0) delete theElectronOccupancy;
306     delete theElectronOccupancy;               << 323   theElectronOccupancy =0;
307     theElectronOccupancy = nullptr;            << 324   //AllocateElectronOccupancy();
308   }                                            << 325 
309 }                                                 326 }
310                                                   327 
311 G4bool G4DynamicParticle::operator==(const G4D << 328 ////////////////////
                                                   >> 329 G4int G4DynamicParticle::operator==(const G4DynamicParticle &right) const
312 {                                                 330 {
313   return (this == (G4DynamicParticle*)&right); << 331   return (this == (G4DynamicParticle *) &right);
314 }                                                 332 }
315                                                   333 
316 G4bool G4DynamicParticle::operator!=(const G4D << 334 ////////////////////
                                                   >> 335 G4int G4DynamicParticle::operator!=(const G4DynamicParticle &right) const
317 {                                                 336 {
318   return (this != (G4DynamicParticle*)&right); << 337   return (this != (G4DynamicParticle *) &right);
319 }                                                 338 }
320                                                   339 
321 void G4DynamicParticle::AllocateElectronOccupa << 340 
                                                   >> 341 
                                                   >> 342 ////////////////////
                                                   >> 343 // -- AllocateElectronOccupancy --
                                                   >> 344 ////////////////////
                                                   >> 345 void  G4DynamicParticle::AllocateElectronOccupancy()
322 {                                                 346 {
323   if (G4IonTable::IsIon(theParticleDefinition) << 347   const G4ParticleDefinition* particle = GetDefinition();
                                                   >> 348 
                                                   >> 349   if (G4IonTable::IsIon(particle)) {
324     // Only ions can have ElectronOccupancy       350     // Only ions can have ElectronOccupancy
325     theElectronOccupancy = new G4ElectronOccup    351     theElectronOccupancy = new G4ElectronOccupancy();
326   }                                            << 352 
327   else {                                       << 353   } else {
328     theElectronOccupancy = nullptr;            << 354     theElectronOccupancy = 0;
                                                   >> 355 
329   }                                               356   }
330 }                                                 357 }
331                                                   358 
332 void G4DynamicParticle::SetMomentum(const G4Th << 359 ////////////////////
                                                   >> 360 // -- methods for setting Energy/Momentum  --
                                                   >> 361 ////////////////////
                                                   >> 362 void G4DynamicParticle::SetMomentum(const G4ThreeVector &momentum)
333 {                                                 363 {
334   G4double pModule2 = momentum.mag2();            364   G4double pModule2 = momentum.mag2();
335   if (pModule2 > 0.0) {                        << 365   if (pModule2>0.0) {
336     const G4double mass = theDynamicalMass;    << 366     G4double mass = theDynamicalMass;
337     SetMomentumDirection(momentum.unit());        367     SetMomentumDirection(momentum.unit());
338     SetKineticEnergy(pModule2 / (std::sqrt(pMo << 368     SetKineticEnergy(std::sqrt(pModule2 + mass*mass)-mass);
339   }                                            << 369   } else {
340   else {                                       << 370     SetMomentumDirection(1.0,0.0,0.0);
341     SetMomentumDirection(1.0, 0.0, 0.0);       << 
342     SetKineticEnergy(0.0);                        371     SetKineticEnergy(0.0);
343   }                                               372   }
344 }                                                 373 }
345                                                   374 
346 void G4DynamicParticle::Set4Momentum(const G4L << 375 ////////////////////
                                                   >> 376 void G4DynamicParticle::Set4Momentum(const G4LorentzVector &momentum )
347 {                                                 377 {
348   G4double pModule2 = momentum.vect().mag2();     378   G4double pModule2 = momentum.vect().mag2();
349   if (pModule2 > 0.0) {                        << 379   if (pModule2>0.0) {
350     SetMomentumDirection(momentum.vect().unit(    380     SetMomentumDirection(momentum.vect().unit());
351     const G4double totalenergy = momentum.t(); << 381     G4double totalenergy = momentum.t();
352     const G4double mass2 = totalenergy * total << 382     G4double mass2 = totalenergy*totalenergy - pModule2;
353     const G4double PDGmass2 =                  << 383     if(mass2 < EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance) {
354       (theParticleDefinition->GetPDGMass()) *  << 
355     if (mass2 < EnergyMRA2) {                  << 
356       theDynamicalMass = 0.;                      384       theDynamicalMass = 0.;
357     }                                          << 385       SetKineticEnergy(totalenergy);
358     else if (std::abs(PDGmass2 - mass2) > Ener << 386     } else {
359       theDynamicalMass = std::sqrt(mass2);        387       theDynamicalMass = std::sqrt(mass2);
                                                   >> 388       SetKineticEnergy(totalenergy-theDynamicalMass);
360     }                                             389     }
361     SetKineticEnergy(totalenergy - theDynamica << 390   } else {
362   }                                            << 391     SetMomentumDirection(1.0,0.0,0.0);
363   else {                                       << 
364     SetMomentumDirection(1.0, 0.0, 0.0);       << 
365     SetKineticEnergy(0.0);                        392     SetKineticEnergy(0.0);
366   }                                               393   }
367 }                                                 394 }
368                                                   395 
                                                   >> 396 
                                                   >> 397 ////////////////////
                                                   >> 398 //  --- Dump Information --
                                                   >> 399 ////////////////////
369 #ifdef G4VERBOSE                                  400 #ifdef G4VERBOSE
370 void G4DynamicParticle::DumpInfo(G4int mode) c    401 void G4DynamicParticle::DumpInfo(G4int mode) const
371 {                                                 402 {
372   if (theParticleDefinition == nullptr) {      << 403   if (theParticleDefinition == 0) {
373     G4cout << " G4DynamicParticle::DumpInfo()  << 404     G4cout << " G4DynamicParticle::DumpInfo():: !!!Particle type not defined !!!! " << G4endl;
374   }                                            << 405   } else {
375   else {                                       << 
376     G4cout << " Particle type - " << thePartic    406     G4cout << " Particle type - " << theParticleDefinition->GetParticleName() << G4endl
377            << "   mass:        " << GetMass()  << 407          << "   mass:        " << GetMass()/GeV <<  "[GeV]" <<G4endl
378            << "   charge:      " << GetCharge( << 408          << "   charge:      " << GetCharge()/eplus <<  "[e]" <<G4endl
379            << "   Direction x: " << GetMomentu << 409          << "   Direction x: " << GetMomentumDirection().x() << ", y: "
380            << ", y: " << GetMomentumDirection( << 410    << GetMomentumDirection().y() << ", z: "
381            << G4endl << "   Total Momentum = " << 411                              << GetMomentumDirection().z() << G4endl
382            << G4endl << "   Momentum: " << Get << 412          << "   Total Momentum = " << GetTotalMomentum() /GeV << "[GeV]" << G4endl
383            << ", y: " << GetMomentum().y() / C << 413          << "   Momentum: "    << GetMomentum().x() /GeV << "[GeV]" << ", y: "
384            << ", z: " << GetMomentum().z() / C << 414                                << GetMomentum().y() /GeV << "[GeV]" << ", z: "
385            << "   Total Energy   = " << GetTot << 415                                << GetMomentum().z() /GeV << "[GeV]" << G4endl
386            << "   Kinetic Energy = " << GetKin << 416          << "   Total Energy   = " << GetTotalEnergy()/GeV << "[GeV]"  << G4endl
387            << " MagneticMoment  [MeV/T]: " <<  << 417          << "   Kinetic Energy = " << GetKineticEnergy() /GeV << "[GeV]" << G4endl
388            << G4endl << "   ProperTime     = " << 418    << " MagneticMoment  [MeV/T]: " << GetMagneticMoment()/MeV*tesla << G4endl
389                                                << 419          << "   ProperTime     = " << GetProperTime() /ns <<  "[ns]" << G4endl;
390     if (mode > 0) {                            << 420 
391       if (theElectronOccupancy != nullptr) {   << 421     if (mode>0) {
392         theElectronOccupancy->DumpInfo();      << 422       if( theElectronOccupancy != 0) {
                                                   >> 423   theElectronOccupancy->DumpInfo();
393       }                                           424       }
394     }                                             425     }
395   }                                               426   }
396 }                                                 427 }
397 #else                                             428 #else
398 void G4DynamicParticle::DumpInfo(G4int) const     429 void G4DynamicParticle::DumpInfo(G4int) const
399 {                                                 430 {
400   return;                                         431   return;
401 }                                                 432 }
402 #endif                                            433 #endif
403                                                   434 
404 G4double G4DynamicParticle::GetElectronMass()  << 435 ////////////////////////
                                                   >> 436 G4double  G4DynamicParticle::GetElectronMass() const
405 {                                                 437 {
406   return CLHEP::electron_mass_c2;              << 438   static G4ThreadLocal G4double electronMass = 0.0;
                                                   >> 439 
                                                   >> 440   // check if electron exits and get the mass
                                                   >> 441   if (electronMass<=0.0) {
                                                   >> 442     G4ParticleDefinition* electron = G4ParticleTable::GetParticleTable()->FindParticle("e-");
                                                   >> 443     if (electron == 0) {
                                                   >> 444       G4Exception("G4DynamicParticle::GetElectronMass()","PART021",
                                                   >> 445       FatalException,"G4DynamicParticle: G4Electron is not defined !!");
                                                   >> 446     }
                                                   >> 447     electronMass = electron->GetPDGMass();
                                                   >> 448   }
                                                   >> 449 
                                                   >> 450   return electronMass;
407 }                                                 451 }
408                                                   452