67const G4double G4CascadeFinalStateAlgorithm::maxCosTheta = 0.9999;
68const G4double G4CascadeFinalStateAlgorithm::oneOverE = 0.3678794;
69const G4double G4CascadeFinalStateAlgorithm::small = 1.e-10;
70const G4int G4CascadeFinalStateAlgorithm::itry_max = 10;
77 momDist(0), angDist(0), multiplicity(0), bullet_ekin(0.) {;}
94 const std::vector<G4int>& particle_kinds) {
99 multiplicity = (
G4int)particle_kinds.size();
101 G4int fs = (multiplicity==2) ? particle_kinds[0]*particle_kinds[1] : 0;
109 kinds = particle_kinds;
139 <<
" is " << is <<
" fs " << fs <<
G4endl;
145 if (fs > 0 && multiplicity == 2) {
146 G4int kw = (fs==is) ? 1 : 2;
148 }
else if (multiplicity == 3) {
155 G4cout <<
" " << (momDist?momDist->
GetName().c_str():
"") <<
" "
165 std::vector<G4LorentzVector>& finalState) {
171 if (multiplicity != 2)
return;
182 G4cout <<
" Particle kinds = " << kinds[0] <<
" , " << kinds[1]
183 <<
"\n pmod " << pscm
184 <<
"\n before rotation px " << mom.
x() <<
" py " << mom.
y()
185 <<
" pz " << mom.
z() <<
G4endl;
188 finalState.resize(2);
190 finalState[0].setVectM(mom, masses[0]);
191 finalState[0] = toSCM.
rotate(finalState[0]);
194 G4cout <<
" after rotation px " << finalState[0].x() <<
" py "
195 << finalState[0].y() <<
" pz " << finalState[0].z() <<
G4endl;
198 finalState[1].setVectM(-finalState[0].vect(), masses[1]);
206 std::vector<G4LorentzVector>& finalState) {
216 if (multiplicity < 3)
return;
217 if (!momDist)
return;
220 while ((
G4int)finalState.size() != multiplicity && ++itry < itry_max) {
233 if (!momDist)
return;
235 modules.resize(multiplicity,0.);
241 G4cout <<
" knd_last " << kinds.back() <<
" mass_last "
246 while (++itry < itry_max) {
254 for (i=0; i < multiplicity-1; i++) {
255 pmod = momDist->
GetMomentum(kinds[i], bullet_ekin);
257 if (pmod < small)
break;
258 eleft -= std::sqrt(pmod*pmod + masses[i]*masses[i]);
261 G4cout <<
" kp " << kinds[i] <<
" pmod " << pmod
262 <<
" mass2 " << masses[i]*masses[i] <<
" eleft " << eleft
263 <<
"\n x1 " << eleft - mass_last <<
G4endl;
266 if (eleft <= mass_last)
break;
271 if (i < multiplicity-1)
continue;
273 G4double plast = eleft * eleft - masses.back()*masses.back();
276 if (plast <= small)
continue;
278 plast = std::sqrt(plast);
279 modules.back() = plast;
284 if (itry >= itry_max) {
286 G4cerr <<
" Unable to generate momenta for multiplicity "
287 << multiplicity <<
G4endl;
300 return ( (pmod.size() != 3) ||
301 !(pmod[0] < std::fabs(pmod[1] - pmod[2]) ||
302 pmod[0] > pmod[1] + pmod[2] ||
303 pmod[1] < std::fabs(pmod[0] - pmod[2]) ||
304 pmod[1] > pmod[0] + pmod[2] ||
305 pmod[2] < std::fabs(pmod[0] - pmod[1]) ||
306 pmod[2] > pmod[1] + pmod[0])
314 std::vector<G4LorentzVector>& finalState) {
319 if ((
G4int)modules.size() != multiplicity)
return;
322 if (multiplicity == 3)
330 std::vector<G4LorentzVector>& finalState) {
334 finalState.resize(3);
338 finalState[2] = toSCM.
rotate(finalState[2]);
341 costh = -0.5 * (modules[2]*modules[2] + modules[0]*modules[0] -
342 modules[1]*modules[1]) / modules[2] / modules[0];
344 if (std::fabs(costh) >= maxCosTheta) {
354 finalState[0] = toSCM.
rotate(finalState[2], finalState[0]);
357 finalState[1].
set(0.,0.,0.,initialMass);
358 finalState[1] -= finalState[0] + finalState[2];
363 std::vector<G4LorentzVector>& finalState) {
370 finalState.resize(multiplicity);
372 for (
G4int i=0; i<multiplicity-2; i++) {
375 finalState[i] = toSCM.
rotate(finalState[i]);
380 std::accumulate(finalState.begin(), finalState.end()-2,
G4LorentzVector());
383 costh = -0.5 * (pmod*pmod +
384 modules[multiplicity-2]*modules[multiplicity-2] -
385 modules[multiplicity-1]*modules[multiplicity-1])
386 / pmod / modules[multiplicity-2];
390 if (std::fabs(costh) >= maxCosTheta) {
399 finalState[multiplicity-2] =
401 masses[multiplicity-2]);
402 finalState[multiplicity-2] = toSCM.
rotate(psum, finalState[multiplicity-2]);
405 finalState[multiplicity-1].
set(0.,0.,0.,initialMass);
406 finalState[multiplicity-1] -= psum + finalState[multiplicity-2];
415 G4cout <<
" >>> " <<
GetName() <<
"::GenerateCosTheta " << ptype
419 if (multiplicity == 3) {
424 G4double p0 = ptype<3 ? 0.36 : 0.25;
425 G4double alf = 1.0 / p0 / (p0 - (pmod+p0)*
G4Exp(-pmod / p0));
430 while (std::fabs(sinth) > maxCosTheta && ++itry1 < itry_max) {
435 G4cout <<
" s1 * alf * G4Exp(-s1 / p0) " << salf
436 <<
" s2 " << s2 <<
G4endl;
439 if (salf > s2) sinth = s1 / pmod;
443 G4cout <<
" itry1 " << itry1 <<
" sinth " << sinth <<
G4endl;
445 if (itry1 == itry_max) {
447 G4cout <<
" high energy angles generation: itry1 " << itry1 <<
G4endl;
453 G4double costh = std::sqrt(1.0 - sinth * sinth);
465 const std::vector<G4double>& masses,
466 std::vector<G4LorentzVector>& finalState) {
472 std::size_t
N = masses.size();
473 finalState.resize(
N);
475 G4double mtot = std::accumulate(masses.begin(), masses.end(), 0.0);
483 for (std::size_t k=
N-1; k>0; --k) {
496 finalState[k].setVectM(momV,masses[k]);
499 finalState[k].boost(boostV);
500 recoil.
boost(boostV);
504 finalState[0] = recoil;
512 G4double Fmax = std::sqrt(g4pow->
powN(xN/(xN+1.),
N)/(xN+1.));
517 F = std::sqrt(g4pow->
powN(chi,
N)*(1.-chi));
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void setRThetaPhi(double r, double theta, double phi)
Hep3Vector boostVector() const
HepLorentzVector & boost(double, double, double)
void setVectM(const Hep3Vector &spatial, double mass)
void set(double x, double y, double z, double t)
void FillDirThreeBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
virtual void GenerateMultiBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
G4CascadeFinalStateAlgorithm()
virtual void SetVerboseLevel(G4int verbose)
void FillUsingKopylov(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
virtual ~G4CascadeFinalStateAlgorithm()
void SaveKinematics(G4InuclElementaryParticle *bullet, G4InuclElementaryParticle *target)
void Configure(G4InuclElementaryParticle *bullet, G4InuclElementaryParticle *target, const std::vector< G4int > &particle_kinds)
G4double GenerateCosTheta(G4int ptype, G4double pmod) const
void FillDirManyBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
void FillDirections(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
virtual void GenerateTwoBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
void ChooseGenerators(G4int is, G4int fs)
void FillMagnitudes(G4double initialMass, const std::vector< G4double > &masses)
G4bool satisfyTriangle(const std::vector< G4double > &pmod) const
G4double BetaKopylov(G4int K) const
static G4bool usePhaseSpace()
void setVerbose(G4int vb=0)
void setBullet(const G4InuclParticle *bullet)
G4LorentzVector rotate(const G4LorentzVector &mom) const
G4double getKinEnergyInTheTRS() const
void setTarget(const G4InuclParticle *target)
static const G4VMultiBodyMomDst * GetDist(G4int is, G4int mult)
static void setVerboseLevel(G4int vb=0)
static G4Pow * GetInstance()
G4double powN(G4double x, G4int n) const
static void setVerboseLevel(G4int vb=0)
static const G4VTwoBodyAngDst * GetDist(G4int is, G4int fs, G4int kw)
G4double UniformTheta() const
const G4String & GetName() const
G4double UniformPhi() const
G4int GetVerboseLevel() const
G4double TwoBodyMomentum(G4double M0, G4double M1, G4double M2) const
virtual void SetVerboseLevel(G4int verbose)
virtual const G4String & GetName() const
virtual G4double GetMomentum(G4int ptype, const G4double &ekin) const =0
virtual const G4String & GetName() const
virtual G4double GetCosTheta(const G4double &ekin, const G4double &pcm) const =0
G4LorentzVector generateWithFixedTheta(G4double ct, G4double p, G4double mass=0.)