Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 /**
0003 SRM.h : Running Mode
0004 =====================
0005 
0006 HMM: if needed to combine these modes would need to split or 
0007 change this to using bitmasks 
0008 
0009 **/
0010 
0011 
0012 enum { SRM_UNKNOWN=-1, 
0013        SRM_DEFAULT, 
0014        SRM_G4STATE_SAVE, 
0015        SRM_G4STATE_RERUN, 
0016        SRM_TORCH, 
0017        SRM_INPUT_PHOTON, 
0018        SRM_INPUT_GENSTEP, 
0019        SRM_GUN } ;  
0020 
0021 #include <cstdint>
0022 #include <cstring>
0023 
0024 struct SRM
0025 {
0026     static const char* Name(int32_t mode);
0027     static int32_t     Type(const char* name);
0028 
0029     static constexpr const char* DEFAULT_ = "SRM_DEFAULT" ;
0030     static constexpr const char* G4STATE_SAVE_ = "SRM_G4STATE_SAVE" ;
0031     static constexpr const char* G4STATE_RERUN_ = "SRM_G4STATE_RERUN" ;
0032 
0033     static constexpr const char* TORCH_ = "SRM_TORCH" ;
0034     static constexpr const char* INPUT_PHOTON_ = "SRM_INPUT_PHOTON" ;
0035     static constexpr const char* INPUT_GENSTEP_ = "SRM_INPUT_GENSTEP" ;
0036     static constexpr const char* GUN_ = "SRM_GUN" ;
0037 };
0038 inline const char* SRM::Name(int32_t mode)
0039 {
0040     const char* s = nullptr ;
0041     switch(mode)
0042     {
0043         case SRM_DEFAULT:       s = DEFAULT_       ; break ;
0044         case SRM_G4STATE_SAVE:  s = G4STATE_SAVE_  ; break ;
0045         case SRM_G4STATE_RERUN: s = G4STATE_RERUN_ ; break ;
0046         case SRM_TORCH        : s = TORCH_         ; break ;
0047         case SRM_INPUT_PHOTON:  s = INPUT_PHOTON_  ; break ;
0048         case SRM_INPUT_GENSTEP: s = INPUT_GENSTEP_ ; break ;
0049         case SRM_GUN          : s = GUN_           ; break ;
0050     }
0051     return s ; 
0052 }
0053 inline int32_t SRM::Type(const char* name)
0054 {
0055     int32_t type = SRM_UNKNOWN ;
0056     if(strcmp(name,DEFAULT_) == 0 )       type = SRM_DEFAULT      ;
0057     if(strcmp(name,G4STATE_SAVE_) == 0 )  type = SRM_G4STATE_SAVE ;
0058     if(strcmp(name,G4STATE_RERUN_) == 0 ) type = SRM_G4STATE_RERUN ;
0059     if(strcmp(name,TORCH_) == 0 )         type = SRM_TORCH ;
0060     if(strcmp(name,INPUT_PHOTON_) == 0 )  type = SRM_INPUT_PHOTON ;
0061     if(strcmp(name,INPUT_GENSTEP_) == 0 ) type = SRM_INPUT_GENSTEP ;
0062     if(strcmp(name,GUN_) == 0 )           type = SRM_GUN ;
0063 
0064     assert( type != SRM_UNKNOWN ); 
0065     return type ;
0066 }
0067