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

Go to the source code of this file.

Functions

tpia_target_heatedtpia_target_heated_create (statusMessageReporting *smr)
 
int tpia_target_heated_initialize (statusMessageReporting *, tpia_target_heated *target)
 
tpia_target_heatedtpia_target_heated_createRead (statusMessageReporting *smr, const char *fileName, int checkElememtsForAccess)
 
tpia_target_heatedtpia_target_heated_free (statusMessageReporting *smr, tpia_target_heated *target)
 
int tpia_target_heated_release (statusMessageReporting *smr, tpia_target_heated *target)
 
int tpia_target_heated_read (statusMessageReporting *smr, tpia_target_heated *target, const char *fileName, int checkElememtsForAccess)
 
int tpia_target_heated_numberOfChannels (statusMessageReporting *, tpia_target_heated *target)
 
int tpia_target_heated_numberOfProductionChannels (statusMessageReporting *, tpia_target_heated *target)
 
tpia_channeltpia_target_heated_getChannelAtIndex (tpia_target_heated *target, int index)
 
tpia_channeltpia_target_heated_getChannelAtIndex_smr (statusMessageReporting *smr, tpia_target_heated *target, int index)
 
tpia_channeltpia_target_heated_getProductionChannelAtIndex (tpia_target_heated *target, int index)
 
xData_Int tpia_target_heated_getEnergyGrid (statusMessageReporting *, tpia_target_heated *target, double **energyGrid)
 
xData_Int tpia_target_heated_getEIndex (tpia_target_heated *target, double e_in)
 
double tpia_target_heated_getTotalCrossSectionAtE (statusMessageReporting *smr, tpia_target_heated *target, xData_Int, double e_in, int crossSectionType)
 
double tpia_target_heated_getIndexChannelCrossSectionAtE (statusMessageReporting *smr, tpia_target_heated *target, int index, xData_Int iEg, double e_in, int crossSectionType)
 
int tpia_target_heated_sampleIndexChannelProductsAtE (statusMessageReporting *smr, tpia_target_heated *target, int index, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productDatas)
 

Function Documentation

◆ tpia_target_heated_create()

tpia_target_heated * tpia_target_heated_create ( statusMessageReporting smr)

Definition at line 52 of file tpia_target_heated.cc.

52 {
53
54 tpia_target_heated *target;
55
56 //if( ( target = xData_malloc2( smr, sizeof( tpia_target_heated ), 0, "target" ) ) == NULL ) return( NULL );
57 if( ( target = (tpia_target_heated*) xData_malloc2( smr, sizeof( tpia_target_heated ), 0, "target" ) ) == NULL ) return( NULL );
58 //if( tpia_target_heated_initialize( smr, target ) ) target = xData_free( smr, target );
59 if( tpia_target_heated_initialize( smr, target ) ) target = (tpia_target_heated*) xData_free( smr, target );
60 return( target );
61}
int tpia_target_heated_initialize(statusMessageReporting *, tpia_target_heated *target)
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

Referenced by tpia_target_heated_createRead().

◆ tpia_target_heated_createRead()

tpia_target_heated * tpia_target_heated_createRead ( statusMessageReporting smr,
const char *  fileName,
int  checkElememtsForAccess 
)

Definition at line 74 of file tpia_target_heated.cc.

74 {
75
76 tpia_target_heated *target;
77
78 if( ( target = tpia_target_heated_create( smr ) ) == NULL ) return( NULL );
79 //if( tpia_target_heated_read( smr, target, fileName, checkElememtsForAccess ) != 0 ) target = xData_free( smr, target );
80 if( tpia_target_heated_read( smr, target, fileName, checkElememtsForAccess ) != 0 ) target = (tpia_target_heated*) xData_free( smr, target );
81 return( target );
82}
int tpia_target_heated_read(statusMessageReporting *smr, tpia_target_heated *target, const char *fileName, int checkElememtsForAccess)
tpia_target_heated * tpia_target_heated_create(statusMessageReporting *smr)

Referenced by tpia_target_readHeatedTarget().

◆ tpia_target_heated_free()

tpia_target_heated * tpia_target_heated_free ( statusMessageReporting smr,
tpia_target_heated target 
)

Definition at line 86 of file tpia_target_heated.cc.

86 {
87
88 tpia_target_heated_release( smr, target );
89 xData_free( smr, target );
90 return( NULL );
91}
int tpia_target_heated_release(statusMessageReporting *smr, tpia_target_heated *target)

Referenced by tpia_target_release().

◆ tpia_target_heated_getChannelAtIndex()

tpia_channel * tpia_target_heated_getChannelAtIndex ( tpia_target_heated target,
int  index 
)

Definition at line 263 of file tpia_target_heated.cc.

263 {
264
265 tpia_channel *channel = NULL;
266
267 if( ( index >= 0 ) && ( index < target->nChannels ) ) channel = target->channels[index];
268 return( channel );
269}
tpia_channel ** channels
Definition: tpia_target.h:281

Referenced by G4GIDI_target::init(), and tpia_target_heated_getChannelAtIndex_smr().

◆ tpia_target_heated_getChannelAtIndex_smr()

tpia_channel * tpia_target_heated_getChannelAtIndex_smr ( statusMessageReporting smr,
tpia_target_heated target,
int  index 
)

Definition at line 273 of file tpia_target_heated.cc.

273 {
274
275 tpia_channel *channel = tpia_target_heated_getChannelAtIndex( target, index );
276
277 if( channel == NULL ) {
278 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad channel index = %d for %s + %s", index,
279 target->projectileID->name, target->targetID->name );
280 }
281 return( channel );
282}
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
tpia_particle * targetID
Definition: tpia_target.h:272
tpia_particle * projectileID
Definition: tpia_target.h:271
tpia_channel * tpia_target_heated_getChannelAtIndex(tpia_target_heated *target, int index)

Referenced by G4GIDI_target::getElasticFinalState(), tpia_target_heated_getIndexChannelCrossSectionAtE(), and tpia_target_heated_sampleIndexChannelProductsAtE().

◆ tpia_target_heated_getEIndex()

xData_Int tpia_target_heated_getEIndex ( tpia_target_heated target,
double  e_in 
)

Definition at line 305 of file tpia_target_heated.cc.

305 {
306
307 return( tpia_misc_binarySearch( target->energyGridLength, target->energyGrid, e_in ) );
308}
xData_Int energyGridLength
Definition: tpia_target.h:274
xData_Int tpia_misc_binarySearch(xData_Int n, double *ds, double d)
Definition: tpia_misc.cc:208

Referenced by tpia_channel_getCrossSectionAtE(), and tpia_target_heated_getTotalCrossSectionAtE().

◆ tpia_target_heated_getEnergyGrid()

xData_Int tpia_target_heated_getEnergyGrid ( statusMessageReporting smr,
tpia_target_heated target,
double **  energyGrid 
)

Definition at line 297 of file tpia_target_heated.cc.

297 {
298
299 if( energyGrid != NULL ) *energyGrid = target->energyGrid;
300 return( target->energyGridLength );
301}

Referenced by tpia_target_getEnergyGridAtTIndex().

◆ tpia_target_heated_getIndexChannelCrossSectionAtE()

double tpia_target_heated_getIndexChannelCrossSectionAtE ( statusMessageReporting smr,
tpia_target_heated target,
int  index,
xData_Int  iEg,
double  e_in,
int  crossSectionType 
)

Definition at line 329 of file tpia_target_heated.cc.

330 {
331
332 double xsec = 0.;
333 tpia_channel *channel = tpia_target_heated_getChannelAtIndex_smr( smr, target, index );
334
335 if( channel != NULL ) xsec = tpia_channel_getCrossSectionAtE( smr, channel, iEg, e_in, crossSectionType );
336 return( xsec );
337}
double tpia_channel_getCrossSectionAtE(statusMessageReporting *smr, tpia_channel *channel, xData_Int iEg, double e_in, int crossSectionType)
tpia_channel * tpia_target_heated_getChannelAtIndex_smr(statusMessageReporting *smr, tpia_target_heated *target, int index)

Referenced by tpia_target_getIndexChannelCrossSectionAtE().

◆ tpia_target_heated_getProductionChannelAtIndex()

tpia_channel * tpia_target_heated_getProductionChannelAtIndex ( tpia_target_heated target,
int  index 
)

Definition at line 286 of file tpia_target_heated.cc.

286 {
287
288 tpia_channel *channel = NULL;
289
290 if( ( index >= 0 ) && ( index < target->nProductionChannels ) ) channel = target->productionChannels[index];
291 return( channel );
292}
tpia_channel ** productionChannels
Definition: tpia_target.h:282

◆ tpia_target_heated_getTotalCrossSectionAtE()

double tpia_target_heated_getTotalCrossSectionAtE ( statusMessageReporting smr,
tpia_target_heated target,
xData_Int  gE,
double  e_in,
int  crossSectionType 
)

Definition at line 313 of file tpia_target_heated.cc.

314 {
315
316 double xsec = 0.;
317
318 if( crossSectionType == tpia_crossSectionType_grouped ) {
319 xsec = 0; }
320 else if( crossSectionType == tpia_crossSectionType_pointwise ) {
322 tpia_target_heated_getEIndex( target, e_in ), e_in );
323 }
324 return( xsec );
325}
tpia_1dData totalCrossSectionPointwise
Definition: tpia_target.h:276
double tpia_misc_getPointwiseCrossSectionAtE(statusMessageReporting *smr, tpia_1dData *crossSection, double *energyGrid, xData_Int index, double e_in)
Definition: tpia_misc.cc:298
#define tpia_crossSectionType_grouped
Definition: tpia_target.h:88
#define tpia_crossSectionType_pointwise
Definition: tpia_target.h:89
xData_Int tpia_target_heated_getEIndex(tpia_target_heated *target, double e_in)

Referenced by tpia_target_getTotalCrossSectionAtTAndE().

◆ tpia_target_heated_initialize()

int tpia_target_heated_initialize ( statusMessageReporting smr,
tpia_target_heated target 
)

Definition at line 66 of file tpia_target_heated.cc.

66 {
67
68 memset( target, 0, sizeof( tpia_target_heated ) );
69 return( 0 );
70}

Referenced by tpia_target_heated_create(), and tpia_target_heated_read().

◆ tpia_target_heated_numberOfChannels()

int tpia_target_heated_numberOfChannels ( statusMessageReporting smr,
tpia_target_heated target 
)

Definition at line 248 of file tpia_target_heated.cc.

248 {
249
250 return( target->nChannels );
251}

Referenced by tpia_target_numberOfChannels().

◆ tpia_target_heated_numberOfProductionChannels()

int tpia_target_heated_numberOfProductionChannels ( statusMessageReporting smr,
tpia_target_heated target 
)

Definition at line 256 of file tpia_target_heated.cc.

256 {
257
258 return( target->nProductionChannels );
259}

Referenced by tpia_target_numberOfProductionChannels().

◆ tpia_target_heated_read()

int tpia_target_heated_read ( statusMessageReporting smr,
tpia_target_heated target,
const char *  fileName,
int  checkElememtsForAccess 
)

Definition at line 126 of file tpia_target_heated.cc.

126 {
127/*
128* If a target has already been read into this target, user must have called tpia_target_heated_release before calling this routine.
129* Otherwise, there will be memory leaks.
130*/
131 xData_document *doc = NULL;
132 xData_element *element, *channelElement, *channels;
133 int nChannels;
134 tpia_channel *channel;
135 char *name;
136 xData_Int i, j;
137
138 tpia_target_heated_initialize( smr, target );
139 if( ( target->path = xDataMisc_allocateCopyString2( smr, fileName, "path" ) ) == NULL ) return( 1 );
140 if( ( target->absPath = xDataMisc_getAbsPath( smr, fileName ) ) == NULL ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) );
141 if( ( doc = xData_parseReadFile( smr, fileName, NULL, NULL ) ) == NULL ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) );
142 element = xData_getDocumentsElement( doc );
143 xData_addToAccessed( smr, element, 1 );
144 if( xData_convertAttributeTo_xData_Int( smr, element, "nGroups", &i ) != 0 ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) );
145 target->nGroups = (int) i;
146 if( strcmp( element->name, "xTargetHeated" ) != 0 ) {
147 tpia_misc_setMessageError_Element( smr, NULL, element, __FILE__, __LINE__, 1, "input file's top element must be xTargetHeated and not %s",
148 element->name ); }
149 else {
150 xData_copyAttributionList( smr, &(target->attributes), &(element->attributes) );
151 if( smr_isOk( smr ) ) target->contents = xData_getAttributesValue( &(target->attributes), "contents" );
152 if( ( name = tpia_misc_pointerToAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "projectile" ) ) != NULL )
153 target->projectileID = tpia_particle_getInternalID( smr, name );
154 if( ( name = tpia_misc_pointerToAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "target" ) ) != NULL )
155 target->targetID = tpia_particle_getInternalID( smr, name );
156 if( smr_isOk( smr ) ) _tpia_target_heated_getEnergyGridAndAllocateTotalCrossSections( smr, target, element );
157 if( smr_isOk( smr ) ) { /* Get channels. */
158 //if( ( channels = xData_getOneElementByTagName( smr, element, "channels", 1 ) ) == NULL )
159 if( ( channels = xData_getOneElementByTagName( smr, element, (char*)"channels", 1 ) ) == NULL )
160 return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) );
161 xData_addToAccessed( smr, channels, 1 );
162 if( ( nChannels = xData_numberOfElementsByTagName( smr, channels, "channel" ) ) > 0 ) {
163 //if( ( target->channels = xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) == NULL )
164 if( ( target->channels = (tpia_channel**) xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) == NULL )
165 return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) );
166 for( channelElement = xData_getFirstElement( channels ); channelElement != NULL; channelElement = xData_getNextElement( channelElement ) ) {
167 if( !strcmp( channelElement->name, "channel" ) ) {
168 if( ( channel = tpia_channel_createGetFromElement( smr, target, channelElement, 1 ) ) == NULL ) break;
169 target->channels[target->nChannels] = channel;
170 target->nChannels++;
171 for( i = channel->crossSectionPointwise.start, j = 0; i < channel->crossSectionPointwise.end; i++, j++ )
173 for( i = channel->crossSectionGrouped.start, j = 0; i < channel->crossSectionGrouped.end; i++, j++ )
174 target->totalCrossSectionGrouped.data[i] += channel->crossSectionGrouped.data[j];
175 }
176 }
177 }
178 }
179 if( smr_isOk( smr ) ) { /* Get production channels. */
180 //if( ( channels = xData_getOneElementByTagName( smr, element, "productionChannels", 0 ) ) == NULL ) {
181 if( ( channels = xData_getOneElementByTagName( smr, element, (char*) "productionChannels", 0 ) ) == NULL ) {
182 if( !smr_isOk( smr ) ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); }
183 else {
184 xData_addToAccessed( smr, channels, 1 );
185 if( ( nChannels = xData_numberOfElementsByTagName( smr, channels, "channel" ) ) > 0 ) {
186 //if( ( target->productionChannels = xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) != NULL ) {
187 if( ( target->productionChannels = (tpia_channel**) xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) != NULL ) {
188 for( channelElement = xData_getFirstElement(channels); channelElement != NULL; channelElement = xData_getNextElement(channelElement) ) {
189 if( !strcmp( channelElement->name, "channel" ) ) {
190 channel = tpia_channel_createGetFromElement( smr, target, channelElement, 1 );
191 if( channel == NULL ) break;
192 target->productionChannels[target->nProductionChannels] = channel;
193 target->nProductionChannels++;
194 }
195 }
196 }
197 }
198 }
199 }
200 }
201 if( smr_isOk( smr ) && checkElememtsForAccess ) _tpia_target_heated_checkElememtsForAccess( smr, doc );
202 xData_parseFree( smr, doc );
203 if( !smr_isOk( smr ) ) tpia_target_heated_release( smr, target );
204 return( !smr_isOk( smr ) );
205}
int smr_isOk(statusMessageReporting *smr)
xData_Int start
Definition: tpia_target.h:144
double * data
Definition: tpia_target.h:145
tpia_1dData crossSectionPointwise
Definition: tpia_target.h:261
tpia_1dData crossSectionGrouped
Definition: tpia_target.h:262
xData_attributionList attributes
Definition: tpia_target.h:278
tpia_1dData totalCrossSectionGrouped
Definition: tpia_target.h:277
xData_attributionList attributes
Definition: xData.h:186
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
#define tpia_misc_pointerToAttributeIfAllOk3(smr, path, required, attributes, name)
Definition: tpia_misc.h:44
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)
tpia_channel * tpia_channel_createGetFromElement(statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, int pointwiseRequired)
Definition: tpia_channel.cc:71
char * xDataMisc_getAbsPath(statusMessageReporting *smr, const char *fileName)
Definition: xDataMisc.cc:112
int xData_numberOfElementsByTagName(statusMessageReporting *smr, xData_element *element, const char *tagName)
Definition: xData.cc:750
#define xDataMisc_allocateCopyString2(smr, s, forItem)
Definition: xData.h:315
int xData_copyAttributionList(statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
Definition: xData.cc:564
xData_element * xData_getOneElementByTagName(statusMessageReporting *smr, xData_element *element, char *name, int required)
Definition: xData.cc:810
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
Definition: xData.cc:1078
void * xData_parseFree(statusMessageReporting *smr, xData_document *xData_doc)
Definition: xData.cc:208
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
Definition: xData.cc:710
xData_element * xData_getNextElement(xData_element *element)
Definition: xData.cc:478
xData_element * xData_getDocumentsElement(xData_document *xData_doc)
Definition: xData.cc:476
xData_element * xData_getFirstElement(xData_element *element)
Definition: xData.cc:477
xData_document * xData_parseReadFile(statusMessageReporting *smr, const char *fileName, xData_xDataTypeOk func, void *userData)
Definition: xData.cc:84
char * xData_getAttributesValue(xData_attributionList *attributes, const char *name)
Definition: xData.cc:530
int xData_Int
Definition: xData.h:50

Referenced by tpia_target_heated_createRead().

◆ tpia_target_heated_release()

int tpia_target_heated_release ( statusMessageReporting smr,
tpia_target_heated target 
)

Definition at line 95 of file tpia_target_heated.cc.

95 {
96
97 int i;
98
99 //target->path = xData_free( smr, target->path );
100 target->path = (char*) xData_free( smr, target->path );
101 //target->absPath = xData_free( smr, target->absPath );
102 target->absPath = (char*) xData_free( smr, target->absPath );
103 target->energyGridLength = 0;
104 //target->energyGrid = xData_free( smr, target->energyGrid );
105 target->energyGrid = (double*) xData_free( smr, target->energyGrid );
106 //target->kerma = xData_free( smr, target->kerma );
107 target->kerma = (double*) xData_free( smr, target->kerma );
108 //target->totalCrossSectionPointwise.data = xData_free( smr, target->totalCrossSectionPointwise.data );
110 //target->totalCrossSectionGrouped.data = xData_free( smr, target->totalCrossSectionGrouped.data );
111 target->totalCrossSectionGrouped.data = (double*) xData_free( smr, target->totalCrossSectionGrouped.data );
112 xData_releaseAttributionList( smr, &(target->attributes) );
113 for( i = 0; i < target->nChannels; i++ ) tpia_channel_free( smr, target->channels[i] );
114 target->nChannels = 0;
115 //target->channels = xData_free( smr, target->channels );
116 target->channels = (tpia_channel**) xData_free( smr, target->channels );
117 for( i = 0; i < target->nProductionChannels; i++ ) tpia_channel_free( smr, target->productionChannels[i] );
118 target->nProductionChannels = 0;
119 //target->productionChannels = xData_free( smr, target->productionChannels );
120 target->productionChannels = (tpia_channel**) xData_free( smr, target->productionChannels );
121 return( 0 );
122}
tpia_channel * tpia_channel_free(statusMessageReporting *smr, tpia_channel *channel)
Definition: tpia_channel.cc:83
int xData_releaseAttributionList(statusMessageReporting *smr, xData_attributionList *attributes)
Definition: xData.cc:611

Referenced by tpia_target_heated_free(), and tpia_target_heated_read().

◆ tpia_target_heated_sampleIndexChannelProductsAtE()

int tpia_target_heated_sampleIndexChannelProductsAtE ( statusMessageReporting smr,
tpia_target_heated target,
int  index,
tpia_decaySamplingInfo decaySamplingInfo,
int  nProductData,
tpia_productOutgoingData productDatas 
)

Definition at line 341 of file tpia_target_heated.cc.

342 {
343
344 tpia_channel *channel = tpia_target_heated_getChannelAtIndex_smr( smr, target, index );
345
346 if( channel == NULL ) return( -1 );
347 return( tpia_decayChannel_sampleProductsAtE( smr, &(channel->decayChannel), decaySamplingInfo, nProductData, productDatas ) );
348}
tpia_decayChannel decayChannel
Definition: tpia_target.h:264
int tpia_decayChannel_sampleProductsAtE(statusMessageReporting *smr, tpia_decayChannel *decayChannel, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productData)

Referenced by G4GIDI_target::getFinalState(), and tpia_target_sampleIndexChannelProductsAtE().