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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/xDataTOM_axes.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/xDataTOM_axes.cc (Version 11.2.1)


  1 /*                                                  1 /*
  2 # <<BEGIN-copyright>>                               2 # <<BEGIN-copyright>>
  3 # <<END-copyright>>                                 3 # <<END-copyright>>
  4 */                                                  4 */
  5                                                     5 
  6 #include <string.h>                                 6 #include <string.h>
  7                                                     7 
  8 #include "xDataTOM_private.h"                       8 #include "xDataTOM_private.h"
  9                                                     9 
 10 #if defined __cplusplus                            10 #if defined __cplusplus
 11 namespace GIDI {                                   11 namespace GIDI {
 12 using namespace GIDI;                              12 using namespace GIDI;
 13 #endif                                             13 #endif
 14                                                    14 
 15 static char const *xDataTOM_frame_labString =      15 static char const *xDataTOM_frame_labString = "lab";
 16 static char const *xDataTOM_frame_centerOfMass     16 static char const *xDataTOM_frame_centerOfMassString = "centerOfMass";
 17 static char const *xDataTOM_frame_invalidStrin     17 static char const *xDataTOM_frame_invalidString = "invalid";
 18 /*                                                 18 /*
 19 **********************************************     19 ************************************************************
 20 */                                                 20 */
 21 int xDataTOM_axes_initialize( statusMessageRep     21 int xDataTOM_axes_initialize( statusMessageReporting *smr, xDataTOM_axes *axes, int numberOfAxes ) {
 22                                                    22 
 23     axes->numberOfAxes = 0;                        23     axes->numberOfAxes = 0;
 24     if( ( axes->axis = (xDataTOM_axis *) smr_m     24     if( ( axes->axis = (xDataTOM_axis *) smr_malloc2( smr, numberOfAxes * sizeof( xDataTOM_axis ), 1, "axes->axis" ) ) == NULL ) return( 1 );
 25     axes->numberOfAxes = numberOfAxes;             25     axes->numberOfAxes = numberOfAxes;
 26     return( 0 );                                   26     return( 0 );
 27 }                                                  27 }
 28 /*                                                 28 /*
 29 **********************************************     29 ************************************************************
 30 */                                                 30 */
 31 int xDataTOM_axes_release( xDataTOM_axes *axes     31 int xDataTOM_axes_release( xDataTOM_axes *axes ) {
 32                                                    32 
 33     int i;                                         33     int i;
 34                                                    34 
 35     for( i = 0; i < axes->numberOfAxes; i++ )      35     for( i = 0; i < axes->numberOfAxes; i++ ) {
 36         xDataTOM_axis_release( NULL, &(axes->a     36         xDataTOM_axis_release( NULL, &(axes->axis[i]) );
 37     }                                              37     }
 38     smr_freeMemory( (void **) &(axes->axis) );     38     smr_freeMemory( (void **) &(axes->axis) );
 39     return( 0 );                                   39     return( 0 );
 40 }                                                  40 }
 41 /*                                                 41 /*
 42 **********************************************     42 ************************************************************
 43 */                                                 43 */
 44 char const *xDataTOM_axes_getLabel( statusMess     44 char const *xDataTOM_axes_getLabel( statusMessageReporting *smr, xDataTOM_axes *axes, int index ) {
 45                                                    45 
 46     if( ( index < 0 ) || ( index >= axes->numb     46     if( ( index < 0 ) || ( index >= axes->numberOfAxes ) ) {
 47         smr_setReportError2( smr, xDataTOM_smr     47         smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid axes index = %d", index );
 48         return( NULL );                            48         return( NULL );
 49     }                                              49     }
 50     return( axes->axis[index].label );             50     return( axes->axis[index].label );
 51 }                                                  51 }
 52 /*                                                 52 /*
 53 **********************************************     53 ************************************************************
 54 */                                                 54 */
 55 char const *xDataTOM_axes_getUnit( statusMessa     55 char const *xDataTOM_axes_getUnit( statusMessageReporting *smr, xDataTOM_axes *axes, int index ) {
 56                                                    56 
 57     if( ( index < 0 ) || ( index >= axes->numb     57     if( ( index < 0 ) || ( index >= axes->numberOfAxes ) ) {
 58         smr_setReportError2( smr, xDataTOM_smr     58         smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid axes index = %d", index );
 59         return( NULL );                            59         return( NULL );
 60     }                                              60     }
 61     return( axes->axis[index].unit );              61     return( axes->axis[index].unit );
 62 }                                                  62 }
 63 /*                                                 63 /*
 64 **********************************************     64 ************************************************************
 65 */                                                 65 */
 66 int xDataTOM_axes_getInterpolation( statusMess     66 int xDataTOM_axes_getInterpolation( statusMessageReporting *smr, xDataTOM_axes *axes, int index, enum xDataTOM_interpolationFlag *independent, 
 67         enum xDataTOM_interpolationFlag *depen     67         enum xDataTOM_interpolationFlag *dependent, enum xDataTOM_interpolationQualifier *qualifier ) {
 68                                                    68 
 69     xDataTOM_interpolation *interpolation;         69     xDataTOM_interpolation *interpolation;
 70                                                    70 
 71     if( ( index < 0 ) || ( index >= axes->numb     71     if( ( index < 0 ) || ( index >= axes->numberOfAxes ) ) {
 72         smr_setReportError2( smr, xDataTOM_smr     72         smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid axes index = %d", index );
 73         return( 1 );                               73         return( 1 );
 74     }                                              74     }
 75     interpolation = &(axes->axis[index].interp     75     interpolation = &(axes->axis[index].interpolation);
 76     *independent = interpolation->independent;     76     *independent = interpolation->independent;
 77     *dependent = interpolation->dependent;         77     *dependent = interpolation->dependent;
 78     *qualifier = interpolation->qualifier;         78     *qualifier = interpolation->qualifier;
 79                                                    79 
 80     return( 0 );                                   80     return( 0 );
 81 }                                                  81 }
 82                                                    82 
 83 /*                                                 83 /*
 84 c   subAxes functions.                             84 c   subAxes functions.
 85 */                                                 85 */
 86 /*                                                 86 /*
 87 **********************************************     87 ************************************************************
 88 */                                                 88 */
 89 int xDataTOM_subAxes_initialize( statusMessage     89 int xDataTOM_subAxes_initialize( statusMessageReporting *smr, xDataTOM_subAxes *subAxes, enum xDataTOM_subAxesType type, int offset, 
 90         xDataTOM_axes *axes, xDataTOM_interpol     90         xDataTOM_axes *axes, xDataTOM_interpolation *interpolation ) {
 91                                                    91 
 92     subAxes->type = type;                          92     subAxes->type = type;
 93     if( axes == NULL ) {                           93     if( axes == NULL ) {
 94         smr_setReportError2p( smr, xDataTOM_sm     94         smr_setReportError2p( smr, xDataTOM_smrLibraryID, -1, "Axes must not be NULL" );
 95         return( 1 );                               95         return( 1 );
 96     }                                              96     }
 97     subAxes->offset = offset;                      97     subAxes->offset = offset;
 98     if( ( offset < 0 ) || ( offset >= axes->nu     98     if( ( offset < 0 ) || ( offset >= axes->numberOfAxes ) ) {
 99         smr_setReportError2( smr, xDataTOM_smr     99         smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "offset = %d < 0 or >= axes->numberOfAxes = %d", offset, axes->numberOfAxes );
100         return( 1 );                              100         return( 1 );
101     }                                             101     }
102     if( type == xDataTOM_subAxesType_intepolat    102     if( type == xDataTOM_subAxesType_intepolationAxes ) {
103         if( interpolation == NULL ) {             103         if( interpolation == NULL ) {
104             smr_setReportError2p( smr, xDataTO    104             smr_setReportError2p( smr, xDataTOM_smrLibraryID, -1, "Interpolation must not be NULL for intepolationAxes" );
105             return( 1 );                          105             return( 1 );
106         }                                         106         }
107         if( xDataTOM_interpolation_copy( smr,     107         if( xDataTOM_interpolation_copy( smr, &(subAxes->interpolation), interpolation ) ) return( 1 ); }
108     else {      /* Not used but fill in anyway    108     else {      /* Not used but fill in anyway. */
109         xDataTOM_interpolation_set( smr, &(sub    109         xDataTOM_interpolation_set( smr, &(subAxes->interpolation), xDataTOM_interpolationFlag_linear, xDataTOM_interpolationFlag_linear,
110             xDataTOM_interpolationQualifier_no    110             xDataTOM_interpolationQualifier_none );
111     }                                             111     }
112     subAxes->axes = axes;                         112     subAxes->axes = axes;
113     return( 0 );                                  113     return( 0 );
114 }                                                 114 }
115 /*                                                115 /*
116 **********************************************    116 ************************************************************
117 */                                                117 */
118 int xDataTOM_subAxes_release( xDataTOM_subAxes    118 int xDataTOM_subAxes_release( xDataTOM_subAxes *subAxes ) {
119                                                   119 
120     subAxes->axes = NULL;                         120     subAxes->axes = NULL;
121     return( 0 );                                  121     return( 0 );
122 }                                                 122 }
123 /*                                                123 /*
124 **********************************************    124 ************************************************************
125 */                                                125 */
126 char const *xDataTOM_subAxes_getLabel( statusM    126 char const *xDataTOM_subAxes_getLabel( statusMessageReporting *smr, xDataTOM_subAxes *subAxes, int index ) {
127                                                   127 
128     return( xDataTOM_axes_getLabel( smr, subAx    128     return( xDataTOM_axes_getLabel( smr, subAxes->axes, index + subAxes->offset ) );
129 }                                                 129 }
130 /*                                                130 /*
131 **********************************************    131 ************************************************************
132 */                                                132 */
133 char const *xDataTOM_subAxes_getUnit( statusMe    133 char const *xDataTOM_subAxes_getUnit( statusMessageReporting *smr, xDataTOM_subAxes *subAxes, int index ) {
134                                                   134 
135     return( xDataTOM_axes_getUnit( smr, subAxe    135     return( xDataTOM_axes_getUnit( smr, subAxes->axes, index + subAxes->offset ) );
136 }                                                 136 }
137                                                   137 
138 /*                                                138 /*
139 c   Axis functions.                               139 c   Axis functions.
140 */                                                140 */
141 /*                                                141 /*
142 **********************************************    142 ************************************************************
143 */                                                143 */
144 xDataTOM_axis *xDataTOM_axis_new( statusMessag    144 xDataTOM_axis *xDataTOM_axis_new( statusMessageReporting *smr, int index, char const *label, char const *unit, xDataTOM_interpolation *interpolation ) {
145                                                   145 
146     xDataTOM_axis *axis = NULL;                   146     xDataTOM_axis *axis = NULL;
147                                                   147 
148     if( ( axis = (xDataTOM_axis *) smr_malloc2    148     if( ( axis = (xDataTOM_axis *) smr_malloc2( smr, sizeof( xDataTOM_axis ), 0, "axis" ) ) == NULL ) return( NULL );
149     if( xDataTOM_axis_initialize( smr, axis, i    149     if( xDataTOM_axis_initialize( smr, axis, index, label, unit, interpolation ) != 0 ) smr_freeMemory( (void **) &axis );
150     return( axis );                               150     return( axis );
151 }                                                 151 }
152 /*                                                152 /*
153 **********************************************    153 ************************************************************
154 */                                                154 */
155 int xDataTOM_axis_initialize( statusMessageRep    155 int xDataTOM_axis_initialize( statusMessageReporting *smr, xDataTOM_axis *axis, int index, char const *label, char const *unit, xDataTOM_interpolation *interpolation ) {
156                                                   156 
157     axis->index = index;                          157     axis->index = index;
158     if( ( axis->label = smr_allocateCopyString    158     if( ( axis->label = smr_allocateCopyString2( smr, label, "label" ) ) == NULL ) goto err;
159     if( ( axis->unit = smr_allocateCopyString2    159     if( ( axis->unit = smr_allocateCopyString2( smr, unit, "unit" ) ) == NULL ) goto err;
160     if( xDataTOM_interpolation_copy( smr, &(ax    160     if( xDataTOM_interpolation_copy( smr, &(axis->interpolation), interpolation ) != 0 ) goto err;
161                                                   161 
162     return( 0 );                                  162     return( 0 );
163                                                   163 
164 err:                                              164 err:
165     smr_freeMemory( (void **) &(axis->label) )    165     smr_freeMemory( (void **) &(axis->label) );
166     smr_freeMemory( (void **) &(axis->unit) );    166     smr_freeMemory( (void **) &(axis->unit) );
167     return( 1 );                                  167     return( 1 );
168 }                                                 168 }
169 /*                                                169 /*
170 **********************************************    170 ************************************************************
171 */                                                171 */
172 xDataTOM_axis *xDataTOM_axis_release( statusMe    172 xDataTOM_axis *xDataTOM_axis_release( statusMessageReporting * /*smr*/, xDataTOM_axis *axis ) {
173                                                   173 
174     axis->index = -1;                             174     axis->index = -1;
175     smr_freeMemory( (void **) &(axis->label) )    175     smr_freeMemory( (void **) &(axis->label) );
176     smr_freeMemory( (void **) &(axis->unit) );    176     smr_freeMemory( (void **) &(axis->unit) );
177     return( NULL );                               177     return( NULL );
178 }                                                 178 }
179 /*                                                179 /*
180 **********************************************    180 ************************************************************
181 */                                                181 */
182 enum xDataTOM_frame xDataTOM_axis_stringToFram    182 enum xDataTOM_frame xDataTOM_axis_stringToFrame( statusMessageReporting * /*smr*/, char const *frame ) {
183                                                   183 
184     if( strcmp( "lab", frame ) == 0 ) return(     184     if( strcmp( "lab", frame ) == 0 ) return( xDataTOM_frame_lab );
185     if( strcmp( "centerOfMass", frame ) == 0 )    185     if( strcmp( "centerOfMass", frame ) == 0 ) return( xDataTOM_frame_centerOfMass );
186     return( xDataTOM_frame_invalid );             186     return( xDataTOM_frame_invalid );
187 }                                                 187 }
188 /*                                                188 /*
189 **********************************************    189 ************************************************************
190 */                                                190 */
191 char const *xDataTOM_axis_frameToString( statu    191 char const *xDataTOM_axis_frameToString( statusMessageReporting * /*smr*/, enum xDataTOM_frame frame ) {
192                                                   192 
193     switch( frame ) {                             193     switch( frame ) {
194     case xDataTOM_frame_lab : return( xDataTOM    194     case xDataTOM_frame_lab : return( xDataTOM_frame_labString );
195     case xDataTOM_frame_centerOfMass : return(    195     case xDataTOM_frame_centerOfMass : return( xDataTOM_frame_centerOfMassString );
196     default :                                     196     default :
197         break;                                    197         break;
198     }                                             198     }
199     return( xDataTOM_frame_invalidString );       199     return( xDataTOM_frame_invalidString );
200 }                                                 200 }
201                                                   201 
202 #if defined __cplusplus                           202 #if defined __cplusplus
203 }                                                 203 }
204 #endif                                            204 #endif
205                                                   205