Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:49:40

0001 #pragma once
0002 
0003 /**
0004 qmultifilm.h
0005 ==============
0006 
0007 **/
0008 
0009 
0010 #if defined(__CUDACC__) || defined(__CUDABE__)
0011    #define QMULTIFILM_METHOD __device__
0012 #else
0013    #define QMULTIFILM_METHOD 
0014 #endif 
0015 
0016 struct qmultifilm
0017 {
0018     cudaTextureObject_t nnvt_normal_tex[2];
0019     cudaTextureObject_t nnvt_highqe_tex[2];
0020     cudaTextureObject_t hama_tex[2];
0021     
0022     quad4*              nnvt_normal_meta[2];
0023     quad4*              nnvt_highqe_meta[2];
0024     quad4*              hama_meta[2];
0025  
0026 
0027 #if defined(__CUDACC__) || defined(__CUDABE__)
0028     QMULTIFILM_METHOD float4 lookup(unsigned pmtType, float nm, float aoi);  
0029 #else
0030     qmultifilm(){}
0031 #endif
0032 
0033 }; 
0034 
0035 
0036 #if defined(__CUDACC__) || defined(__CUDABE__)
0037 
0038 /**
0039 qmultifilm::lookup
0040 -----------------------
0041 
0042 x --> width  --> nj --> aoi
0043 y --> height --> ni --> wavelength 
0044 
0045 **/
0046 
0047 inline QMULTIFILM_METHOD float4 qmultifilm::lookup(unsigned pmtType, float nm, float aoi)
0048 {
0049     const unsigned& nx = hama_meta[0]->q0.u.x  ; // aoi
0050     const unsigned& ny = hama_meta[0]->q0.u.y  ; // wavelength
0051     
0052     unsigned half_nx = nx/2; 
0053  
0054     float wv_low  = hama_meta[0]->q2.f.x;
0055     float wv_high = hama_meta[0]->q2.f.y;
0056     float wv_step = (wv_high - wv_low)/(ny-1);   
0057 
0058     float aoi_low = hama_meta[0]->q1.f.x;
0059     //float aoi_high= hama_meta[0]->q1.f.y;
0060     
0061     //float aoi_step= (aoi_high-aoi_low)/(nx-1);   
0062     
0063     float aoi_sublow = hama_meta[0]->q1.f.z;
0064     float aoi_subhigh = hama_meta[0]->q1.f.w;
0065     float aoi_substep = (aoi_subhigh-aoi_sublow)/(nx-1);
0066    
0067     int resolution = ( aoi > aoi_sublow && aoi < aoi_subhigh )? 1 : 0 ;
0068     int tex_index = resolution ;
0069    
0070     cudaTextureObject_t tex = 0 ;
0071     switch(pmtType)
0072     {
0073         case 0: tex = nnvt_normal_tex[tex_index] ; break;
0074         case 1: tex = hama_tex[tex_index]        ; break;
0075         case 2: tex = nnvt_highqe_tex[tex_index] ; break;
0076     }
0077 
0078     float minus_epsilon = -1e-6f;
0079     float plus_epsilon  = 1e-6f;
0080 
0081     float x = 0.f;
0082     float y = 0.f;
0083     
0084     float aoi_halfstep = (minus_epsilon - aoi_low)/(half_nx - 1);
0085     if(resolution == 1){
0086         x = ((aoi - aoi_sublow)/aoi_substep+0.5f)/float(nx);
0087     }else{
0088 
0089         if(aoi < minus_epsilon){
0090             x = ((aoi - aoi_low)/aoi_halfstep + 0.5f)/float(nx);
0091         }
0092         if(aoi > plus_epsilon){
0093             x = (half_nx + (aoi-plus_epsilon)/aoi_halfstep + 0.5f)/float(nx);
0094         }
0095         if(aoi >= minus_epsilon and aoi <= plus_epsilon){
0096             x = (half_nx + (aoi - minus_epsilon)/(2*plus_epsilon) + 0.5f)/float(nx);
0097         }
0098 
0099     }
0100     
0101     //float x = resolution == 1 ? ((aoi - aoi_sublow)/aoi_substep +0.5f)/float(nx) : ((aoi - aoi_low)/aoi_step +0.5f)/float(nx) ;
0102     y = ((nm - wv_low)/wv_step + 0.5f)/float(ny);
0103 
0104     float4 value = tex2D<float4>(tex,x,y);
0105 
0106     return value;
0107 }
0108 
0109 #endif
0110