allpix::Module
Base class for all modules. More…
#include <Module.hpp>
Inherited by allpix::CSADigitizerModule, allpix::CapacitiveTransferModule, allpix::DefaultDigitizerModule, allpix::DepositionLaserModule, allpix::DepositionPointChargeModule, allpix::DetectorHistogrammerModule, allpix::DopingProfileReaderModule, allpix::DummyModule, allpix::ElectricFieldReaderModule, allpix::GDMLOutputWriterModule, allpix::GenericPropagationModule, allpix::GeometryBuilderGeant4Module, allpix::InducedTransferModule, allpix::MagneticFieldReaderModule, allpix::ProjectionPropagationModule, allpix::PulseTransferModule, allpix::ROOTObjectReaderModule, allpix::SequentialModule, allpix::SimpleTransferModule, allpix::TransientPropagationModule, allpix::VisualizationGeant4Module, allpix::WeightingPotentialReaderModule
Public Functions
Name | |
---|---|
Module(const Module & ) =delete Copying a module is not allowed. |
|
Module & | operator=(const Module & ) =delete Copying a module is not allowed. |
Module(Module && ) =delete Disallow move behaviour (not possible with references) |
|
Module & | operator=(Module && ) =delete Disallow move behaviour (not possible with references) |
Module(Configuration & config) Base constructor for unique modules. |
|
Module(Configuration & config, std::shared_ptr< Detector > detector) Base constructor for detector modules. |
|
virtual | ~Module() Essential virtual destructor. |
std::shared_ptr< Detector > | getDetector() const Get the detector linked to this module. |
std::string | getUniqueName() const Get the unique name of this module. |
std::string | createOutputFile(const std::string & pathname, const std::string & extension ="", bool global =false, bool delete_file =false) Create and return an absolute path to be used for output from a relative path. |
TDirectory * | getROOTDirectory() const Get ROOT directory which should be used to output histograms et cetera. |
ConfigManager * | getConfigManager() const Get the config manager object to allow to read the global and other module configurations. |
bool | multithreadingEnabled() const Returns if multithreading of this module is enabled. |
virtual void | initializeThread() Initialize the module for each thread after the global initialization. |
virtual void | initialize() Initialize the module before the event sequence. |
virtual void | run(Event * event) Execute the function of the module for every event. |
virtual void | finalizeThread() Finalize the module after the event sequence for each thread. |
virtual void | finalize() Finalize the module after the event sequence. |
Protected Functions
Name | |
---|---|
void | allow_multithreading() Enable multithreading for this module. |
Configuration & | get_configuration() Get the module configuration for internal use. |
Protected Attributes
Name | |
---|---|
Configuration & | config_ |
Friends
Name | |
---|---|
class | Event |
class | ModuleManager |
class | Messenger |
class | LocalMessenger |
Detailed Description
class allpix::Module;
Base class for all modules.
The module base is the core of the modular framework. All modules should be descendants of this class. The base class defines the methods the children can implement:
- Module::initialize(): for initializing the module at the start
- Module::run(Event*): for doing the job of every module for every event
- Module::finalize(): for finalizing the module at the end
The module class also provides a few utility methods and stores internal data of instantiations. The internal data is used by the ModuleManager and the Messenger to work.
Public Functions Documentation
function Module
Module(
const Module &
) =delete
Copying a module is not allowed.
function operator=
Module & operator=(
const Module &
) =delete
Copying a module is not allowed.
function Module
Module(
Module &&
) =delete
Disallow move behaviour (not possible with references)
function operator=
Module & operator=(
Module &&
) =delete
Disallow move behaviour (not possible with references)
function Module
explicit Module(
Configuration & config
)
Base constructor for unique modules.
Parameters:
- config Configuration for this module
function Module
explicit Module(
Configuration & config,
std::shared_ptr< Detector > detector
)
Base constructor for detector modules.
Parameters:
- config Configuration for this module
- detector Detector bound to this module
Warning: Detector modules should not forget to forward their detector to the base constructor. An InvalidModuleStateException will be raised if the module failed to so.
function ~Module
virtual ~Module()
Essential virtual destructor.
Note: The remove_delegate can throw in theory, but this should never happen in practice
Also removes all delegates linked to this module
function getDetector
inline std::shared_ptr< Detector > getDetector() const
Get the detector linked to this module.
Return: Linked detector or a null pointer if this is an unique module
Detector modules always have a linked detector and unique modules are guaranteed not to have one.
function getUniqueName
std::string getUniqueName() const
Get the unique name of this module.
Exceptions:
- InvalidModuleActionException If this method is called from the constructor
Return: Unique name
Note: Can be used to interact with ROOT objects that require an unique name
This name is guaranteed to be unique for every single instantiation of all modules
function createOutputFile
std::string createOutputFile(
const std::string & pathname,
const std::string & extension ="",
bool global =false,
bool delete_file =false
)
Create and return an absolute path to be used for output from a relative path.
Parameters:
- pathname Relative path to add after the main output directory
- extension File extension to be added to filename if it doesn’t exist yet
- global True if the global output directory should be used instead of the module-specific version
- delete_file True if the created output file should be deleted after testing access
Exceptions:
- ModuleError If the file cannot be accessed (or created if it did not yet exist)
- InvalidModuleActionException If this method is called from the constructor with the global flag false
- ModuleError If the file exists but the “deny_overwrite” flag is set to true (defaults to false)
Return: Canonical path to an output file
Warning: A local path cannot be fetched from the constructor, because the instantiation logic has not finished yet
The output path is automatically created if it does not exists. The path is always accessible if this functions returns. Obeys the “deny_overwrite” parameter of the module.
function getROOTDirectory
TDirectory * getROOTDirectory() const
Get ROOT directory which should be used to output histograms et cetera.
Exceptions:
- InvalidModuleActionException If this method is called from the constructor or destructor
Return: ROOT directory for storage
Note: It is not needed to change directory to this file explicitly in the module, this is done automatically.
Warning:
- Cannot be used from the constructor, because the instantiation logic has not finished yet
- This method should not be accessed from the destructor (the file is then already closed)
function getConfigManager
ConfigManager * getConfigManager() const
Get the config manager object to allow to read the global and other module configurations.
Exceptions:
- InvalidModuleActionException If this method is called from the constructor or destructor
Return: Pointer to the config manager
Warning: This function technically allows to write to the configurations of other modules, but this should never be done
function multithreadingEnabled
inline bool multithreadingEnabled() const
Returns if multithreading of this module is enabled.
Return: True if multithreading is enabled, false otherwise (the default)
function initializeThread
inline virtual void initializeThread()
Initialize the module for each thread after the global initialization.
Note: Useful to prepare thread local objects
Reimplemented by: allpix::DatabaseWriterModule::initializeThread, allpix::DepositionGeant4Module::initializeThread
Does nothing if not overloaded.
function initialize
inline virtual void initialize()
Initialize the module before the event sequence.
Reimplemented by: allpix::CapacitiveTransferModule::initialize, allpix::CorryvreckanWriterModule::initialize, allpix::CSADigitizerModule::initialize, allpix::DefaultDigitizerModule::initialize, allpix::DepositionGeant4Module::initialize, allpix::DepositionGeneratorModule::initialize, allpix::DepositionLaserModule::initialize, allpix::DepositionPointChargeModule::initialize, allpix::DepositionReaderModule::initialize, allpix::DetectorHistogrammerModule::initialize, allpix::DopingProfileReaderModule::initialize, allpix::DummyModule::initialize, allpix::ElectricFieldReaderModule::initialize, allpix::GDMLOutputWriterModule::initialize, allpix::GenericPropagationModule::initialize, allpix::GeometryBuilderGeant4Module::initialize, allpix::InducedTransferModule::initialize, allpix::LCIOWriterModule::initialize, allpix::MagneticFieldReaderModule::initialize, allpix::ProjectionPropagationModule::initialize, allpix::PulseTransferModule::initialize, allpix::RCEWriterModule::initialize, allpix::ROOTObjectReaderModule::initialize, allpix::ROOTObjectWriterModule::initialize, allpix::SimpleTransferModule::initialize, allpix::TextWriterModule::initialize, allpix::TransientPropagationModule::initialize, allpix::VisualizationGeant4Module::initialize, allpix::WeightingPotentialReaderModule::initialize
Does nothing if not overloaded.
function run
inline virtual void run(
Event * event
)
Execute the function of the module for every event.
Parameters:
- event Pointer to the event the module is running
Reimplemented by: allpix::CapacitiveTransferModule::run, allpix::DefaultDigitizerModule::run, allpix::DepositionGeant4Module::run, allpix::DepositionPointChargeModule::run, allpix::DepositionReaderModule::run, allpix::DetectorHistogrammerModule::run, allpix::GenericPropagationModule::run, allpix::InducedTransferModule::run, allpix::ProjectionPropagationModule::run, allpix::PulseTransferModule::run, allpix::ROOTObjectReaderModule::run, allpix::SimpleTransferModule::run, allpix::TransientPropagationModule::run, allpix::VisualizationGeant4Module::run, allpix::CorryvreckanWriterModule::run, allpix::CSADigitizerModule::run, allpix::DatabaseWriterModule::run, allpix::DepositionGeneratorModule::run, allpix::DepositionLaserModule::run, allpix::DummyModule::run, allpix::LCIOWriterModule::run, allpix::RCEWriterModule::run, allpix::ROOTObjectWriterModule::run, allpix::TextWriterModule::run
Does nothing if not overloaded.
function finalizeThread
inline virtual void finalizeThread()
Finalize the module after the event sequence for each thread.
Note: Useful to cleanup thread local objects
Reimplemented by: allpix::DatabaseWriterModule::finalizeThread, allpix::DepositionCosmicsModule::finalizeThread, allpix::DepositionGeant4Module::finalizeThread
Does nothing if not overloaded.
function finalize
inline virtual void finalize()
Finalize the module after the event sequence.
Note: Useful to have before destruction to allow for raising exceptions
Reimplemented by: allpix::CapacitiveTransferModule::finalize, allpix::CorryvreckanWriterModule::finalize, allpix::CSADigitizerModule::finalize, allpix::DatabaseWriterModule::finalize, allpix::DefaultDigitizerModule::finalize, allpix::DepositionCosmicsModule::finalize, allpix::DepositionGeant4Module::finalize, allpix::DepositionLaserModule::finalize, allpix::DepositionPointChargeModule::finalize, allpix::DepositionReaderModule::finalize, allpix::DetectorHistogrammerModule::finalize, allpix::DummyModule::finalize, allpix::GenericPropagationModule::finalize, allpix::LCIOWriterModule::finalize, allpix::ProjectionPropagationModule::finalize, allpix::PulseTransferModule::finalize, allpix::RCEWriterModule::finalize, allpix::ROOTObjectReaderModule::finalize, allpix::ROOTObjectWriterModule::finalize, allpix::SimpleTransferModule::finalize, allpix::TextWriterModule::finalize, allpix::TransientPropagationModule::finalize, allpix::VisualizationGeant4Module::finalize
Does nothing if not overloaded.
Protected Functions Documentation
function allow_multithreading
inline void allow_multithreading()
Enable multithreading for this module.
function get_configuration
inline Configuration & get_configuration()
Get the module configuration for internal use.
Return: Configuration of the module
Protected Attributes Documentation
variable config_
Configuration & config_;
Friends
friend Event
friend class Event(
Event
);
friend ModuleManager
friend class ModuleManager(
ModuleManager
);
friend Messenger
friend class Messenger(
Messenger
);
friend LocalMessenger
friend class LocalMessenger(
LocalMessenger
);
Updated on 2025-02-27 at 14:14:46 +0000