|
| 1 | +#include <iostream> |
| 2 | +#include <string> |
| 3 | + |
| 4 | +#include "sysrap/NP.hh" |
| 5 | +#include "sysrap/SEvent.hh" |
| 6 | +#include "sysrap/sphoton.h" |
| 7 | +#include "sysrap/srng.h" |
| 8 | +#include "sysrap/storch.h" |
| 9 | +#include "sysrap/storchtype.h" |
| 10 | + |
| 11 | +#include <curand_kernel.h> |
| 12 | + |
| 13 | +using namespace std; |
| 14 | + |
| 15 | +int main(int argc, char **argv) |
| 16 | +{ |
| 17 | + unsigned n_photons = 100; |
| 18 | + |
| 19 | + // Initialize one torch object |
| 20 | + storch torch; |
| 21 | + |
| 22 | + // Assign values to all data members based on the FillGenstep function |
| 23 | + torch.gentype = OpticksGenstep_TORCH; |
| 24 | + torch.trackid = 0; |
| 25 | + torch.matline = 0; |
| 26 | + torch.numphoton = n_photons; |
| 27 | + |
| 28 | + // Assign default values for position, time, momentum, and other attributes |
| 29 | + torch.pos = {-10.0f, -30.0f, -90.0f}; |
| 30 | + torch.time = 0.0f; |
| 31 | + |
| 32 | + torch.mom = {0.0f, 0.3f, 1.0f}; |
| 33 | + torch.mom = normalize(torch.mom); |
| 34 | + torch.weight = 0.0f; |
| 35 | + |
| 36 | + torch.pol = {1.0f, 0.0f, 0.0f}; |
| 37 | + torch.wavelength = 420.0f; |
| 38 | + |
| 39 | + torch.zenith = {0.0f, 1.0f}; |
| 40 | + torch.azimuth = {0.0f, 1.0f}; |
| 41 | + |
| 42 | + torch.radius = 15.0f; |
| 43 | + torch.distance = 0.0f; |
| 44 | + torch.mode = 255; |
| 45 | + torch.type = T_DISC; |
| 46 | + |
| 47 | + cout << torch.desc() << endl; |
| 48 | + |
| 49 | + NP *photons = NP::Make<float>(n_photons, 4, 4); |
| 50 | + |
| 51 | + const quad6 &qtorch = *reinterpret_cast<quad6 *>(&torch); |
| 52 | + sphoton *qphotons = reinterpret_cast<sphoton *>(photons->bytes()); |
| 53 | + int unused = -1; |
| 54 | + |
| 55 | + curandStatePhilox4_32_10 rng; |
| 56 | + |
| 57 | + for (unsigned photon_id = 0; photon_id < n_photons; photon_id++) |
| 58 | + { |
| 59 | + storch::generate(qphotons[photon_id], rng, qtorch, unused, unused); |
| 60 | + } |
| 61 | + |
| 62 | + photons->set_meta({"my photon meta info 1", "additional meta info"}); |
| 63 | + photons->dump(); |
| 64 | + photons->save("out/photons.npy"); |
| 65 | + |
| 66 | + return EXIT_SUCCESS; |
| 67 | +} |
0 commit comments