Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
MCGIDI_energy.cc File Reference
#include <string.h>
#include <cmath>
#include "MCGIDI_fromTOM.h"
#include "MCGIDI_misc.h"
#include "MCGIDI_private.h"
#include <nf_specialFunctions.h>

Go to the source code of this file.

Macros

#define _USE_MATH_DEFINES
 

Functions

MCGIDI_energyMCGIDI_energy_new (statusMessageReporting *smr)
 
int MCGIDI_energy_initialize (statusMessageReporting *, MCGIDI_energy *energy)
 
MCGIDI_energyMCGIDI_energy_free (statusMessageReporting *smr, MCGIDI_energy *energy)
 
int MCGIDI_energy_release (statusMessageReporting *smr, MCGIDI_energy *energy)
 
int MCGIDI_energy_parseFromTOM (statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution, ptwXYPoints *norms, enum MCGIDI_energyType energyType, double gammaEnergy_MeV)
 
int MCGIDI_energy_sampleEnergy (statusMessageReporting *smr, MCGIDI_energy *energy, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
 

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 6 of file MCGIDI_energy.cc.

Function Documentation

◆ MCGIDI_energy_free()

MCGIDI_energy * MCGIDI_energy_free ( statusMessageReporting * smr,
MCGIDI_energy * energy )

Definition at line 63 of file MCGIDI_energy.cc.

63 {
64
65 MCGIDI_energy_release( smr, energy );
66 smr_freeMemory( (void **) &energy );
67 return( NULL );
68}
int MCGIDI_energy_release(statusMessageReporting *smr, MCGIDI_energy *energy)
void * smr_freeMemory(void **p)

Referenced by MCGIDI_distribution_release(), MCGIDI_energy_new(), MCGIDI_energy_parseFromTOM(), and MCGIDI_energy_release().

◆ MCGIDI_energy_initialize()

int MCGIDI_energy_initialize ( statusMessageReporting * smr,
MCGIDI_energy * energy )

Definition at line 55 of file MCGIDI_energy.cc.

55 {
56
57 memset( energy, 0, sizeof( MCGIDI_energy ) );
58 return( 0 );
59}

Referenced by MCGIDI_energy_new(), and MCGIDI_energy_release().

◆ MCGIDI_energy_new()

MCGIDI_energy * MCGIDI_energy_new ( statusMessageReporting * smr)

Definition at line 44 of file MCGIDI_energy.cc.

44 {
45
47
48 if( ( energy = (MCGIDI_energy *) smr_malloc2( smr, sizeof( MCGIDI_energy ), 0, "energy" ) ) == NULL ) return( NULL );
49 if( MCGIDI_energy_initialize( smr, energy ) ) energy = MCGIDI_energy_free( smr, energy );
50 return( energy );
51}
MCGIDI_energy * MCGIDI_energy_free(statusMessageReporting *smr, MCGIDI_energy *energy)
int MCGIDI_energy_initialize(statusMessageReporting *, MCGIDI_energy *energy)
G4double energy(const ThreeVector &p, const G4double m)
#define smr_malloc2(smr, size, zero, forItem)

Referenced by MCGIDI_energy_parseFromTOM().

◆ MCGIDI_energy_parseFromTOM()

int MCGIDI_energy_parseFromTOM ( statusMessageReporting * smr,
xDataTOM_element * element,
MCGIDI_distribution * distribution,
ptwXYPoints * norms,
enum MCGIDI_energyType energyType,
double gammaEnergy_MeV )

Definition at line 95 of file MCGIDI_energy.cc.

96 {
97
98 MCGIDI_energy *energy = NULL;
99 xDataTOM_element *energyElement, *linearElement, *functional, *frameElement;
100 char const *nativeData;
101 double projectileMass_MeV, targetMass_MeV;
102
103 if( ( energy = MCGIDI_energy_new( smr ) ) == NULL ) goto err;
104
105 projectileMass_MeV = MCGIDI_product_getProjectileMass_MeV( smr, distribution->product );
106 targetMass_MeV = MCGIDI_product_getTargetMass_MeV( smr, distribution->product );
107 energy->e_inCOMFactor = targetMass_MeV / ( projectileMass_MeV + targetMass_MeV );
108
109 if( ( energyType == MCGIDI_energyType_primaryGamma ) || ( energyType == MCGIDI_energyType_discreteGamma ) ) {
110 energy->type = energyType;
111 energy->gammaEnergy_MeV = gammaEnergy_MeV;
112 energy->frame = xDataTOM_frame_lab; /* BRB. This should not be hardwired?????? Probably needs to be changed in GND also. */
113 if( energyType == MCGIDI_energyType_primaryGamma ) energy->primaryGammaMassFactor = energy->e_inCOMFactor; }
114 else {
115 if( ( energyElement = xDataTOME_getOneElementByName( smr, element, "energy", 1 ) ) == NULL ) goto err;
116 if( ( nativeData = xDataTOM_getAttributesValueInElement( energyElement, "nativeData" ) ) == NULL ) goto err;
117 if( ( linearElement = xDataTOME_getOneElementByName( NULL, energyElement, "linear", 0 ) ) == NULL )
118 linearElement = xDataTOME_getOneElementByName( NULL, energyElement, "pointwise", 0 );
119 if( linearElement == NULL ) {
120 if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "generalEvaporation", 0 ) ) != NULL ) {
121 if( MCGIDI_energy_parseGeneralEvaporationFromTOM( smr, functional, energy ) ) goto err; }
122 else if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "simpleMaxwellianFission", 0 ) ) != NULL ) {
123 if( MCGIDI_energy_parseSimpleMaxwellianFissionFromTOM( smr, functional, energy ) ) goto err; }
124 else if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "evaporation", 0 ) ) != NULL ) {
125 if( MCGIDI_energy_parseEvaporationFromTOM( smr, functional, energy ) ) goto err; }
126 else if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "Watt", 0 ) ) != NULL ) {
127 if( MCGIDI_energy_parseWattFromTOM( smr, functional, energy ) ) goto err; }
128 else if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "MadlandNix", 0 ) ) != NULL ) {
129 if( MCGIDI_energy_parseMadlandNixFromTOM( smr, functional, energy ) ) goto err; }
130 else if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "NBodyPhaseSpace", 0 ) ) != NULL ) {
131 if( MCGIDI_energy_parseNBodyPhaseSpaceFromTOM( smr, functional, energy, distribution ) ) goto err; }
132 else if( ( functional = xDataTOME_getOneElementByName( NULL, energyElement, "weightedFunctionals", 0 ) ) != NULL ) {
133 if( MCGIDI_energy_parseWeightedFunctionalsFromTOM( smr, functional, energy ) ) goto err; }
134 else {
135 smr_setReportError2( smr, smr_unknownID, 1, "unsupported energy type: nativeData = '%s'", nativeData );
136 goto err;
137 }
138 frameElement = functional; }
139 else {
140 char const *toUnits[3] = { "MeV", "MeV", "1/MeV" };
141
142 frameElement = linearElement;
143 if( MCGIDI_fromTOM_pdfsOfXGivenW( smr, linearElement, &(energy->dists), norms, toUnits ) ) goto err;
145 }
146 if( ( energy->frame = MCGIDI_misc_getProductFrame( smr, frameElement ) ) == xDataTOM_frame_invalid ) goto err;
147 }
148 distribution->energy = energy;
149
150 return( 0 );
151
152err:
153 if( energy != NULL ) MCGIDI_energy_free( smr, energy );
154 return( 1 );
155}
double MCGIDI_product_getTargetMass_MeV(statusMessageReporting *smr, MCGIDI_product *product)
double MCGIDI_product_getProjectileMass_MeV(statusMessageReporting *smr, MCGIDI_product *product)
@ MCGIDI_energyType_primaryGamma
Definition MCGIDI.h:210
@ MCGIDI_energyType_discreteGamma
Definition MCGIDI.h:210
@ MCGIDI_energyType_linear
Definition MCGIDI.h:211
MCGIDI_energy * MCGIDI_energy_new(statusMessageReporting *smr)
int MCGIDI_fromTOM_pdfsOfXGivenW(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_pdfsOfXGivenW *dists, ptwXYPoints *norms, char const *toUnits[3])
enum xDataTOM_frame MCGIDI_misc_getProductFrame(statusMessageReporting *smr, xDataTOM_element *frameElement)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
#define smr_unknownID
MCGIDI_energy * energy
Definition MCGIDI.h:380
MCGIDI_product * product
Definition MCGIDI.h:377
xDataTOM_element * xDataTOME_getOneElementByName(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required)
Definition xDataTOM.cc:246
char const * xDataTOM_getAttributesValueInElement(xDataTOM_element *element, char const *name)
Definition xDataTOM.cc:286
@ xDataTOM_frame_invalid
Definition xDataTOM.h:23
@ xDataTOM_frame_lab
Definition xDataTOM.h:23

Referenced by MCGIDI_uncorrelated_parseFromTOM().

◆ MCGIDI_energy_release()

int MCGIDI_energy_release ( statusMessageReporting * smr,
MCGIDI_energy * energy )

Definition at line 72 of file MCGIDI_energy.cc.

72 {
73
74 int i;
75
77 if( energy->theta ) energy->theta = ptwXY_free( energy->theta );
78 if( energy->Watt_a ) energy->Watt_a = ptwXY_free( energy->Watt_a );
79 if( energy->Watt_b ) energy->Watt_b = ptwXY_free( energy->Watt_b );
83 for( i = 0; i < energy->weightedFunctionals.numberOfWeights; i++ ) {
84 ptwXY_free( energy->weightedFunctionals.weightedFunctional[i].weight );
85 MCGIDI_energy_free( smr, energy->weightedFunctionals.weightedFunctional[i].energy );
86 }
87 }
88
89 MCGIDI_energy_initialize( smr, energy );
90 return( 0 );
91}
int MCGIDI_sampling_pdfsOfXGivenW_release(statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *dists)
int MCGIDI_sampling_pdfsOfX_release(statusMessageReporting *smr, MCGIDI_pdfOfX *dist)
@ MCGIDI_energyType_NBodyPhaseSpace
Definition MCGIDI.h:212
@ MCGIDI_energyType_weightedFunctional
Definition MCGIDI.h:212
@ MCGIDI_energyType_generalEvaporation
Definition MCGIDI.h:211
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)

Referenced by MCGIDI_energy_free().

◆ MCGIDI_energy_sampleEnergy()

int MCGIDI_energy_sampleEnergy ( statusMessageReporting * smr,
MCGIDI_energy * energy,
MCGIDI_quantitiesLookupModes & modes,
MCGIDI_decaySamplingInfo * decaySamplingInfo )

Definition at line 496 of file MCGIDI_energy.cc.

497 {
498/*
499* This function must be called before angular sampling as it sets the frame but does not test it.
500*/
501 double theta, randomEp, Watt_a, Watt_b, e_in = modes.getProjectileEnergy( );
503
504 decaySamplingInfo->frame = energy->frame;
505 switch( energy->type ) {
507 decaySamplingInfo->Ep = energy->gammaEnergy_MeV + e_in * energy->primaryGammaMassFactor;
508 break;
510 decaySamplingInfo->Ep = energy->gammaEnergy_MeV;
511 break;
513 randomEp = decaySamplingInfo->rng( decaySamplingInfo->rngState );
514 sampled.smr = smr;
515 sampled.w = e_in;
516 MCGIDI_sampling_sampleX_from_pdfsOfXGivenW( &(energy->dists), &sampled, randomEp );
517 decaySamplingInfo->Ep = sampled.x;
518 break;
520 sampled.interpolationXY = energy->gInterpolation;
521 MCGIDI_sampling_sampleX_from_pdfOfX( &(energy->g), &sampled, decaySamplingInfo->rng( decaySamplingInfo->rngState ) );
522 theta = MCGIDI_sampling_ptwXY_getValueAtX( energy->theta, e_in );
523 decaySamplingInfo->Ep = theta * sampled.x;
524 break;
526 theta = MCGIDI_sampling_ptwXY_getValueAtX( energy->theta, e_in );
527 MCGIDI_energy_sampleSimpleMaxwellianFission( smr, ( e_in - energy->U ) / theta, decaySamplingInfo );
528 decaySamplingInfo->Ep *= theta;
529 break;
531 theta = MCGIDI_sampling_ptwXY_getValueAtX( energy->theta, e_in );
532 MCGIDI_energy_sampleEvaporation( smr, ( e_in - energy->U ) / theta, decaySamplingInfo );
533 decaySamplingInfo->Ep *= theta;
534 break;
536 Watt_a = MCGIDI_sampling_ptwXY_getValueAtX( energy->Watt_a, e_in );
537 Watt_b = MCGIDI_sampling_ptwXY_getValueAtX( energy->Watt_b, e_in );
538 MCGIDI_energy_sampleWatt( smr, e_in - energy->U, Watt_a, Watt_b, decaySamplingInfo );
539 break;
541 MCGIDI_sampling_sampleX_from_pdfsOfXGivenW( &(energy->dists), &sampled, decaySamplingInfo->rng( decaySamplingInfo->rngState ) );
542 decaySamplingInfo->Ep = sampled.x;
543 break;
545 MCGIDI_sampling_sampleX_from_pdfOfX( &(energy->g), &sampled, decaySamplingInfo->rng( decaySamplingInfo->rngState ) );
546 decaySamplingInfo->Ep = ( energy->e_inCOMFactor * e_in + energy->NBodyPhaseSpace.Q_MeV ) * energy->NBodyPhaseSpace.massFactor * sampled.x;
547 break;
549 MCGIDI_energy_sampleWeightedFunctional( smr, energy, modes, decaySamplingInfo );
550 break;
551 default :
552 smr_setReportError2( smr, smr_unknownID, 1, "energy type = %d not supported", energy->type );
553 }
554
555 return( !smr_isOk( smr ) );
556}
double MCGIDI_sampling_ptwXY_getValueAtX(ptwXYPoints *ptwXY, double x1)
int MCGIDI_sampling_sampleX_from_pdfOfX(MCGIDI_pdfOfX *dist, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r)
int MCGIDI_sampling_sampleX_from_pdfsOfXGivenW(MCGIDI_pdfsOfXGivenW *dists, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r)
@ MCGIDI_energyType_simpleMaxwellianFission
Definition MCGIDI.h:211
@ MCGIDI_energyType_MadlandNix
Definition MCGIDI.h:212
@ MCGIDI_energyType_evaporation
Definition MCGIDI.h:211
@ MCGIDI_energyType_Watt
Definition MCGIDI.h:212
double getProjectileEnergy(void) const
Definition MCGIDI.h:93
int smr_isOk(statusMessageReporting *smr)
double(* rng)(void *)
Definition MCGIDI.h:254
enum xDataTOM_frame frame
Definition MCGIDI.h:252
ptwXY_interpolation interpolationXY
Definition MCGIDI.h:309
statusMessageReporting * smr
Definition MCGIDI.h:308

Referenced by MCGIDI_uncorrelated_sampleDistribution().