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

Go to the source code of this file.

Functions

MCGIDI_KalbachMannMCGIDI_KalbachMann_new (statusMessageReporting *smr, ptwXY_interpolation interpolationWY, ptwXY_interpolation interpolationXY)
 
int MCGIDI_KalbachMann_initialize (statusMessageReporting *, MCGIDI_KalbachMann *KalbachMann, ptwXY_interpolation interpolationWY, ptwXY_interpolation interpolationXY)
 
MCGIDI_KalbachMannMCGIDI_KalbachMann_free (statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann)
 
int MCGIDI_KalbachMann_release (statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann)
 
int MCGIDI_KalbachMann_parseFromTOM (statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution)
 
int MCGIDI_KalbachMann_sampleEp (statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
 

Variables

const double C1 = 0.04
 
const double C2 = 1.8e-6
 

Function Documentation

◆ MCGIDI_KalbachMann_free()

MCGIDI_KalbachMann * MCGIDI_KalbachMann_free ( statusMessageReporting smr,
MCGIDI_KalbachMann KalbachMann 
)

Definition at line 61 of file MCGIDI_KalbachMann.cc.

61 {
62
63 MCGIDI_KalbachMann_release( smr, KalbachMann );
64 smr_freeMemory( (void **) &KalbachMann );
65 return( NULL );
66}
int MCGIDI_KalbachMann_release(statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann)
void * smr_freeMemory(void **p)

Referenced by MCGIDI_distribution_release(), MCGIDI_KalbachMann_new(), and MCGIDI_KalbachMann_parseFromTOM().

◆ MCGIDI_KalbachMann_initialize()

int MCGIDI_KalbachMann_initialize ( statusMessageReporting smr,
MCGIDI_KalbachMann KalbachMann,
ptwXY_interpolation  interpolationWY,
ptwXY_interpolation  interpolationXY 
)

Definition at line 51 of file MCGIDI_KalbachMann.cc.

51 {
52
53 memset( KalbachMann, 0, sizeof( MCGIDI_KalbachMann ) );
54 KalbachMann->dists.interpolationWY = interpolationWY;
55 KalbachMann->dists.interpolationXY = interpolationXY;
56 return( 0 );
57}
MCGIDI_pdfsOfXGivenW dists
Definition: MCGIDI.h:376
ptwXY_interpolation interpolationXY
Definition: MCGIDI.h:306
ptwXY_interpolation interpolationWY
Definition: MCGIDI.h:306

Referenced by MCGIDI_KalbachMann_new(), and MCGIDI_KalbachMann_release().

◆ MCGIDI_KalbachMann_new()

MCGIDI_KalbachMann * MCGIDI_KalbachMann_new ( statusMessageReporting smr,
ptwXY_interpolation  interpolationWY,
ptwXY_interpolation  interpolationXY 
)

Definition at line 39 of file MCGIDI_KalbachMann.cc.

40 {
41
42 MCGIDI_KalbachMann *KalbachMann;
43
44 if( ( KalbachMann = (MCGIDI_KalbachMann *) smr_malloc2( smr, sizeof( MCGIDI_KalbachMann ), 0, "KalbachMann" ) ) == NULL ) return( NULL );
45 if( MCGIDI_KalbachMann_initialize( smr, KalbachMann, interpolationWY, interpolationXY ) ) KalbachMann = MCGIDI_KalbachMann_free( smr, KalbachMann );
46 return( KalbachMann );
47}
int MCGIDI_KalbachMann_initialize(statusMessageReporting *, MCGIDI_KalbachMann *KalbachMann, ptwXY_interpolation interpolationWY, ptwXY_interpolation interpolationXY)
MCGIDI_KalbachMann * MCGIDI_KalbachMann_free(statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann)
#define smr_malloc2(smr, size, zero, forItem)

Referenced by MCGIDI_KalbachMann_parseFromTOM().

◆ MCGIDI_KalbachMann_parseFromTOM()

int MCGIDI_KalbachMann_parseFromTOM ( statusMessageReporting smr,
xDataTOM_element element,
MCGIDI_distribution distribution 
)

Definition at line 89 of file MCGIDI_KalbachMann.cc.

89 {
90
91 MCGIDI_KalbachMann *KalbachMann = NULL;
92 xDataTOM_element *KalbachMannElement;
93 int index, dataPerEout = 3;
94 double energyInFactor, energyOutFactor;
95 xDataTOM_xDataInfo *xDataInfo;
96 xDataTOM_KalbachMann *KalbachMannXData;
97 ptwXY_interpolation interpolationXY, interpolationWY;
98 char const *energyFromUnit, *energyToUnit = "MeV";
99
100 MCGIDI_POP *productPOP = distribution->product->pop;
101 double productZ = productPOP->Z, productA = productPOP->A, productN = productA - productZ;
102 MCGIDI_target_heated *targetHeated = MCGIDI_product_getTargetHeated( smr, distribution->product );
103 MCGIDI_POP *projectilePOP = MCGIDI_target_heated_getPOPForProjectile( smr, targetHeated );
104 double projectileZ = projectilePOP->Z, projectileA = projectilePOP->A, projectileN = projectileA - projectileZ;
105 MCGIDI_POP *targetPOP = MCGIDI_target_heated_getPOPForTarget( smr, targetHeated );
106 double targetZ = targetPOP->Z, targetA = targetPOP->A, targetN = targetA - targetZ;
107 double Ia = 0., Ib = 0., Ma = -1, mb = -1;
108
109 if( ( targetA == 0 ) && ( targetZ == 6 ) ) { /* Special case for C_000 evaluation. */
110 targetN = 6;
111 targetA = 12;
112 }
113 if( ( KalbachMannElement = xDataTOME_getOneElementByName( smr, element, "KalbachMann", 1 ) ) == NULL ) goto err;
114
115 if( MCGIDI_fromTOM_interpolation( smr, KalbachMannElement, 0, &interpolationWY ) ) goto err;
116 if( MCGIDI_fromTOM_interpolation( smr, KalbachMannElement, 1, &interpolationXY ) ) goto err;
117
118 xDataInfo = &(KalbachMannElement->xDataInfo);
119 KalbachMannXData = (xDataTOM_KalbachMann *) xDataInfo->data;
120 if( KalbachMannXData->type == xDataTOM_KalbachMannType_fra ) dataPerEout = 4;
121
122 energyFromUnit = xDataTOM_axes_getUnit( smr, &(xDataInfo->axes), 0 );
123 if( !smr_isOk( smr ) ) goto err;
124 energyInFactor = MCGIDI_misc_getUnitConversionFactor( smr, energyFromUnit, energyToUnit );
125 if( !smr_isOk( smr ) ) goto err;
126
127 energyFromUnit = xDataTOM_axes_getUnit( smr, &(xDataInfo->axes), 1 );
128 if( !smr_isOk( smr ) ) goto err;
129 energyOutFactor = MCGIDI_misc_getUnitConversionFactor( smr, energyFromUnit, energyToUnit );
130 if( !smr_isOk( smr ) ) goto err;
131
132 if( ( KalbachMann = distribution->KalbachMann = MCGIDI_KalbachMann_new( smr, interpolationWY, interpolationXY ) ) == NULL ) goto err;
133
134/*
135 double productMass MCGIDI_product_getMass_MeV( smr, distribution->product ), residualMass;
136*/
137 KalbachMann->energyToMeVFactor = MCGIDI_misc_getUnitConversionFactor( smr, energyToUnit, "MeV" );
138 KalbachMann->massFactor = (double) productZ + productN; /* This is not correct as masses are needed not Z and N. */
139 KalbachMann->massFactor /= projectileN + projectileZ + targetZ + targetN - productZ + productN;
140 KalbachMann->massFactor += 1.;
141
142 if( projectileZ == 0 ) {
143 if( projectileN == 1 ) Ma = 1; }
144 else if( projectileZ == 1 ) {
145 if( projectileN == 1 ) {
146 Ma = 1; }
147 else if( projectileN == 2 ) {
148 Ia = 2.22;
149 Ma = 1; } }
150 else if( projectileZ == 2 ) {
151 if( projectileN == 2 ) {
152 Ia = 28.3;
153 Ma = 0;
154 }
155 }
156
157 if( productZ == 0 ) {
158 if( productN == 1 ) mb = 0.5; }
159 else if( productZ == 1 ) {
160 if( productN == 1 ) {
161 mb = 1; }
162 else if( productN == 2 ) {
163 Ia = 2.22;
164 mb = 1; }
165 else if( productN == 3 ) {
166 Ib = 8.48;
167 mb = 1; } }
168 else if( productZ == 2 ) {
169 if( productN == 1 ) {
170 Ib = 7.72;
171 mb = 1; }
172 else if( productN == 2 ) {
173 Ib = 28.3;
174 mb = 2;
175 }
176 }
177
178 KalbachMann->Ma = Ma;
179 KalbachMann->mb = mb;
180
181 KalbachMann->Sa = MCGIDI_KalbachMann_S_a_or_b( targetZ, targetN, targetZ + projectileZ, targetN + projectileN, Ia );
182 KalbachMann->Sb = MCGIDI_KalbachMann_S_a_or_b( projectileZ + targetZ - productZ, projectileN + targetN - productN,
183 targetZ + projectileZ, targetN + projectileN, Ib );
184
185 KalbachMann->dists.numberOfWs = 0;
186 if( ( KalbachMann->dists.Ws = (double *) smr_malloc2( smr, KalbachMannXData->numberOfEnergies * sizeof( double ), 0, "KalbachMann->dists->Ws" ) ) == NULL ) goto err;
187 if( ( KalbachMann->dists.dist = (MCGIDI_pdfOfX *) smr_malloc2( smr, KalbachMannXData->numberOfEnergies * sizeof( MCGIDI_pdfOfX ), 0, "KalbachMann->dists->dist" ) ) == NULL ) goto err;
188 if( ( KalbachMann->ras = (MCGIDI_KalbachMann_ras *) smr_malloc2( smr, KalbachMannXData->numberOfEnergies * sizeof( MCGIDI_KalbachMann_ras ), 0, "KalbachMann->ras" ) ) == NULL ) goto err;
189
190 for( index = 0; index < KalbachMannXData->numberOfEnergies; index++ ) {
191 if( MCGIDI_KalbachMann_parseFromTOM2( smr, dataPerEout, index, &(KalbachMannXData->coefficients[index]),
192 energyInFactor, energyOutFactor, KalbachMann ) ) goto err;
193 }
194
195 if( ( KalbachMann->frame = MCGIDI_misc_getProductFrame( smr, KalbachMannElement ) ) == xDataTOM_frame_invalid ) goto err;
197
198 return( 0 );
199
200err:
201 if( KalbachMann != NULL ) MCGIDI_KalbachMann_free( smr, KalbachMann );
202 return( 1 );
203}
MCGIDI_POP * MCGIDI_target_heated_getPOPForProjectile(statusMessageReporting *smr, MCGIDI_target_heated *target)
MCGIDI_POP * MCGIDI_target_heated_getPOPForTarget(statusMessageReporting *smr, MCGIDI_target_heated *target)
@ MCGIDI_distributionType_KalbachMann_e
Definition: MCGIDI.h:209
MCGIDI_target_heated * MCGIDI_product_getTargetHeated(statusMessageReporting *smr, MCGIDI_product *product)
MCGIDI_KalbachMann * MCGIDI_KalbachMann_new(statusMessageReporting *smr, ptwXY_interpolation interpolationWY, ptwXY_interpolation interpolationXY)
int MCGIDI_fromTOM_interpolation(statusMessageReporting *smr, xDataTOM_element *element, int index, enum ptwXY_interpolation_e *interpolation)
double MCGIDI_misc_getUnitConversionFactor(statusMessageReporting *smr, char const *fromUnit, char const *toUnit)
Definition: MCGIDI_misc.cc:381
enum xDataTOM_frame MCGIDI_misc_getProductFrame(statusMessageReporting *smr, xDataTOM_element *frameElement)
Definition: MCGIDI_misc.cc:315
enum ptwXY_interpolation_e ptwXY_interpolation
int smr_isOk(statusMessageReporting *smr)
enum xDataTOM_frame frame
Definition: MCGIDI.h:374
double energyToMeVFactor
Definition: MCGIDI.h:375
MCGIDI_KalbachMann_ras * ras
Definition: MCGIDI.h:377
MCGIDI_product * product
Definition: MCGIDI.h:381
enum MCGIDI_distributionType type
Definition: MCGIDI.h:382
MCGIDI_KalbachMann * KalbachMann
Definition: MCGIDI.h:387
MCGIDI_pdfOfX * dist
Definition: MCGIDI.h:308
MCGIDI_POP * pop
Definition: MCGIDI.h:401
enum xDataTOM_KalbachMannType type
Definition: xDataTOM.h:138
xDataTOM_KalbachMannCoefficients * coefficients
Definition: xDataTOM.h:141
xDataTOM_xDataInfo xDataInfo
Definition: xDataTOM.h:187
xDataTOM_axes axes
Definition: xDataTOM.h:153
char const * xDataTOM_axes_getUnit(statusMessageReporting *smr, xDataTOM_axes *axes, int index)
xDataTOM_element * xDataTOME_getOneElementByName(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required)
Definition: xDataTOM.cc:246
@ xDataTOM_frame_invalid
Definition: xDataTOM.h:23
@ xDataTOM_KalbachMannType_fra
Definition: xDataTOM.h:25

Referenced by MCGIDI_energyAngular_parseFromTOM().

◆ MCGIDI_KalbachMann_release()

int MCGIDI_KalbachMann_release ( statusMessageReporting smr,
MCGIDI_KalbachMann KalbachMann 
)

Definition at line 70 of file MCGIDI_KalbachMann.cc.

70 {
71
72 int i;
73 MCGIDI_pdfsOfXGivenW *dists = &(KalbachMann->dists);
74
75 for( i = 0; i < dists->numberOfWs; i++ ) {
76 smr_freeMemory( (void **) &(KalbachMann->ras[i].rs) );
77 smr_freeMemory( (void **) &(dists->dist[i].Xs) );
78 }
79 smr_freeMemory( (void **) &(KalbachMann->ras) );
80 smr_freeMemory( (void **) &(dists->Ws) );
81 smr_freeMemory( (void **) &(dists->dist) );
82
84 return( 0 );
85}
@ ptwXY_interpolationLinLin
Definition: ptwXY.h:35
double * Xs
Definition: MCGIDI.h:299

Referenced by MCGIDI_KalbachMann_free().

◆ MCGIDI_KalbachMann_sampleEp()

int MCGIDI_KalbachMann_sampleEp ( statusMessageReporting smr,
MCGIDI_KalbachMann KalbachMann,
MCGIDI_quantitiesLookupModes modes,
MCGIDI_decaySamplingInfo decaySamplingInfo 
)

Definition at line 294 of file MCGIDI_KalbachMann.cc.

295 {
296
297 double Epl, Epu, Ep, r, r2, rl, ru, a, a2, al, au, mu, randomEp = decaySamplingInfo->rng( decaySamplingInfo->rngState );
299 MCGIDI_pdfsOfXGivenW *dists = &(KalbachMann->dists);
300 ptwXY_interpolation interpolationWY;
301
302 sampled.smr = smr;
303 sampled.w = modes.getProjectileEnergy( );
304 MCGIDI_sampling_sampleX_from_pdfsOfXGivenW( dists, &sampled, randomEp );
305
306 interpolationWY = sampled.interpolationWY;
307 if( sampled.iW < 0 ) {
308 interpolationWY = ptwXY_interpolationFlat;
309 if( sampled.iW == -2 ) { /* ???????????? This should probably report a warning. */
310 sampled.iW = 0; }
311 else if( sampled.iW == -1 ) {
312 sampled.iW = dists->numberOfWs - 1;
313 }
314 }
315
316 Ep = sampled.x; /* Sampled Ep. */
317 if( sampled.interpolationXY == ptwXY_interpolationFlat ) { /* Now sample r. */
318 r = KalbachMann->ras[sampled.iW].rs[sampled.iX1]; }
319 else {
320 Epl = dists->dist[sampled.iW].Xs[sampled.iX1];
321 Epu = dists->dist[sampled.iW].Xs[sampled.iX1+1];
322 rl = KalbachMann->ras[sampled.iW].rs[sampled.iX1];
323 ru = KalbachMann->ras[sampled.iW].rs[sampled.iX1+1];
324 r = ( ru - rl ) / ( Epu - Epl ) * ( Ep - Epl ) + rl;
325 }
326 if( interpolationWY == ptwXY_interpolationLinLin ) {
328 r2 = KalbachMann->ras[sampled.iW+1].rs[sampled.iX2]; }
329 else {
330 Epl = dists->dist[sampled.iW+1].Xs[sampled.iX2];
331 Epu = dists->dist[sampled.iW+1].Xs[sampled.iX2+1];
332 rl = KalbachMann->ras[sampled.iW+1].rs[sampled.iX2];
333 ru = KalbachMann->ras[sampled.iW+1].rs[sampled.iX2+1];
334 r2 = ( ru - rl ) / ( Epu - Epl ) * ( Ep - Epl ) + rl;
335 }
336 r = sampled.frac * r + ( 1. - sampled.frac ) * r2;
337 }
338
339 if( KalbachMann->ras[0].as == NULL ) { /* Now determine a. */
340 double X1, X3_2;
341 double eb = KalbachMann->massFactor * KalbachMann->energyToMeVFactor * Ep + KalbachMann->Sb;
342
343 X1 = eb; /* Not valid for ea > Et1. */
344 X3_2 = eb * eb; /* Not valid for ea > Et3. */
345 a = X1 * ( C1 + C2 * X1 * X1 ) + C2 * KalbachMann->Ma * KalbachMann->mb * X3_2 * X3_2; }
346 else {
348 a = KalbachMann->ras[sampled.iW].as[sampled.iX1]; }
349 else {
350 Epl = dists->dist[sampled.iW].Xs[sampled.iX1];
351 Epu = dists->dist[sampled.iW].Xs[sampled.iX1+1];
352 al = KalbachMann->ras[sampled.iW].as[sampled.iX1];
353 au = KalbachMann->ras[sampled.iW].as[sampled.iX1+1];
354 a = ( au - al ) / ( Epu - Epl ) * ( Ep - Epl ) + al;
355 }
356 a2 = 0.;
357 if( interpolationWY == ptwXY_interpolationLinLin ) {
359 a2 = KalbachMann->ras[sampled.iW+1].as[sampled.iX2]; }
360 else {
361 Epl = dists->dist[sampled.iW+1].Xs[sampled.iX2];
362 Epu = dists->dist[sampled.iW+1].Xs[sampled.iX2+1];
363 al = KalbachMann->ras[sampled.iW+1].as[sampled.iX2];
364 au = KalbachMann->ras[sampled.iW+1].as[sampled.iX2+1];
365 a2 = ( au - al ) / ( Epu - Epl ) * ( Ep - Epl ) + al;
366 }
367 }
368 a = sampled.frac * a + ( 1. - sampled.frac ) * a2;
369 }
370
371 /* In the following: Cosh[ a mu ] + r Sinh[ a mu ] = ( 1 - r ) Cosh[ a mu ] + r ( Cosh[ a mu ] + Sinh[ a mu ] ). */
372 if( decaySamplingInfo->rng( decaySamplingInfo->rngState ) >= r ) { /* Sample the '( 1 - r ) Cosh[ a mu ]' term. */
373 double T = ( 2. * decaySamplingInfo->rng( decaySamplingInfo->rngState ) - 1. ) * std::sinh( a );
374
375 mu = G4Log( T + std::sqrt( T * T + 1. ) ) / a; }
376 else { /* Sample the 'r ( Cosh[ a mu ] + Sinh[ a mu ]' term. */
377 double rng1 = decaySamplingInfo->rng( decaySamplingInfo->rngState ), exp_a = G4Exp( a );
378
379 mu = G4Log( rng1 * exp_a + ( 1. - rng1 ) / exp_a ) / a;
380 }
381 if( mu < -1 ) {
382 mu = -1;}
383 else if( mu > 1 ) {
384 mu = 1;
385 }
386
387 decaySamplingInfo->frame = KalbachMann->frame;
388 decaySamplingInfo->Ep = Ep;
389 decaySamplingInfo->mu = mu;
390 return( !smr_isOk( smr ) );
391}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:179
G4double G4Log(G4double x)
Definition: G4Log.hh:226
int MCGIDI_sampling_sampleX_from_pdfsOfXGivenW(MCGIDI_pdfsOfXGivenW *dists, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r)
const double C2
const double C1
double getProjectileEnergy(void) const
Definition: MCGIDI.h:97
@ ptwXY_interpolationFlat
Definition: ptwXY.h:36
double(* rng)(void *)
Definition: MCGIDI.h:258
enum xDataTOM_frame frame
Definition: MCGIDI.h:256
ptwXY_interpolation interpolationWY
Definition: MCGIDI.h:313
ptwXY_interpolation interpolationXY
Definition: MCGIDI.h:313
statusMessageReporting * smr
Definition: MCGIDI.h:312

Referenced by MCGIDI_outputChannel_sampleProductsAtE().

Variable Documentation

◆ C1

const double C1 = 0.04

Definition at line 15 of file MCGIDI_KalbachMann.cc.

◆ C2