Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
tpia_Legendre.cc File Reference
#include <string.h>
#include <math.h>
#include <tpia_target.h>
#include <tpia_misc.h>

Go to the source code of this file.

Functions

int tpia_Legendre_initialize (statusMessageReporting *smr, tpia_Legendre *Legendre)
 
int tpia_Legendre_release (statusMessageReporting *smr, tpia_Legendre *Legendre)
 
int tpia_Legendre_getFromElement (statusMessageReporting *smr, xData_element *LegendreElement, tpia_Legendre *Legendre)
 
int tpia_Legendre_SampleEp (statusMessageReporting *smr, tpia_Legendre *Legendre, int sampleMu, tpia_decaySamplingInfo *decaySamplingInfo)
 

Function Documentation

◆ tpia_Legendre_getFromElement()

int tpia_Legendre_getFromElement ( statusMessageReporting smr,
xData_element LegendreElement,
tpia_Legendre Legendre 
)

Definition at line 78 of file tpia_Legendre.cc.

78 {
79
80 int i, status = 0;
82
83 xData_addToAccessed( smr, LegendreElement, 1 );
84 if( ( tpia_frame_setFromElement( smr, LegendreElement, 4, &(Legendre->frame) ) ) != 0 ) return( 1 );
85 list = xData_getElementsByTagNameAndSort( smr, LegendreElement, "l", NULL, NULL );
86 if( list->n == 0 ) {
87 status = 1;
88 tpia_misc_setMessageError_Element( smr, NULL, LegendreElement, __FILE__, __LINE__, 1, "Legendre element does not contain any l elements" ); }
89 else {
90 //if( ( Legendre->binned.ls = xData_malloc2( smr, list->n * sizeof( tpia_EqualProbableBinSpectra ), 1, "ls" ) ) != NULL ) {
91 if( ( Legendre->binned.ls = (tpia_EqualProbableBinSpectra*) xData_malloc2( smr, list->n * sizeof( tpia_EqualProbableBinSpectra ), 1, "ls" ) ) != NULL ) {
92 Legendre->binned.numberOfLs = 0;
93 for( i = 0; i < list->n; i++ ) {
94 if( ( status = _tpia_Legendre_getOrder( smr, list->items[i].element, Legendre, &(Legendre->binned.ls[i]) ) ) != 0 ) break;
95 Legendre->binned.numberOfLs++;
96 }
97 }
98 }
99 xData_freeElementList( smr, list );
100 return( status );
101}
tpia_EqualProbableBinSpectra * ls
Definition: tpia_target.h:201
tpia_data_frame frame
Definition: tpia_target.h:222
tpia_LegendreBin binned
Definition: tpia_target.h:223
xData_element * element
Definition: xData.h:145
xData_elementListItem * items
Definition: xData.h:151
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
Definition: tpia_misc.cc:183
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:61
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)
Definition: xData.cc:832
xData_elementList * xData_getElementsByTagNameAndSort(statusMessageReporting *smr, xData_element *element, const char *tagName, const char *sortAttributeName, xData_sortElementFunc sortFunction)
Definition: xData.cc:788
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
Definition: xData.cc:1078
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

◆ tpia_Legendre_initialize()

int tpia_Legendre_initialize ( statusMessageReporting smr,
tpia_Legendre Legendre 
)

Definition at line 54 of file tpia_Legendre.cc.

54 {
55
56 memset( Legendre, 0, sizeof( tpia_Legendre ) );
57 if( tpia_frame_setFromString( smr, "", "", 0, &(Legendre->frame) ) ) return( 1 );
58 Legendre->binned.numberOfLs = 0;
59 Legendre->binned.ls = NULL;
60 return( 0 );
61}
int tpia_frame_setFromString(statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:74

Referenced by tpia_Legendre_release(), and tpia_product_initialize().

◆ tpia_Legendre_release()

int tpia_Legendre_release ( statusMessageReporting smr,
tpia_Legendre Legendre 
)

Definition at line 65 of file tpia_Legendre.cc.

65 {
66
67 int i;
68
69 for( i = 0; i < Legendre->binned.numberOfLs; i++ ) xData_free( smr, Legendre->binned.ls[i].energies );
70 //Legendre->binned.ls = xData_free( smr, Legendre->binned.ls );
71 Legendre->binned.ls = (tpia_EqualProbableBinSpectra*) xData_free( smr, Legendre->binned.ls );
72 tpia_Legendre_initialize( smr, Legendre );
73 return( 0 );
74}
tpia_EqualProbableBinSpectrum * energies
Definition: tpia_target.h:196
int tpia_Legendre_initialize(statusMessageReporting *smr, tpia_Legendre *Legendre)
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

Referenced by tpia_product_release().

◆ tpia_Legendre_SampleEp()

int tpia_Legendre_SampleEp ( statusMessageReporting smr,
tpia_Legendre Legendre,
int  sampleMu,
tpia_decaySamplingInfo decaySamplingInfo 
)

Definition at line 127 of file tpia_Legendre.cc.

127 {
128
129 tpia_EqualProbableBinSpectra *binned_l0 = Legendre->binned.ls;
130 double Ep;
131
132/*
133Currently, only l = 0, equal probable binning is supported.
134Need to return frame info for Ep, mu, also.
135*/
136 if( Legendre->binned.numberOfLs > 0 ) {
137 if( sampleMu ) decaySamplingInfo->mu = 2. * tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState ) - 1.;
138#ifndef WIN32
139 if( decaySamplingInfo->mu <= -1 ) decaySamplingInfo->mu = nextafter( -1., 0. );
140#endif
141#ifdef WIN32
142 if( decaySamplingInfo->mu <= -1 ) decaySamplingInfo->mu = _nextafter( -1., 0. );
143#endif
144
145 tpia_misc_sampleEqualProbableBin( smr, decaySamplingInfo, decaySamplingInfo->e_in, binned_l0->nBins, binned_l0, &Ep );
146 /* ??? Need to check that e_in > E_Threshold */
147 decaySamplingInfo->Ep = Ep; }
148 else {
149 return( 1 );
150 }
151
152 return( 0 );
153}
double(* rng)(void *)
Definition: tpia_target.h:153
double tpia_misc_drng(double(*rng)(void *), void *rngState)
Definition: tpia_misc.cc:403
int tpia_misc_sampleEqualProbableBin(statusMessageReporting *smr, tpia_decaySamplingInfo *decaySamplingInfo, double e_in, int nBins, tpia_EqualProbableBinSpectra *binned, double *value_)
Definition: tpia_misc.cc:420

Referenced by tpia_decayChannel_sampleProductsAtE().