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

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

Definition at line 78 of file tpia_Legendre.cc.

References tpia_frame_setFromElement(), tpia_misc_setMessageError_Element(), xData_addToAccessed(), xData_freeElementList(), and xData_getElementsByTagNameAndSort().

00078                                                                                                                          {
00079 
00080     int i, status = 0;
00081     xData_elementList *list;
00082 
00083     xData_addToAccessed( smr, LegendreElement, 1 );
00084     if( ( tpia_frame_setFromElement( smr, LegendreElement, 4, &(Legendre->frame) ) ) != 0 ) return( 1 );
00085     list = xData_getElementsByTagNameAndSort( smr, LegendreElement, "l", NULL, NULL );
00086     if( list->n == 0 ) {
00087         status = 1;
00088         tpia_misc_setMessageError_Element( smr, NULL, LegendreElement, __FILE__, __LINE__, 1, "Legendre element does not contain any l elements" ); }
00089     else {
00090         //if( ( Legendre->binned.ls = xData_malloc2( smr, list->n * sizeof( tpia_EqualProbableBinSpectra ), 1, "ls" ) ) != NULL ) {
00091         if( ( Legendre->binned.ls = (tpia_EqualProbableBinSpectra*) xData_malloc2( smr, list->n * sizeof( tpia_EqualProbableBinSpectra ), 1, "ls" ) ) != NULL ) {
00092             Legendre->binned.numberOfLs = 0;
00093             for( i = 0; i < list->n; i++ ) {
00094                 if( ( status = _tpia_Legendre_getOrder( smr, list->items[i].element, Legendre, &(Legendre->binned.ls[i]) ) ) != 0 ) break;
00095                 Legendre->binned.numberOfLs++;
00096             }
00097         }
00098     }
00099     xData_freeElementList( smr, list );
00100     return( status );
00101 }

int tpia_Legendre_initialize ( statusMessageReporting *  smr,
tpia_Legendre *  Legendre 
)

Definition at line 54 of file tpia_Legendre.cc.

References tpia_frame_setFromString().

Referenced by tpia_Legendre_release(), and tpia_product_initialize().

00054                                                                                      {
00055 
00056     memset( Legendre, 0, sizeof( tpia_Legendre ) );
00057     if( tpia_frame_setFromString( smr, "", "", 0, &(Legendre->frame) ) ) return( 1 );
00058     Legendre->binned.numberOfLs = 0;
00059     Legendre->binned.ls = NULL;
00060     return( 0 );
00061 }

int tpia_Legendre_release ( statusMessageReporting *  smr,
tpia_Legendre *  Legendre 
)

Definition at line 65 of file tpia_Legendre.cc.

References tpia_Legendre_initialize(), and xData_free().

Referenced by tpia_product_release().

00065                                                                                   {
00066 
00067     int i;
00068 
00069     for( i = 0; i < Legendre->binned.numberOfLs; i++ ) xData_free( smr, Legendre->binned.ls[i].energies );
00070     //Legendre->binned.ls = xData_free( smr, Legendre->binned.ls );
00071     Legendre->binned.ls = (tpia_EqualProbableBinSpectra*) xData_free( smr, Legendre->binned.ls );
00072     tpia_Legendre_initialize( smr, Legendre );
00073     return( 0 );
00074 }

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

Definition at line 127 of file tpia_Legendre.cc.

References tpia_misc_drng(), and tpia_misc_sampleEqualProbableBin().

Referenced by tpia_decayChannel_sampleProductsAtE().

00127                                                                                                                                             {
00128 
00129     tpia_EqualProbableBinSpectra *binned_l0 = Legendre->binned.ls;
00130     double Ep;
00131 
00132 /*
00133 Currently, only l = 0, equal probable binning is supported.
00134 Need to return frame info for Ep, mu, also.
00135 */
00136     if( Legendre->binned.numberOfLs > 0 ) {
00137         if( sampleMu ) decaySamplingInfo->mu = 2. * tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState ) - 1.;
00138 #ifndef WIN32
00139         if( decaySamplingInfo->mu <= -1 ) decaySamplingInfo->mu = nextafter( -1., 0. );
00140 #endif
00141 #ifdef WIN32
00142         if( decaySamplingInfo->mu <= -1 ) decaySamplingInfo->mu = _nextafter( -1., 0. );
00143 #endif
00144 
00145         tpia_misc_sampleEqualProbableBin( smr, decaySamplingInfo, decaySamplingInfo->e_in, binned_l0->nBins, binned_l0, &Ep );
00146         /* ??? Need to check that e_in > E_Threshold */
00147         decaySamplingInfo->Ep = Ep; }
00148     else {
00149         return( 1 );
00150     }
00151 
00152     return( 0 );
00153 }


Generated on Mon May 27 17:51:16 2013 for Geant4 by  doxygen 1.4.7