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 11.1.1)


  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          26 // G4DynamicParticle class implementation
 27 //                                                 27 //
 28 // History:                                        28 // History:
 29 // - 2 December 1995, G.Cosmo - first design,      29 // - 2 December 1995, G.Cosmo - first design, based on object model.
 30 // - 29 January 1996, M.Asai - first implement     30 // - 29 January 1996, M.Asai - first implementation.
 31 // - 1996 - 2007,     H.Kurashige - revisions.     31 // - 1996 - 2007,     H.Kurashige - revisions.
 32 // - 15 March 2019,   M.Novak - log-kinetic en <<  32 // - 15 March 2019,   M.Novak - log-kinetic energy value is computed only 
 33 //                    on demand if its stored  <<  33 //                    on demand if its stored value is not up-to-date.  
 34 //--------------------------------------------     34 //---------------------------------------------------------------------
 35                                                    35 
 36 #include "G4DynamicParticle.hh"                    36 #include "G4DynamicParticle.hh"
 37                                                << 
 38 #include "G4DecayProducts.hh"                      37 #include "G4DecayProducts.hh"
 39 #include "G4IonTable.hh"                       << 
 40 #include "G4LorentzVector.hh"                      38 #include "G4LorentzVector.hh"
 41 #include "G4ParticleDefinition.hh"                 39 #include "G4ParticleDefinition.hh"
                                                   >>  40 #include "G4IonTable.hh"
 42 #include "G4PrimaryParticle.hh"                    41 #include "G4PrimaryParticle.hh"
 43                                                    42 
 44 G4Allocator<G4DynamicParticle>*& pDynamicParti     43 G4Allocator<G4DynamicParticle>*& pDynamicParticleAllocator()
 45 {                                                  44 {
 46   G4ThreadLocalStatic G4Allocator<G4DynamicPar     45   G4ThreadLocalStatic G4Allocator<G4DynamicParticle>* _instance = nullptr;
 47   return _instance;                                46   return _instance;
 48 }                                                  47 }
 49                                                    48 
 50 static const G4double EnergyMomentumRelationAl <<  49 static const G4double EnergyMomentumRelationAllowance = 1.0e-2*CLHEP::keV;
 51 static const G4double EnergyMRA2 =             <<  50 static const G4double EnergyMRA2 = 
 52   EnergyMomentumRelationAllowance * EnergyMome <<  51   EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance;
 53                                                <<  52 
                                                   >>  53 ////////////////////
                                                   >>  54 // -- constructors ----
                                                   >>  55 ////////////////////
 54 G4DynamicParticle::G4DynamicParticle()             56 G4DynamicParticle::G4DynamicParticle()
 55   : theMomentumDirection(0.0, 0.0, 1.0), thePo <<  57   : theMomentumDirection(0.0,0.0,1.0),
 56 {}                                             <<  58     thePolarization(0.0,0.0,0.0)
                                                   >>  59 {
                                                   >>  60 }
 57                                                    61 
 58 G4DynamicParticle::G4DynamicParticle(const G4P <<  62 ////////////////////
 59                                      const G4T <<  63 G4DynamicParticle::
 60                                      G4double  <<  64 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
                                                   >>  65                   const G4ThreeVector& aMomentumDirection,
                                                   >>  66                         G4double aKineticEnergy)
 61   : theMomentumDirection(aMomentumDirection),      67   : theMomentumDirection(aMomentumDirection),
 62     thePolarization(0.0, 0.0, 0.0),            <<  68     thePolarization(0.0,0.0,0.0),
 63     theParticleDefinition(aParticleDefinition)     69     theParticleDefinition(aParticleDefinition),
 64     theKineticEnergy(aKineticEnergy),              70     theKineticEnergy(aKineticEnergy),
 65     theDynamicalMass(aParticleDefinition->GetP     71     theDynamicalMass(aParticleDefinition->GetPDGMass()),
 66     theDynamicalCharge(aParticleDefinition->Ge     72     theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
 67     theDynamicalSpin(aParticleDefinition->GetP     73     theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
 68     theDynamicalMagneticMoment(aParticleDefini     74     theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment())
 69 {}                                             <<  75 {
                                                   >>  76 }
 70                                                    77 
 71 G4DynamicParticle::G4DynamicParticle(const G4P <<  78 ////////////////////
 72                                      const G4T <<  79 G4DynamicParticle::
 73                                      G4double  <<  80 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
                                                   >>  81                   const G4ThreeVector& aMomentumDirection,
                                                   >>  82                         G4double aKineticEnergy,
                                                   >>  83                   const G4double dynamicalMass)
 74   : theMomentumDirection(aMomentumDirection),      84   : theMomentumDirection(aMomentumDirection),
 75     thePolarization(0.0, 0.0, 0.0),            <<  85     thePolarization(0.0,0.0,0.0),
 76     theParticleDefinition(aParticleDefinition)     86     theParticleDefinition(aParticleDefinition),
 77     theKineticEnergy(aKineticEnergy),              87     theKineticEnergy(aKineticEnergy),
 78     theDynamicalMass(aParticleDefinition->GetP     88     theDynamicalMass(aParticleDefinition->GetPDGMass()),
 79     theDynamicalCharge(aParticleDefinition->Ge     89     theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
 80     theDynamicalSpin(aParticleDefinition->GetP     90     theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
 81     theDynamicalMagneticMoment(aParticleDefini     91     theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment())
 82 {                                                  92 {
 83   if (std::abs(theDynamicalMass - dynamicalMas <<  93   if (std::abs(theDynamicalMass-dynamicalMass)
 84     if (dynamicalMass > EnergyMomentumRelation <<  94       > EnergyMomentumRelationAllowance)
 85       theDynamicalMass = dynamicalMass;        <<  95   {
                                                   >>  96     if (dynamicalMass>EnergyMomentumRelationAllowance)
                                                   >>  97       theDynamicalMass= dynamicalMass;
 86     else                                           98     else
 87       theDynamicalMass = 0.0;                  <<  99       theDynamicalMass= 0.0;
 88   }                                            << 100   } 
 89 }                                                 101 }
 90                                                   102 
 91 G4DynamicParticle::G4DynamicParticle(const G4P << 103 ////////////////////
 92                                      const G4T << 104 G4DynamicParticle::
 93   : thePolarization(0.0, 0.0, 0.0),            << 105 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
                                                   >> 106                   const G4ThreeVector& aParticleMomentum)
                                                   >> 107   : thePolarization(0.0,0.0,0.0),
 94     theParticleDefinition(aParticleDefinition)    108     theParticleDefinition(aParticleDefinition),
 95     theDynamicalMass(aParticleDefinition->GetP    109     theDynamicalMass(aParticleDefinition->GetPDGMass()),
 96     theDynamicalCharge(aParticleDefinition->Ge    110     theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
 97     theDynamicalSpin(aParticleDefinition->GetP    111     theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
 98     theDynamicalMagneticMoment(aParticleDefini    112     theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment())
 99 {                                                 113 {
100   SetMomentum(aParticleMomentum);  // 3-dim mo    114   SetMomentum(aParticleMomentum);  // 3-dim momentum is given
101 }                                                 115 }
102                                                   116 
103 G4DynamicParticle::G4DynamicParticle(const G4P << 117 ////////////////////
104                                      const G4L << 118 G4DynamicParticle::
105   : thePolarization(0.0, 0.0, 0.0),            << 119 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
                                                   >> 120                   const G4LorentzVector& aParticleMomentum)
                                                   >> 121   : thePolarization(0.0,0.0,0.0),
106     theParticleDefinition(aParticleDefinition)    122     theParticleDefinition(aParticleDefinition),
107     theDynamicalMass(aParticleDefinition->GetP    123     theDynamicalMass(aParticleDefinition->GetPDGMass()),
108     theDynamicalCharge(aParticleDefinition->Ge    124     theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
109     theDynamicalSpin(aParticleDefinition->GetP    125     theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
110     theDynamicalMagneticMoment(aParticleDefini    126     theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment())
111 {                                                 127 {
112   Set4Momentum(aParticleMomentum);  // 4-momen    128   Set4Momentum(aParticleMomentum);  // 4-momentum vector (Lorentz vector)
113 }                                                 129 }
114                                                   130 
115 G4DynamicParticle::G4DynamicParticle(const G4P << 131 ////////////////////
116                                      G4double  << 132 G4DynamicParticle::
117   : thePolarization(0.0, 0.0, 0.0),            << 133 G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
                                                   >> 134                         G4double totalEnergy,
                                                   >> 135                   const G4ThreeVector &aParticleMomentum)
                                                   >> 136   : thePolarization(0.0,0.0,0.0),
118     theParticleDefinition(aParticleDefinition)    137     theParticleDefinition(aParticleDefinition),
119     theDynamicalMass(aParticleDefinition->GetP    138     theDynamicalMass(aParticleDefinition->GetPDGMass()),
120     theDynamicalCharge(aParticleDefinition->Ge    139     theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
121     theDynamicalSpin(aParticleDefinition->GetP    140     theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
122     theDynamicalMagneticMoment(aParticleDefini    141     theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment())
123 {                                                 142 {
124   // total energy and 3-dim momentum are given    143   // total energy and 3-dim momentum are given
125   G4double pModule2 = aParticleMomentum.mag2()    144   G4double pModule2 = aParticleMomentum.mag2();
126   if (pModule2 > 0.0) {                        << 145   if (pModule2 > 0.0)
127     G4double mass2 = totalEnergy * totalEnergy << 146   {
128     G4double PDGmass2 = (aParticleDefinition-> << 147     G4double mass2 = totalEnergy*totalEnergy - pModule2;
                                                   >> 148     G4double PDGmass2 = (aParticleDefinition->GetPDGMass())
                                                   >> 149                       * (aParticleDefinition->GetPDGMass());
129     SetMomentumDirection(aParticleMomentum.uni    150     SetMomentumDirection(aParticleMomentum.unit());
130     if (mass2 < EnergyMRA2) {                  << 151     if (mass2 < EnergyMRA2)
                                                   >> 152     {
131       theDynamicalMass = 0.;                      153       theDynamicalMass = 0.;
132       SetKineticEnergy(totalEnergy);              154       SetKineticEnergy(totalEnergy);
133     }                                             155     }
134     else {                                     << 156     else
135       if (std::abs(PDGmass2 - mass2) > EnergyM << 157     {
                                                   >> 158       if (std::abs(PDGmass2-mass2)>EnergyMRA2)
                                                   >> 159       {
136         theDynamicalMass = std::sqrt(mass2);      160         theDynamicalMass = std::sqrt(mass2);
137         SetKineticEnergy(totalEnergy - theDyna << 161         SetKineticEnergy(totalEnergy-theDynamicalMass);
138       }                                           162       }
139       else {                                   << 163       else
140         SetKineticEnergy(totalEnergy - theDyna << 164       {
                                                   >> 165         SetKineticEnergy(totalEnergy-theDynamicalMass);
141       }                                           166       }
142     }                                             167     }
143   }                                               168   }
144   else {                                       << 169   else
145     SetMomentumDirection(1.0, 0.0, 0.0);       << 170   {
                                                   >> 171     SetMomentumDirection(1.0,0.0,0.0);
146     SetKineticEnergy(0.0);                        172     SetKineticEnergy(0.0);
147   }                                               173   }
148 }                                                 174 }
149                                                   175 
                                                   >> 176 ////////////////////
150 G4DynamicParticle::G4DynamicParticle(const G4D    177 G4DynamicParticle::G4DynamicParticle(const G4DynamicParticle& right)
151   : theMomentumDirection(right.theMomentumDire    178   : theMomentumDirection(right.theMomentumDirection),
152     thePolarization(right.thePolarization),       179     thePolarization(right.thePolarization),
153     theParticleDefinition(right.theParticleDef    180     theParticleDefinition(right.theParticleDefinition),
154     // Don't copy preassignedDecayProducts     << 181     theElectronOccupancy(nullptr),
                                                   >> 182     thePreAssignedDecayProducts(nullptr), // Don't copy preassignedDecayProducts
155     primaryParticle(right.primaryParticle),       183     primaryParticle(right.primaryParticle),
156     theKineticEnergy(right.theKineticEnergy),     184     theKineticEnergy(right.theKineticEnergy),
157     theLogKineticEnergy(right.theLogKineticEne    185     theLogKineticEnergy(right.theLogKineticEnergy),
158     theBeta(right.theBeta),                       186     theBeta(right.theBeta),
159     theProperTime(right.theProperTime),           187     theProperTime(right.theProperTime),
160     theDynamicalMass(right.theDynamicalMass),     188     theDynamicalMass(right.theDynamicalMass),
161     theDynamicalCharge(right.theDynamicalCharg    189     theDynamicalCharge(right.theDynamicalCharge),
162     theDynamicalSpin(right.theDynamicalSpin),     190     theDynamicalSpin(right.theDynamicalSpin),
163     theDynamicalMagneticMoment(right.theDynami    191     theDynamicalMagneticMoment(right.theDynamicalMagneticMoment),
164                                                << 192     thePreAssignedDecayTime(-1.0),
165     verboseLevel(right.verboseLevel),             193     verboseLevel(right.verboseLevel),
166     thePDGcode(right.thePDGcode)                  194     thePDGcode(right.thePDGcode)
167 {                                                 195 {
168   if (right.theElectronOccupancy != nullptr) { << 196   if (right.theElectronOccupancy != nullptr)
                                                   >> 197   {
169     theElectronOccupancy = new G4ElectronOccup    198     theElectronOccupancy = new G4ElectronOccupancy(*right.theElectronOccupancy);
170   }                                               199   }
171 }                                                 200 }
172                                                   201 
                                                   >> 202 ////////////////////
173 G4DynamicParticle::G4DynamicParticle(G4Dynamic    203 G4DynamicParticle::G4DynamicParticle(G4DynamicParticle&& from)
174   : theMomentumDirection(from.theMomentumDirec    204   : theMomentumDirection(from.theMomentumDirection),
175     thePolarization(from.thePolarization),        205     thePolarization(from.thePolarization),
176     theParticleDefinition(from.theParticleDefi    206     theParticleDefinition(from.theParticleDefinition),
177     theElectronOccupancy(from.theElectronOccup    207     theElectronOccupancy(from.theElectronOccupancy),
178     // Don't move preassignedDecayProducts     << 208     thePreAssignedDecayProducts(nullptr), // Don't move preassignedDecayProducts
179     primaryParticle(from.primaryParticle),        209     primaryParticle(from.primaryParticle),
180     theKineticEnergy(from.theKineticEnergy),      210     theKineticEnergy(from.theKineticEnergy),
181     theLogKineticEnergy(from.theLogKineticEner    211     theLogKineticEnergy(from.theLogKineticEnergy),
182     theBeta(from.theBeta),                        212     theBeta(from.theBeta),
183     theProperTime(from.theProperTime),            213     theProperTime(from.theProperTime),
184     theDynamicalMass(from.theDynamicalMass),      214     theDynamicalMass(from.theDynamicalMass),
185     theDynamicalCharge(from.theDynamicalCharge    215     theDynamicalCharge(from.theDynamicalCharge),
186     theDynamicalSpin(from.theDynamicalSpin),      216     theDynamicalSpin(from.theDynamicalSpin),
187     theDynamicalMagneticMoment(from.theDynamic    217     theDynamicalMagneticMoment(from.theDynamicalMagneticMoment),
188                                                << 218     thePreAssignedDecayTime(-1.0),
189     verboseLevel(from.verboseLevel),              219     verboseLevel(from.verboseLevel),
190     thePDGcode(from.thePDGcode)                   220     thePDGcode(from.thePDGcode)
191 {                                                 221 {
192   // Release the data from the source object   << 222     // Release the data from the source object
193   from.theParticleDefinition = nullptr;        << 223     from.theParticleDefinition = nullptr;
194   from.theElectronOccupancy = nullptr;         << 224     from.theElectronOccupancy = nullptr;
195   from.thePreAssignedDecayProducts = nullptr;  << 225     from.thePreAssignedDecayProducts = nullptr;
196   from.primaryParticle = nullptr;              << 226     from.primaryParticle = nullptr;
197 }                                                 227 }
198                                                   228 
                                                   >> 229 ////////////////////
                                                   >> 230 // -- destructor ----
                                                   >> 231 ////////////////////
199 G4DynamicParticle::~G4DynamicParticle()           232 G4DynamicParticle::~G4DynamicParticle()
200 {                                                 233 {
201   delete thePreAssignedDecayProducts;          << 234   if (thePreAssignedDecayProducts != nullptr)
                                                   >> 235     delete thePreAssignedDecayProducts;
202   thePreAssignedDecayProducts = nullptr;          236   thePreAssignedDecayProducts = nullptr;
203                                                   237 
204   delete theElectronOccupancy;                 << 238   if (theElectronOccupancy != nullptr)
                                                   >> 239     delete theElectronOccupancy;
205   theElectronOccupancy = nullptr;                 240   theElectronOccupancy = nullptr;
206 }                                                 241 }
207                                                   242 
                                                   >> 243 ////////////////////
                                                   >> 244 // -- operators ----
                                                   >> 245 ////////////////////
208 G4DynamicParticle& G4DynamicParticle::operator    246 G4DynamicParticle& G4DynamicParticle::operator=(const G4DynamicParticle& right)
209 {                                                 247 {
210   if (this != &right) {                        << 248   if (this != &right)
                                                   >> 249   {
211     theMomentumDirection = right.theMomentumDi    250     theMomentumDirection = right.theMomentumDirection;
212     theParticleDefinition = right.theParticleD    251     theParticleDefinition = right.theParticleDefinition;
213     thePolarization = right.thePolarization;      252     thePolarization = right.thePolarization;
214     theKineticEnergy = right.theKineticEnergy;    253     theKineticEnergy = right.theKineticEnergy;
215     theProperTime = right.theProperTime;          254     theProperTime = right.theProperTime;
216                                                   255 
217     theDynamicalMass = right.theDynamicalMass;    256     theDynamicalMass = right.theDynamicalMass;
218     theDynamicalCharge = right.theDynamicalCha    257     theDynamicalCharge = right.theDynamicalCharge;
219     theDynamicalSpin = right.theDynamicalSpin;    258     theDynamicalSpin = right.theDynamicalSpin;
220     theDynamicalMagneticMoment = right.theDyna    259     theDynamicalMagneticMoment = right.theDynamicalMagneticMoment;
221                                                   260 
222     delete theElectronOccupancy;               << 261     if (theElectronOccupancy != nullptr) { delete theElectronOccupancy; }
223     if (right.theElectronOccupancy != nullptr) << 262     if (right.theElectronOccupancy != nullptr)
224       theElectronOccupancy = new G4ElectronOcc << 263     {
                                                   >> 264       theElectronOccupancy =
                                                   >> 265              new G4ElectronOccupancy(*right.theElectronOccupancy);
225     }                                             266     }
226     else {                                     << 267     else
                                                   >> 268     {
227       theElectronOccupancy = nullptr;             269       theElectronOccupancy = nullptr;
228     }                                             270     }
229                                                   271 
230     // thePreAssignedDecayProducts must not be    272     // thePreAssignedDecayProducts must not be copied.
231     thePreAssignedDecayProducts = nullptr;        273     thePreAssignedDecayProducts = nullptr;
232     thePreAssignedDecayTime = -1.0;               274     thePreAssignedDecayTime = -1.0;
233                                                   275 
234     verboseLevel = right.verboseLevel;            276     verboseLevel = right.verboseLevel;
235                                                   277 
236     // Primary particle information must be pr    278     // Primary particle information must be preserved
237     //*** primaryParticle = right.primaryParti    279     //*** primaryParticle = right.primaryParticle;
238                                                   280 
239     thePDGcode = right.thePDGcode;                281     thePDGcode = right.thePDGcode;
240   }                                               282   }
241   return *this;                                   283   return *this;
242 }                                                 284 }
243                                                   285 
                                                   >> 286 ////////////////////
244 G4DynamicParticle& G4DynamicParticle::operator    287 G4DynamicParticle& G4DynamicParticle::operator=(G4DynamicParticle&& from)
245 {                                                 288 {
246   if (this != &from) {                         << 289   if (this != &from)
                                                   >> 290   {
247     theMomentumDirection = from.theMomentumDir    291     theMomentumDirection = from.theMomentumDirection;
248     thePolarization = from.thePolarization;       292     thePolarization = from.thePolarization;
249     theKineticEnergy = from.theKineticEnergy;     293     theKineticEnergy = from.theKineticEnergy;
250     theProperTime = from.theProperTime;           294     theProperTime = from.theProperTime;
251                                                   295 
252     theDynamicalMass = from.theDynamicalMass;     296     theDynamicalMass = from.theDynamicalMass;
253     theDynamicalCharge = from.theDynamicalChar    297     theDynamicalCharge = from.theDynamicalCharge;
254     theDynamicalSpin = from.theDynamicalSpin;     298     theDynamicalSpin = from.theDynamicalSpin;
255     theDynamicalMagneticMoment = from.theDynam    299     theDynamicalMagneticMoment = from.theDynamicalMagneticMoment;
256                                                   300 
257     delete theElectronOccupancy;               << 301     if (theElectronOccupancy != nullptr) { delete theElectronOccupancy; }
258     theElectronOccupancy = from.theElectronOcc    302     theElectronOccupancy = from.theElectronOccupancy;
259     from.theElectronOccupancy = nullptr;          303     from.theElectronOccupancy = nullptr;
260                                                   304 
261     // thePreAssignedDecayProducts must not be    305     // thePreAssignedDecayProducts must not be moved.
262     thePreAssignedDecayProducts = nullptr;        306     thePreAssignedDecayProducts = nullptr;
263     from.thePreAssignedDecayProducts = nullptr    307     from.thePreAssignedDecayProducts = nullptr;
264     thePreAssignedDecayTime = -1.0;               308     thePreAssignedDecayTime = -1.0;
265                                                   309 
266     theParticleDefinition = from.theParticleDe    310     theParticleDefinition = from.theParticleDefinition;
267     from.theParticleDefinition = nullptr;         311     from.theParticleDefinition = nullptr;
268                                                   312 
269     verboseLevel = from.verboseLevel;             313     verboseLevel = from.verboseLevel;
270                                                   314 
271     primaryParticle = from.primaryParticle;       315     primaryParticle = from.primaryParticle;
272     from.primaryParticle = nullptr;               316     from.primaryParticle = nullptr;
273                                                   317 
274     thePDGcode = from.thePDGcode;                 318     thePDGcode = from.thePDGcode;
275   }                                               319   }
276   return *this;                                   320   return *this;
277 }                                                 321 }
278                                                   322 
279 void G4DynamicParticle::SetDefinition(const G4 << 323 ////////////////////
                                                   >> 324 void G4DynamicParticle::
                                                   >> 325 SetDefinition(const G4ParticleDefinition* aParticleDefinition)
280 {                                                 326 {
281   // remove preassigned decay                     327   // remove preassigned decay
282   if (thePreAssignedDecayProducts != nullptr)  << 328   if (thePreAssignedDecayProducts != nullptr)
                                                   >> 329   {
283 #ifdef G4VERBOSE                                  330 #ifdef G4VERBOSE
284     if (verboseLevel > 0) {                    << 331     if (verboseLevel>0)
                                                   >> 332     {
285       G4cout << " G4DynamicParticle::SetDefini    333       G4cout << " G4DynamicParticle::SetDefinition()::"
286              << "!!! Pre-assigned decay produc    334              << "!!! Pre-assigned decay products is attached !!!! " << G4endl;
287       G4cout << "!!! New Definition is " << aP << 335       G4cout << "!!! New Definition is "
                                                   >> 336              << aParticleDefinition->GetParticleName()  << " !!! " << G4endl;
                                                   >> 337       G4cout << "!!! Pre-assigned decay products will be deleted !!!! "
288              << G4endl;                           338              << G4endl;
289       G4cout << "!!! Pre-assigned decay produc << 
290     }                                             339     }
291 #endif                                            340 #endif
292     delete thePreAssignedDecayProducts;           341     delete thePreAssignedDecayProducts;
293   }                                               342   }
294   thePreAssignedDecayProducts = nullptr;          343   thePreAssignedDecayProducts = nullptr;
295                                                   344 
296   theParticleDefinition = aParticleDefinition;    345   theParticleDefinition = aParticleDefinition;
297                                                   346 
298   // set Dynamic mass/charge                      347   // set Dynamic mass/charge
299   SetMass(theParticleDefinition->GetPDGMass())    348   SetMass(theParticleDefinition->GetPDGMass());
300   theDynamicalCharge = theParticleDefinition->    349   theDynamicalCharge = theParticleDefinition->GetPDGCharge();
301   theDynamicalSpin = theParticleDefinition->Ge    350   theDynamicalSpin = theParticleDefinition->GetPDGSpin();
302   theDynamicalMagneticMoment = theParticleDefi    351   theDynamicalMagneticMoment = theParticleDefinition->GetPDGMagneticMoment();
303                                                   352 
304   // Set electron orbits                          353   // Set electron orbits
305   if (theElectronOccupancy != nullptr) {       << 354   if (theElectronOccupancy != nullptr)
                                                   >> 355   {
306     delete theElectronOccupancy;                  356     delete theElectronOccupancy;
307     theElectronOccupancy = nullptr;               357     theElectronOccupancy = nullptr;
308   }                                               358   }
309 }                                                 359 }
310                                                   360 
                                                   >> 361 ////////////////////
311 G4bool G4DynamicParticle::operator==(const G4D    362 G4bool G4DynamicParticle::operator==(const G4DynamicParticle& right) const
312 {                                                 363 {
313   return (this == (G4DynamicParticle*)&right); << 364   return (this == (G4DynamicParticle *) &right);
314 }                                                 365 }
315                                                   366 
                                                   >> 367 ////////////////////
316 G4bool G4DynamicParticle::operator!=(const G4D    368 G4bool G4DynamicParticle::operator!=(const G4DynamicParticle& right) const
317 {                                                 369 {
318   return (this != (G4DynamicParticle*)&right); << 370   return (this != (G4DynamicParticle *) &right);
319 }                                                 371 }
320                                                   372 
321 void G4DynamicParticle::AllocateElectronOccupa << 373 ////////////////////
                                                   >> 374 // -- AllocateElectronOccupancy --
                                                   >> 375 ////////////////////
                                                   >> 376 void  G4DynamicParticle::AllocateElectronOccupancy()
322 {                                                 377 {
323   if (G4IonTable::IsIon(theParticleDefinition) << 378   if (G4IonTable::IsIon(theParticleDefinition))
                                                   >> 379   {
324     // Only ions can have ElectronOccupancy       380     // Only ions can have ElectronOccupancy
325     theElectronOccupancy = new G4ElectronOccup    381     theElectronOccupancy = new G4ElectronOccupancy();
                                                   >> 382 
326   }                                               383   }
327   else {                                       << 384   else
                                                   >> 385   {
328     theElectronOccupancy = nullptr;               386     theElectronOccupancy = nullptr;
329   }                                               387   }
330 }                                                 388 }
331                                                   389 
                                                   >> 390 ////////////////////
                                                   >> 391 // -- methods for setting Energy/Momentum  --
                                                   >> 392 ////////////////////
332 void G4DynamicParticle::SetMomentum(const G4Th    393 void G4DynamicParticle::SetMomentum(const G4ThreeVector& momentum)
333 {                                                 394 {
334   G4double pModule2 = momentum.mag2();            395   G4double pModule2 = momentum.mag2();
335   if (pModule2 > 0.0) {                        << 396   if (pModule2>0.0)
                                                   >> 397   {
336     const G4double mass = theDynamicalMass;       398     const G4double mass = theDynamicalMass;
337     SetMomentumDirection(momentum.unit());        399     SetMomentumDirection(momentum.unit());
338     SetKineticEnergy(pModule2 / (std::sqrt(pMo << 400     SetKineticEnergy(pModule2/(std::sqrt(pModule2 + mass*mass)+mass));
339   }                                               401   }
340   else {                                       << 402   else
341     SetMomentumDirection(1.0, 0.0, 0.0);       << 403   {
                                                   >> 404     SetMomentumDirection(1.0,0.0,0.0);
342     SetKineticEnergy(0.0);                        405     SetKineticEnergy(0.0);
343   }                                               406   }
344 }                                                 407 }
345                                                   408 
346 void G4DynamicParticle::Set4Momentum(const G4L << 409 ////////////////////
                                                   >> 410 void G4DynamicParticle::Set4Momentum(const G4LorentzVector& momentum )
347 {                                                 411 {
348   G4double pModule2 = momentum.vect().mag2();     412   G4double pModule2 = momentum.vect().mag2();
349   if (pModule2 > 0.0) {                        << 413   if (pModule2>0.0)
                                                   >> 414   {
350     SetMomentumDirection(momentum.vect().unit(    415     SetMomentumDirection(momentum.vect().unit());
351     const G4double totalenergy = momentum.t();    416     const G4double totalenergy = momentum.t();
352     const G4double mass2 = totalenergy * total << 417     const G4double mass2 = totalenergy*totalenergy - pModule2;
353     const G4double PDGmass2 =                  << 418     const G4double PDGmass2 = (theParticleDefinition->GetPDGMass())
354       (theParticleDefinition->GetPDGMass()) *  << 419                             * (theParticleDefinition->GetPDGMass());
355     if (mass2 < EnergyMRA2) {                  << 420     if (mass2 < EnergyMRA2)
                                                   >> 421     {
356       theDynamicalMass = 0.;                      422       theDynamicalMass = 0.;
357     }                                             423     }
358     else if (std::abs(PDGmass2 - mass2) > Ener << 424     else if (std::abs(PDGmass2-mass2)>EnergyMRA2)
                                                   >> 425     {
359       theDynamicalMass = std::sqrt(mass2);        426       theDynamicalMass = std::sqrt(mass2);
360     }                                             427     }
361     SetKineticEnergy(totalenergy - theDynamica << 428     SetKineticEnergy(totalenergy-theDynamicalMass);
362   }                                               429   }
363   else {                                       << 430   else
364     SetMomentumDirection(1.0, 0.0, 0.0);       << 431   {
                                                   >> 432     SetMomentumDirection(1.0,0.0,0.0);
365     SetKineticEnergy(0.0);                        433     SetKineticEnergy(0.0);
366   }                                               434   }
367 }                                                 435 }
368                                                   436 
                                                   >> 437 ////////////////////
                                                   >> 438 //  --- Dump Information --
                                                   >> 439 ////////////////////
369 #ifdef G4VERBOSE                                  440 #ifdef G4VERBOSE
370 void G4DynamicParticle::DumpInfo(G4int mode) c    441 void G4DynamicParticle::DumpInfo(G4int mode) const
371 {                                                 442 {
372   if (theParticleDefinition == nullptr) {      << 443   if (theParticleDefinition == nullptr)
373     G4cout << " G4DynamicParticle::DumpInfo()  << 444   {
374   }                                            << 445     G4cout << " G4DynamicParticle::DumpInfo() - Particle type not defined !!! "
375   else {                                       << 446            << G4endl;
376     G4cout << " Particle type - " << thePartic << 447   }
377            << "   mass:        " << GetMass()  << 448   else
378            << "   charge:      " << GetCharge( << 449   {
379            << "   Direction x: " << GetMomentu << 450     G4cout << " Particle type - " << theParticleDefinition->GetParticleName()
380            << ", y: " << GetMomentumDirection( << 451            << G4endl
381            << G4endl << "   Total Momentum = " << 452            << "   mass:        " << GetMass()/CLHEP::GeV <<  "[GeV]" << G4endl
382            << G4endl << "   Momentum: " << Get << 453            << "   charge:      " << GetCharge()/CLHEP::eplus <<  "[e]" << G4endl
383            << ", y: " << GetMomentum().y() / C << 454            << "   Direction x: " << GetMomentumDirection().x() << ", y: "
384            << ", z: " << GetMomentum().z() / C << 455            << GetMomentumDirection().y() << ", z: "
385            << "   Total Energy   = " << GetTot << 456            << GetMomentumDirection().z() << G4endl
386            << "   Kinetic Energy = " << GetKin << 457            << "   Total Momentum = "
387            << " MagneticMoment  [MeV/T]: " <<  << 458            << GetTotalMomentum()/CLHEP::GeV << "[GeV]" << G4endl
388            << G4endl << "   ProperTime     = " << 459            << "   Momentum: "    << GetMomentum().x() /CLHEP::GeV << "[GeV]"
389                                                << 460            << ", y: " << GetMomentum().y() /CLHEP::GeV << "[GeV]"
390     if (mode > 0) {                            << 461            << ", z: " << GetMomentum().z() /CLHEP::GeV << "[GeV]" << G4endl
391       if (theElectronOccupancy != nullptr) {   << 462            << "   Total Energy   = "
                                                   >> 463            << GetTotalEnergy()/CLHEP::GeV << "[GeV]" << G4endl
                                                   >> 464            << "   Kinetic Energy = "
                                                   >> 465            << GetKineticEnergy()/CLHEP::GeV << "[GeV]" << G4endl
                                                   >> 466            << " MagneticMoment  [MeV/T]: "
                                                   >> 467            << GetMagneticMoment()/CLHEP::MeV*CLHEP::tesla << G4endl
                                                   >> 468            << "   ProperTime     = "
                                                   >> 469            << GetProperTime() /CLHEP::ns <<  "[ns]" << G4endl;
                                                   >> 470 
                                                   >> 471     if (mode>0)
                                                   >> 472     {
                                                   >> 473       if( theElectronOccupancy != nullptr)
                                                   >> 474       {
392         theElectronOccupancy->DumpInfo();         475         theElectronOccupancy->DumpInfo();
393       }                                           476       }
394     }                                             477     }
395   }                                               478   }
396 }                                                 479 }
397 #else                                             480 #else
398 void G4DynamicParticle::DumpInfo(G4int) const     481 void G4DynamicParticle::DumpInfo(G4int) const
399 {                                                 482 {
400   return;                                         483   return;
401 }                                                 484 }
402 #endif                                            485 #endif
403                                                   486 
                                                   >> 487 ////////////////////////
404 G4double G4DynamicParticle::GetElectronMass()     488 G4double G4DynamicParticle::GetElectronMass() const
405 {                                                 489 {
406   return CLHEP::electron_mass_c2;                 490   return CLHEP::electron_mass_c2;
407 }                                                 491 }
408                                                   492