src/core/module/ModuleManager.hpp
Loading and execution of all modules. More…
Namespaces
Name |
---|
allpix Helper class to hold support layers for a detector model. |
Classes
Name | |
---|---|
class | allpix::ModuleManager Manager responsible for dynamically loading all modules and running their event sequence. |
Types
Name | |
---|---|
using std::list< std::shared_ptr< Module > > | ModuleList |
Detailed Description
Loading and execution of all modules.
Copyright: Copyright (c) 2017-2024 CERN and the Allpix Squared authors. This software is distributed under the terms of the MIT License, copied verbatim in the file “LICENSE.md”. In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction. SPDX-License-Identifier: MIT
Types Documentation
using ModuleList
using allpix::ModuleList = typedef std::list<std::shared_ptr<Module> >;
Source code
#ifndef ALLPIX_MODULE_MANAGER_H
#define ALLPIX_MODULE_MANAGER_H
#include <atomic>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <TDirectory.h>
#include <TFile.h>
#include <TH1D.h>
#include "Module.hpp"
#include "ThreadPool.hpp"
#include "core/config/Configuration.hpp"
#include "core/utils/log.h"
#include "tools/ROOT.h"
namespace allpix {
using ModuleList = std::list<std::shared_ptr<Module>>;
class ConfigManager;
class Messenger;
class GeometryManager;
class ModuleManager {
friend class Event;
public:
ModuleManager();
~ModuleManager() = default;
ModuleManager(const ModuleManager&) = delete;
ModuleManager& operator=(const ModuleManager&) = delete;
ModuleManager(ModuleManager&&) = delete;
ModuleManager& operator=(ModuleManager&&) = delete;
void load(Messenger* messenger, ConfigManager* conf_manager, GeometryManager* geo_manager);
void initialize();
void run(RandomNumberGenerator& seeder);
void finalize();
void terminate();
private:
std::pair<ModuleIdentifier, Module*> create_unique_modules(void*, Configuration&, Messenger*, GeometryManager*);
std::vector<std::pair<ModuleIdentifier, Module*>>
create_detector_modules(void*, Configuration&, Messenger*, GeometryManager*);
static std::tuple<LogLevel, LogFormat, std::string, uint64_t> set_module_before(const std::string& mod_name,
const Configuration& config,
const std::string& prefix = "",
const uint64_t event = 0);
static void set_module_after(std::tuple<LogLevel, LogFormat, std::string, uint64_t> prev);
using IdentifierToModuleMap = std::map<ModuleIdentifier, ModuleList::iterator>;
ModuleList modules_;
IdentifierToModuleMap id_to_module_;
ConfigManager* conf_manager_{};
std::unique_ptr<TFile> modules_file_;
// Duration in ns
std::map<Module*, std::atomic_int64_t> module_execution_time_;
std::map<Module*, Histogram<TH1D>> module_event_time_;
Histogram<TH1D> event_time_;
Histogram<TH1D> buffer_fill_level_;
// Durations in ns
uint64_t initialize_time_{}, run_time_{}, finalize_time_{};
std::map<std::string, void*> loaded_libraries_;
std::atomic<bool> terminate_;
Messenger* messenger_{};
// The thread pool used in the run method
std::unique_ptr<ThreadPool> thread_pool_{nullptr};
// User defined multithreading flags and parameters from configuration
bool multithreading_flag_{false};
unsigned int number_of_threads_{0};
size_t max_buffer_size_{1};
// Possibility of running loaded modules in parallel
bool can_parallelize_{true};
};
} // namespace allpix
#endif /* ALLPIX_MODULE_MANAGER_H */
Updated on 2024-12-13 at 08:31:37 +0000