Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:39

0001 #pragma once
0002 /**
0003 smatsur.h : "ems" : enumeration of Material and Surface types   
0004 ===============================================================
0005 
0006 **/
0007 
0008 enum {
0009     smatsur_Material                       = 0, 
0010     smatsur_NoSurface                      = 1,
0011     smatsur_Surface                        = 2,
0012     smatsur_Surface_zplus_sensor_A         = 3,
0013     smatsur_Surface_zplus_sensor_CustomART = 4,
0014     smatsur_Surface_zminus                 = 5
0015  
0016 };
0017  
0018 #if defined(__CUDACC__) || defined(__CUDABE__)
0019 #else
0020 #include <cstring>
0021 #include <cassert>
0022 #include <string>
0023 #include <sstream>
0024 #include <iomanip>
0025 #include <csignal>
0026 
0027 struct smatsur
0028 {
0029     static constexpr const char* Material                        = "Material" ; 
0030     static constexpr const char* NoSurface                       = "NoSurface" ; 
0031     static constexpr const char* Surface                         = "Surface" ; 
0032     static constexpr const char* Surface_zplus_sensor_A          = "Surface_zplus_sensor_A" ; 
0033     static constexpr const char* Surface_zplus_sensor_CustomART  = "Surface_zplus_sensor_CustomART" ; 
0034     static constexpr const char* Surface_zminus                  = "Surface_zminus" ; 
0035 
0036     static int TypeFromChar(char OpticalSurfaceName0); 
0037     static std::string Desc(); 
0038     static int Type(const char* name); 
0039     static const char* Name(int type); 
0040 };
0041 
0042 
0043 inline int smatsur::TypeFromChar(char OpticalSurfaceName0)
0044 {
0045     int type = -1  ;
0046     switch(OpticalSurfaceName0)
0047     {
0048         case '\0': type = smatsur_Material                       ; break ;  
0049         case '-':  type = smatsur_NoSurface                      ; break ;  
0050         case '@':  type = smatsur_Surface_zplus_sensor_CustomART ; break ; 
0051         case '#':  type = smatsur_Surface_zplus_sensor_A         ; break ; 
0052         case '!':  type = smatsur_Surface_zminus                 ; break ; 
0053         default:   type = smatsur_Surface                        ; break ; 
0054     }
0055     return type ; 
0056 }
0057 
0058 inline std::string smatsur::Desc() 
0059 {
0060     const int N = 6 ; 
0061     char cc[N] = { '\0', '-', 'X', '#', '@', '!' } ; 
0062     std::stringstream ss ; 
0063     ss << "smatsur::Desc" << std::endl ; 
0064     for(int i=0 ; i < N ; i++)
0065     {
0066        char c = cc[i] ;  
0067        int type = TypeFromChar(c) ; 
0068        const char* name = Name(type) ;  
0069        int type2 = Type(name) ; 
0070        bool type_expect = type == type2 ;
0071        if(!type_expect) std::raise(SIGINT); 
0072        assert( type_expect ); 
0073        ss 
0074            << " c " << std::setw(3) << ( c == '\0' ? '0' : c ) 
0075            << " type " << std::setw(2) << type
0076            << " name " << name 
0077            << std::endl 
0078            ;
0079     }
0080     std::string str = ss.str(); 
0081     return str ; 
0082 }
0083 
0084 inline int smatsur::Type(const char* name)
0085 {
0086     int type = -1  ;
0087     if(strcmp(name,Material)==0)                       type = smatsur_Material ;
0088     if(strcmp(name,NoSurface)==0)                      type = smatsur_NoSurface ;
0089     if(strcmp(name,Surface)==0)                        type = smatsur_Surface ;
0090     if(strcmp(name,Surface_zplus_sensor_A)==0)         type = smatsur_Surface_zplus_sensor_A ;
0091     if(strcmp(name,Surface_zplus_sensor_CustomART)==0) type = smatsur_Surface_zplus_sensor_CustomART ;
0092     if(strcmp(name,Surface_zminus)==0)                 type = smatsur_Surface_zminus ;
0093     return type ; 
0094 }
0095 
0096 inline const char* smatsur::Name(int type)
0097 {
0098     const char* n = nullptr ;
0099     switch(type)
0100     {
0101         case smatsur_Material:                        n = Material                       ; break ;
0102         case smatsur_NoSurface:                       n = NoSurface                      ; break ;
0103         case smatsur_Surface:                         n = Surface                        ; break ;
0104         case smatsur_Surface_zplus_sensor_A:          n = Surface_zplus_sensor_A         ; break ;
0105         case smatsur_Surface_zplus_sensor_CustomART:  n = Surface_zplus_sensor_CustomART ; break ;
0106         case smatsur_Surface_zminus:                  n = Surface_zminus                 ; break ;
0107     }
0108     return n ; 
0109 }
0110 
0111 #endif
0112