-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Rework detector handling in Examples
- Loading branch information
Showing
40 changed files
with
782 additions
and
860 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
add_library(ActsExamplesDetectorCommons SHARED src/Detector.cpp) | ||
target_include_directories( | ||
ActsExamplesDetectorCommons | ||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
) | ||
target_link_libraries( | ||
ActsExamplesDetectorCommons | ||
PUBLIC ActsCore ActsExamplesFramework | ||
) | ||
|
||
install( | ||
TARGETS ActsExamplesDetectorCommons | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) |
75 changes: 75 additions & 0 deletions
75
Examples/Detectors/Common/include/ActsExamples/DetectorCommons/Detector.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// This file is part of the ACTS project. | ||
// | ||
// Copyright (C) 2016 CERN for the benefit of the ACTS project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2024 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include "Acts/Geometry/GeometryContext.hpp" | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
namespace Acts { | ||
class TrackingGeometry; | ||
class DetectorElementBase; | ||
class IMaterialDecorator; | ||
class Logger; | ||
namespace Experimental { | ||
class Detector; | ||
} // namespace Experimental | ||
} // namespace Acts | ||
|
||
namespace ActsExamples { | ||
class IContextDecorator; | ||
} // namespace ActsExamples | ||
|
||
namespace ActsExamples::DetectorCommons { | ||
|
||
class Detector { | ||
public: | ||
using TrackingGeometryPtr = std::shared_ptr<const Acts::TrackingGeometry>; | ||
using DetectorPtr = std::shared_ptr<Acts::Experimental::Detector>; | ||
using ContextDecorators = | ||
std::vector<std::shared_ptr<ActsExamples::IContextDecorator>>; | ||
|
||
using DetectorElement = Acts::DetectorElementBase; | ||
using DetectorStore = std::vector<std::shared_ptr<const DetectorElement>>; | ||
|
||
explicit Detector(std::unique_ptr<const Acts::Logger> logger); | ||
virtual ~Detector() = default; | ||
|
||
virtual std::tuple<TrackingGeometryPtr, ContextDecorators, DetectorStore> | ||
trackingGeometry(); | ||
|
||
virtual std::tuple<DetectorPtr, ContextDecorators, DetectorStore> detector(); | ||
|
||
virtual void drop(); | ||
|
||
protected: | ||
TrackingGeometryPtr m_trackingGeometry; | ||
DetectorPtr m_detector; | ||
ContextDecorators m_contextDecorators; | ||
DetectorStore m_detectorStore; | ||
|
||
std::unique_ptr<const Acts::Logger> m_logger; | ||
|
||
const Acts::Logger& logger() const { return *m_logger; } | ||
|
||
virtual void buildTrackingGeometry() = 0; | ||
|
||
virtual void buildDetector(); | ||
}; | ||
|
||
} // namespace ActsExamples::DetectorCommons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// This file is part of the ACTS project. | ||
// | ||
// Copyright (C) 2016 CERN for the benefit of the ACTS project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2024 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include "ActsExamples/DetectorCommons/Detector.hpp" | ||
|
||
#include "Acts/Utilities/Logger.hpp" | ||
|
||
namespace ActsExamples::DetectorCommons { | ||
|
||
Detector::Detector(std::unique_ptr<const Acts::Logger> logger) | ||
: m_logger(std::move(logger)) {} | ||
|
||
std::tuple<Detector::TrackingGeometryPtr, Detector::ContextDecorators, | ||
Detector::DetectorStore> | ||
Detector::trackingGeometry() { | ||
if (m_trackingGeometry == nullptr) { | ||
buildTrackingGeometry(); | ||
} | ||
return {m_trackingGeometry, m_contextDecorators, m_detectorStore}; | ||
} | ||
|
||
std::tuple<Detector::DetectorPtr, Detector::ContextDecorators, | ||
Detector::DetectorStore> | ||
Detector::detector() { | ||
if (m_detector == nullptr) { | ||
buildDetector(); | ||
} | ||
return {m_detector, m_contextDecorators, m_detectorStore}; | ||
} | ||
|
||
void Detector::drop() { | ||
m_trackingGeometry.reset(); | ||
m_detector.reset(); | ||
m_contextDecorators.clear(); | ||
m_detectorStore.clear(); | ||
} | ||
|
||
void Detector::buildDetector() {} | ||
|
||
} // namespace ActsExamples::DetectorCommons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.