|
CORSIKA
@c8_version@
The framework to simulate particle cascades for astroparticle physics
|
SecondaryView can only be constructed by giving a valid Projectile particle, following calls to addSecondary will populate the original Stack, but will be directly accessible via the SecondaryView, e.g.StackViewPr. More...
#include <SecondaryView.hpp>

Public Types | |
| typedef SecondaryView< TStackDataType, TParticleInterface, MSecondaryProducer > | view_type |
| typedef Stack< TStackDataType &, TParticleInterface, MSecondaryProducer > | inner_stack_reference_type |
| Helper type for inside this class. | |
| typedef StackIteratorInterface< typename std::remove_reference< TStackDataType >::type, TParticleInterface, MSecondaryProducer, view_type > | stack_view_iterator |
| typedef ConstStackIteratorInterface< typename std::remove_reference< TStackDataType >::type, TParticleInterface, MSecondaryProducer, view_type > | const_stack_view_iterator |
| using | ParticleType = stack_view_iterator |
| this is the full type of the declared TParticleInterface: | |
| using | ParticleInterfaceType = typename stack_view_iterator::particle_interface_type |
We need this "value" types with non-reference TStackData for | |
the constructor of the SecondaryView class | |
| typedef Stack< TStackDataType, TParticleInterface, MSecondaryProducer > | inner_stack_value_type |
| typedef StackIteratorInterface< typename std::remove_reference< TStackDataType >::type, TParticleInterface, MSecondaryProducer, inner_stack_value_type > | stack_value_iterator |
| typedef ConstStackIteratorInterface< typename std::remove_reference< TStackDataType >::type, TParticleInterface, MSecondaryProducer, inner_stack_value_type > | const_stack_value_iterator |
Public Types inherited from corsika::Stack< TStackDataType &, TParticleInterface, MSecondaryProducer > | |
| typedef TStackDataType & | stack_data_type |
| this is the type of the user-provided data structure | |
| typedef SecondaryView< TStackDataType &, TParticleInterface, MSecondaryProducer > | stack_view_type |
| using | pi_type = TParticleInterface< TStackIterator > |
| typedef StackIteratorInterface< value_type, TParticleInterface, MSecondaryProducer, Stack > | stack_iterator_type |
| Via the StackIteratorInterface and ConstStackIteratorInterface specialization, the type of the stack_iterator_type template class is declared for a particular stack data object. More... | |
| typedef ConstStackIteratorInterface< value_type, TParticleInterface, MSecondaryProducer, Stack > | const_stack_iterator_type |
| typedef stack_iterator_type::particle_interface_type | particle_interface_type |
| this is the full type of the user-declared MParticleInterface | |
| typedef stack_iterator_type | particle_type |
| In all programming context, the object to access, copy, and transport particle data is via the stack_iterator_type. | |
Public Member Functions | |
| template<typename... TArgs> | |
| SecondaryView (TArgs... args)=delete | |
| This is not accessible, since we don't want to allow creating a new stack. | |
| SecondaryView (stack_value_iterator &particle) | |
| SecondaryView can only be constructed passing it a valid stack_view_iterator to another Stack object (here: lvalue) | |
| inner_stack_ (particle.getStack()) | |
| projectile_index_ (particle.getIndex()) | |
| SecondaryView (stack_value_iterator &&particle) | |
| SecondaryView can only be constructed passing it a valid stack_view_iterator to another Stack object (here: rvalue) | |
| inner_stack_ (particle.getStack()) | |
| projectile_index_ (particle.getIndex()) | |
| SecondaryView (view_type &view, stack_view_iterator &projectile) | |
| Also allow to create a new View from a Projectile (stack_view_iterator on View) More... | |
| unsigned int | getSize () const |
| overwrite Stack::getSize to return actual number of secondaries | |
| unsigned int | getEntries () const |
| bool | isEmpty () const |
| void | swap (stack_view_iterator a, stack_view_iterator b) |
| void | copy (stack_view_iterator a, stack_view_iterator b) |
| void | copy (const_stack_view_iterator a, stack_view_iterator b) |
| void | erase (stack_view_iterator p) |
| need overwrite Stack::Delete, since we want to call SecondaryView::DeleteLast More... | |
| stack_view_iterator | getNextParticle () |
| return next particle from stack, need to overwrtie Stack::getNextParticle to get right reference | |
| bool | isErased (const stack_view_iterator &p) const |
| check if this particle was already deleted More... | |
| bool | isErased (const const_stack_view_iterator &p) const |
| bool | isErased (const ParticleInterfaceType &p) const |
| delete this particle | |
| bool | isDeleted (const const_stack_view_iterator &p) const |
| bool | purgeLastIfDeleted () |
| Function to ultimatively remove the last entry from the stack, if it was marked as deleted before. More... | |
| void | purge () |
| Function to ultimatively remove all entries from the stack marked as deleted. More... | |
| std::string | asString () const |
These are functions required by std containers and std loops | |
The Stack-versions must be overwritten, since here we need the correct SecondaryView::getSize | |
| stack_view_iterator | begin () |
| stack_view_iterator | end () |
| stack_view_iterator | last () |
| const_stack_view_iterator | begin () const |
| const_stack_view_iterator | end () const |
| const_stack_view_iterator | last () const |
| const_stack_view_iterator | cbegin () const |
| const_stack_view_iterator | cend () const |
| const_stack_view_iterator | clast () const |
| stack_view_iterator | at (unsigned int i) |
| const_stack_view_iterator | at (unsigned int i) const |
| stack_view_iterator | first () |
| const_stack_view_iterator | cfirst () const |
Public Member Functions inherited from corsika::Stack< TStackDataType &, TParticleInterface, MSecondaryProducer > | |
| Stack () | |
| create a new Stack, if there is already data associated prepare needed initialization. | |
| Stack (Stack &)=delete | |
| since Stack can be very big, we don't want to copy it | |
| Stack (TStackDataType & vD) | |
| if TStackData is a reference member we HAVE to initialize it in the constructor, this is typically needed for SecondaryView | |
| Stack (TArgs... args) | |
| This constructor takes any argument and passes it on to the TStackData user class. More... | |
| Stack & | operator= (Stack &)=delete |
| since Stack can be very big, we don't want to copy it | |
| unsigned int | getCapacity () const |
| unsigned int | getErased () const |
| unsigned int | getEntries () const |
| void | clear (TArgs... args) |
| stack_iterator_type | begin () |
| const_stack_iterator_type | begin () const |
| stack_iterator_type | end () |
| const_stack_iterator_type | end () const |
| stack_iterator_type | last () |
| const_stack_iterator_type | last () const |
| const_stack_iterator_type | cbegin () const |
| const_stack_iterator_type | cend () const |
| const_stack_iterator_type | clast () const |
| stack_iterator_type | at (unsigned int i) |
| const_stack_iterator_type | at (unsigned int i) const |
| stack_iterator_type | first () |
| const_stack_iterator_type | cfirst () const |
| stack_iterator_type | getNextParticle () |
| stack_iterator_type | addParticle (const TArgs... v) |
| increase stack size, create new particle at end of stack | |
| void | swap (stack_iterator_type a, stack_iterator_type b) |
| void | copy (stack_iterator_type a, stack_iterator_type b) |
| void | copy (const_stack_iterator_type a, stack_iterator_type b) |
| void | erase (stack_iterator_type p) |
| void | erase (particle_interface_type p) |
| delete this particle | |
| bool | isEmpty () |
| check if there are no further non-deleted particles on stack | |
| bool | isErased (const stack_iterator_type &p) const |
| check if this particle was already deleted | |
| bool | isErased (const const_stack_iterator_type &p) const |
| bool | isErased (const particle_interface_type &p) const |
| bool | purgeLastIfDeleted () |
| Function to ultimatively remove the last entry from the stack, if it was marked as deleted before. More... | |
| void | purge () |
| Function to ultimatively remove all entries from the stack marked as deleted. More... | |
| unsigned int | getSize () const |
| std::string | asString () const |
Public Attributes | |
| MSecondaryProducer< TStackDataType, TParticleInterface > | |
| inner_stack_ {view.inner_stack_} | |
| projectile_index_ | |
Protected Member Functions | |
| template<typename... Args> | |
| stack_view_iterator | addSecondary (stack_view_iterator &proj, const Args... v) |
| Overwrite of Stack::stack_view_iterator. More... | |
| bool | isErased (unsigned int i) const |
| unsigned int | getIndexFromIterator (const unsigned int vI) const |
| We only want to 'see' secondaries indexed in indices_. More... | |
Protected Member Functions inherited from corsika::Stack< TStackDataType &, TParticleInterface, MSecondaryProducer > | |
| value_type & | getStackData () |
| const value_type & | getStackData () const |
| void | swap (unsigned int const a, unsigned int const b) |
| void | copy (unsigned int const a, unsigned int const b) |
| void | erase (unsigned int const i) |
| bool | isErased (unsigned int const i) const |
| void | purge (unsigned int i) |
| will remove from storage the element i. More... | |
| stack_iterator_type | addSecondary (stack_iterator_type &parent, const TArgs... v) |
| increase stack size, create new particle at end of stack, related to parent particle/projectile More... | |
| unsigned int | getIndexFromIterator (const unsigned int vI) const |
| Function to perform eventual transformation from StackIterator::getIndex() to index in data stored in TStackData data_. More... | |
Additional Inherited Members | |
Protected Attributes inherited from corsika::Stack< TStackDataType &, TParticleInterface, MSecondaryProducer > | |
| unsigned int | nDeleted_ |
SecondaryView can only be constructed by giving a valid Projectile particle, following calls to addSecondary will populate the original Stack, but will be directly accessible via the SecondaryView, e.g.StackViewPr.
This allows to write code like
auto projectileInput = mainStack.getNextParticle(); const unsigned int nMain = mainStack.getSize(); SecondaryView<StackData, ParticleInterface> mainStackView(projectileInput); mainStackView.addSecondary(...data...); mainStackView.addSecondary(...data...); mainStackView.addSecondary(...data...); mainStackView.addSecondary(...data...); assert(mainStackView.getSize() == 4); assert(mainStack.getSize() = nMain+4);
All operations possible on a Stack object are also possible on a SecondaryView object. This means you can add, delete, copy, swap, iterate, etc.
Further information about implementation (for developers):* All data is stored in the original stack privided at construction time. The secondary particle (view) indices are stored in an extra std::vector of SecondaryView class 'indices_' referring to the original stack slot indices. The index of the primary projectle particle is also explicitly stored in 'projectile_index_'. StackIterator indices 'i = StackIterator::getIndex()' are referring to those numbers, where 'i==0' refers to the 'projectile_index_', and 'StackIterator::getIndex()>0' to 'indices_[i-1]', see function getIndexFromIterator.
Definition at line 64 of file SecondaryView.hpp.
|
inline |
Also allow to create a new View from a Projectile (stack_view_iterator on View)
Note, the view generated this way will be equivalent to the orignal view in terms of reference to the underlying data stack. It is not a "view to a view".
Definition at line 150 of file SecondaryView.hpp.
|
protected |
Overwrite of Stack::stack_view_iterator.
increase stack size, create new particle at end of stack, related to parent particle/projectile
This should only get internally called from a stack_view_iterator::addSecondary via ParticleBase
| void corsika::SecondaryView< TStackDataType, TParticleInterface, MSecondaryProducer >::erase | ( | stack_view_iterator | p | ) |
need overwrite Stack::Delete, since we want to call SecondaryView::DeleteLast
The particle is deleted on the underlying (internal) stack. The local references in SecondaryView in indices_ must be fixed, too. The approach is to a) check if the particle 'p' is at the very end of the internal stack, b) if not: move it there by copying the last particle to the current particle location, c) remove the last particle.
|
inlineprotected |
We only want to 'see' secondaries indexed in indices_.
In this function the conversion form iterator-index to stack-index is performed.
Definition at line 363 of file SecondaryView.hpp.
|
inline |
check if this particle was already deleted
need to re-implement for SecondaryView since stack_view_iterator types are a bit different
Definition at line 292 of file SecondaryView.hpp.
| void corsika::SecondaryView< TStackDataType, TParticleInterface, MSecondaryProducer >::purge | ( | ) |
Function to ultimatively remove all entries from the stack marked as deleted.
Careful: this will re-order the entries on the stack, since "gaps" in the stack are filled with entries from the back (copied).
| bool corsika::SecondaryView< TStackDataType, TParticleInterface, MSecondaryProducer >::purgeLastIfDeleted | ( | ) |
Function to ultimatively remove the last entry from the stack, if it was marked as deleted before.
If this is not the case, the function will just return false and do nothing.
| corsika::SecondaryView< TStackDataType, TParticleInterface, MSecondaryProducer >::MSecondaryProducer< TStackDataType, TParticleInterface > |
Definition at line 153 of file SecondaryView.hpp.
| corsika::SecondaryView< TStackDataType, TParticleInterface, MSecondaryProducer >::projectile_index_ |
Definition at line 156 of file SecondaryView.hpp.