Geant4 11.1.1
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.

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)
 

Function Documentation

◆ MCGIDI_energy_free()

MCGIDI_energy * MCGIDI_energy_free ( statusMessageReporting smr,
MCGIDI_energy energy 
)

Definition at line 65 of file MCGIDI_energy.cc.

65 {
66
67 MCGIDI_energy_release( smr, energy );
68 smr_freeMemory( (void **) &energy );
69 return( NULL );
70}
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 57 of file MCGIDI_energy.cc.

57 {
58
59 memset( energy, 0, sizeof( MCGIDI_energy ) );
60 return( 0 );
61}

Referenced by MCGIDI_energy_new(), and MCGIDI_energy_release().

◆ MCGIDI_energy_new()

MCGIDI_energy * MCGIDI_energy_new ( statusMessageReporting smr)

Definition at line 46 of file MCGIDI_energy.cc.

46 {
47
49
50 if( ( energy = (MCGIDI_energy *) smr_malloc2( smr, sizeof( MCGIDI_energy ), 0, "energy" ) ) == NULL ) return( NULL );
51 if( MCGIDI_energy_initialize( smr, energy ) ) energy = MCGIDI_energy_free( smr, energy );
52 return( energy );
53}
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 97 of file MCGIDI_energy.cc.

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

74 {
75
76 int i;
77
79 if( energy->theta ) energy->theta = ptwXY_free( energy->theta );
80 if( energy->Watt_a ) energy->Watt_a = ptwXY_free( energy->Watt_a );
81 if( energy->Watt_b ) energy->Watt_b = ptwXY_free( energy->Watt_b );
85 for( i = 0; i < energy->weightedFunctionals.numberOfWeights; i++ ) {
86 ptwXY_free( energy->weightedFunctionals.weightedFunctional[i].weight );
87 MCGIDI_energy_free( smr, energy->weightedFunctionals.weightedFunctional[i].energy );
88 }
89 }
90
91 MCGIDI_energy_initialize( smr, energy );
92 return( 0 );
93}
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:216
@ MCGIDI_energyType_weightedFunctional
Definition: MCGIDI.h:216
@ MCGIDI_energyType_generalEvaporation
Definition: MCGIDI.h:215
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
Definition: ptwXY_core.cc:574

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 498 of file MCGIDI_energy.cc.

499 {
500/*
501* This function must be called before angular sampling as it sets the frame but does not test it.
502*/
503 double theta, randomEp, Watt_a, Watt_b, e_in = modes.getProjectileEnergy( );
505
506 decaySamplingInfo->frame = energy->frame;
507 switch( energy->type ) {
509 decaySamplingInfo->Ep = energy->gammaEnergy_MeV + e_in * energy->primaryGammaMassFactor;
510 break;
512 decaySamplingInfo->Ep = energy->gammaEnergy_MeV;
513 break;
515 randomEp = decaySamplingInfo->rng( decaySamplingInfo->rngState );
516 sampled.smr = smr;
517 sampled.w = e_in;
518 MCGIDI_sampling_sampleX_from_pdfsOfXGivenW( &(energy->dists), &sampled, randomEp );
519 decaySamplingInfo->Ep = sampled.x;
520 break;
522 sampled.interpolationXY = energy->gInterpolation;
523 MCGIDI_sampling_sampleX_from_pdfOfX( &(energy->g), &sampled, decaySamplingInfo->rng( decaySamplingInfo->rngState ) );
524 theta = MCGIDI_sampling_ptwXY_getValueAtX( energy->theta, e_in );
525 decaySamplingInfo->Ep = theta * sampled.x;
526 break;
528 theta = MCGIDI_sampling_ptwXY_getValueAtX( energy->theta, e_in );
529 MCGIDI_energy_sampleSimpleMaxwellianFission( smr, ( e_in - energy->U ) / theta, decaySamplingInfo );
530 decaySamplingInfo->Ep *= theta;
531 break;
533 theta = MCGIDI_sampling_ptwXY_getValueAtX( energy->theta, e_in );
534 MCGIDI_energy_sampleEvaporation( smr, ( e_in - energy->U ) / theta, decaySamplingInfo );
535 decaySamplingInfo->Ep *= theta;
536 break;
538 Watt_a = MCGIDI_sampling_ptwXY_getValueAtX( energy->Watt_a, e_in );
539 Watt_b = MCGIDI_sampling_ptwXY_getValueAtX( energy->Watt_b, e_in );
540 MCGIDI_energy_sampleWatt( smr, e_in - energy->U, Watt_a, Watt_b, decaySamplingInfo );
541 break;
543 MCGIDI_sampling_sampleX_from_pdfsOfXGivenW( &(energy->dists), &sampled, decaySamplingInfo->rng( decaySamplingInfo->rngState ) );
544 decaySamplingInfo->Ep = sampled.x;
545 break;
547 MCGIDI_sampling_sampleX_from_pdfOfX( &(energy->g), &sampled, decaySamplingInfo->rng( decaySamplingInfo->rngState ) );
548 decaySamplingInfo->Ep = ( energy->e_inCOMFactor * e_in + energy->NBodyPhaseSpace.Q_MeV ) * energy->NBodyPhaseSpace.massFactor * sampled.x;
549 break;
551 MCGIDI_energy_sampleWeightedFunctional( smr, energy, modes, decaySamplingInfo );
552 break;
553 default :
554 smr_setReportError2( smr, smr_unknownID, 1, "energy type = %d not supported", energy->type );
555 }
556
557 return( !smr_isOk( smr ) );
558}
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:215
@ MCGIDI_energyType_MadlandNix
Definition: MCGIDI.h:216
@ MCGIDI_energyType_evaporation
Definition: MCGIDI.h:215
@ MCGIDI_energyType_Watt
Definition: MCGIDI.h:216
double getProjectileEnergy(void) const
Definition: MCGIDI.h:97
int smr_isOk(statusMessageReporting *smr)
double(* rng)(void *)
Definition: MCGIDI.h:258
enum xDataTOM_frame frame
Definition: MCGIDI.h:256
ptwXY_interpolation interpolationXY
Definition: MCGIDI.h:313
statusMessageReporting * smr
Definition: MCGIDI.h:312

Referenced by MCGIDI_uncorrelated_sampleDistribution().