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

Go to the source code of this file.

Functions

tpia_multiplicitytpia_multiplicity_create (statusMessageReporting *smr)
 
int tpia_multiplicity_initialize (statusMessageReporting *smr, tpia_multiplicity *multiplicity)
 
tpia_multiplicitytpia_multiplicity_free (statusMessageReporting *smr, tpia_multiplicity *multiplicity)
 
int tpia_multiplicity_release (statusMessageReporting *smr, tpia_multiplicity *multiplicity)
 
tpia_multiplicitytpia_multiplicity_createGetFromElement (statusMessageReporting *smr, xData_element *multiplicityElement, int nGroups)
 
int tpia_multiplicity_getFromElement (statusMessageReporting *smr, xData_element *multiplicityElement, tpia_multiplicity *multiplicity, int)
 
int tpia_multiplicity_getTimeScaleFromElement (statusMessageReporting *smr, xData_element *element, const char **timeScale, int *isDelayedNeutrons, double *dTimeScale)
 

Function Documentation

◆ tpia_multiplicity_create()

tpia_multiplicity * tpia_multiplicity_create ( statusMessageReporting smr)

Definition at line 50 of file tpia_multiplicity.cc.

50 {
51
52 tpia_multiplicity *multiplicity;
53
54 //if( ( multiplicity = xData_malloc2( smr, sizeof( tpia_multiplicity ), 0, "multiplicity" ) ) == NULL ) return( NULL );
55 if( ( multiplicity = (tpia_multiplicity*) xData_malloc2( smr, sizeof( tpia_multiplicity ), 0, "multiplicity" ) ) == NULL ) return( NULL );
56 if( tpia_multiplicity_initialize( smr, multiplicity ) ) multiplicity = tpia_multiplicity_free( smr, multiplicity );
57 return( multiplicity );
58}
tpia_multiplicity * tpia_multiplicity_free(statusMessageReporting *smr, tpia_multiplicity *multiplicity)
int tpia_multiplicity_initialize(statusMessageReporting *smr, tpia_multiplicity *multiplicity)
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

Referenced by tpia_multiplicity_createGetFromElement().

◆ tpia_multiplicity_createGetFromElement()

tpia_multiplicity * tpia_multiplicity_createGetFromElement ( statusMessageReporting smr,
xData_element multiplicityElement,
int  nGroups 
)

Definition at line 92 of file tpia_multiplicity.cc.

92 {
93
94 tpia_multiplicity *multiplicity;
95
96 if( ( multiplicity = tpia_multiplicity_create( smr ) ) == NULL ) return( NULL );
97 if( tpia_multiplicity_getFromElement( smr, multiplicityElement, multiplicity, nGroups ) != 0 ) multiplicity = tpia_multiplicity_free( smr, multiplicity );
98 return( multiplicity );
99}
int tpia_multiplicity_getFromElement(statusMessageReporting *smr, xData_element *multiplicityElement, tpia_multiplicity *multiplicity, int)
tpia_multiplicity * tpia_multiplicity_create(statusMessageReporting *smr)

◆ tpia_multiplicity_free()

tpia_multiplicity * tpia_multiplicity_free ( statusMessageReporting smr,
tpia_multiplicity multiplicity 
)

Definition at line 71 of file tpia_multiplicity.cc.

71 {
72
73 tpia_multiplicity_release( smr, multiplicity );
74 xData_free( smr, multiplicity );
75 return( NULL );
76}
int tpia_multiplicity_release(statusMessageReporting *smr, tpia_multiplicity *multiplicity)
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

Referenced by tpia_multiplicity_create(), tpia_multiplicity_createGetFromElement(), and tpia_product_release().

◆ tpia_multiplicity_getFromElement()

int tpia_multiplicity_getFromElement ( statusMessageReporting smr,
xData_element multiplicityElement,
tpia_multiplicity multiplicity,
int  nGroups 
)

Definition at line 104 of file tpia_multiplicity.cc.

104 {
105
106 const char *timeScale;
107 int isDelayedNeutrons;
108 xData_element *data;
109
110 xData_addToAccessed( smr, multiplicityElement, 1 );
111 if( ( tpia_frame_setFromElement( smr, multiplicityElement, 2, &(multiplicity->frame) ) ) != 0 ) return( 1 );
112 if( tpia_multiplicity_getTimeScaleFromElement( smr, multiplicityElement, &timeScale, &isDelayedNeutrons, &(multiplicity->timeScale) ) ) return( 1 );
113 for( data = xData_getFirstElement( multiplicityElement ); data != NULL; data = xData_getNextElement( data ) ) {
114 if( strcmp( data->name, "grouped" ) == 0 ) {
115 if( tpia_misc_get2d_xShared_yHistogram_data_Grouped( smr, data, &(multiplicity->grouped) ) ) return( 1 ); }
116 else if( strcmp( data->name, "pointwise" ) == 0 ) {
117 if( ( multiplicity->pointwise = tpia_misc_get2dx_y_data( smr, data, &multiplicity->numberOfPointwise ) ) == NULL ) return( 1 ); }
118 else {
119 tpia_misc_setMessageError_Element( smr, NULL, multiplicityElement, __FILE__, __LINE__, 1, "unsupported multiplicity type = %s", data->name );
120 return( 1 );
121 }
122 }
123 return( 0 );
124}
tpia_data_frame frame
Definition: tpia_target.h:175
xData_Int numberOfPointwise
Definition: tpia_target.h:177
tpia_1dData grouped
Definition: tpia_target.h:178
char * name
Definition: xData.h:184
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_multiplicity_getTimeScaleFromElement(statusMessageReporting *smr, xData_element *element, const char **timeScale, int *isDelayedNeutrons, double *dTimeScale)
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:61
double * tpia_misc_get2dx_y_data(statusMessageReporting *smr, xData_element *element, xData_Int *length)
Definition: tpia_misc.cc:228
int tpia_misc_get2d_xShared_yHistogram_data_Grouped(statusMessageReporting *smr, xData_element *element, tpia_1dData *group)
Definition: tpia_misc.cc:289
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
Definition: xData.cc:1078
xData_element * xData_getNextElement(xData_element *element)
Definition: xData.cc:478
xData_element * xData_getFirstElement(xData_element *element)
Definition: xData.cc:477

Referenced by tpia_multiplicity_createGetFromElement().

◆ tpia_multiplicity_getTimeScaleFromElement()

int tpia_multiplicity_getTimeScaleFromElement ( statusMessageReporting smr,
xData_element element,
const char **  timeScale,
int *  isDelayedNeutrons,
double *  dTimeScale 
)

Definition at line 128 of file tpia_multiplicity.cc.

129 {
130
131 const char *p;
132 char *e;
133
134 *isDelayedNeutrons = 0;
135 *dTimeScale = 0.;
136 *timeScale = xData_getAttributesValue( &(element->attributes), "timeScale" );
137 if( *timeScale != NULL ) {
138 if( strcmp( *timeScale, "prompt" ) ) {
139 if( strncmp( *timeScale, "delayed", 7 ) ) {
140 tpia_misc_setMessageError_Element( smr, NULL, element, __FILE__, __LINE__, 1, "invalid timeScale attribute = %s", *timeScale );
141 return( 1 ); }
142 else {
143 for( p = &((*timeScale)[7]); *p; p++ ) if( !isspace( *p ) ) break;
144 if( *p != '=' ) {
145 tpia_misc_setMessageError_Element( smr, NULL, element, __FILE__, __LINE__, 1, "timeScale attribute '%s' missing '='", *timeScale );
146 return( 1 );
147 }
148 p++;
149 *dTimeScale = strtod( p, &e );
150 if( *e != 0 ) {
151 tpia_misc_setMessageError_Element( smr, NULL, element, __FILE__, __LINE__, 1, "could not convert timeScale attribute '%s' to double",
152 *timeScale );
153 return( 1 );
154 }
155 *isDelayedNeutrons = 1;
156 }
157 }
158 }
159 return( 0 );
160}
xData_attributionList attributes
Definition: xData.h:186
char * xData_getAttributesValue(xData_attributionList *attributes, const char *name)
Definition: xData.cc:530

Referenced by tpia_multiplicity_getFromElement().

◆ tpia_multiplicity_initialize()

int tpia_multiplicity_initialize ( statusMessageReporting smr,
tpia_multiplicity multiplicity 
)

Definition at line 62 of file tpia_multiplicity.cc.

62 {
63
64 memset( multiplicity, 0, sizeof( tpia_multiplicity ) );
65 if( tpia_frame_setFromString( smr, "", "", 0, &(multiplicity->frame) ) ) return( 1 );
66 return( 0 );
67}
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_multiplicity_create(), and tpia_multiplicity_release().

◆ tpia_multiplicity_release()

int tpia_multiplicity_release ( statusMessageReporting smr,
tpia_multiplicity multiplicity 
)

Definition at line 80 of file tpia_multiplicity.cc.

80 {
81
82 //multiplicity->grouped.data = xData_free( smr, multiplicity->grouped.data );
83 multiplicity->grouped.data = (double*) xData_free( smr, multiplicity->grouped.data );
84 //multiplicity->pointwise = xData_free( smr, multiplicity->pointwise );
85 multiplicity->pointwise = (double*) xData_free( smr, multiplicity->pointwise );
86 tpia_multiplicity_initialize( smr, multiplicity );
87 return( 0 );
88}
double * data
Definition: tpia_target.h:145

Referenced by tpia_multiplicity_free().