|
CORSIKA8
0.0.0
The framework to simulate particle cascades for astroparticle physics
|
The StackIteratorInterface is the main interface to iterator over particles on a stack. More...
#include <StackIteratorInterface.hpp>

Public Types | |
| typedef TParticleInterface< corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType > > | particle_interface_type |
| typedef TStackType | stack_type |
| typedef TStackData | stack_data_type |
Public Member Functions | |
| StackIteratorInterface (StackIteratorInterface &&rhs) | |
| StackIteratorInterface (StackIteratorInterface const &vR) | |
| StackIteratorInterface & | operator= (StackIteratorInterface const &vR) |
| StackIteratorInterface (stack_type &data, unsigned int const index) | |
| iterator must always point to data, with an index: More... | |
| template<typename... TArgs> | |
| StackIteratorInterface (stack_type &data, unsigned int const index, const TArgs... args) | |
| constructor that also sets new values on particle data object More... | |
| template<typename... TArgs> | |
| StackIteratorInterface (stack_type &data, unsigned int const index, StackIteratorInterface &parent, const TArgs... args) | |
| constructor that also sets new values on particle data object, including reference to parent particle More... | |
| bool | isErased () const |
Iterator interface | |
| StackIteratorInterface & | operator++ () |
| StackIteratorInterface | operator++ (int) |
| StackIteratorInterface | operator+ (int delta) const |
| bool | operator== (StackIteratorInterface const &rhs) const |
| bool | operator!= (StackIteratorInterface const &rhs) const |
| bool | operator== (const ConstStackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, stack_type > &rhs) const |
| bool | operator!= (const ConstStackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, stack_type > &rhs) const |
| particle_interface_type & | operator* () |
| Convert iterator to value type, where value type is the user-provided particle readout class. | |
| particle_interface_type const & | operator* () const |
| Convert iterator to const value type, where value type is the user-provided particle readout class. | |
Protected Member Functions | |
Stack data access | |
| unsigned int | getIndex () const |
| Get current particle index. | |
| stack_type & | getStack () |
| Get current particle Stack object. | |
| stack_type const & | getStack () const |
| Get current particle const Stack object. | |
| TStackData & | getStackData () |
| Get current user particle TStackData object. | |
| TStackData const & | getStackData () const |
| Get current const user particle TStackData object. | |
| unsigned int | getIndexFromIterator () const |
| Get data index as mapped in Stack class. | |
Protected Attributes | |
| unsigned int | index_ = 0 |
The StackIteratorInterface is the main interface to iterator over particles on a stack.
At the same time StackIteratorInterface is a Particle object by itself, thus there is no difference between type and ref_type for convenience of the physicist.
This allows to write code like
for (auto& p : theStack) { p.SetEnergy(newEnergy); }
The template argument Stack determines the type of Stack object the data is stored in. A pointer to the Stack object is part of the StackIteratorInterface. In addition to Stack the iterator only knows the index index_ in the Stack data.
The template argument TParticleInterface acts as a policy to provide readout function of Particle data from the stack. The TParticleInterface class must know how to retrieve information from the Stack data for a particle entry at any index index_.
The TParticleInterface class must be written and provided by the user, it contains methods like auto getData() const { return getStackData().getData(getIndex()); }, where StackIteratorInterface::getStackData() return a reference to the object storing the particle data of type TStackData. And StackIteratorInterface::getIndex() provides the iterator index to be readout. The TStackData is another user-provided class to store data and must implement functions compatible with TParticleInterface, in this example TStackData::getData(const unsigned int vIndex).
For two examples see stack_example.cc, or the corsikaes::sibyll::SibStack class
Definition at line 77 of file StackIteratorInterface.hpp.
|
inline |
Definition at line 92 of file StackIteratorInterface.hpp.
|
inline |
iterator must always point to data, with an index:
| data | reference to the stack [rw] |
| index | index on stack |
Definition at line 112 of file StackIteratorInterface.hpp.
|
inline |
constructor that also sets new values on particle data object
| data | reference to the stack [rw] |
| index | index on stack |
| args | variadic list of data to initialize stack entry, this must be consistent with the definition of the user-provided particle_interface_type::setParticleData(...) function |
Definition at line 124 of file StackIteratorInterface.hpp.
|
inline |
constructor that also sets new values on particle data object, including reference to parent particle
| data | reference to the stack [rw] |
| index | index on stack |
| reference | to parent particle [rw]. This can be used for thinning, particle counting, history, etc. |
| args | variadic list of data to initialize stack entry, this must be consistent with the definition of the user-provided particle_interface_type::setParticleData(...) function |
Definition at line 143 of file StackIteratorInterface.hpp.