openPMD_raytrace_API  0.1.0
Public Member Functions | List of all members
raytracing::openPMD_io Class Reference

I/O API for the ray trace extension of the openPMD format. More...

#include <openPMD_io.hh>

Public Member Functions

 openPMD_io (const std::string &filename, const std::string mc_code_name="", const std::string mc_code_version="", const std::string instrument_name="", const std::string name_current_component="")
 constructor More...
 
Writing mode
void init_write (std::string particle_species, unsigned long long int n_rays, unsigned int iter=1)
 initializes the "series" object from the openPMD API in WRITE MODE More...
 
void init_rays (std::string particle_species, unsigned long long int n_rays, unsigned int iter)
 declare the ray particle species in the file More...
 
void trace_write (Ray this_ray)
 save ray properties for further writing to file by save_write()
 
void save_write (void)
 Flushes the output to file before closing it. More...
 
Reading mode
unsigned long long int init_read (std::string pdgId, unsigned int iter=1, unsigned long long int n_rays=0, unsigned int repeat=1)
 initializes the "series" object from the openPMD API in READ MODE More...
 
Ray trace_read (void)
 Read rays from file and returns the next in the list. More...
 
void set_gravity_direction (float x, float y, float z)
 
void get_gravity_direction (float *x, float *y, float *z)
 
void get_horizontal_direction (float *x, float *y, float *z)
 
void set_horizontal_direction (float *x, float *y, float *z)
 

Detailed Description

I/O API for the ray trace extension of the openPMD format.

This API is a higher level API of the official openPMD API.
This is meant to be used to save/read a coherent set of rays to/from file.
Coherent in this case means that a single type of rays (particles) are going to used.

Examples:
test_write.cpp.

Definition at line 20 of file openPMD_io.hh.

Constructor & Destructor Documentation

◆ openPMD_io()

raytracing::openPMD_io::openPMD_io ( const std::string &  filename,
const std::string  mc_code_name = "",
const std::string  mc_code_version = "",
const std::string  instrument_name = "",
const std::string  name_current_component = "" 
)
explicit

constructor

At construction, no file is created. The init_write() or init_read() methods should be called to performed the desired operations.

Todo:
use particlePatches ... but I don't understand if/how
Parameters
filenamefilename
mc_code_name[optional] Name of the simulation code name
mc_code_version[optional] Simulation software version
instrument_name[optional] Name of the instrument
name_current_component[optional] current component name along the beamline

Definition at line 36 of file openPMD_io.cc.

Member Function Documentation

◆ init_write()

void raytracing::openPMD_io::init_write ( std::string  particle_species,
unsigned long long int  n_rays,
unsigned int  iter = 1 
)

initializes the "series" object from the openPMD API in WRITE MODE

It is extremely important to set the n_rays as the maximum number of rays to save in the file. If it is not known in advance, the user should guess it. The file size increases according to this value, so it should be kept the lowest possible.

This method calls init_rays() a first time.

Todo:
I don't how to add the directionOfGravity
Parameters
particle_speciesPDG ID of the particles
n_raysnumber of rays being simulated (max)
iteropenPMD iteration
Todo:
add gravity direction and horizontal direction
Examples:
test_write.cpp.

Definition at line 128 of file openPMD_io.cc.

◆ init_rays()

void raytracing::openPMD_io::init_rays ( std::string  particle_species,
unsigned long long int  n_rays,
unsigned int  iter 
)

declare the ray particle species in the file

This function must be called each time the particle species are changed and for each new iteration.

Definition at line 80 of file openPMD_io.cc.

◆ save_write()

void raytracing::openPMD_io::save_write ( void  )

Flushes the output to file before closing it.

Examples:
test_write.cpp.

Definition at line 182 of file openPMD_io.cc.

◆ init_read()

unsigned long long int raytracing::openPMD_io::init_read ( std::string  pdgId,
unsigned int  iter = 1,
unsigned long long int  n_rays = 0,
unsigned int  repeat = 1 
)

initializes the "series" object from the openPMD API in READ MODE

Todo:
the file access type was defined in the openPMD_io constructor
Todo:
check if the iteration exists
Todo:
make it more meaningful
Parameters
pdgIdPDG ID of the particle
iteropenPMD iteration
n_raysmax number of rays to read, 0=ALL
repeat[optional] Number of times a ray should be repeatedly retrieved

Definition at line 343 of file openPMD_io.cc.

◆ trace_read()

raytracing::Ray raytracing::openPMD_io::trace_read ( void  )

Read rays from file and returns the next in the list.

Returns
Ray object Loads the data from file in chunks. Each ray is returned as many times as requested at init_read() step.

Each time this method is called, the ray counter increments

Todo:
reordering if conditions can improve performance

Definition at line 408 of file openPMD_io.cc.


The documentation for this class was generated from the following files: