Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
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_Legendre_s::binned, xData_elementListItem_s::element, tpia_Legendre_s::frame, xData_elementList_s::items, tpia_LegendreBin_s::ls, xData_elementList_s::n, tpia_LegendreBin_s::numberOfLs, status, tpia_frame_setFromElement(), tpia_misc_setMessageError_Element(), xData_addToAccessed(), xData_freeElementList(), xData_getElementsByTagNameAndSort(), and xData_malloc2.

78  {
79 
80  int i, status = 0;
81  xData_elementList *list;
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 }
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
tpia_data_frame frame
Definition: tpia_target.h:222
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:62
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
tpia_EqualProbableBinSpectra * ls
Definition: tpia_target.h:201
int status
Definition: tracer.cxx:24
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
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)
Definition: xData.cc:832
tpia_LegendreBin binned
Definition: tpia_target.h:223
xData_elementListItem * items
Definition: xData.h:151
xData_element * element
Definition: xData.h:145
int tpia_Legendre_initialize ( statusMessageReporting smr,
tpia_Legendre Legendre 
)

Definition at line 54 of file tpia_Legendre.cc.

References tpia_Legendre_s::binned, tpia_Legendre_s::frame, tpia_LegendreBin_s::ls, tpia_LegendreBin_s::numberOfLs, and tpia_frame_setFromString().

Referenced by tpia_Legendre_release(), and tpia_product_initialize().

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 }
tpia_data_frame frame
Definition: tpia_target.h:222
tpia_EqualProbableBinSpectra * ls
Definition: tpia_target.h:201
tpia_LegendreBin binned
Definition: tpia_target.h:223
int tpia_frame_setFromString(statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:75
int tpia_Legendre_release ( statusMessageReporting smr,
tpia_Legendre Legendre 
)

Definition at line 65 of file tpia_Legendre.cc.

References tpia_Legendre_s::binned, tpia_EqualProbableBinSpectra_s::energies, tpia_LegendreBin_s::ls, tpia_LegendreBin_s::numberOfLs, tpia_Legendre_initialize(), and xData_free().

Referenced by tpia_product_release().

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
tpia_EqualProbableBinSpectra * ls
Definition: tpia_target.h:201
tpia_LegendreBin binned
Definition: tpia_target.h:223
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_Legendre_s::binned, tpia_decaySamplingInfo_s::e_in, tpia_decaySamplingInfo_s::Ep, tpia_LegendreBin_s::ls, tpia_decaySamplingInfo_s::mu, tpia_EqualProbableBinSpectra_s::nBins, tpia_LegendreBin_s::numberOfLs, tpia_decaySamplingInfo_s::rng, tpia_decaySamplingInfo_s::rngState, tpia_misc_drng(), and tpia_misc_sampleEqualProbableBin().

Referenced by tpia_decayChannel_sampleProductsAtE().

127  {
128 
129  tpia_EqualProbableBinSpectra *binned_l0 = Legendre->binned.ls;
130  double Ep;
131 
132 /*
133 Currently, only l = 0, equal probable binning is supported.
134 Need 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 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
double(* rng)(void *)
Definition: tpia_target.h:153
tpia_EqualProbableBinSpectra * ls
Definition: tpia_target.h:201
tpia_LegendreBin binned
Definition: tpia_target.h:223