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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/MCGIDI_fromTOM.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/MCGIDI_fromTOM.cc (Version 9.2)


  1 /*                                                  1 
  2 # <<BEGIN-copyright>>                             
  3 # <<END-copyright>>                               
  4 */                                                
  5 #include <stdio.h>                                
  6 #include <stdlib.h>                               
  7 #include <string.h>                               
  8 #include <cmath>                                  
  9 /*                                                
 10 #include <unistd.h>                               
 11 #include <ctype.h>                                
 12 */                                                
 13                                                   
 14 #include "MCGIDI_fromTOM.h"                       
 15 #include "MCGIDI_misc.h"                          
 16                                                   
 17 #if defined __cplusplus                           
 18 namespace GIDI {                                  
 19 using namespace GIDI;                             
 20 #endif                                            
 21                                                   
 22 static int MCGIDI_fromTOM_pdfOfXGivenW( status    
 23 /*                                                
 24 **********************************************    
 25 */                                                
 26 int MCGIDI_fromTOM_pdfsOfXGivenW( statusMessag    
 27     char const *toUnits[3] ) {                    
 28                                                   
 29     int i;                                        
 30     double norm, wUnitFactor;                     
 31     char const *wFromUnit, *toUnitsXY[2] = { t    
 32     xDataTOM_XYs *XYs;                            
 33     xDataTOM_W_XYs *W_XYs;                        
 34     ptwXYPoints *pdfXY = NULL;                    
 35     ptwXY_interpolation interpolationXY, inter    
 36                                                   
 37     wFromUnit = xDataTOM_axes_getUnit( smr, &(    
 38     if( !smr_isOk( smr ) ) goto err;              
 39     wUnitFactor = MCGIDI_misc_getUnitConversio    
 40     if( !smr_isOk( smr ) ) goto err;              
 41                                                   
 42     if( MCGIDI_fromTOM_interpolation( smr, ele    
 43     if( MCGIDI_fromTOM_interpolation( smr, ele    
 44     dists->interpolationWY = interpolationWY;     
 45     dists->interpolationXY = interpolationXY;     
 46     if( norms != NULL ) {                         
 47         if( interpolationWY == ptwXY_interpola    
 48             smr_setReportError2p( smr, smr_unk    
 49             goto err;                             
 50         }                                         
 51     }                                             
 52                                                   
 53     W_XYs = (xDataTOM_W_XYs *) xDataTOME_getXD    
 54     if( ( dists->Ws = (double *) smr_malloc2(     
 55     if( ( dists->dist = (MCGIDI_pdfOfX *) smr_    
 56                                                   
 57     for( i = 0; i < W_XYs->length; i++ ) {        
 58         XYs = &(W_XYs->XYs[i]);                   
 59         dists->Ws[i] = wUnitFactor * XYs->valu    
 60         if( ( pdfXY =  MCGIDI_misc_dataFromXYs    
 61         if( MCGIDI_fromTOM_pdfOfXGivenW( smr,     
 62         if( norms != NULL ) {                     
 63             ptwXY_setValueAtX( norms, XYs->val    
 64         else if( std::fabs( 1. - norm ) > 0.99    
 65             smr_setReportError2( smr, smr_unkn    
 66             goto err;                             
 67         }                                         
 68         ptwXY_free( pdfXY );                      
 69         pdfXY = NULL;                             
 70     }                                             
 71                                                   
 72     return( 0 );                                  
 73                                                   
 74 err:                                              
 75     if( pdfXY != NULL ) ptwXY_free( pdfXY );      
 76     return( 1 );                                  
 77 }                                                 
 78 /*                                                
 79 **********************************************    
 80 */                                                
 81 static int MCGIDI_fromTOM_pdfOfXGivenW( status    
 82                                                   
 83     if( MCGIDI_fromTOM_pdfOfX( smr, pdfXY, &(d    
 84     dists->numberOfWs++;                          
 85     return( 0 );                                  
 86 }                                                 
 87 /*                                                
 88 **********************************************    
 89 */                                                
 90 int MCGIDI_fromTOM_pdfOfX( statusMessageReport    
 91                                                   
 92     int j1, n1 = (int) ptwXY_length( pdfXY );     
 93     nfu_status status;                            
 94     ptwXPoints *cdfX = NULL;                      
 95     ptwXYPoint *point;                            
 96                                                   
 97     dist->numberOfXs = 0;                         
 98     dist->Xs = NULL;                              
 99     if( ptwXY_simpleCoalescePoints( pdfXY ) !=    
100                                                   
101     if( ( dist->Xs = (double *) smr_malloc2( s    
102     dist->pdf = &(dist->Xs[n1]);                  
103     dist->cdf = &(dist->pdf[n1]);                 
104                                                   
105     for( j1 = 0; j1 < n1; j1++ ) {                
106             point = ptwXY_getPointAtIndex_Unsa    
107             dist->Xs[j1] = point->x;              
108             dist->pdf[j1] = point->y;             
109     }                                             
110                                                   
111     if( ( cdfX = ptwXY_runningIntegral( pdfXY,    
112             smr_setReportError2( smr, smr_unkn    
113             goto err;                             
114     }                                             
115     *norm = ptwX_getPointAtIndex_Unsafely( cdf    
116     if( *norm == 0. ) {             /* Should     
117         double inv_norm, sum = 0;                 
118                                                   
119         inv_norm = 1.0 / ( dist->Xs[n1-1] - di    
120         for( j1 = 0; j1 < n1; ++j1 ) {            
121             if( j1 > 0 ) sum += dist->Xs[j1] -    
122             dist->pdf[j1] = 1;                    
123             dist->cdf[j1] = sum * inv_norm;       
124         }                                         
125         dist->cdf[n1-1] = 1.; }                   
126     else {                                        
127         for( j1 = 0; j1 < n1; j1++ ) dist->cdf    
128         for( j1 = 0; j1 < n1; j1++ ) dist->pdf    
129     }                                             
130     ptwX_free( cdfX );                            
131                                                   
132     dist->numberOfXs = n1;                        
133     return( 0 );                                  
134                                                   
135 err:                                              
136     if( dist->Xs != NULL ) smr_freeMemory( (vo    
137     if( cdfX != NULL ) ptwX_free( cdfX );         
138     return( 1 );                                  
139 }                                                 
140 /*                                                
141 **********************************************    
142 */                                                
143 int MCGIDI_fromTOM_interpolation( statusMessag    
144                                                   
145     enum xDataTOM_interpolationFlag independen    
146     enum xDataTOM_interpolationQualifier quali    
147                                                   
148     if( xDataTOME_getInterpolation( smr, eleme    
149                                                   
150     *interpolation = ptwXY_interpolationOther;    
151                                                   
152     if( dependent == xDataTOM_interpolationFla    
153         *interpolation = ptwXY_interpolationFl    
154     else if( independent == xDataTOM_interpola    
155         if( dependent == xDataTOM_interpolatio    
156             *interpolation = ptwXY_interpolati    
157         else if( dependent == xDataTOM_interpo    
158             *interpolation = ptwXY_interpolati    
159         } }                                       
160     else if( independent == xDataTOM_interpola    
161         if( dependent == xDataTOM_interpolatio    
162             *interpolation = ptwXY_interpolati    
163         else if( dependent == xDataTOM_interpo    
164             *interpolation = ptwXY_interpolati    
165         }                                         
166     }                                             
167                                                   
168     return( 0 );                                  
169 }                                                 
170                                                   
171 #if defined __cplusplus                           
172 }                                                 
173 #endif                                            
174