forked from acts-project/acts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8eda2a
commit f793eb6
Showing
10 changed files
with
318 additions
and
27 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
79 changes: 79 additions & 0 deletions
79
Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorSurfaceFactory.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,79 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 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 "Acts/Utilities/Logger.hpp" | ||
|
||
#include <tuple> | ||
#include <vector> | ||
#include <memory> | ||
#include <string> | ||
|
||
namespace Acts { | ||
|
||
struct GeoModelTree; | ||
class GeoModelDetectorElement; | ||
class Surface; | ||
|
||
/// A factory to convert GeoModel volume into sensitive | ||
/// or passive surfaces which are filled into a Cache object, | ||
/// also the create GeoModelDetectorElements which are also | ||
/// returned. | ||
class GeoModelDetectorSurfaceFactory { | ||
public: | ||
/// Collect the sensitive surface & detector element | ||
using GeoModelSensitiveSurface = | ||
std::tuple<std::shared_ptr<GeoModelDetectorElement>, | ||
std::shared_ptr<Surface>>; | ||
|
||
/// Collect the passive surfaces, bool whether it should be | ||
/// added as an "always try, i.e. assignToAll=true" surface | ||
using GeoModelPassiveSurface = std::tuple<std::shared_ptr<Surface>, bool>; | ||
|
||
/// Nested cache that records the conversion status | ||
struct Cache { | ||
/// The created detector elements - for the detector store | ||
std::vector<GeoModelSensitiveSurface> sensitiveSurfaces; | ||
/// The created non-const surfaces - for further processing, | ||
std::vector<GeoModelPassiveSurface> passiveSurfaces; | ||
}; | ||
|
||
/// The options to steer the conversion | ||
struct Options { | ||
std::vector<std::string> queries = {}; | ||
}; | ||
|
||
/// The GeoModel detector element factory | ||
/// | ||
/// @param mlogger a screen output logger | ||
GeoModelDetectorSurfaceFactory( | ||
std::unique_ptr<const Logger> mlogger = getDefaultLogger( | ||
"GeoModelDetectorSurfaceFactory", Acts::Logging::INFO)); | ||
|
||
/// Construction method of the detector elements | ||
/// | ||
/// @param cache [in,out] into which the Elements are filled | ||
/// @param gctx the geometry context | ||
/// @param geoModelTree the gjeo model tree | ||
/// @param options to steer the conversion | ||
/// | ||
/// @note this method will call the recursive construction | ||
void construct(Cache& cache, const GeometryContext& gctx, | ||
const GeoModelTree& geoModelTree, const Options& options); | ||
|
||
private: | ||
/// Logging instance | ||
std::unique_ptr<const Logger> m_logger; | ||
|
||
/// Private access to the logger | ||
const Logger& logger() const { return *m_logger; } | ||
}; | ||
|
||
} // namespace Acts |
32 changes: 32 additions & 0 deletions
32
Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelSurfaceConverter.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,32 @@ | ||
// 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/Plugins/GeoModel/GeoModelDetectorElement.hpp" | ||
|
||
class GeoFullPhysVol; | ||
|
||
namespace Acts { | ||
/// Collect the sensitive surface & detector element | ||
using GeoModelSensitiveSurface = | ||
std::tuple<std::shared_ptr<GeoModelDetectorElement>, | ||
std::shared_ptr<Surface>>; | ||
|
||
namespace GeoModelSurfaceConverter { | ||
|
||
|
||
/// @brief conversion to sensitive surface | ||
/// | ||
/// @param geoPhysVol the geoPhysVol to convert | ||
/// | ||
/// @return a detector element and a surface | ||
GeoModelSensitiveSurface convertToSensitiveSurface( | ||
const GeoFullPhysVol& geoPhysVol); | ||
} | ||
} // namespace Acts |
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,49 @@ | ||
// 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 "Acts/Plugins/GeoModel/GeoModelDetectorSurfaceFactory.hpp" | ||
|
||
#include "Acts/Plugins/GeoModel/GeoModelDetectorElement.hpp" | ||
#include "Acts/Plugins/GeoModel/GeoModelSurfaceConverter.hpp" | ||
#include "Acts/Plugins/GeoModel/GeoModelTree.hpp" | ||
|
||
using namespace Acts::detail; | ||
|
||
Acts::GeoModelDetectorSurfaceFactory::GeoModelDetectorSurfaceFactory( | ||
std::unique_ptr<const Logger> mlogger) | ||
: m_logger(std::move(mlogger)) {} | ||
|
||
void Acts::GeoModelDetectorSurfaceFactory::construct( | ||
Cache& cache, const GeometryContext& gctx, const GeoModelTree& geoModelTree, | ||
const Options& options) { | ||
if (geoModelTree.geoReader == nullptr) { | ||
throw std::invalid_argument("GeoModelTree has no GeoModelReader"); | ||
} | ||
|
||
for (const auto& q : options.queries) { | ||
ACTS_VERBOSE("Constructing detector elements for query " << q); | ||
auto qFPV = | ||
geoModelTree.geoReader->getPublishedNodes<std::string, GeoFullPhysVol*>( | ||
q); | ||
|
||
for (auto& [name, fpv] : qFPV) { | ||
// Convert the full physical volume to a sensitive surface | ||
auto sensitive = | ||
GeoModelSurfaceConverter::convertToSensitiveSurface(*fpv); | ||
if (std::get<0>(sensitive) != nullptr) { | ||
// Add the surface to the cache | ||
cache.sensitiveSurfaces.push_back(sensitive); | ||
} | ||
} | ||
ACTS_VERBOSE("Found " << qFPV.size() | ||
<< " full physical volumes matching the query."); | ||
} | ||
ACTS_DEBUG("Constructed " | ||
<< cache.sensitiveSurfaces.size() << " sensitive elements and " | ||
<< cache.passiveSurfaces.size() << " passive elements"); | ||
} |
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.