Geant4-11
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
G4INCL::INCL::RecoilFunctor Class Reference

Class to adjust remnant recoil. More...

Inheritance diagram for G4INCL::INCL::RecoilFunctor:
G4INCL::RootFunctor G4INCL::IFunction1D

Public Types

typedef G4double(*const ManipulatorFunc) (const G4double)
 Typedef to simplify the syntax of inverseCDFTable. More...
 

Public Member Functions

void cleanUp (const G4bool success) const
 Clean up after root finding. More...
 
virtual G4double getXMaximum () const
 Return the maximum allowed value of the independent variable. More...
 
virtual G4double getXMinimum () const
 Return the minimum allowed value of the independent variable. More...
 
virtual G4double integrate (const G4double x0, const G4double x1, const G4double step=-1.) const
 Integrate the function between two values. More...
 
InterpolationTableinverseCDFTable (ManipulatorFunc fWrap=0, const G4int nNodes=60) const
 Return a pointer to the inverse of the CDF of this function. More...
 
G4double operator() (const G4double x) const
 Compute the energy-conservation violation. More...
 
IFunction1Dprimitive () const
 Return a pointer to the (numerical) primitive to this function. More...
 
 RecoilFunctor (Nucleus *const n, const EventInfo &ei)
 Prepare for calling the () operator and scaleParticleEnergies. More...
 
virtual ~RecoilFunctor ()
 

Protected Attributes

G4double xMax
 Maximum value of the independent variable. More...
 
G4double xMin
 Minimum value of the independent variable. More...
 

Private Member Functions

void scaleParticleEnergies (const G4double rescale) const
 Scale the kinetic energies of the outgoing particles. More...
 

Private Attributes

Nucleusnucleus
 Pointer to the nucleus. More...
 
ParticleList outgoingParticles
 List of final-state particles. More...
 
std::list< G4doubleparticleKineticEnergies
 Initial kinetic energies of the outgoing particles. More...
 
std::list< ThreeVectorparticleMomenta
 Initial momenta of the outgoing particles. More...
 
EventInfo const & theEventInfo
 

Static Private Attributes

static const G4double integrationCoefficients []
 Coefficients for numerical integration. More...
 

Detailed Description

Class to adjust remnant recoil.

Definition at line 107 of file G4INCLCascade.hh.

Member Typedef Documentation

◆ ManipulatorFunc

typedef G4double(*const G4INCL::IFunction1D::ManipulatorFunc) (const G4double)
inherited

Typedef to simplify the syntax of inverseCDFTable.

Definition at line 93 of file G4INCLIFunction1D.hh.

Constructor & Destructor Documentation

◆ RecoilFunctor()

G4INCL::INCL::RecoilFunctor::RecoilFunctor ( Nucleus *const  n,
const EventInfo ei 
)
inline

Prepare for calling the () operator and scaleParticleEnergies.

The constructor sets the private class members.

Definition at line 113 of file G4INCLCascade.hh.

113 :
114 RootFunctor(0., 1E6),
115 nucleus(n),
116 outgoingParticles(n->getStore()->getOutgoingParticles()),
117 theEventInfo(ei) {
118 for(ParticleIter p=outgoingParticles.begin(), e=outgoingParticles.end(); p!=e; ++p) {
119 particleMomenta.push_back((*p)->getMomentum());
120 particleKineticEnergies.push_back((*p)->getKineticEnergy());
121 }
122 ProjectileRemnant * const aPR = n->getProjectileRemnant();
123 if(aPR && aPR->getA()>0) {
124 particleMomenta.push_back(aPR->getMomentum());
125 particleKineticEnergies.push_back(aPR->getKineticEnergy());
126 outgoingParticles.push_back(aPR);
127 }
128 }
ParticleList outgoingParticles
List of final-state particles.
Nucleus * nucleus
Pointer to the nucleus.
std::list< G4double > particleKineticEnergies
Initial kinetic energies of the outgoing particles.
EventInfo const & theEventInfo
std::list< ThreeVector > particleMomenta
Initial momenta of the outgoing particles.
RootFunctor(const G4double x0, const G4double x1)
ParticleList::const_iterator ParticleIter

References G4INCL::Particle::getA(), G4INCL::Particle::getKineticEnergy(), G4INCL::Particle::getMomentum(), CLHEP::detail::n, outgoingParticles, particleKineticEnergies, and particleMomenta.

◆ ~RecoilFunctor()

virtual G4INCL::INCL::RecoilFunctor::~RecoilFunctor ( )
inlinevirtual

Definition at line 129 of file G4INCLCascade.hh.

129{}

Member Function Documentation

◆ cleanUp()

void G4INCL::INCL::RecoilFunctor::cleanUp ( const G4bool  success) const
inlinevirtual

Clean up after root finding.

Implements G4INCL::RootFunctor.

Definition at line 142 of file G4INCLCascade.hh.

142 {
143 if(!success)
145 }
void scaleParticleEnergies(const G4double rescale) const
Scale the kinetic energies of the outgoing particles.

References scaleParticleEnergies().

◆ getXMaximum()

virtual G4double G4INCL::IFunction1D::getXMaximum ( ) const
inlinevirtualinherited

Return the maximum allowed value of the independent variable.

Definition at line 75 of file G4INCLIFunction1D.hh.

75{ return xMax; }
G4double xMax
Maximum value of the independent variable.

References G4INCL::IFunction1D::xMax.

Referenced by G4INCL::IFunction1D::inverseCDFTable(), G4INCL::InvFInterpolationTable::InvFInterpolationTable(), and G4INCL::IFunction1D::primitive().

◆ getXMinimum()

virtual G4double G4INCL::IFunction1D::getXMinimum ( ) const
inlinevirtualinherited

Return the minimum allowed value of the independent variable.

Definition at line 72 of file G4INCLIFunction1D.hh.

72{ return xMin; }
G4double xMin
Minimum value of the independent variable.

References G4INCL::IFunction1D::xMin.

Referenced by G4INCL::IFunction1D::inverseCDFTable(), G4INCL::InvFInterpolationTable::InvFInterpolationTable(), and G4INCL::IFunction1D::primitive().

◆ integrate()

G4double G4INCL::IFunction1D::integrate ( const G4double  x0,
const G4double  x1,
const G4double  step = -1. 
) const
virtualinherited

Integrate the function between two values.

Parameters
x0lower integration bound
x1upper integration bound
steplargest integration step size; if <0, 45 steps will be used
Returns
$\int_{x_0}^{x_1} f(x) dx$

Definition at line 66 of file G4INCLIFunction1D.cc.

66 {
67 G4double xi = std::max(x0, xMin);
68 G4double xa = std::min(x1, xMax);
70
71 if(x1 <= x0) {
72 sign = -1.0;
73 std::swap(xi, xa);
74 } else
75 sign = 1.0;
76
77 const G4double interval = xa - xi;
78
79 G4int nIntervals;
80 if(step<0.) {
81 nIntervals = 45;
82 } else {
83 nIntervals = G4int(interval/step);
84
85 // Round up nIntervals to the closest multiple of 9
86 G4int remainder = nIntervals % 9;
87 if (remainder != 0)
88 nIntervals += 9 - remainder;
89
90 nIntervals = std::max(nIntervals, 9);
91 }
92
93 const G4double dx = interval/nIntervals;
94 G4double result = (operator()(xi) + operator()(xa)) * integrationCoefficients[0]/2;
95 for(G4int j = 1; j<nIntervals; ++j) {
96 const G4double x = xi + interval*G4double(j)/G4double(nIntervals);
97 const unsigned index = j%9;
98 result += operator()(x) * integrationCoefficients[index];
99 }
100
101 return result*dx*sign;
102
103 }
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
virtual G4double operator()(const G4double x) const =0
Compute the value of the function.
static const G4double integrationCoefficients[]
Coefficients for numerical integration.
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4int sign(const T t)

References G4INCL::IFunction1D::integrationCoefficients, G4INCL::Math::max(), G4INCL::Math::min(), G4INCL::IFunction1D::operator()(), G4INCL::Math::sign(), G4INCL::IFunction1D::xMax, and G4INCL::IFunction1D::xMin.

◆ inverseCDFTable()

InterpolationTable * G4INCL::IFunction1D::inverseCDFTable ( IFunction1D::ManipulatorFunc  fWrap = 0,
const G4int  nNodes = 60 
) const
inherited

Return a pointer to the inverse of the CDF of this function.

The function parameter fWrap is wrapped around the return value of operator(). If fWrap=NULL (default), fWrap=identity.

Definition at line 123 of file G4INCLIFunction1D.cc.

123 {
124 class InverseCDF : public IFunction1D {
125 public:
126 InverseCDF(IFunction1D const * const f, ManipulatorFunc fw) :
128 theFunction(f),
129 normalisation(1./theFunction->integrate(xMin,xMax)),
130 fWrap(fw)
131 {}
132
133 G4double operator()(const G4double x) const {
134 if(fWrap)
135 return fWrap(std::min(1., normalisation * theFunction->integrate(xMin,x)));
136 else
137 return std::min(1., normalisation * theFunction->integrate(xMin,x));
138 }
139 private:
140 IFunction1D const * const theFunction;
141 const G4double normalisation;
142 ManipulatorFunc fWrap;
143 } *theInverseCDF = new InverseCDF(this, fWrap);
144
145 InterpolationTable *theTable = new InvFInterpolationTable(*theInverseCDF, nNodes);
146 delete theInverseCDF;
147 return theTable;
148 }
virtual G4double getXMaximum() const
Return the maximum allowed value of the independent variable.
G4double(*const ManipulatorFunc)(const G4double)
Typedef to simplify the syntax of inverseCDFTable.
virtual G4double integrate(const G4double x0, const G4double x1, const G4double step=-1.) const
Integrate the function between two values.
virtual G4double getXMinimum() const
Return the minimum allowed value of the independent variable.

References G4INCL::IFunction1D::getXMaximum(), G4INCL::IFunction1D::getXMinimum(), G4INCL::IFunction1D::IFunction1D(), G4INCL::Math::min(), G4INCL::IFunction1D::operator()(), G4INCL::IFunction1D::xMax, and G4INCL::IFunction1D::xMin.

Referenced by G4INCL::NuclearDensityFactory::createPCDFTable(), G4INCL::NuclearDensityFactory::createRCDFTable(), and G4INCL::NuclearDensityFactory::createRPCorrelationTable().

◆ operator()()

G4double G4INCL::INCL::RecoilFunctor::operator() ( const G4double  x) const
inlinevirtual

Compute the energy-conservation violation.

Parameters
xscale factor for the particle energies
Returns
the energy-conservation violation

Implements G4INCL::IFunction1D.

Definition at line 136 of file G4INCLCascade.hh.

136 {
139 }
ConservationBalance getConservationBalance(EventInfo const &theEventInfo, const G4bool afterRecoil) const
Compute charge, mass, energy and momentum balance.

References G4INCL::Nucleus::ConservationBalance::energy, G4INCL::Nucleus::getConservationBalance(), nucleus, scaleParticleEnergies(), and theEventInfo.

◆ primitive()

IFunction1D * G4INCL::IFunction1D::primitive ( ) const
inherited

Return a pointer to the (numerical) primitive to this function.

Definition at line 105 of file G4INCLIFunction1D.cc.

105 {
106 class Primitive : public IFunction1D {
107 public:
108 Primitive(IFunction1D const * const f) :
110 theFunction(f)
111 {}
112
113 G4double operator()(const G4double x) const {
114 return theFunction->integrate(xMin,x);
115 }
116 private:
117 IFunction1D const * const theFunction;
118 } *thePrimitive = new Primitive(this);
119
120 return thePrimitive;
121 }

References G4INCL::IFunction1D::getXMaximum(), G4INCL::IFunction1D::getXMinimum(), G4INCL::IFunction1D::IFunction1D(), G4INCL::IFunction1D::operator()(), Primitive, and G4INCL::IFunction1D::xMin.

◆ scaleParticleEnergies()

void G4INCL::INCL::RecoilFunctor::scaleParticleEnergies ( const G4double  rescale) const
inlineprivate

Scale the kinetic energies of the outgoing particles.

Parameters
rescalescale factor

Definition at line 163 of file G4INCLCascade.hh.

163 {
164 // Rescale the energies (and the momenta) of the outgoing particles.
165 ThreeVector pBalance = nucleus->getIncomingMomentum();
166 std::list<ThreeVector>::const_iterator iP = particleMomenta.begin();
167 std::list<G4double>::const_iterator iE = particleKineticEnergies.begin();
168 for( ParticleIter i = outgoingParticles.begin(), e = outgoingParticles.end(); i!=e; ++i, ++iP, ++iE)
169 {
170 const G4double mass = (*i)->getMass();
171 const G4double newKineticEnergy = (*iE) * rescale;
172
173 (*i)->setMomentum(*iP);
174 (*i)->setEnergy(mass + newKineticEnergy);
175 (*i)->adjustMomentumFromEnergy();
176
177 pBalance -= (*i)->getMomentum();
178 }
179
180 nucleus->setMomentum(pBalance);
182 const G4double pRem2 = pBalance.mag2();
183 const G4double recoilEnergy = pRem2/
184 (std::sqrt(pRem2+remnantMass*remnantMass) + remnantMass);
185 nucleus->setEnergy(remnantMass + recoilEnergy);
186 }
const ThreeVector & getIncomingMomentum() const
Get the incoming momentum vector.
G4double getExcitationEnergy() const
Get the excitation energy of the nucleus.
G4int getS() const
Returns the strangeness number.
G4int getZ() const
Returns the charge number.
virtual void setMomentum(const G4INCL::ThreeVector &momentum)
void setEnergy(G4double energy)
G4int getA() const
Returns the baryon number.
G4ThreadLocal NuclearMassFn getTableMass
Static pointer to the mass function for nuclei.

References G4INCL::Particle::getA(), G4INCL::Nucleus::getExcitationEnergy(), G4INCL::Nucleus::getIncomingMomentum(), G4INCL::Particle::getS(), G4INCL::ParticleTable::getTableMass, G4INCL::Particle::getZ(), G4INCL::ThreeVector::mag2(), nucleus, outgoingParticles, particleKineticEnergies, particleMomenta, G4INCL::Particle::setEnergy(), and G4INCL::Particle::setMomentum().

Referenced by cleanUp(), and operator()().

Field Documentation

◆ integrationCoefficients

const G4double G4INCL::IFunction1D::integrationCoefficients
staticprivateinherited
Initial value:
= {
2.*95.0/288.0,
317.0/240.0,
23.0/30.0,
793.0/720.0,
157.0/160.0,
157.0/160.0,
793.0/720.0,
23.0/30.0,
317.0/240.0,
}

Coefficients for numerical integration.

Definition at line 110 of file G4INCLIFunction1D.hh.

Referenced by G4INCL::IFunction1D::integrate().

◆ nucleus

Nucleus* G4INCL::INCL::RecoilFunctor::nucleus
private

Pointer to the nucleus.

Definition at line 149 of file G4INCLCascade.hh.

Referenced by operator()(), and scaleParticleEnergies().

◆ outgoingParticles

ParticleList G4INCL::INCL::RecoilFunctor::outgoingParticles
private

List of final-state particles.

Definition at line 151 of file G4INCLCascade.hh.

Referenced by RecoilFunctor(), and scaleParticleEnergies().

◆ particleKineticEnergies

std::list<G4double> G4INCL::INCL::RecoilFunctor::particleKineticEnergies
private

Initial kinetic energies of the outgoing particles.

Definition at line 157 of file G4INCLCascade.hh.

Referenced by RecoilFunctor(), and scaleParticleEnergies().

◆ particleMomenta

std::list<ThreeVector> G4INCL::INCL::RecoilFunctor::particleMomenta
private

Initial momenta of the outgoing particles.

Definition at line 155 of file G4INCLCascade.hh.

Referenced by RecoilFunctor(), and scaleParticleEnergies().

◆ theEventInfo

EventInfo const& G4INCL::INCL::RecoilFunctor::theEventInfo
private

Definition at line 153 of file G4INCLCascade.hh.

Referenced by operator()().

◆ xMax

G4double G4INCL::IFunction1D::xMax
protectedinherited

Maximum value of the independent variable.

Definition at line 106 of file G4INCLIFunction1D.hh.

Referenced by G4INCL::IFunction1D::getXMaximum(), G4INCL::IFunction1D::integrate(), and G4INCL::IFunction1D::inverseCDFTable().

◆ xMin

G4double G4INCL::IFunction1D::xMin
protectedinherited

The documentation for this class was generated from the following file: