Class ModuleList

Inheritance Relationships

Base Type

Class Documentation

class ModuleList : public Module

The simulation itself: A list of simulation modules.

To use this module first create a instance over the constructor ModuleList SIM();. After that add some modules with SIM.add(SomeModule) When all module are added you can run the simulation over SIM.run()

For a detailed description see the function descriptions.

Public Types

typedef std::list<ref_ptr<Module>> module_list_t
typedef std::vector<ref_ptr<Candidate>> candidate_vector_t
typedef module_list_t::iterator iterator
typedef module_list_t::const_iterator const_iterator

Public Functions

ModuleList()

Constructor.

virtual ~ModuleList()

Destructor.

void setShowProgress(bool show = true)

Activates/Deactivates the progess bar If you want to see the progess of the simulation in stdout you can activate the progess bar with this function.

Parameters:

show – Whether or not to show a progress bar

void add(Module *module)

Function to add modules to the simulation With this function you can add any class derived from Module to the simulation. During ModuleList::run the Module::process function is called to process the simulated Candidate

Parameters:

moduleModule raw pointer

void remove(std::size_t i)

Removes module from index i in modules vector This function removes the module located at index i in the modules vector. The modules are added in order to the back of the modules vector.

Parameters:

i – Index to remove

std::size_t size() const
Returns:

Returns size of the modules vector, so the number of modules in ModuleList

ref_ptr<Module> operator[](const std::size_t i)

Operator to get the module at index i

Parameters:

iModule index in modules vector

virtual void process(Candidate *candidate) const

process function The process function calls process in order on very module in the modules vector with the given Candidate pointer

Parameters:

candidate – The candidate to call modules process on

void process(ref_ptr<Candidate> candidate) const

process function Wrapps the process(Candidate* candidate) function The process function calls process in order on very module in the modules vector with the given Candidate pointer

Parameters:

candidate – The candidate to call modules process on

void run(Candidate *candidate, bool recursive = true, bool secondariesFirst = true, bool waitForSecondaries = true)

Run function This run function does the full simulation for a single given candidate

Parameters:
  • candidateCandidate to use for the simulation

  • recursive – Whether to also process possible created secondaries

  • secondariesFirst – Whether to process the secondaries directly after the step where they are created or to only process them after the primary is fully finished

  • waitForSecondaries – Whether to wait for the secondaries to be fully processed before continuing with the primary candidate if secondariesFirst is set to true

void run(ref_ptr<Candidate> candidate, bool recursive = true, bool secondariesFirst = true, bool waitForSecondaries = true)

Run function This function wrapps the ModuleList::run(Candidate* candidate) function This run function does the full simulation for a single given candidate

Parameters:
  • candidateCandidate to use for the simulation

  • recursive – Whether to also process possible created secondaries

  • secondariesFirst – Whether to process the secondaries directly after the step where they are created or to only process them after the primary is fully finished

  • waitForSecondaries – Whether to wait for the secondaries to be fully processed before continuing with the primary candidate if secondariesFirst is set to true

void run(const candidate_vector_t *candidates, bool recursive = true, bool secondariesFirst = true, bool waitForSecondaries = true)

Run function This function calls the run function for a single Candidate on each entry of the given candidate_vector. If OpenMP parallelization is activated (default) the execution of the run function for each member of candidate_vector is parallelized.

Parameters:
  • candidatesCandidate vector

  • recursive – Whether to also process possible created secondaries

  • secondariesFirst – Whether to process the secondaries directly after the step where they are created or to only process them after the primary is fully finished

  • waitForSecondaries – Whether to wait for the secondaries to be fully processed before continuing with the primary candidate if secondariesFirst is set to true

void run(SourceInterface *source, size_t count, bool recursive = true, bool secondariesFirst = true, bool waitForSecondaries = true)

Run function This function generates count Candidates over the given source. Each generated Candidate is then handed over to ModuleList::run(Candidate*) where it is simulated. If OpenMP parallelization is activated (default) the count primary Candidates are generated and simulated in parallel.

Parameters:
  • source – The source to generate Candidates from

  • count – The number of Candidates to simulate

  • recursive – Whether to also process possible created secondaries

  • secondariesFirst – Whether to process the secondaries directly after the step where they are created or to only process them after the primary is fully finished

  • waitForSecondaries – Whether to wait for the secondaries to be fully processed before continuing with the primary candidate if secondariesFirst is set to true

virtual std::string getDescription() const
Returns:

Returns the description string for all modules

void showModules() const

Prints the getDescription string to stdout.

iterator begin()

Begin iterator of modules vector

const_iterator begin() const

Constant begin iterator of modules vector

iterator end()

End iterator of modules vector

const_iterator end() const

Constant end iterator of modules vector

void setInterruptAction(Output *action)

Sets outputmodule that should be called on interruption If CRPropa receives an interruption signal (4) the here set Output module is called

Parameters:

action – The Output module to call when CRPropa is interrupted

void dumpCandidate(Candidate *cand) const

Function to dump Candidates manually With this function it is possible to dump the currently still active simulated Candidates manually. When called the with ModuleList::setInterruptAction set module is called on all still active Candidates.

Parameters:

CandidateCandidate to dump

void setDescription(const std::string &description)

Sets description, can be used instead of getDescription in derived class

Parameters:

description – Description string

inline size_t addReference() const
inline size_t removeReference() const
inline int removeReferenceNoDelete() const
inline size_t getReferenceCount() const

Protected Attributes

mutable size_t _referenceCount