Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generalized conversion of FullPhysicalVolume #3585

Merged
merged 193 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 183 commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
5c69706
Changes to fix finding geomodel on system and first round of converter
Jun 3, 2024
daaf5b8
format changes
Jun 7, 2024
0700fc7
Changes to fix finding geomodel on system and first round of converter
Jun 3, 2024
891280f
format changes
Jun 7, 2024
15612c9
fix
Jun 7, 2024
b8712b4
small changes
Jun 7, 2024
fa55d0e
Final changes for using system geomodel
Jun 7, 2024
656c771
oops
Jun 7, 2024
b0c1a09
Merge branch 'main' into geoShapeToDetVol
Matthewharri Jun 12, 2024
1660a53
Use forward declare and move around some includes
Jun 13, 2024
a7fb341
Change to GeoModel namespace
Jun 13, 2024
53334ab
fix format
Jun 13, 2024
6b016ca
change from dynamic_cast to static_cast
Jun 17, 2024
cd12571
Address Johannes comments
Jun 28, 2024
654904a
geomodel conversion of the mdt tubes for the muon system
dimitra97 Jul 3, 2024
e57bb00
add database to publish it to people
dimitra97 Jul 3, 2024
cf77083
format python
dimitra97 Jul 3, 2024
5a871ab
spelling fix
dimitra97 Jul 3, 2024
a9386d6
Update Plugins/GeoModel/src/GeoModelDetectorSurfaceFactory.cpp
dimitra97 Jul 3, 2024
c7dccce
Update Plugins/GeoModel/src/GeoModelDetectorSurfaceFactory.cpp
dimitra97 Jul 3, 2024
9cb2c8f
pr comments
dimitra97 Jul 3, 2024
9581e28
Merge branch 'geomodel-muons' of github.com:dimitra97/acts into geomo…
dimitra97 Jul 3, 2024
08419cd
format check
dimitra97 Jul 3, 2024
f749c3b
fix
dimitra97 Jul 3, 2024
4cc0263
Update Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelConvert…
dimitra97 Jul 3, 2024
65320d4
Update Plugins/GeoModel/src/GeoModelDetectorSurfaceFactory.cpp
dimitra97 Jul 3, 2024
3669c82
forgotten comments
dimitra97 Jul 3, 2024
4e3b05b
Merge branch 'geomodel-muons' of github.com:dimitra97/acts into geomo…
dimitra97 Jul 3, 2024
8dc4cb2
Update Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetecto…
dimitra97 Jul 3, 2024
d6aa993
again forgotten comments that andreas sawgit add Examples/Scripts/Pyt…
dimitra97 Jul 3, 2024
baf84cf
Merge branch 'geomodel-muons' of github.com:dimitra97/acts into geomo…
dimitra97 Jul 3, 2024
e8965ff
format check
dimitra97 Jul 3, 2024
8976721
remove the database
dimitra97 Jul 3, 2024
fc7bd0f
remove include not needed
dimitra97 Jul 3, 2024
aca782f
remove forgotten comment again!
dimitra97 Jul 3, 2024
877a6d1
Update Plugins/GeoModel/src/GeoModelDetectorSurfaceFactory.cpp
dimitra97 Jul 4, 2024
9563956
Update Plugins/GeoModel/src/GeoModelDetectorSurfaceFactory.cpp
dimitra97 Jul 4, 2024
47547d9
bump GeoModel to 6.0.0 and add GeoMaterial converter
Jul 4, 2024
c418f5b
Changes to DetVol converter
Jul 4, 2024
e6c8ac0
format fix
Jul 4, 2024
2792e65
last format fix i hope
Jul 4, 2024
fe54079
fix
Jul 4, 2024
e892533
Apply suggestions from code review
Matthewharri Jul 4, 2024
140cd91
fix GeoModelTree.hpp
Jul 4, 2024
bb1a21b
changes after using the 6.2 geomodel version and the new database
dimitra97 Jul 4, 2024
ca05ce0
Merge branch 'geomodel-muons' of github.com:dimitra97/acts into geomo…
dimitra97 Jul 4, 2024
b021387
switch from class to namespace definition for mat conv
Jul 4, 2024
b7463da
parse shape by pointer
Jul 4, 2024
35fbd02
simplify transforms
Jul 4, 2024
7c7c3c3
format yet again
Jul 4, 2024
43e3b92
Merge branch 'acts-project:main' into geomodel-muons
dimitra97 Jul 4, 2024
8a8eb1f
Merge branch 'main' into geomodel-muons
dimitra97 Jul 4, 2024
8df082d
remove some forgotten couts
dimitra97 Jul 5, 2024
ff65f65
Merge branch 'geomodel-muons' of github.com:dimitra97/acts into geomo…
dimitra97 Jul 5, 2024
c32c40b
Merge branch 'main' into geomodel-muons
dimitra97 Jul 5, 2024
59b530c
fix: GeoModel plugin (#3351)
asalzburger Jul 5, 2024
119ef13
resolved conflict
Jul 8, 2024
8761e4a
move to 6.3.0 and change to returning a volume instead of vector
Jul 11, 2024
6fdc26b
Merge branch 'main' into geoShapeToDetVol
Matthewharri Jul 11, 2024
96d1499
merged with matthiew
Jul 11, 2024
f44d6a8
merged with matthiew
Jul 11, 2024
2a462ff
weird error
Jul 12, 2024
9265652
weird error with pybind
Jul 12, 2024
f94edbb
implemented bounding boxes
Jul 16, 2024
47b7235
Merge branch 'main' into geoShapeToDetVol
Matthewharri Jul 19, 2024
268b35a
convert both surfaces and bounding boxes according to the requirement…
Jul 19, 2024
07e3897
adding surfaces a parameter works. did noting with them yet
Jul 23, 2024
9eb991d
adding surfaces a parameter works. did noting with them yet
Jul 23, 2024
5e62ff8
adding surfaces a parameter works. did noting with them yet
Jul 23, 2024
ecc1ad3
sensitive surfaces are implemented into volumes (issue: duplicate con…
Jul 24, 2024
b86ea66
hideous solution for the memory issue
Jul 24, 2024
d6e91ff
working version (surfaces cache?)
Jul 25, 2024
a2b5e8f
cleaned up a bit (still caching tubes)
Jul 26, 2024
b55fe88
implemented tree recursion with dummy matching function for RPC (surf…
Jul 29, 2024
0fc1acf
implemented tree recursion with dummy matching function for RPC (surf…
Jul 29, 2024
1989113
recursive RPC conversion implemented, transforms still TODO
Jul 29, 2024
16365d6
recursive RPC conversion implemented, transform first try
Jul 29, 2024
a052cfc
Merge branch 'main' into geoShapeToDetVol
Matthewharri Jul 30, 2024
f6433ff
first working version of matching function for RPCs (not general enou…
Jul 31, 2024
035343d
convert-boundingboxes flag added: converter works (hopefully) for all…
Jul 31, 2024
90648e5
implemeted ID conversion
Aug 1, 2024
cbea39c
implemeted ID conversion
Aug 1, 2024
1a5afbb
fix build issue + renaming
Aug 2, 2024
68d51a0
fix format
Aug 2, 2024
247f90c
change the version to fetch from gitlab
Aug 2, 2024
787daf5
Merge branch 'geoShapeToDetVol' of github.com:Matthewharri/acts into …
Aug 2, 2024
88f140d
implemented combined MDT and RPC conversion (hard coded bounding box …
Aug 2, 2024
169519d
first version of unit test (broke with database)
Aug 5, 2024
ee9e0e7
checked out earlier commit
Aug 6, 2024
dab6de3
fucked up git
Aug 6, 2024
7c3dfe8
fixed broken git?
Aug 6, 2024
984d0a0
first working Unit test
Aug 6, 2024
417eb76
first working unit test checking the dimensions for conv surface
Aug 6, 2024
664264b
unit test checking th dimensions of bounding box with a straw and a s…
Aug 7, 2024
6fe761f
delete separate check of cached surfaces
Aug 7, 2024
798e1d0
merged successfully with pending prs
Aug 8, 2024
a02d9a3
implemented TGC conversion including a SimplePolygonBrepConverter
Aug 13, 2024
d50c92b
implemented TGC conversion including a SimplePolygonBrepConverter
Aug 13, 2024
d3a2c36
merged with upstream and removed surfaceFactory
Aug 14, 2024
8f8c963
Merge branch 'main' into jonas-merge
Berggren-Jonas Aug 15, 2024
e911c99
CI fix
Aug 15, 2024
966473c
Merge branch 'jonas-merge' of github.com:Berggren-Jonas/acts into jon…
Aug 15, 2024
e90222b
fixed ci complaints
Aug 15, 2024
9d2f07a
merged tgc conversion with version bump
Aug 15, 2024
9113a47
removed problematic auto
Aug 15, 2024
f459a06
pre-commit
Aug 15, 2024
5d6dcd8
renamed unit test
Aug 15, 2024
71aeb32
moved unit test
Aug 15, 2024
1b4ac58
introduced polygon into unit test (need to set vertices)
Aug 16, 2024
e04c77c
improved convertBox parameter and took out database of repo
Aug 16, 2024
3f5a958
renamed unit test and deleted SurfaceFactory
Aug 16, 2024
48b1e3e
Merge branch 'main' into jonas-merge
Berggren-Jonas Aug 16, 2024
89f156b
pre-commit
Aug 16, 2024
80c4eb0
fixed PVConstLink error
Aug 16, 2024
8fd3f4c
merged with own pr
Aug 16, 2024
50d3f07
added traps to unit test (nasty vertex ordering)
Aug 19, 2024
dfd6d50
made polygon converter more robust?
Aug 19, 2024
852fba3
made tgc converter ordering independent and adder tgc to unit test
Aug 19, 2024
5cd5843
unit test for straws missing
Aug 20, 2024
eb95d1b
Update Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetecto…
Berggren-Jonas Aug 20, 2024
338bfb2
Update Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelMateria…
Berggren-Jonas Aug 20, 2024
ce90b26
Update Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp
Berggren-Jonas Aug 20, 2024
4e97dce
Update Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelToDetec…
Berggren-Jonas Aug 20, 2024
bfd0f1d
Update Plugins/GeoModel/src/detail/GeoUnionDoubleTrdConverter.cpp
Berggren-Jonas Aug 20, 2024
ccad430
Update Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Berggren-Jonas Aug 20, 2024
8840644
Update Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Berggren-Jonas Aug 20, 2024
a0aa897
Update Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelConvert…
Berggren-Jonas Aug 20, 2024
fb76559
Update Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Berggren-Jonas Aug 20, 2024
d33e81c
Update Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Berggren-Jonas Aug 20, 2024
2284bf8
Update Tests/UnitTests/Core/EventData/CMakeLists.txt
Berggren-Jonas Aug 20, 2024
4e20f7a
Update Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp
Berggren-Jonas Aug 20, 2024
44ef727
reverted cmake
Aug 20, 2024
6efa42a
Merge branch 'jonas-merge' of github.com:Berggren-Jonas/acts into jon…
Aug 20, 2024
02baaff
MaterialConverter broke
Aug 20, 2024
19cf847
did the simple changes
Aug 20, 2024
e6686de
implemented simple comments
Aug 20, 2024
aa94e9e
Merge branch 'main' into jonas-merge
Berggren-Jonas Aug 20, 2024
a343b57
fixed surface reference
Aug 21, 2024
32efa4e
Merge branch 'main' into jonas-merge
Berggren-Jonas Aug 21, 2024
c89e6a0
added straws to unit test
Aug 21, 2024
131791b
addressed some more comments
Aug 21, 2024
ead4de8
Merge branch 'jonas-merge' of github.com:Berggren-Jonas/acts into jon…
Aug 21, 2024
6847045
make clang happy
Aug 21, 2024
0e1ed90
pulled main
Aug 21, 2024
b541e40
figured out Micro Mega conversion
Aug 21, 2024
6b1915a
added Trd conversion to unit test
Aug 22, 2024
65bdd03
understood Trds
Aug 22, 2024
f8f8070
pulled main
Aug 22, 2024
c074804
addressed CI complaints
Aug 23, 2024
d80905e
lint
Aug 23, 2024
452cfa4
checkout main CMake
Aug 23, 2024
ebabb28
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 26, 2024
4eaeeae
implemented Acts::Volume function
Aug 26, 2024
5951a83
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 26, 2024
3fbca91
refactored unit test
Aug 27, 2024
1ae4c2f
lcg105 stuff
Aug 27, 2024
9317e75
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 27, 2024
fba5681
addressed comments
Aug 27, 2024
b28738b
Merge branch 'jonas-tgc' of github.com:Berggren-Jonas/acts into jonas…
Aug 27, 2024
4778f6d
synced with origin
Aug 27, 2024
3a970f9
implemented GeoIntrusivePtrs for unit test
Aug 27, 2024
dab5077
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 27, 2024
d974f8d
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 28, 2024
7aa43bd
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 28, 2024
77ef2c2
added unit test for GeoSimplePolygonBrep to surface conversion
Aug 28, 2024
e4374c0
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 28, 2024
7285734
added GeoTrdToVolume unit test
Aug 29, 2024
b07c8fc
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 29, 2024
decec6c
fixed clang-tidy?
Aug 29, 2024
8a4b6e6
added error case to unit test
Aug 29, 2024
42eda14
added GeoBox to volume test
Aug 29, 2024
85edec5
added GeoTube to unit test
Aug 29, 2024
17d4aac
clang
Aug 29, 2024
0d27860
fixed conflict
Aug 29, 2024
f4f66d6
Merge branch 'main' into jonas-refactor
Berggren-Jonas Aug 29, 2024
adbc32e
Merge branch 'main' into jonas-refactor
Berggren-Jonas Aug 30, 2024
80d35d7
addressed comments
Aug 30, 2024
b5d62e4
first working version for general volume conversion
Sep 2, 2024
c29b9a9
added the volume unit tests
Sep 2, 2024
5a1ee78
adapted test to converter changege
Sep 2, 2024
afe2092
cleaned up converter
Sep 2, 2024
5b4dff5
generalized fpv conversion
Sep 2, 2024
d14aeab
fix compiler error
Sep 2, 2024
5f5b89b
fixed merge conflict
Sep 3, 2024
bc0f630
addressed comments
Sep 3, 2024
a12a486
Merge branch 'main' into jonas-childless
Berggren-Jonas Sep 3, 2024
eee3eab
clang-tidy
Sep 4, 2024
b641321
Merge branch 'main' into jonas-childless
Berggren-Jonas Sep 4, 2024
6f15f3c
Merge branch 'jonas-childless' of github.com:Berggren-Jonas/acts into…
Sep 4, 2024
4f7cda3
Merge branch 'main' into jonas-childless
Berggren-Jonas Sep 5, 2024
c757efc
pulled main
Sep 12, 2024
fe7178e
Merge branch 'jonas-childless' of github.com:Berggren-Jonas/acts into…
Sep 12, 2024
8b1c97f
Merge branch 'main' into jonas-childless
Berggren-Jonas Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Plugins/GeoModel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_library(
src/detail/GeoBoxConverter.cpp
src/detail/GeoTrdConverter.cpp
src/detail/GeoTubeConverter.cpp
src/detail/GeoPolygonConverter.cpp
src/detail/GeoShiftConverter.cpp
src/detail/GeoIntersectionAnnulusConverter.cpp
src/detail/GeoModelBinningHelper.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Acts/Plugins/GeoModel/detail/GenericGeoShapeConverter.hpp"
#include "Acts/Plugins/GeoModel/detail/GeoBoxConverter.hpp"
#include "Acts/Plugins/GeoModel/detail/GeoIntersectionAnnulusConverter.hpp"
#include "Acts/Plugins/GeoModel/detail/GeoPolygonConverter.hpp"
#include "Acts/Plugins/GeoModel/detail/GeoShiftConverter.hpp"
#include "Acts/Plugins/GeoModel/detail/GeoTrdConverter.hpp"
#include "Acts/Plugins/GeoModel/detail/GeoTubeConverter.hpp"
Expand All @@ -37,6 +38,9 @@ namespace Acts {
using GeoBoxConverter =
detail::GenericGeoShapeConverter<GeoBox, detail::GeoBoxConverter>;

using GeoPolygonConverter =
detail::GenericGeoShapeConverter<GeoSimplePolygonBrep,
detail::GeoPolygonConverter>;
/// @brief A dedicated converter for GeoInterseciton that describe annulus bounds
///
/// This is very much tailored to the AnnulusBounds class
Expand Down Expand Up @@ -83,6 +87,8 @@ inline std::shared_ptr<const IGeoShapeConverter> geoShapesConverters(
std::make_shared<GeoShiftConverter>()},
{GeoTrd::getClassTypeID(), std::make_shared<GeoTrdConverter>()},
{GeoTube::getClassTypeID(), std::make_shared<GeoTubeConverter>()},
{GeoSimplePolygonBrep::getClassTypeID(),
std::make_shared<GeoPolygonConverter>()},
{GeoShapeUnion::getClassTypeID(),
std::make_shared<GeoUnionDoubleTrdConverter>()}};
auto itr = converters.find(geoShapeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Acts::GeoModel {
/// @param shape the GeoModel shape
/// @param transform the transform to be applied
/// @return the DetectorVolume
Volume package(const Transform3& trf, const GeoShape& shape);
std::shared_ptr<Experimental::DetectorVolume> convertVolume(
const GeometryContext& context, const GeoShape& shape,
const std::string& name, const GeoTrf::Transform3D& transform,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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/Definitions/Algebra.hpp"
#include "Acts/Plugins/GeoModel/GeoModelDetectorElement.hpp"
#include "Acts/Utilities/Result.hpp"

#include <memory>
#include <tuple>

#include <GeoModelKernel/GeoSimplePolygonBrep.h>

namespace Acts::detail {
struct GeoPolygonConverter {
/// @brief Convert a GeoBox to a detector element and surface
///
/// @param geoFPV The full physical volume to convert (contains shape)
/// @param geoBox The GeoBox to convert
/// @param absTransform from the GeoPhysVol
/// @param bool sensitive
///
/// @return The detector element and surface
Result<GeoModelSensitiveSurface> operator()(
const PVConstLink& geoPV, const GeoSimplePolygonBrep& geoPolygon,
const Transform3& absTransform, bool sensitive) const;
};
} // namespace Acts::detail
55 changes: 28 additions & 27 deletions Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@ Acts::GeoModelDetectorObjectFactory::findAllSubVolumes(const PVConstLink &vol) {
}
return sensitives;
}

bool Acts::GeoModelDetectorObjectFactory::convertBox(std::string name) {
auto convB = std::any_of(
m_cfg.convertBox.begin(), m_cfg.convertBox.end(),
[&](const auto &n) { return name.find(n) != std::string::npos; });
// return (name.find(m_cfg.convertBox) != std::string::npos);
return convB;
}

void Acts::GeoModelDetectorObjectFactory::convertFpv(
const std::string &name, GeoFullPhysVol *fpv, Cache &cache,
const GeometryContext &gctx) {
Expand All @@ -154,37 +155,37 @@ void Acts::GeoModelDetectorObjectFactory::convertFpv(
// get children
std::vector<GeoChildNodeWithTrf> subvolumes =
getChildrenWithRef(physVol, false);
if (!subvolumes.empty()) {
// vector containing all subvolumes to be converted to surfaces
std::vector<GeoChildNodeWithTrf> surfaces = findAllSubVolumes(physVol);
std::vector<GeoModelSensitiveSurface> sensitives;

for (const auto &surface : surfaces) {
const Transform3 &transform =
fpv->getAbsoluteTransform() * surface.transform;
convertSensitive(surface.volume, transform, sensitives);
}
cache.sensitiveSurfaces.insert(cache.sensitiveSurfaces.end(),
sensitives.begin(), sensitives.end());
if (convertBox(name)) {
const GeoLogVol *logVol =
physVol->getLogVol(); // get logVol for the shape of the volume
const GeoShape *shape = logVol->getShape(); // get shape
const Acts::Transform3 &fpvtransform = fpv->getAbsoluteTransform(nullptr);

// convert bounding boxes with surfaces inside
std::shared_ptr<Experimental::DetectorVolume> box =
Acts::GeoModel::convertVolume(gctx, *shape, name, fpvtransform,
sensitives);
cache.boundingBoxes.push_back(box);
}
} else {
// vector containing all subvolumes to be converted to surfaces
std::vector<GeoChildNodeWithTrf> surfaces = findAllSubVolumes(physVol);
std::vector<GeoModelSensitiveSurface> sensitives;

for (const auto &surface : surfaces) {
const Transform3 &transform =
fpv->getAbsoluteTransform() * surface.transform;
convertSensitive(surface.volume, transform, sensitives);
}
cache.sensitiveSurfaces.insert(cache.sensitiveSurfaces.end(),
sensitives.begin(), sensitives.end());
if (convertBox(name)) {
const GeoLogVol *logVol =
physVol->getLogVol(); // get logVol for the shape of the volume
const GeoShape *shape = logVol->getShape(); // get shape
const Acts::Transform3 &fpvtransform = fpv->getAbsoluteTransform(nullptr);

// convert bounding boxes with surfaces inside
std::shared_ptr<Experimental::DetectorVolume> box =
Acts::GeoModel::convertVolume(gctx, *shape, name, fpvtransform,
sensitives);
cache.boundingBoxes.push_back(box);
}
// If fpv has no subs and should not be converted to volume convert to surface
else if (subvolumes.empty()) {
// convert fpvs to surfaces
const Transform3 &transform = fpv->getAbsoluteTransform();
convertSensitive(fpv, transform, cache.sensitiveSurfaces);
}
}
// lambda to determine if object fits query
// function to determine if object fits query
bool Acts::GeoModelDetectorObjectFactory::matches(const std::string &name,
const PVConstLink &physvol) {
if (m_cfg.nameList.empty() && m_cfg.materialList.empty()) {
Expand Down
172 changes: 67 additions & 105 deletions Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,62 +29,23 @@
#include <GeoModelKernel/GeoTubs.h>

namespace Acts::GeoModel {

std::shared_ptr<Experimental::DetectorVolume> convertVolume(
const GeometryContext& context, const GeoShape& shape,
const std::string& name, const GeoTrf::Transform3D& transform,
const std::vector<GeoModelSensitiveSurface>& sensitives) {
// dummy volume for conversion with surfaces
std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>> a;

// type conversion from GeoModelSensitiveSurface to Surface
std::vector<std::shared_ptr<Surface>> sensSurfaces(sensitives.size());
std::transform(sensitives.begin(), sensitives.end(), sensSurfaces.begin(),
[](const std::tuple<std::shared_ptr<GeoModelDetectorElement>,
std::shared_ptr<Surface>>& t) {
return std::get<1>(t);
});
auto portalGenerator = Experimental::defaultPortalAndSubPortalGenerator();
Volume package(const Transform3& trf, const GeoShape& shape) {
std::shared_ptr<const VolumeBounds> bounds;
GeoTrf::Transform3D newTrf = trf;
if (shape.typeID() == GeoTube::getClassTypeID()) {
const GeoTube* tube = dynamic_cast<const GeoTube*>(&shape);
std::shared_ptr<CylinderVolumeBounds> bounds =
std::make_shared<CylinderVolumeBounds>(tube->getRMin(), tube->getRMax(),
tube->getZHalfLength());
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, transform, bounds,
Experimental::tryAllPortalsAndSurfaces());
bounds = std::make_shared<CylinderVolumeBounds>(
tube->getRMin(), tube->getRMax(), tube->getZHalfLength());
} else if (shape.typeID() == GeoTubs::getClassTypeID()) {
const GeoTubs* tubs = dynamic_cast<const GeoTubs*>(&shape);
std::shared_ptr<CylinderVolumeBounds> bounds =
std::make_shared<CylinderVolumeBounds>(tubs->getRMin(), tubs->getRMax(),
tubs->getZHalfLength(),
tubs->getDPhi() / 2);
GeoTrf::Transform3D newTransform =
transform * GeoTrf::RotateZ3D(tubs->getSPhi() + 0.5 * tubs->getDPhi());
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, newTransform, bounds,
Experimental::tryAllPortalsAndSurfaces());
bounds = std::make_shared<CylinderVolumeBounds>(
tubs->getRMin(), tubs->getRMax(), tubs->getZHalfLength(),
tubs->getDPhi() / 2);
newTrf = trf * GeoTrf::RotateZ3D(tubs->getSPhi() + 0.5 * tubs->getDPhi());
} else if (shape.typeID() == GeoBox::getClassTypeID()) {
// TODO do the surfaces
const GeoBox* box = dynamic_cast<const GeoBox*>(&shape);
std::shared_ptr<CuboidVolumeBounds> bounds =
std::make_shared<CuboidVolumeBounds>(box->getXHalfLength(),
box->getYHalfLength(),
box->getZHalfLength());
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, transform, bounds, sensSurfaces, a,
Experimental::tryNoVolumes(), Experimental::tryAllPortalsAndSurfaces());
} else if (shape.typeID() == GeoSimplePolygonBrep::getClassTypeID()) {
const GeoSimplePolygonBrep* brep =
dynamic_cast<const GeoSimplePolygonBrep*>(&shape);
double xmin{0}, xmax{0}, ymin{0}, ymax{0}, zmin{0}, zmax{0};
brep->extent(xmin, ymin, zmin, xmax, ymax, zmax);
std::shared_ptr<CuboidVolumeBounds> bounds =
std::make_shared<CuboidVolumeBounds>(
(xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, transform, bounds,
Experimental::tryAllPortalsAndSurfaces());
bounds = std::make_shared<const CuboidVolumeBounds>(
box->getXHalfLength(), box->getYHalfLength(), box->getZHalfLength());
} else if (shape.typeID() == GeoTrd::getClassTypeID()) {
const GeoTrd* trd = dynamic_cast<const GeoTrd*>(&shape);
double x1 = trd->getXHalfLength1();
Expand All @@ -96,93 +57,94 @@ std::shared_ptr<Experimental::DetectorVolume> convertVolume(
if (y1 == y2) {
if (x1 <= x2) {
// y axis in ACTS is z axis in geomodel
std::shared_ptr<TrapezoidVolumeBounds> bounds =
std::make_shared<TrapezoidVolumeBounds>(x1, x2, z, y1);
bounds = std::make_shared<TrapezoidVolumeBounds>(x1, x2, z, y1);
constexpr double rotationAngle = M_PI / 2;
GeoTrf::Transform3D newTransform =
transform * GeoTrf::RotateX3D(rotationAngle);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, newTransform, bounds, sensSurfaces,
a, Experimental::tryNoVolumes(),
Experimental::tryAllPortalsAndSurfaces());
newTrf = trf * GeoTrf::RotateX3D(rotationAngle);
} else {
std::shared_ptr<TrapezoidVolumeBounds> bounds =
std::make_shared<TrapezoidVolumeBounds>(x2, x1, z, y1);
bounds = std::make_shared<TrapezoidVolumeBounds>(x2, x1, z, y1);
constexpr double rotationAngle = M_PI;
GeoTrf::Transform3D newTransform = transform *
GeoTrf::RotateY3D(rotationAngle) *
GeoTrf::RotateZ3D(rotationAngle);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, newTransform, bounds, sensSurfaces,
a, Experimental::tryNoVolumes(),
Experimental::tryAllPortalsAndSurfaces());
newTrf = trf * GeoTrf::RotateY3D(rotationAngle) *
GeoTrf::RotateZ3D(rotationAngle);
}
} else if (x1 == x2) {
if (y1 < y2) {
std::shared_ptr<TrapezoidVolumeBounds> bounds =
std::make_shared<TrapezoidVolumeBounds>(y1, y2, z, x1);
bounds = std::make_shared<TrapezoidVolumeBounds>(y1, y2, z, x1);
auto rotationAngle = M_PI / 2;
GeoTrf::Transform3D newTransform = transform *
GeoTrf::RotateZ3D(rotationAngle) *
GeoTrf::RotateX3D(rotationAngle);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, newTransform, bounds, sensSurfaces,
a, Experimental::tryNoVolumes(),
Experimental::tryAllPortalsAndSurfaces());
newTrf = trf * GeoTrf::RotateZ3D(rotationAngle) *
GeoTrf::RotateX3D(rotationAngle);
} else {
std::shared_ptr<TrapezoidVolumeBounds> bounds =
std::make_shared<TrapezoidVolumeBounds>(y2, y1, z, x1);
bounds = std::make_shared<TrapezoidVolumeBounds>(y2, y1, z, x1);
auto rotationAngle = M_PI;
GeoTrf::Transform3D newTransform =
transform * GeoTrf::RotateX3D(rotationAngle) *
GeoTrf::RotateZ3D(rotationAngle / 2) *
GeoTrf::RotateX3D(rotationAngle / 2);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, newTransform, bounds, sensSurfaces,
a, Experimental::tryNoVolumes(),
Experimental::tryAllPortalsAndSurfaces());
newTrf = trf * GeoTrf::RotateX3D(rotationAngle) *
GeoTrf::RotateZ3D(rotationAngle / 2) *
GeoTrf::RotateX3D(rotationAngle / 2);
}
} else {
throw std::runtime_error("FATAL: Translating GeoTrd to ACTS failed");
}
} else if (shape.typeID() == GeoShapeUnion::getClassTypeID()) {
}

else if (shape.typeID() == GeoShapeUnion::getClassTypeID()) {
const GeoShapeUnion* unionShape =
dynamic_cast<const GeoShapeUnion*>(&shape);
double xmin{0}, xmax{0}, ymin{0}, ymax{0}, zmin{0}, zmax{0};
unionShape->extent(xmin, ymin, zmin, xmax, ymax, zmax);
std::shared_ptr<CuboidVolumeBounds> bounds =
std::make_shared<CuboidVolumeBounds>(
(xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, transform, bounds,
Experimental::tryAllPortalsAndSurfaces());
bounds = std::make_shared<CuboidVolumeBounds>(
(xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2);
} else if (shape.typeID() == GeoShapeSubtraction::getClassTypeID()) {
// Go down the left side (opA) of the subtraction until we reach a normal
// shape
const GeoShapeSubtraction* subtractionShape =
dynamic_cast<const GeoShapeSubtraction*>(&shape);
const GeoShape* shapeA = subtractionShape->getOpA();
return convertVolume(context, *shapeA, name, transform, sensitives);
return package(trf, *shapeA);
Berggren-Jonas marked this conversation as resolved.
Show resolved Hide resolved
} else if (shape.typeID() == GeoShapeSubtraction::getClassTypeID()) {
// Go down the left side (opA) of the subtraction until we reach a normal
// shape
const GeoShapeSubtraction* subtractionShape =
dynamic_cast<const GeoShapeSubtraction*>(&shape);
const GeoShape* shapeA = subtractionShape->getOpA();
return package(trf, *shapeA);
} else if (shape.typeID() == GeoPcon::getClassTypeID()) {
// Will change in future, get bounding box for now
double xmin{0}, xmax{0}, ymin{0}, ymax{0}, zmin{0}, zmax{0};
const GeoPcon* pcon = dynamic_cast<const GeoPcon*>(&shape);
pcon->extent(xmin, ymin, zmin, xmax, ymax, zmax);
std::shared_ptr<CuboidVolumeBounds> bounds =
std::make_shared<CuboidVolumeBounds>(
(xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, transform, bounds,
Experimental::tryAllPortalsAndSurfaces());
}
if (shape.typeID() == GeoShapeShift::getClassTypeID()) {
bounds = std::make_shared<CuboidVolumeBounds>(
(xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2);
} else if (shape.typeID() == GeoShapeShift::getClassTypeID()) {
const GeoShapeShift* shiftShape =
dynamic_cast<const GeoShapeShift*>(&shape);
const GeoShape* shapeOp = shiftShape->getOp();
GeoTrf::Transform3D newTransform = transform * shiftShape->getX();
return convertVolume(context, *shapeOp, name, newTransform, sensitives);
newTrf = trf * shiftShape->getX();
return package(trf, *shapeOp);
} else {
throw std::runtime_error("FATAL: Unsupported GeoModel shape");
}
throw std::runtime_error("FATAL: Unsupported GeoModel shape");

Volume vol = Volume(newTrf, bounds);
return vol;
}

std::shared_ptr<Experimental::DetectorVolume> convertVolume(
const GeometryContext& context, const GeoShape& shape,
const std::string& name, const GeoTrf::Transform3D& transform,
const std::vector<GeoModelSensitiveSurface>& sensitives) {
// type conversion from GeoModelSensitiveSurface to Surface
std::vector<std::shared_ptr<Surface>> sensSurfaces(sensitives.size());
std::transform(sensitives.begin(), sensitives.end(), sensSurfaces.begin(),
[](const std::tuple<std::shared_ptr<GeoModelDetectorElement>,
std::shared_ptr<Surface>>& t) {
return std::get<1>(t);
});
auto portalGenerator = Experimental::defaultPortalAndSubPortalGenerator();
Volume vol = package(transform, shape);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, vol.transform(),
std::const_pointer_cast<VolumeBounds>(vol.volumeBoundsPtr()),
sensSurfaces,
std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>>{},
Experimental::tryNoVolumes(), Experimental::tryAllPortalsAndSurfaces());
}

} // namespace Acts::GeoModel
Loading