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

RootFunctor-derived object for enforcing energy conservation in N-N. More...

Inheritance diagram for G4INCL::InteractionAvatar::ViolationEMomentumFunctor:
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...
 
 ViolationEMomentumFunctor (Nucleus *const nucleus, ParticleList const &modAndCre, const G4double totalEnergyBeforeInteraction, ThreeVector const &boost, const G4bool localE)
 Prepare for calling the () operator and scaleParticleMomenta. More...
 
virtual ~ViolationEMomentumFunctor ()
 

Protected Attributes

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

Private Member Functions

void scaleParticleMomenta (const G4double alpha) const
 Scale the momenta of the modified and created particles. More...
 

Private Attributes

ThreeVector const & boostVector
 Pointer to the boost vector. More...
 
ParticleList finalParticles
 List of final-state particles. More...
 
G4double initialEnergy
 Total energy before the interaction. More...
 
std::vector< ThreeVectorparticleMomenta
 CM particle momenta, as determined by the channel. More...
 
const G4bool shouldUseLocalEnergy
 True if we should use local energy. More...
 
NucleustheNucleus
 Pointer to the nucleus. More...
 

Static Private Attributes

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

Detailed Description

RootFunctor-derived object for enforcing energy conservation in N-N.

Definition at line 116 of file G4INCLInteractionAvatar.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

◆ ViolationEMomentumFunctor()

G4INCL::InteractionAvatar::ViolationEMomentumFunctor::ViolationEMomentumFunctor ( Nucleus *const  nucleus,
ParticleList const &  modAndCre,
const G4double  totalEnergyBeforeInteraction,
ThreeVector const &  boost,
const G4bool  localE 
)

Prepare for calling the () operator and scaleParticleMomenta.

The constructor sets the private class members.

Definition at line 391 of file G4INCLInteractionAvatar.cc.

391 :
392 RootFunctor(0., 1E6),
393 finalParticles(modAndCre),
394 initialEnergy(totalEnergyBeforeInteraction),
395 theNucleus(nucleus),
396 boostVector(boost),
398 {
399 // Store the particle momenta (necessary for the calls to
400 // scaleParticleMomenta() to work)
401 for(ParticleIter i=finalParticles.begin(), e=finalParticles.end(); i!=e; ++i) {
402 (*i)->boost(boostVector);
403 particleMomenta.push_back((*i)->getMomentum());
404 }
405 }
ThreeVector const & boostVector
Pointer to the boost vector.
ParticleList finalParticles
List of final-state particles.
std::vector< ThreeVector > particleMomenta
CM particle momenta, as determined by the channel.
const G4bool shouldUseLocalEnergy
True if we should use local energy.
G4double initialEnergy
Total energy before the interaction.
RootFunctor(const G4double x0, const G4double x1)
ParticleList::const_iterator ParticleIter

References boostVector, finalParticles, and particleMomenta.

◆ ~ViolationEMomentumFunctor()

G4INCL::InteractionAvatar::ViolationEMomentumFunctor::~ViolationEMomentumFunctor ( )
virtual

Definition at line 407 of file G4INCLInteractionAvatar.cc.

407 {
408 particleMomenta.clear();
409 }

Member Function Documentation

◆ cleanUp()

void G4INCL::InteractionAvatar::ViolationEMomentumFunctor::cleanUp ( const G4bool  success) const
virtual

Clean up after root finding.

Implements G4INCL::RootFunctor.

Definition at line 475 of file G4INCLInteractionAvatar.cc.

475 {
476 if(!success)
478 }
void scaleParticleMomenta(const G4double alpha) const
Scale the momenta of the modified and created particles.

◆ 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::InteractionAvatar::ViolationEMomentumFunctor::operator() ( const G4double  x) const
virtual

Compute the energy-conservation violation.

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

Implements G4INCL::IFunction1D.

Definition at line 411 of file G4INCLInteractionAvatar.cc.

411 {
413
414 G4double deltaE = 0.0;
415 for(ParticleIter i=finalParticles.begin(), e=finalParticles.end(); i!=e; ++i)
416 deltaE += (*i)->getEnergy() - (*i)->getPotentialEnergy();
417 deltaE -= initialEnergy;
418 return deltaE;
419 }
static const G4double alpha

References alpha.

◆ 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.

◆ scaleParticleMomenta()

void G4INCL::InteractionAvatar::ViolationEMomentumFunctor::scaleParticleMomenta ( const G4double  alpha) const
private

Scale the momenta of the modified and created particles.

Set the momenta of the modified and created particles to alpha times their original momenta (stored in particleMomenta). You must call init() before using this method.

Parameters
alphascale factor

Definition at line 421 of file G4INCLInteractionAvatar.cc.

421 {
422
423 std::vector<ThreeVector>::const_iterator iP = particleMomenta.begin();
424 for(ParticleIter i=finalParticles.begin(), e=finalParticles.end(); i!=e; ++i, ++iP) {
425 (*i)->setMomentum((*iP)*alpha);
426 (*i)->adjustEnergyFromMomentum();
427 (*i)->rpCorrelate();
428 (*i)->boost(-boostVector);
429 if(theNucleus){
431 } else {
432 (*i)->setPotentialEnergy(0.);
433 }
434//jcd if(shouldUseLocalEnergy && !(*i)->isPion()) { // This translates AECSVT's loops 1, 3 and 4
435 if(shouldUseLocalEnergy && !(*i)->isPion() && !(*i)->isEta() && !(*i)->isOmega() &&
436 !(*i)->isKaon() && !(*i)->isAntiKaon() && !(*i)->isSigma() && !(*i)->isLambda()) { // This translates AECSVT's loops 1, 3 and 4
437// assert(theNucleus); // Local energy without a nucleus doesn't make sense
438 const G4double energy = (*i)->getEnergy(); // Store the energy of the particle
439 G4double locE = KinematicsUtils::getLocalEnergy(theNucleus, *i); // Initial value of local energy
440 G4double locEOld;
442 for(G4int iterLocE=0;
444 ++iterLocE) {
445 locEOld = locE;
446 (*i)->setEnergy(energy + locE); // Update the energy of the particle...
447 (*i)->adjustMomentumFromEnergy();
448 theNucleus->updatePotentialEnergy(*i); // ...update its potential energy...
449 locE = KinematicsUtils::getLocalEnergy(theNucleus, *i); // ...and recompute locE.
450 deltaLocE = std::abs(locE-locEOld);
451 }
452 }
453
454//jlrs For lambdas and nuclei with masses higher than 19 also local energy
455 if(shouldUseLocalEnergy && (*i)->isLambda() && theNucleus->getA()>19) {
456// assert(theNucleus); // Local energy without a nucleus doesn't make sense
457 const G4double energy = (*i)->getEnergy(); // Store the energy of the particle
458 G4double locE = KinematicsUtils::getLocalEnergy(theNucleus, *i); // Initial value of local energy
459 G4double locEOld;
461 for(G4int iterLocE=0;
463 ++iterLocE) {
464 locEOld = locE;
465 (*i)->setEnergy(energy + locE); // Update the energy of the particle...
466 (*i)->adjustMomentumFromEnergy();
467 theNucleus->updatePotentialEnergy(*i); // ...update its potential energy...
468 locE = KinematicsUtils::getLocalEnergy(theNucleus, *i); // ...and recompute locE.
469 deltaLocE = std::abs(locE-locEOld);
470 }
471 }
472 }
473 }
static const G4int maxIterLocE
Max number of iterations for the determination of the local-energy Q-value.
static const G4double locEAccuracy
Target accuracy in the determination of the local-energy Q-value.
void updatePotentialEnergy(Particle *p) const
Update the particle potential energy.
G4int getA() const
Returns the baryon number.
G4double energy(const ThreeVector &p, const G4double m)
G4double getLocalEnergy(Nucleus const *const n, Particle *const p)

References alpha, G4INCL::InteractionAvatar::boostVector, G4INCL::KinematicsUtils::energy(), G4INCL::Particle::getA(), G4INCL::KinematicsUtils::getLocalEnergy(), G4INCL::InteractionAvatar::locEAccuracy, G4INCL::InteractionAvatar::maxIterLocE, G4INCL::InteractionAvatar::shouldUseLocalEnergy(), G4INCL::InteractionAvatar::theNucleus, and G4INCL::Nucleus::updatePotentialEnergy().

Field Documentation

◆ boostVector

ThreeVector const& G4INCL::InteractionAvatar::ViolationEMomentumFunctor::boostVector
private

Pointer to the boost vector.

Definition at line 145 of file G4INCLInteractionAvatar.hh.

Referenced by ViolationEMomentumFunctor().

◆ finalParticles

ParticleList G4INCL::InteractionAvatar::ViolationEMomentumFunctor::finalParticles
private

List of final-state particles.

Definition at line 137 of file G4INCLInteractionAvatar.hh.

Referenced by ViolationEMomentumFunctor().

◆ initialEnergy

G4double G4INCL::InteractionAvatar::ViolationEMomentumFunctor::initialEnergy
private

Total energy before the interaction.

Definition at line 141 of file G4INCLInteractionAvatar.hh.

◆ 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().

◆ particleMomenta

std::vector<ThreeVector> G4INCL::InteractionAvatar::ViolationEMomentumFunctor::particleMomenta
private

CM particle momenta, as determined by the channel.

Definition at line 139 of file G4INCLInteractionAvatar.hh.

Referenced by ViolationEMomentumFunctor().

◆ shouldUseLocalEnergy

const G4bool G4INCL::InteractionAvatar::ViolationEMomentumFunctor::shouldUseLocalEnergy
private

True if we should use local energy.

Definition at line 148 of file G4INCLInteractionAvatar.hh.

◆ theNucleus

Nucleus* G4INCL::InteractionAvatar::ViolationEMomentumFunctor::theNucleus
private

Pointer to the nucleus.

Definition at line 143 of file G4INCLInteractionAvatar.hh.

◆ 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 files: