Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 /**
0003 sgs.h : Aiming to replace cfg4/CGenstep
0004 -----------------------------------------
0005 **/
0006 
0007 
0008 #if defined(__CUDACC__) || defined(__CUDABE__)
0009 #    define SGS_METHOD __host__ __device__ __forceinline__
0010 #else
0011 #    define SGS_METHOD inline
0012 #endif
0013 
0014 #if defined(__CUDACC__) || defined(__CUDABE__)
0015 #else
0016      #include <string>
0017      #include "spho.h"
0018 #endif
0019 
0020 
0021 struct sgs
0022 {
0023     int64_t index ;     // 0-based index of genstep in the event
0024     int64_t photons ;   // number of photons in the genstep
0025     int64_t offset ;    // photon offset in the sequence of gensteps, ie number of photons in event before this genstep
0026     int64_t gentype  ;  // OpticksGenstep_ enum
0027     // HMM: only offset needs to be int64
0028 
0029 #if defined(__CUDACC__) || defined(__CUDABE__)
0030 #else
0031     spho MakePho(unsigned idx, const spho& ancestor);
0032     std::string desc() const ;
0033 #endif
0034 };
0035 
0036 #if defined(__CUDACC__) || defined(__CUDABE__)
0037 #else
0038 #include <sstream>
0039 #include <iomanip>
0040 #include "OpticksGenstep.h"
0041 
0042 /**
0043 sgs::MakePho
0044 -------------
0045 
0046 ancestor.isDefined:false
0047     the more common case, when generating primary optical
0048     photons via the Cerenkov or Scintillation processes
0049 
0050     HMM: "ancestor" should more correctly be called "reemissionAncestorPhoton"
0051 
0052 ancestor.isDefined:true
0053     when a photon undergoes reemission the ancestor is the parent photon
0054 
0055 **/
0056 
0057 inline spho sgs::MakePho(unsigned idx, const spho& ancestor)
0058 {
0059     return ancestor.isDefined() ? ancestor.make_nextgen() : spho::MakePho(index, idx, offset + idx ) ;
0060 }
0061 
0062 inline std::string sgs::desc() const
0063 {
0064     std::stringstream ss ;
0065     ss << "sgs:"
0066        << " idx" << std::setw(4) << index
0067        << " pho" << std::setw(6) << photons
0068        << " off " << std::setw(6) << offset
0069        << " typ " << OpticksGenstep_::Name(gentype)
0070        ;
0071     std::string s = ss.str();
0072     return s ;
0073 }
0074 #endif
0075