Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCLPhaseSpaceDecay.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // INCL++ intra-nuclear cascade model
27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28 // Davide Mancusi, CEA
29 // Alain Boudard, CEA
30 // Sylvie Leray, CEA
31 // Joseph Cugnon, University of Liege
32 //
33 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 #include "G4INCLPhaseSpaceDecay.hh"
38 #include "G4INCLRandom.hh"
39 #include "G4INCLKinematicsUtils.hh"
40 #include <algorithm>
41 #include <numeric>
42 #include <functional>
43 
44 namespace G4INCL {
45  namespace PhaseSpaceDecay {
46  namespace {
47  // Generate scale factor for final state particle
48  G4double betaKopylov(G4int K) {
49  G4int N = 3*K - 5;
50  G4double xN = G4double(N);
51  G4double Fmax = std::sqrt(std::pow(xN/(xN+1.),N)/(xN+1.));
52 
53  G4double F, chi;
54  do {
55  chi = Random::shoot();
56  F = std::sqrt(std::pow(chi,N)*(1.-chi));
57  } while ( Fmax*Random::shoot() > F);
58  return chi;
59  }
60  }
61 
62  void decay(const G4double initialMass, ThreeVector const &theBoostVector, ParticleList &particles) {
63 
64  size_t N = particles.size();
65  std::vector<G4double> masses(N);
66  std::vector<G4double> sumMasses(N);
67  std::transform(particles.begin(), particles.end(), masses.begin(), std::mem_fun(&Particle::getMass));
68  std::partial_sum(masses.begin(), masses.end(), sumMasses.begin());
69 
70  G4double PFragMagCM = 0.0;
71  G4double T = initialMass-sumMasses.back();
72 // assert(T>-1.e-5);
73  if(T<0.)
74  T=0.;
75 
76  ThreeVector PFragCM, PRestCM, PRestLab;
77 
78  // The first particle in the list will pick up all the recoil
79  Particle *restParticle = particles.front();
80  restParticle->setMass(initialMass);
81  restParticle->adjustEnergyFromMomentum();
82 
83  ThreeVector boostV;
84 
85  G4int k=N-1;
86  for (ParticleList::reverse_iterator p=particles.rbegin(); k>0; ++p, --k) {
87  const G4double mu = sumMasses[k-1];
88  T *= (k>1) ? betaKopylov(k) : 0.;
89 
90  const G4double restMass = mu + T;
91 
92  PFragMagCM = KinematicsUtils::momentumInCM(restParticle->getMass(), masses[k], restMass);
93  PFragCM = Random::normVector(PFragMagCM);
94  (*p)->setMomentum(PFragCM);
95  (*p)->adjustEnergyFromMomentum();
96  restParticle->setMass(restMass);
97  restParticle->setMomentum(-PFragCM);
98  restParticle->adjustEnergyFromMomentum();
99 
100  (*p)->boost(boostV);
101  (*p)->boost(theBoostVector);
102  restParticle->boost(boostV);
103 
104  boostV = -restParticle->boostVector();
105  }
106  restParticle->setMass(masses[0]);
107  restParticle->adjustEnergyFromMomentum();
108  restParticle->boost(theBoostVector);
109  }
110  }
111 }
112 
113 
void setMass(G4double mass)
G4double getMass() const
Get the cached particle mass.
const char * p
Definition: xmltok.h:285
void boost(const ThreeVector &aBoostVector)
G4double adjustEnergyFromMomentum()
Recompute the energy to match the momentum.
G4double momentumInCM(Particle const *const p1, Particle const *const p2)
gives the momentum in the CM frame of two particles.
ThreeVector boostVector() const
int G4int
Definition: G4Types.hh:78
ThreeVector normVector(G4double norm=1.)
void decay(G4double initialMass, const ThreeVector &theBoostVector, ParticleList &particles)
Generate decay momenta according to a uniform phase-space model.
**D E S C R I P T I O N
G4double shoot()
Definition: G4INCLRandom.cc:74
double G4double
Definition: G4Types.hh:76
virtual void setMomentum(const G4INCL::ThreeVector &momentum)