Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MCGIDI_energyAngular.cc File Reference
#include <string.h>
#include "MCGIDI_fromTOM.h"
#include "MCGIDI.h"
#include "MCGIDI_misc.h"
Include dependency graph for MCGIDI_energyAngular.cc:

Go to the source code of this file.

Functions

static int MCGIDI_energyAngular_linear_parseFromTOM (statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution)
 
MCGIDI_energyAngularMCGIDI_energyAngular_new (statusMessageReporting *smr)
 
int MCGIDI_energyAngular_initialize (statusMessageReporting *, MCGIDI_energyAngular *energyAngular)
 
MCGIDI_energyAngularMCGIDI_energyAngular_free (statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)
 
int MCGIDI_energyAngular_release (statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)
 
int MCGIDI_energyAngular_parseFromTOM (statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution)
 
int MCGIDI_energyAngular_sampleDistribution (statusMessageReporting *smr, MCGIDI_distribution *distribution, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
 

Function Documentation

MCGIDI_energyAngular* MCGIDI_energyAngular_free ( statusMessageReporting smr,
MCGIDI_energyAngular energyAngular 
)

Definition at line 39 of file MCGIDI_energyAngular.cc.

39  {
40 
41  MCGIDI_energyAngular_release( smr, energyAngular );
42  smr_freeMemory( (void **) &energyAngular );
43  return( NULL );
44 }
int MCGIDI_energyAngular_release(statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_energyAngular_initialize ( statusMessageReporting ,
MCGIDI_energyAngular energyAngular 
)

Definition at line 31 of file MCGIDI_energyAngular.cc.

31  {
32 
33  memset( energyAngular, 0, sizeof( MCGIDI_energyAngular ) );
34  return( 0 );
35 }

Here is the caller graph for this function:

static int MCGIDI_energyAngular_linear_parseFromTOM ( statusMessageReporting smr,
xDataTOM_element element,
MCGIDI_distribution distribution 
)
static

Definition at line 89 of file MCGIDI_energyAngular.cc.

89  {
90 
91  int iV, iW;
92  double y, norm, energyInFactor, energyOutFactor;
93  char const *energyUnit, *multiplicityProbabilityUnits[2] = { "", "1/MeV" };
94  xDataTOM_element *linear;
95  ptwXY_interpolation interpolationXY, interpolationWY, interpolationVY;
96  xDataTOM_XYs *XYs;
97  xDataTOM_W_XYs *W_XYs;
98  xDataTOM_V_W_XYs *V_W_XYs;
99  MCGIDI_pdfsOfXGivenW *pdfOfEpGivenE, *pdfOfMuGivenEAndEp = NULL, *pdfOfMuGivenEAndEp2 = NULL;
100  MCGIDI_energyAngular *energyAngular = NULL;
101  ptwXYPoints *pdfXY1 = NULL, *pdfXY2 = NULL;
102  nfu_status status;
103 
104  if( ( linear = xDataTOME_getOneElementByName( smr, element, "linear", 1 ) ) == NULL ) goto err;
105 
106  if( MCGIDI_fromTOM_interpolation( smr, linear, 0, &interpolationVY ) ) goto err;
107  if( MCGIDI_fromTOM_interpolation( smr, linear, 1, &interpolationWY ) ) goto err;
108  if( MCGIDI_fromTOM_interpolation( smr, linear, 2, &interpolationXY ) ) goto err;
109 
110  if( ( energyAngular = MCGIDI_energyAngular_new( smr ) ) == NULL ) goto err;
111  if( ( energyAngular->frame = MCGIDI_misc_getProductFrame( smr, linear ) ) == xDataTOM_frame_invalid ) goto err;
112 
113  pdfOfEpGivenE = &(energyAngular->pdfOfEpGivenE);
114  pdfOfEpGivenE->interpolationWY = interpolationVY;
115  pdfOfEpGivenE->interpolationXY = interpolationWY;
116 
117  if( ( V_W_XYs = (xDataTOM_V_W_XYs *) xDataTOME_getXDataIfID( smr, linear, "V_W_XYs" ) ) == NULL ) goto err;
118  if( ( pdfOfEpGivenE->Ws = (double *) smr_malloc2( smr, V_W_XYs->length * sizeof( double ), 1, "pdfOfEpGivenE->Ws" ) ) == NULL ) goto err;
119  if( ( pdfOfEpGivenE->dist = (MCGIDI_pdfOfX *) smr_malloc2( smr, V_W_XYs->length * sizeof( MCGIDI_pdfOfX ), 0, "pdfOfEpGivenE->dist" ) ) == NULL ) goto err;
120  if( ( pdfOfMuGivenEAndEp = (MCGIDI_pdfsOfXGivenW *) smr_malloc2( smr, V_W_XYs->length * sizeof( MCGIDI_pdfsOfXGivenW ), 1, "pdfOfMuGivenEAndEp" ) ) == NULL ) goto err;
121 
122  energyUnit = xDataTOM_subAxes_getUnit( smr, &(V_W_XYs->subAxes), 0 );
123  if( !smr_isOk( smr ) ) goto err;
124  energyInFactor = MCGIDI_misc_getUnitConversionFactor( smr, energyUnit, "MeV" );
125  if( !smr_isOk( smr ) ) goto err;
126 
127  energyUnit = xDataTOM_subAxes_getUnit( smr, &(V_W_XYs->subAxes), 1 );
128  if( !smr_isOk( smr ) ) goto err;
129  energyOutFactor = MCGIDI_misc_getUnitConversionFactor( smr, energyUnit, "MeV" );
130  if( !smr_isOk( smr ) ) goto err;
131 
132  for( iV = 0; iV < V_W_XYs->length; iV++ ) {
133  W_XYs = &(V_W_XYs->W_XYs[iV]);
134  pdfOfMuGivenEAndEp2 = &(pdfOfMuGivenEAndEp[iV]);
135  pdfOfMuGivenEAndEp2->interpolationWY = interpolationWY;
136  pdfOfMuGivenEAndEp2->interpolationXY = interpolationXY;
137  if( ( pdfXY2 = ptwXY_new( interpolationWY, NULL, 2., 1e-6, W_XYs->length, 10, &status, 0 ) ) == NULL ) goto errA;
138  if( ( pdfOfMuGivenEAndEp2->Ws = (double *) smr_malloc2( smr, W_XYs->length * sizeof( double ), 1, "pdfOfMuGivenEAndEp2->Ws" ) ) == NULL ) goto err;
139  if( ( pdfOfMuGivenEAndEp2->dist = (MCGIDI_pdfOfX *) smr_malloc2( smr, W_XYs->length * sizeof( MCGIDI_pdfOfX ), 0, "pdfOfMuGivenEAndEp2->dist" ) ) == NULL ) goto err;
140  for( iW = 0; iW < W_XYs->length; iW++ ) {
141  XYs = &(W_XYs->XYs[iW]);
142  if( ( pdfXY1 = MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf( smr, XYs, interpolationXY, multiplicityProbabilityUnits ) ) == NULL ) goto err;
143  y = ptwXY_integrateDomain( pdfXY1, &status );
144  if( ( status = ptwXY_setValueAtX( pdfXY2, energyOutFactor * XYs->value, y ) ) != nfu_Okay ) goto errA;
145  if( status != nfu_Okay ) goto errA;
146 
147  if( y == 0 ) {
148  if( ( status = ptwXY_add_double( pdfXY1, 0.5 ) ) != nfu_Okay ) goto errA;
149  }
150  pdfOfMuGivenEAndEp2->Ws[iW] = energyOutFactor * XYs->value;
151  if( MCGIDI_fromTOM_pdfOfX( smr, pdfXY1, &(pdfOfMuGivenEAndEp2->dist[iW]), &norm ) ) goto err;
152  pdfOfMuGivenEAndEp2->numberOfWs++;
153 
154  pdfXY1 = ptwXY_free( pdfXY1 );
155  }
156  pdfOfEpGivenE->Ws[iV] = energyInFactor * W_XYs->value;
157  if( MCGIDI_fromTOM_pdfOfX( smr, pdfXY2, &(pdfOfEpGivenE->dist[iV]), &norm ) ) goto err;
158  pdfOfEpGivenE->numberOfWs++;
159 
160  pdfXY2 = ptwXY_free( pdfXY2 );
161  }
162  energyAngular->pdfOfMuGivenEAndEp = pdfOfMuGivenEAndEp;
163  distribution->energyAngular = energyAngular;
165 
166  return( 0 );
167 
168 errA:
169  smr_setReportError2( smr, smr_unknownID, 1, "ptwXY_integrateDomain err = %d: %s\n", status, nfu_statusMessage( status ) );
170 err:
171  if( pdfXY1 != NULL ) ptwXY_free( pdfXY1 );
172  if( pdfXY2 != NULL ) ptwXY_free( pdfXY2 );
173  if( energyAngular != NULL ) MCGIDI_energyAngular_free( smr, energyAngular );
174 /* ????????? Need to free pdfOfMuGivenEAndEp, now may be handled by MCGIDI_energyAngular_free. Need to check. */
175  return( 1 );
176 }
ptwXY_interpolation interpolationXY
Definition: MCGIDI.h:306
xDataTOM_W_XYs * W_XYs
Definition: xDataTOM.h:103
MCGIDI_energyAngular * energyAngular
Definition: MCGIDI.h:385
xDataTOM_XYs * XYs
Definition: xDataTOM.h:97
MCGIDI_energyAngular * MCGIDI_energyAngular_new(statusMessageReporting *smr)
enum xDataTOM_frame frame
Definition: MCGIDI.h:357
MCGIDI_pdfsOfXGivenW * pdfOfMuGivenEAndEp
Definition: MCGIDI.h:359
int MCGIDI_fromTOM_interpolation(statusMessageReporting *smr, xDataTOM_element *element, int index, enum ptwXY_interpolation_e *interpolation)
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
Definition: ptwXY_core.cc:574
nfu_status ptwXY_setValueAtX(ptwXYPoints *ptwXY, double x, double y)
Definition: ptwXY_core.cc:876
double ptwXY_integrateDomain(ptwXYPoints *ptwXY, nfu_status *status)
nfu_status ptwXY_add_double(ptwXYPoints *ptwXY, double value)
int MCGIDI_fromTOM_pdfOfX(statusMessageReporting *smr, ptwXYPoints *pdfXY, MCGIDI_pdfOfX *dist, double *norm)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
xDataTOM_element * xDataTOME_getOneElementByName(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required)
Definition: xDataTOM.cc:246
enum nfu_status_e nfu_status
ptwXY_interpolation interpolationWY
Definition: MCGIDI.h:306
void * xDataTOME_getXDataIfID(statusMessageReporting *smr, xDataTOM_element *TE, char const *ID)
Definition: xDataTOM.cc:512
#define smr_malloc2(smr, size, zero, forItem)
#define smr_unknownID
MCGIDI_energyAngular * MCGIDI_energyAngular_free(statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)
int smr_isOk(statusMessageReporting *smr)
enum ptwXY_interpolation_e ptwXY_interpolation
double value
Definition: xDataTOM.h:95
double value
Definition: xDataTOM.h:82
ptwXYPoints * ptwXY_new(ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, nfu_status *status, int userFlag)
Definition: ptwXY_core.cc:29
enum MCGIDI_distributionType type
Definition: MCGIDI.h:382
ptwXYPoints * MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf(statusMessageReporting *smr, xDataTOM_XYs *XYs, ptwXY_interpolation interpolation, char const *units[2])
Definition: MCGIDI_misc.cc:405
enum xDataTOM_frame MCGIDI_misc_getProductFrame(statusMessageReporting *smr, xDataTOM_element *frameElement)
Definition: MCGIDI_misc.cc:315
double MCGIDI_misc_getUnitConversionFactor(statusMessageReporting *smr, char const *fromUnit, char const *toUnit)
Definition: MCGIDI_misc.cc:381
MCGIDI_pdfsOfXGivenW pdfOfEpGivenE
Definition: MCGIDI.h:358
const char * nfu_statusMessage(nfu_status status)
Definition: nf_utilities.cc:76
MCGIDI_pdfOfX * dist
Definition: MCGIDI.h:308
xDataTOM_subAxes subAxes
Definition: xDataTOM.h:102
char const * xDataTOM_subAxes_getUnit(statusMessageReporting *smr, xDataTOM_subAxes *subAxes, int index)

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_energyAngular* MCGIDI_energyAngular_new ( statusMessageReporting smr)

Definition at line 20 of file MCGIDI_energyAngular.cc.

20  {
21 
22  MCGIDI_energyAngular *energyAngular;
23 
24  if( ( energyAngular = (MCGIDI_energyAngular *) smr_malloc2( smr, sizeof( MCGIDI_energyAngular ), 0, "energyAngular" ) ) == NULL ) return( NULL );
25  if( MCGIDI_energyAngular_initialize( smr, energyAngular ) ) energyAngular = MCGIDI_energyAngular_free( smr, energyAngular );
26  return( energyAngular );
27 }
int MCGIDI_energyAngular_initialize(statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)
#define smr_malloc2(smr, size, zero, forItem)
MCGIDI_energyAngular * MCGIDI_energyAngular_free(statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 64 of file MCGIDI_energyAngular.cc.

64  {
65 
66  xDataTOM_element *energyAngularElement;
67  char const *nativeData;
68 
69  if( ( energyAngularElement = xDataTOME_getOneElementByName( smr, element, "energyAngular", 1 ) ) == NULL ) goto err;
70 
71  if( ( nativeData = xDataTOM_getAttributesValueInElement( energyAngularElement, "nativeData" ) ) == NULL ) goto err;
72  if( strcmp( nativeData, "KalbachMann" ) == 0 ) {
73  return( MCGIDI_KalbachMann_parseFromTOM( smr, energyAngularElement, distribution ) ); }
74  else if( strcmp( nativeData, "linear" ) == 0 ) {
75  return( MCGIDI_energyAngular_linear_parseFromTOM( smr, energyAngularElement, distribution ) ); }
76  else {
77  smr_setReportError2( smr, smr_unknownID, 1, "energyAngular nativeData = '%s' not supported", nativeData );
78  goto err;
79  }
80 
81  return( 0 );
82 
83 err:
84  return( 1 );
85 }
#define smr_setReportError2(smr, libraryID, code, fmt,...)
xDataTOM_element * xDataTOME_getOneElementByName(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required)
Definition: xDataTOM.cc:246
#define smr_unknownID
int MCGIDI_KalbachMann_parseFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution)
char const * xDataTOM_getAttributesValueInElement(xDataTOM_element *element, char const *name)
Definition: xDataTOM.cc:286
static int MCGIDI_energyAngular_linear_parseFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution)

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_energyAngular_release ( statusMessageReporting smr,
MCGIDI_energyAngular energyAngular 
)

Definition at line 48 of file MCGIDI_energyAngular.cc.

48  {
49 
50  int i;
51 
52  for( i = 0; i < energyAngular->pdfOfEpGivenE.numberOfWs; i++ ) {
53  MCGIDI_sampling_pdfsOfXGivenW_release( smr, &(energyAngular->pdfOfMuGivenEAndEp[i]) );
54  }
55  smr_freeMemory( (void **) &(energyAngular->pdfOfMuGivenEAndEp) );
56  MCGIDI_sampling_pdfsOfXGivenW_release( smr, &(energyAngular->pdfOfEpGivenE) );
57  MCGIDI_energyAngular_initialize( smr, energyAngular );
58 
59  return( 0 );
60 }
MCGIDI_pdfsOfXGivenW * pdfOfMuGivenEAndEp
Definition: MCGIDI.h:359
int MCGIDI_energyAngular_initialize(statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular)
int MCGIDI_sampling_pdfsOfXGivenW_release(statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *dists)
void * smr_freeMemory(void **p)
MCGIDI_pdfsOfXGivenW pdfOfEpGivenE
Definition: MCGIDI.h:358

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_energyAngular_sampleDistribution ( statusMessageReporting smr,
MCGIDI_distribution distribution,
MCGIDI_quantitiesLookupModes modes,
MCGIDI_decaySamplingInfo decaySamplingInfo 
)

Definition at line 180 of file MCGIDI_energyAngular.cc.

181  {
182 
183  double Ep;
184  MCGIDI_energyAngular *energyAngular = distribution->energyAngular;
185 
186  MCGIDI_sampling_doubleDistribution( smr, &(energyAngular->pdfOfEpGivenE), energyAngular->pdfOfMuGivenEAndEp, modes, decaySamplingInfo );
187  Ep = decaySamplingInfo->mu;
188  decaySamplingInfo->mu = decaySamplingInfo->Ep;
189  decaySamplingInfo->Ep = Ep;
190  decaySamplingInfo->frame = energyAngular->frame;
191 
192  return( 0 );
193 }
MCGIDI_energyAngular * energyAngular
Definition: MCGIDI.h:385
int MCGIDI_sampling_doubleDistribution(statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *pdfOfWGivenV, MCGIDI_pdfsOfXGivenW *pdfOfXGivenVAndW, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
enum xDataTOM_frame frame
Definition: MCGIDI.h:357
MCGIDI_pdfsOfXGivenW * pdfOfMuGivenEAndEp
Definition: MCGIDI.h:359
enum xDataTOM_frame frame
Definition: MCGIDI.h:256
MCGIDI_pdfsOfXGivenW pdfOfEpGivenE
Definition: MCGIDI.h:358

Here is the call graph for this function:

Here is the caller graph for this function: