63 using namespace G4InuclSpecialFunctions;
68 const G4double G4CascadeFinalStateAlgorithm::maxCosTheta = 0.9999;
69 const G4double G4CascadeFinalStateAlgorithm::oneOverE = 0.3678794;
70 const G4double G4CascadeFinalStateAlgorithm::small = 1.e-10;
71 const G4int G4CascadeFinalStateAlgorithm::itry_max = 10;
78 momDist(0), angDist(0), multiplicity(0), bullet_ekin(0.) {;}
95 const std::vector<G4int>& particle_kinds) {
100 multiplicity = particle_kinds.size();
102 G4int fs = (multiplicity==2) ? particle_kinds[0]*particle_kinds[1] : 0;
110 kinds = particle_kinds;
140 <<
" is " << is <<
" fs " << fs <<
G4endl;
146 if (fs > 0 && multiplicity == 2) {
147 G4int kw = (fs==is) ? 1 : 2;
149 }
else if (multiplicity == 3) {
156 G4cout <<
" " << (momDist?momDist->
GetName().c_str():
"") <<
" "
157 << (angDist?angDist->
GetName().c_str():
"") << G4endl;
166 std::vector<G4LorentzVector>& finalState) {
172 if (multiplicity != 2)
return;
183 G4cout <<
" Particle kinds = " << kinds[0] <<
" , " << kinds[1]
184 <<
"\n pmod " << pscm
185 <<
"\n before rotation px " << mom.
x() <<
" py " << mom.
y()
186 <<
" pz " << mom.
z() <<
G4endl;
189 finalState.resize(2);
191 finalState[0].setVectM(mom, masses[0]);
192 finalState[0] = toSCM.
rotate(finalState[0]);
195 G4cout <<
" after rotation px " << finalState[0].x() <<
" py "
196 << finalState[0].y() <<
" pz " << finalState[0].z() <<
G4endl;
199 finalState[1].setVectM(-finalState[0].vect(), masses[1]);
207 std::vector<G4LorentzVector>& finalState) {
217 if (multiplicity < 3)
return;
218 if (!momDist)
return;
221 while ((
G4int)finalState.size() != multiplicity && ++itry < itry_max) {
234 if (!momDist)
return;
236 modules.resize(multiplicity,0.);
242 G4cout <<
" knd_last " << kinds.back() <<
" mass_last "
247 while (++itry < itry_max) {
255 for (i=0; i < multiplicity-1; i++) {
256 pmod = momDist->
GetMomentum(kinds[i], bullet_ekin);
258 if (pmod < small)
break;
259 eleft -= std::sqrt(pmod*pmod + masses[i]*masses[i]);
262 G4cout <<
" kp " << kinds[i] <<
" pmod " << pmod
263 <<
" mass2 " << masses[i]*masses[i] <<
" eleft " << eleft
264 <<
"\n x1 " << eleft - mass_last <<
G4endl;
267 if (eleft <= mass_last)
break;
272 if (i < multiplicity-1)
continue;
274 G4double plast = eleft * eleft - masses.back()*masses.back();
277 if (plast <= small)
continue;
279 plast = std::sqrt(plast);
280 modules.back() = plast;
285 if (itry >= itry_max) {
287 G4cerr <<
" Unable to generate momenta for multiplicity "
288 << multiplicity <<
G4endl;
301 return ( (pmod.size() != 3) ||
302 !(pmod[0] < std::fabs(pmod[1] - pmod[2]) ||
303 pmod[0] > pmod[1] + pmod[2] ||
304 pmod[1] < std::fabs(pmod[0] - pmod[2]) ||
305 pmod[1] > pmod[0] + pmod[2] ||
306 pmod[2] < std::fabs(pmod[0] - pmod[1]) ||
307 pmod[2] > pmod[1] + pmod[0])
315 std::vector<G4LorentzVector>& finalState) {
320 if ((
G4int)modules.size() != multiplicity)
return;
323 if (multiplicity == 3)
331 std::vector<G4LorentzVector>& finalState) {
335 finalState.resize(3);
339 finalState[2] = toSCM.
rotate(finalState[2]);
342 costh = -0.5 * (modules[2]*modules[2] + modules[0]*modules[0] -
343 modules[1]*modules[1]) / modules[2] / modules[0];
345 if (std::fabs(costh) >= maxCosTheta) {
355 finalState[0] = toSCM.
rotate(finalState[2], finalState[0]);
358 finalState[1].
set(0.,0.,0.,initialMass);
359 finalState[1] -= finalState[0] + finalState[2];
364 std::vector<G4LorentzVector>& finalState) {
371 finalState.resize(multiplicity);
373 for (
G4int i=0; i<multiplicity-2; i++) {
376 finalState[i] = toSCM.
rotate(finalState[i]);
381 std::accumulate(finalState.begin(), finalState.end()-2,
G4LorentzVector());
384 costh = -0.5 * (pmod*pmod +
385 modules[multiplicity-2]*modules[multiplicity-2] -
386 modules[multiplicity-1]*modules[multiplicity-1])
387 / pmod / modules[multiplicity-2];
391 if (std::fabs(costh) >= maxCosTheta) {
400 finalState[multiplicity-2] =
402 masses[multiplicity-2]);
403 finalState[multiplicity-2] = toSCM.
rotate(psum, finalState[multiplicity-2]);
406 finalState[multiplicity-1].
set(0.,0.,0.,initialMass);
407 finalState[multiplicity-1] -= psum + finalState[multiplicity-2];
416 G4cout <<
" >>> " <<
GetName() <<
"::GenerateCosTheta " << ptype
420 if (multiplicity == 3) {
425 G4double p0 = ptype<3 ? 0.36 : 0.25;
426 G4double alf = 1.0 / p0 / (p0 - (pmod+p0)*
G4Exp(-pmod / p0));
431 while (std::fabs(sinth) > maxCosTheta && ++itry1 < itry_max) {
436 G4cout <<
" s1 * alf * G4Exp(-s1 / p0) " << salf
437 <<
" s2 " << s2 <<
G4endl;
440 if (salf > s2) sinth = s1 / pmod;
444 G4cout <<
" itry1 " << itry1 <<
" sinth " << sinth <<
G4endl;
446 if (itry1 == itry_max) {
448 G4cout <<
" high energy angles generation: itry1 " << itry1 <<
G4endl;
454 G4double costh = std::sqrt(1.0 - sinth * sinth);
466 const std::vector<G4double>& masses,
467 std::vector<G4LorentzVector>& finalState) {
473 size_t N = masses.size();
474 finalState.resize(N);
476 G4double mtot = std::accumulate(masses.begin(), masses.end(), 0.0);
484 for (
size_t k=N-1; k>0; --k) {
497 finalState[k].setVectM(momV,masses[k]);
500 finalState[k].boost(boostV);
501 recoil.
boost(boostV);
505 finalState[0] = recoil;
513 G4double Fmax = std::sqrt(g4pow->
powN(xN/(xN+1.),N)/(xN+1.));
518 F = std::sqrt(g4pow->
powN(chi,N)*(1.-chi));
virtual const G4String & GetName() const
static G4Pow * GetInstance()
static void setVerboseLevel(G4int vb=0)
static const G4VTwoBodyAngDst * GetDist(G4int is, G4int fs, G4int kw)
Hep3Vector boostVector() const
virtual void GenerateMultiBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
G4double UniformTheta() const
G4double powN(G4double x, G4int n) const
void FillDirThreeBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
G4int GetVerboseLevel() const
G4LorentzVector rotate(const G4LorentzVector &mom) const
void setBullet(const G4InuclParticle *bullet)
void SaveKinematics(G4InuclElementaryParticle *bullet, G4InuclElementaryParticle *target)
void setVectM(const Hep3Vector &spatial, double mass)
void FillMagnitudes(G4double initialMass, const std::vector< G4double > &masses)
G4GLOB_DLL std::ostream G4cout
void setVerbose(G4int vb=0)
HepLorentzVector & boost(double, double, double)
G4bool satisfyTriangle(const std::vector< G4double > &pmod) const
G4double getKinEnergyInTheTRS() const
void setRThetaPhi(double r, double theta, double phi)
G4double GenerateCosTheta(G4int ptype, G4double pmod) const
virtual const G4String & GetName() const
virtual G4double GetMomentum(G4int ptype, const G4double &ekin) const =0
static void setVerboseLevel(G4int vb=0)
static G4bool usePhaseSpace()
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
virtual void SetVerboseLevel(G4int verbose)
void Configure(G4InuclElementaryParticle *bullet, G4InuclElementaryParticle *target, const std::vector< G4int > &particle_kinds)
const G4String & GetName() const
void set(double x, double y, double z, double t)
virtual void GenerateTwoBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
G4LorentzVector generateWithFixedTheta(G4double ct, G4double p, G4double mass=0.)
G4double UniformPhi() const
G4double TwoBodyMomentum(G4double M0, G4double M1, G4double M2) const
void FillDirections(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
void FillUsingKopylov(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
G4CascadeFinalStateAlgorithm()
virtual void SetVerboseLevel(G4int verbose)
void ChooseGenerators(G4int is, G4int fs)
void FillDirManyBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
virtual ~G4CascadeFinalStateAlgorithm()
virtual G4double GetCosTheta(const G4double &ekin, const G4double &pcm) const =0
static const G4VMultiBodyMomDst * GetDist(G4int is, G4int mult)
G4double BetaKopylov(G4int K) const
G4GLOB_DLL std::ostream G4cerr
void setTarget(const G4InuclParticle *target)
CLHEP::HepLorentzVector G4LorentzVector