#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tpia_target.h>
#include <tpia_misc.h>
Go to the source code of this file.
Functions | |
int | tpia_frame_clear (statusMessageReporting *, tpia_data_frame *frame) |
int | tpia_frame_setFromElement (statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame) |
int | tpia_frame_setFromString (statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame) |
int | tpia_frame_getDimensions (statusMessageReporting *, tpia_data_frame *frame) |
char * | tpia_frame_toString (statusMessageReporting *smr, const char *, tpia_data_frame *frame) |
int | tpia_frame_setColumns (statusMessageReporting *smr, tpia_data_frame *frame, int nColumns, int *values) |
int | tpia_frame_setColumn (statusMessageReporting *smr, tpia_data_frame *frame, int column, int value) |
int | tpia_frame_getColumn (statusMessageReporting *smr, tpia_data_frame *frame, int column) |
int tpia_frame_clear | ( | statusMessageReporting * | , | |
tpia_data_frame * | frame | |||
) |
int tpia_frame_getColumn | ( | statusMessageReporting * | smr, | |
tpia_data_frame * | frame, | |||
int | column | |||
) |
Definition at line 213 of file tpia_frame.cc.
References smr_setMessageError().
Referenced by tpia_frame_toString(), and tpia_kinetics_COMKineticEnergy2LabEnergyAndMomentum().
00213 { 00214 00215 unsigned int value; 00216 00217 if( ( column < 0 ) || ( column >= tpia_maxNumberOfFrames ) ) { 00218 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad column = %d value for getting frame (0 <= column < %d)", column, tpia_maxNumberOfFrames ); 00219 return( -1 ); } 00220 else { 00221 value = frame->frames >> ( 2 * column ); 00222 } 00223 return( (int) ( value & 3 ) ); 00224 }
int tpia_frame_getDimensions | ( | statusMessageReporting * | , | |
tpia_data_frame * | frame | |||
) |
Definition at line 121 of file tpia_frame.cc.
Referenced by tpia_frame_toString().
00121 { 00122 00123 int i, dimension = 0; 00124 unsigned value = frame->frames; 00125 00126 for( i = 0; i < tpia_maxNumberOfFrames; i++ ) { 00127 if( ( value & 3 ) == 0 ) break; 00128 dimension++; 00129 value = value >> 2; 00130 } 00131 return( dimension ); 00132 }
int tpia_frame_setColumn | ( | statusMessageReporting * | smr, | |
tpia_data_frame * | frame, | |||
int | column, | |||
int | value | |||
) |
Definition at line 190 of file tpia_frame.cc.
References smr_setMessageError().
Referenced by G4GIDI_target::getElasticFinalState(), G4GIDI_target::getFinalState(), tpia_frame_setColumns(), and tpia_frame_setFromString().
00190 { 00191 00192 int i; 00193 00194 if( ( column < 0 ) || ( column >= tpia_maxNumberOfFrames ) ) { 00195 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad column = %d value for setting frame (0 <= column < %d)", column, tpia_maxNumberOfFrames ); 00196 return( 1 ); } 00197 else { 00198 if( ( value < tpia_referenceFrame_None ) || ( value > tpia_referenceFrame_Max ) ) { 00199 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad frame value = %d for column = %d", value, column ); 00200 return( 1 ); } 00201 else { 00202 i = 3 << ( 2 * column ); 00203 frame->frames = frame->frames & (~i); 00204 value = value << ( 2 * column ); 00205 frame->frames = frame->frames | value; 00206 } 00207 } 00208 return( 0 ); 00209 }
int tpia_frame_setColumns | ( | statusMessageReporting * | smr, | |
tpia_data_frame * | frame, | |||
int | nColumns, | |||
int * | values | |||
) |
Definition at line 178 of file tpia_frame.cc.
References tpia_frame_clear(), and tpia_frame_setColumn().
Referenced by tpia_decayChannel_sampleProductsAtE().
00178 { 00179 00180 int i; 00181 00182 tpia_frame_clear( smr, frame ); 00183 for( i = 0; i < nColumns; i++ ) if( tpia_frame_setColumn( smr, frame, i, values[i] ) != 0 ) return( 1 ); 00184 00185 return( 0 ); 00186 }
int tpia_frame_setFromElement | ( | statusMessageReporting * | smr, | |
xData_element * | element, | |||
int | dimension, | |||
tpia_data_frame * | frame | |||
) |
Definition at line 61 of file tpia_frame.cc.
References tpia_frame_setFromString(), tpia_misc_setMessageError_Element(), and xData_getAttributesValueInElement().
Referenced by tpia_angular_getFromElement(), tpia_angularEnergy_getFromElement(), tpia_channel_getFromElement(), tpia_Legendre_getFromElement(), and tpia_multiplicity_getFromElement().
00061 { 00062 00063 char const *value = xData_getAttributesValueInElement( element, "frame" ); 00064 00065 if( value == NULL ) { 00066 tpia_misc_setMessageError_Element( smr, NULL, element, __FILE__, __LINE__, 1, "element is missing frame attribute" ); 00067 return( 1 ); 00068 } 00069 return( tpia_frame_setFromString( smr, element->fullName, value, dimension, frame ) ); 00070 }
int tpia_frame_setFromString | ( | statusMessageReporting * | smr, | |
const char * | forItem, | |||
const char * | value, | |||
int | dimension, | |||
tpia_data_frame * | frame | |||
) |
Definition at line 74 of file tpia_frame.cc.
References smr_isOk(), smr_setMessageError(), and tpia_frame_setColumn().
Referenced by tpia_angular_initialize(), tpia_angularEnergy_initialize(), tpia_frame_setFromElement(), tpia_Legendre_initialize(), and tpia_multiplicity_initialize().
00074 { 00075 00076 char const *e; 00077 int status = 1, i; 00078 00079 for( i = 0; i < tpia_maxNumberOfFrames; i++ ) tpia_frame_setColumn( smr, frame, i, tpia_referenceFrame_None ); 00080 if( dimension > tpia_maxNumberOfFrames ) { 00081 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "dimension argument = %d is greater than tpia_maxNumberOfFrames = %d", dimension, 00082 tpia_maxNumberOfFrames ); 00083 return( status ); 00084 } 00085 for( i = 0, e = value; ( i < dimension ) && ( *e != 0 ); i++ ) { 00086 if( strstr( e, lab_Str ) == e ) { 00087 tpia_frame_setColumn( smr, frame, i, tpia_referenceFrame_lab ); 00088 e += 3; } 00089 else if( strstr( e, COM_Str ) == e ) { 00090 tpia_frame_setColumn( smr, frame, i, tpia_referenceFrame_COM ); 00091 e += 12; } 00092 else { 00093 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad frame '%s' for %s", value, forItem ); 00094 break; 00095 } 00096 if( *e != 0 ) { 00097 if( *e != ',' ) { 00098 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad separater for frame '%s' for %s", value, forItem ); 00099 break; 00100 } 00101 e++; 00102 } 00103 } 00104 if( smr_isOk( smr ) ) { 00105 if( i == dimension ) { 00106 if( *e == 0 ) { 00107 status = 0; } 00108 else { 00109 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "extra values for frame '%s' for %s", value, forItem ); 00110 } } 00111 else { 00112 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "missing values for frame '%s' for %s", value, forItem ); 00113 } 00114 } 00115 return( status ); 00116 }
char* tpia_frame_toString | ( | statusMessageReporting * | smr, | |
const char * | , | |||
tpia_data_frame * | frame | |||
) |
Definition at line 137 of file tpia_frame.cc.
References CLHEP::detail::n, smr_setMessageError(), tpia_frame_getColumn(), and tpia_frame_getDimensions().
00137 { 00138 00139 int i, n = tpia_frame_getDimensions( smr, frame ), value, nStr = 0; 00140 char *str = NULL, *p; 00141 00142 if( nlab_Str == 0 ) { 00143 nlab_Str = strlen( lab_Str ); 00144 nCOM_Str = strlen( COM_Str ); 00145 } 00146 for( i = 0; i < n; i++ ) { 00147 value = tpia_frame_getColumn( smr, frame, i ); 00148 if( value == tpia_referenceFrame_COM ) { 00149 nStr += nCOM_Str + 1; } 00150 else if( value == tpia_referenceFrame_lab ) { 00151 nStr += nlab_Str + 1; } 00152 else { 00153 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad frame value = %d for column = %d", value, i ); 00154 return( NULL ); 00155 } 00156 } 00157 if( nStr == 0 ) nStr = 1; 00158 //if( ( str = xData_malloc2( smr, nStr, 1, "str" ) ) == NULL ) return( NULL ); 00159 if( ( str = (char*) xData_malloc2( smr, nStr, 1, "str" ) ) == NULL ) return( NULL ); 00160 for( i = 0, p = str - 1; i < n; i++ ) { 00161 p++; 00162 value = tpia_frame_getColumn( smr, frame, i ); 00163 if( value == tpia_referenceFrame_COM ) { 00164 strcpy( p, COM_Str ); 00165 p += nCOM_Str; } 00166 else { 00167 strcpy( p, lab_Str ); 00168 p += nlab_Str; 00169 } 00170 *p = ','; 00171 } 00172 *p = 0; 00173 return( str ); 00174 }