src/core/module/Event.hpp
Creation and execution of an event. More…
Namespaces
Name |
---|
allpix Helper class to hold support layers for a detector model. |
Classes
Name | |
---|---|
class | allpix::Event Holds the data required for running an event. |
Detailed Description
Creation and execution of an event.
Copyright: Copyright (c) 2018-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
Source code
#ifndef ALLPIX_MODULE_EVENT_H
#define ALLPIX_MODULE_EVENT_H
#include <atomic>
#include <condition_variable>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <vector>
#include "core/utils/prng.h"
namespace allpix {
class Module;
class Messenger;
class BaseMessage;
class LocalMessenger;
class Event {
friend class ModuleManager;
friend class Messenger;
friend class SequentialModule;
public:
explicit Event(Messenger& messenger, uint64_t event_num, uint64_t seed);
~Event() = default;
Event(Event&&) = delete;
Event& operator=(Event&&) = delete;
const uint64_t number;
RandomNumberGenerator& getRandomEngine();
uint64_t getRandomNumber() { return getRandomEngine()(); }
uint64_t getSeed() const { return seed_; }
private:
void set_and_seed_random_engine(RandomNumberGenerator* random_engine);
void store_random_engine_state();
void restore_random_engine_state();
// The random number engine associated with this event
RandomNumberGenerator* random_engine_{nullptr};
// Seed for random number generator
uint64_t seed_;
// State of the random number generator
std::stringstream state_;
LocalMessenger* get_local_messenger() const;
// Local messenger used to dispatch messages in this event
std::unique_ptr<LocalMessenger> local_messenger_;
// Mutex for execution time
static std::mutex stats_mutex_;
};
} // namespace allpix
#endif /* ALLPIX_MODULE_EVENT_H */
Updated on 2025-02-27 at 14:14:46 +0000