File indexing completed on 2026-04-09 07:49:43
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 #include <cstdint>
0048 #include <vector>
0049 #include <string>
0050 #include "G4ThreeVector.hh"
0051 #include "NP.hh"
0052
0053 template<char N>
0054 struct SPhoton_Debug
0055 {
0056 static std::vector<SPhoton_Debug> record ;
0057 static constexpr const char* NAME = "SPhoton_Debug.npy" ;
0058 static constexpr const unsigned NUM_QUAD = 5u ;
0059
0060 static int Count();
0061 static std::string Name();
0062 static void Save(const char* dir);
0063 void add();
0064 void fill(double value);
0065
0066 G4ThreeVector pos ;
0067 G4double time ;
0068
0069 G4ThreeVector mom ;
0070 uint64_t iindex ;
0071
0072 G4ThreeVector pol ;
0073 G4double wavelength ;
0074
0075 G4ThreeVector nrm ;
0076 G4double spare ;
0077
0078 G4double u0 ;
0079 G4double x1 ;
0080 G4double x2 ;
0081 uint64_t u0_idx ;
0082
0083 };
0084
0085 template<char N>
0086 inline std::string SPhoton_Debug<N>::Name()
0087 {
0088 std::string name ;
0089 name += N ;
0090 name += '_' ;
0091 name += NAME ;
0092 return name ;
0093 }
0094
0095 template<char N>
0096 inline void SPhoton_Debug<N>::Save(const char* dir)
0097 {
0098 std::string name = Name();
0099 std::cout
0100 << "SPhoton_Debug::Save"
0101 << " dir " << dir
0102 << " name " << name
0103 << " num_record " << record.size()
0104 << std::endl
0105 ;
0106
0107 if( record.size() > 0) NP::Write<double>(dir, name.c_str(), (double*)record.data(), record.size(), NUM_QUAD, 4 );
0108 record.clear();
0109 }
0110
0111 template<char N>
0112 inline int SPhoton_Debug<N>::Count()
0113 {
0114 return record.size() ;
0115 }
0116
0117 template<char N>
0118 inline void SPhoton_Debug<N>::fill(double value)
0119 {
0120 for(unsigned i=0 ; i < 4*NUM_QUAD ; i++) *((double*)&pos + i) = value ;
0121 }
0122
0123 template<char N>
0124 inline void SPhoton_Debug<N>::add()
0125 {
0126 record.push_back(*this);
0127 }
0128
0129