src/core/geometry/GeometryManager.hpp
Keeping track of the global geometry of independent detectors. More…
Namespaces
Name |
---|
allpix Helper class to hold support layers for a detector model. |
Classes
Name | |
---|---|
class | allpix::GeometryManager Manager responsible for the global geometry. |
Types
Name | |
---|---|
enum class | MagneticFieldType { NONE = 0, CONSTANT, CUSTOM} Type of the magnetic field. |
using std::function< ROOT::Math::XYZVector(const ROOT::Math::XYZPoint &)> | MagneticFieldFunction |
Detailed Description
Keeping track of the global geometry of independent detectors.
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
enum MagneticFieldType
Enumerator | Value | Description |
---|---|---|
NONE | 0 | No magnetic field is simulated. |
CONSTANT | Constant magnetic field (mostly for testing) | |
CUSTOM | Custom magnetic field function. |
Type of the magnetic field.
using MagneticFieldFunction
using allpix::MagneticFieldFunction = typedef std::function<ROOT::Math::XYZVector(const ROOT::Math::XYZPoint&)>;
Source code
#ifndef ALLPIX_GEOMETRY_MANAGER_H
#define ALLPIX_GEOMETRY_MANAGER_H
#include <filesystem>
#include <memory>
#include <regex>
#include <set>
#include <string>
#include <vector>
#include <Math/Vector3D.h>
#include "Detector.hpp"
#include "DetectorModel.hpp"
#include "core/config/ConfigManager.hpp"
#include "core/config/ConfigReader.hpp"
#include "core/utils/prng.h"
namespace allpix {
enum class MagneticFieldType {
NONE = 0,
CONSTANT,
CUSTOM,
};
using MagneticFieldFunction = std::function<ROOT::Math::XYZVector(const ROOT::Math::XYZPoint&)>;
class GeometryManager {
public:
GeometryManager();
~GeometryManager() = default;
GeometryManager(const GeometryManager&) = delete;
GeometryManager& operator=(const GeometryManager&) = delete;
GeometryManager(GeometryManager&&) = delete;
GeometryManager& operator=(GeometryManager&&) = delete;
void load(ConfigManager* conf_manager, RandomNumberGenerator& seeder);
const std::vector<std::string>& getModelsPath() const { return model_paths_; }
std::pair<ROOT::Math::XYZPoint, ROOT::Math::Rotation3D>
getPassiveElementOrientation(const std::string& passive_element) const;
ROOT::Math::XYZPoint getMinimumCoordinate();
ROOT::Math::XYZPoint getMaximumCoordinate();
// TODO: Add more details to the point and interaction with external geometry
void addPoint(ROOT::Math::XYZPoint point);
bool needsModel(const std::string& name) const;
void addModel(std::shared_ptr<DetectorModel> model);
bool hasModel(const std::string& name) const;
const std::vector<std::shared_ptr<DetectorModel>>& getModels() const { return models_; }
std::shared_ptr<DetectorModel> getModel(const std::string& name) const;
void addDetector(std::shared_ptr<Detector> detector);
bool hasDetector(const std::string& name) const;
std::vector<std::shared_ptr<Detector>> getDetectors();
std::shared_ptr<Detector> getDetector(const std::string& name);
std::vector<std::shared_ptr<Detector>> getDetectorsByType(const std::string& type);
void setMagneticFieldFunction(MagneticFieldFunction function, MagneticFieldType type = MagneticFieldType::CUSTOM);
bool hasMagneticField() const;
ROOT::Math::XYZVector getMagneticField(const ROOT::Math::XYZPoint& position) const;
MagneticFieldType getMagneticFieldType() const;
template <typename T>
std::shared_ptr<T> getExternalObject(const std::string& associated_name, const std::string& id) const;
template <typename T>
std::vector<std::shared_ptr<T>> getExternalObjects(const std::string& associated_name,
const std::regex& regex) const;
template <typename T>
void
setExternalObject(const std::string& associated_name, const std::string& id, std::shared_ptr<T> external_object);
const std::set<std::string>& getExternalObjectNames() const { return external_object_names_; }
const std::list<Configuration>& getPassiveElements() const { return passive_elements_; }
private:
void load_models();
void read_model_file(const std::filesystem::path& path);
std::pair<ROOT::Math::XYZPoint, ROOT::Math::Rotation3D> calculate_orientation(const Configuration& config);
void close_geometry();
std::atomic_bool closed_;
RandomNumberGenerator random_generator_;
std::vector<ROOT::Math::XYZPoint> points_;
std::vector<std::string> model_paths_;
std::vector<std::shared_ptr<DetectorModel>> models_;
std::set<std::string> model_names_;
std::map<std::string, std::vector<std::pair<Configuration, Detector*>>> nonresolved_models_;
std::vector<std::shared_ptr<Detector>> detectors_;
std::set<std::string> detector_names_;
std::list<Configuration> passive_elements_;
std::map<std::string, std::pair<ROOT::Math::XYZPoint, ROOT::Math::Rotation3D>> passive_orientations_;
MagneticFieldType magnetic_field_type_{MagneticFieldType::NONE};
MagneticFieldFunction magnetic_field_function_;
std::map<std::type_index, std::map<std::pair<std::string, std::string>, std::shared_ptr<void>>> external_objects_;
std::set<std::string> external_object_names_;
};
} // namespace allpix
// Include template members
#include "GeometryManager.tpp"
#endif /* ALLPIX_GEOMETRY_MANAGER_H */
Updated on 2024-12-13 at 08:31:37 +0000