-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC4GS.h
More file actions
87 lines (68 loc) · 2.03 KB
/
C4GS.h
File metadata and controls
87 lines (68 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
/**
C4GS.h : Genstep Label : Equivalent to sysrap/sgs.h
------------------------------------------------------
**/
#if defined(__CUDACC__) || defined(__CUDABE__)
# define C4GS_METHOD __host__ __device__ __forceinline__
#else
# define C4GS_METHOD inline
#endif
#if defined(__CUDACC__) || defined(__CUDABE__)
#else
#include <string>
#include "C4Pho.h"
#endif
struct C4GS
{
int index ; // 0-based index of genstep in the event
int photons ; // number of photons in the genstep
int offset ; // photon offset in the sequence of gensteps, ie number of photons in event before this genstep
int gentype ; // OpticksGenstep_ enum
#if defined(__CUDACC__) || defined(__CUDABE__)
#else
static C4GS Make(int _index, int _photons, int _offset, int _gentype);
C4Pho MakePho(unsigned idx, const C4Pho& ancestor);
std::string desc() const ;
#endif
};
#if defined(__CUDACC__) || defined(__CUDABE__)
#else
#include <sstream>
#include <iomanip>
/**
C4GS::Make
-----------
**/
inline C4GS C4GS::Make( int _index, int _photons, int _offset, int _gentype ) // static
{
C4GS gs = { _index, _photons, _offset, _gentype } ;
return gs ;
}
/**
C4GS::MakePho
-------------
ancestor.isDefined:false
the more common case, when generating primary optical
photons via the Cerenkov or Scintillation processes
HMM: "ancestor" should more correctly be called "reemissionAncestorPhoton"
ancestor.isDefined:true
when a photon undergoes reemission the ancestor is the parent photon
**/
inline C4Pho C4GS::MakePho(unsigned idx, const C4Pho& ancestor)
{
return ancestor.isDefined() ? ancestor.make_nextgen() : C4Pho::MakePho(index, idx, offset + idx ) ;
}
inline std::string C4GS::desc() const
{
std::stringstream ss ;
ss << "C4GS:"
<< " idx" << std::setw(4) << index
<< " pho" << std::setw(6) << photons
<< " off " << std::setw(6) << offset
<< " typ " << std::setw(4) << gentype
;
std::string s = ss.str();
return s ;
}
#endif