Geant4  10.01.p01
G4INCLPhaseSpaceKopylov.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 // Alain Boudard, CEA-Saclay, France
28 // Joseph Cugnon, University of Liege, Belgium
29 // Jean-Christophe David, CEA-Saclay, France
30 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
31 // Sylvie Leray, CEA-Saclay, France
32 // Davide Mancusi, CEA-Saclay, France
33 //
34 #define INCLXX_IN_GEANT4_MODE 1
35 
36 #include "globals.hh"
37 
39 #include "G4INCLRandom.hh"
40 #include "G4INCLKinematicsUtils.hh"
41 #include <algorithm>
42 #include <numeric>
43 #include <functional>
44 
45 namespace G4INCL {
46 
48  G4int N = 3*K - 5;
49  G4double xN = G4double(N);
50  G4double Fmax = std::sqrt(std::pow(xN/(xN+1.),N)/(xN+1.));
51 
52  G4double F, chi;
53  do {
54  chi = Random::shoot();
55  F = std::sqrt(std::pow(chi,N)*(1.-chi));
56  } while ( Fmax*Random::shoot() > F);
57  return chi;
58  }
59 
60  void PhaseSpaceKopylov::generate(const G4double sqrtS, ParticleList &particles) {
61 
62  boostV.setX(0.0);
63  boostV.setY(0.0);
64  boostV.setZ(0.0);
65 
66  const size_t N = particles.size();
67  masses.resize(N);
68  sumMasses.resize(N);
69  std::transform(particles.begin(), particles.end(), masses.begin(), std::mem_fun(&Particle::getMass));
70  std::partial_sum(masses.begin(), masses.end(), sumMasses.begin());
71 
72  G4double PFragMagCM = 0.0;
73  G4double T = sqrtS-sumMasses.back();
74 // assert(T>-1.e-5);
75  if(T<0.)
76  T=0.;
77 
78  // The first particle in the list will pick up all the recoil
79  Particle *restParticle = particles.front();
80  restParticle->setMass(sqrtS);
81  restParticle->adjustEnergyFromMomentum();
82 
83  G4int k=N-1;
84  for (ParticleList::reverse_iterator p=particles.rbegin(); k>0; ++p, --k) {
85  const G4double mu = sumMasses[k-1];
86  T *= (k>1) ? betaKopylov(k) : 0.;
87 
88  const G4double restMass = mu + T;
89 
90  PFragMagCM = KinematicsUtils::momentumInCM(restParticle->getMass(), masses[k], restMass);
91  PFragCM = Random::normVector(PFragMagCM);
92  (*p)->setMomentum(PFragCM);
93  (*p)->adjustEnergyFromMomentum();
94  restParticle->setMass(restMass);
95  restParticle->setMomentum(-PFragCM);
96  restParticle->adjustEnergyFromMomentum();
97 
98  (*p)->boost(boostV);
99  restParticle->boost(boostV);
100 
101  boostV = -restParticle->boostVector();
102  }
103  restParticle->setMass(masses[0]);
104  restParticle->adjustEnergyFromMomentum();
105  }
106 
107 }
void setMass(G4double mass)
Set the mass of the particle in MeV/c^2.
G4double getMass() const
Get the cached particle mass.
std::vector< G4double > sumMasses
void boost(const ThreeVector &aBoostVector)
Boost the particle using a boost vector.
G4double adjustEnergyFromMomentum()
Recompute the energy to match the momentum.
std::vector< G4double > masses
G4double momentumInCM(Particle const *const p1, Particle const *const p2)
gives the momentum in the CM frame of two particles.
ThreeVector boostVector() const
Returns a three vector we can give to the boost() -method.
int G4int
Definition: G4Types.hh:78
ThreeVector normVector(G4double norm=1.)
Generate isotropically-distributed ThreeVectors of given norm.
void setY(G4double ay)
Set the y coordinate.
void generate(const G4double sqrtS, ParticleList &particles)
Generate momenta according to a uniform, non-Lorentz-invariant phase-space model. ...
G4double shoot()
Generate flat distribution of random numbers.
Definition: G4INCLRandom.cc:93
void setX(G4double ax)
Set the x coordinate.
double G4double
Definition: G4Types.hh:76
void setZ(G4double az)
Set the z coordinate.
G4double betaKopylov(G4int K) const
Internal function used by the Kopylov algorithm.
virtual void setMomentum(const G4INCL::ThreeVector &momentum)
Set the momentum vector.