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: GeoModel conversion for TGC, sTGC and MicroMega #3540

Merged
merged 171 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 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
5951a83
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 26, 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
e4374c0
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 28, 2024
b07c8fc
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 29, 2024
decec6c
fixed clang-tidy?
Aug 29, 2024
7069e34
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 29, 2024
a791f9a
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 30, 2024
43f8b2c
addressed comments
Aug 30, 2024
d06d502
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 30, 2024
d8c66ee
Merge branch 'main' into jonas-tgc
Berggren-Jonas Aug 30, 2024
2107f3c
Merge branch 'main' into jonas-tgc
kodiakhq[bot] Aug 30, 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
@@ -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
3 changes: 2 additions & 1 deletion 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 Down
1 change: 0 additions & 1 deletion Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ std::shared_ptr<Experimental::DetectorVolume> convertVolume(
portalGenerator, context, name, newTransform, bounds,
Experimental::tryAllPortalsAndSurfaces());
} 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(),
Expand Down
125 changes: 125 additions & 0 deletions Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// 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/detail/GeoPolygonConverter.hpp"

#include "Acts/Definitions/Common.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/Plugins/GeoModel/GeoModelConversionError.hpp"
#include "Acts/Surfaces/DiamondBounds.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Surfaces/TrapezoidBounds.hpp"

#include <GeoModelKernel/GeoBox.h>
#include <GeoModelKernel/GeoFullPhysVol.h>
#include <GeoModelKernel/GeoLogVol.h>
#include <GeoModelKernel/GeoShape.h>
#include <GeoModelKernel/Units.h>

Acts::Result<Acts::GeoModelSensitiveSurface>
Acts::detail::GeoPolygonConverter::operator()(
const PVConstLink& geoPV, const GeoSimplePolygonBrep& polygon,
const Transform3& absTransform, bool sensitive) const {
/// auto-calculate the unit length conversion
static constexpr ActsScalar unitLength =
Acts::UnitConstants::mm / GeoModelKernelUnits::millimeter;

// Create the surface transform
Transform3 transform = Transform3::Identity();
transform.translation() = unitLength * absTransform.translation();
auto rotation = absTransform.rotation();
// Get the half lengths
int nVertices = polygon.getNVertices();
std::vector<std::vector<double>> vertices;

for (int i = 0; i < nVertices; i++) {
vertices.push_back({polygon.getXVertex(i), polygon.getYVertex(i)});
}
// sort based on the y-coordinate
std::sort(vertices.begin(), vertices.end(),
[](const std::vector<double>& a, const std::vector<double>& b) {
return a[1] < b[1];
});
if (nVertices == 4) {
double hlxnegy = fabs(vertices[0][0] - vertices[1][0]) / 2;
double hlxposy = fabs(vertices[2][0] - vertices[3][0]) / 2;
double hly = fabs(vertices[0][1] - vertices[3][1]) / 2;
std::vector<ActsScalar> halfLengths = {hlxnegy, hlxposy, hly};

// Create the surface
Vector3 colX = rotation.col(0);
Vector3 colY = rotation.col(1);
Vector3 colZ = rotation.col(2);
rotation.col(0) = colX;
rotation.col(1) = colY;
rotation.col(2) = colZ;
transform.linear() = rotation;
// Create the surface bounds
ActsScalar halfXnegY = unitLength * halfLengths[0];
ActsScalar halfXposY = unitLength * halfLengths[1];
ActsScalar halfY = unitLength * halfLengths[2];
auto trapBounds =
std::make_shared<Acts::TrapezoidBounds>(halfXnegY, halfXposY, halfY);
if (!sensitive) {
auto surface = Surface::makeShared<PlaneSurface>(transform, trapBounds);
return std::make_tuple(nullptr, surface);
}
// Create the element and the surface
auto detectorElement =
GeoModelDetectorElement::createDetectorElement<PlaneSurface>(
geoPV, trapBounds, transform, unitLength * polygon.getDZ());
auto surface = detectorElement->surface().getSharedPtr();
// Return the detector element and surface
return std::make_tuple(detectorElement, surface);
} else if (nVertices == 6) {
double hlxnegy = fabs(vertices[0][0] - vertices[1][0]) / 2;
double hlxzeroy = fabs(vertices[2][0] - vertices[3][0]) / 2;
double hlxposy = fabs(vertices[4][0] - vertices[5][0]) / 2;
double hly = fabs(vertices[0][1] - vertices[4][1]) / 2;
std::vector<ActsScalar> halfLengths = {hlxnegy, hlxzeroy, hlxposy, hly,
hly};

// Create the surface

Vector3 colX = rotation.col(0);
Vector3 colY = rotation.col(1);
Vector3 colZ = rotation.col(2);
rotation.col(0) = colX;
rotation.col(1) = colY;
rotation.col(2) = colZ;
transform.linear() = rotation;

// Create the surface bounds
ActsScalar halfXnegY = unitLength * halfLengths[0];
ActsScalar halfXzeroY = unitLength * halfLengths[1];
ActsScalar halfXposY = unitLength * halfLengths[2];
ActsScalar halfYnegX = unitLength * halfLengths[3];
ActsScalar halfYposX = unitLength * halfLengths[4];

auto diamondBounds = std::make_shared<Acts::DiamondBounds>(
halfXnegY, halfXzeroY, halfXposY, halfYnegX, halfYposX);
if (!sensitive) {
auto surface =
Surface::makeShared<PlaneSurface>(transform, diamondBounds);
return std::make_tuple(nullptr, surface);
}
// Create the element and the surface
auto detectorElement =
GeoModelDetectorElement::createDetectorElement<PlaneSurface>(
geoPV, diamondBounds, transform, unitLength * polygon.getDZ());
auto surface = detectorElement->surface().getSharedPtr();
// Return the detector element and surface
return std::make_tuple(detectorElement, surface);
} else {
throw std::runtime_error("GeoSimplePolygonBrep with " +
std::to_string(nVertices) +
" can not be converted");
}
}
4 changes: 2 additions & 2 deletions Plugins/GeoModel/src/detail/GeoTrdConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Acts::detail::GeoTrdConverter::operator()(const PVConstLink& geoPV,
Transform3 transform = Transform3::Identity();
transform.translation() = unitLength * absTransform.translation();

// GeoTrd is defined that halfZ needs to map onto surface halfY
// Create the surface
// GeoTrd coordinates: x is the extrusion direction, y is orthogonal to the
// symmetry axis and z is along the symmetry axis
ActsScalar halfX1 = geoTrd.getXHalfLength1();
ActsScalar halfX2 = geoTrd.getXHalfLength2();
ActsScalar halfY1 = geoTrd.getYHalfLength1();
Expand Down
110 changes: 83 additions & 27 deletions Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

#include "Acts/Plugins/GeoModel/GeoModelDetectorObjectFactory.hpp"
#include "Acts/Plugins/GeoModel/GeoModelReader.hpp"
#include "Acts/Surfaces/CylinderBounds.hpp"
#include "Acts/Surfaces/DiamondBounds.hpp"
#include "Acts/Surfaces/LineBounds.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Surfaces/StrawSurface.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Surfaces/TrapezoidBounds.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <typeinfo>
Expand All @@ -22,38 +26,69 @@
#include <GeoModelKernel/GeoFullPhysVol.h>
#include <GeoModelKernel/GeoLogVol.h>
#include <GeoModelKernel/GeoMaterial.h>
#include <GeoModelKernel/GeoSimplePolygonBrep.h>
#include <GeoModelKernel/GeoTrd.h>
#include <GeoModelKernel/GeoTube.h>

BOOST_AUTO_TEST_SUITE(GeoModelDetObj)

BOOST_AUTO_TEST_CASE(GeoModelDetectorObjectFactory) {
// define materials
auto material = new GeoMaterial("Material", 1.0);
auto al = new GeoMaterial("Aluminium", 1.0);
GeoIntrusivePtr<GeoMaterial> material(new GeoMaterial("Material", 1.0));
GeoIntrusivePtr<GeoMaterial> al(new GeoMaterial("Aluminium", 1.0));

// define dimensions
double gmhlx = 100, gmhly = 200, gmhlz = 2;
double gmrmin = 5, gmrmax = 5, gmhlzt = 100;
double gmhlxs = 100, gmhlys = 200, gmhlzs = 2;
double gmBoxHlx = 100, gmBoxHly = 200, gmBoxHlz = 2;
double gmTubeRmin = 5, gmTubeRmax = 6, gmTubeHlz = 100;
double gmRsurfHlx = 100, gmRsurfHly = 200, gmRsurfHlz = 2;
double gmPolyZ = 2;
std::vector<double> trapXVerts = {-103, 103, 183, -183};
std::vector<double> trapYVerts = {-50, -50, 50, 50};
std::vector<double> polyXVerts = {-60, 60, 153, 123, -123, -153};
std::vector<double> polyYVerts = {-50, -50, 0, 50, 50, 0};

// create shapes
auto boxXY = new GeoBox(gmhlx, gmhly, gmhlz);
auto tube = new GeoTube(gmrmin, gmrmax, gmhlzt);
auto ssurface = new GeoBox(gmhlxs, gmhlys, gmhlzs);
GeoIntrusivePtr<GeoBox> boxXY(new GeoBox(gmBoxHlx, gmBoxHly, gmBoxHlz));
GeoIntrusivePtr<GeoTube> tube(new GeoTube(gmTubeRmin, gmTubeRmax, gmTubeHlz));
GeoIntrusivePtr<GeoBox> ssurface(
new GeoBox(gmRsurfHlx, gmRsurfHly, gmRsurfHlz));
double halfX1 = fabs(trapXVerts[0] - trapXVerts[1]) / 2;
double halfX2 = fabs(trapXVerts[2] - trapXVerts[3]) / 2;
double halfY1 = fabs(trapYVerts[0] - trapYVerts[2]) / 2;
GeoIntrusivePtr<GeoTrd> trd(new GeoTrd(1, 1, halfX1, halfX2, halfY1));
GeoIntrusivePtr<GeoSimplePolygonBrep> trap(new GeoSimplePolygonBrep(gmPolyZ));
for (long unsigned int i = 0; i < trapXVerts.size(); i++) {
trap->addVertex(trapXVerts[i], trapYVerts[i]);
}
GeoIntrusivePtr<GeoSimplePolygonBrep> poly(new GeoSimplePolygonBrep(gmPolyZ));
for (long unsigned int i = 0; i < polyXVerts.size(); i++) {
poly->addVertex(polyXVerts[i], polyYVerts[i]);
}

// create logvols
auto logXY = new GeoLogVol("LogVolumeXY", boxXY, material);
auto logTube = new GeoLogVol("LogTube", tube, al);
auto logSurface = new GeoLogVol("LogSurface", ssurface, al);
GeoIntrusivePtr<GeoLogVol> logXY(
new GeoLogVol("LogVolumeXY", boxXY, material.get()));
GeoIntrusivePtr<GeoLogVol> logTube(new GeoLogVol("LogTube", tube, al));
GeoIntrusivePtr<GeoLogVol> logSurface(
new GeoLogVol("LogSurface", ssurface, al));
GeoIntrusivePtr<GeoLogVol> logTrap(new GeoLogVol("LogTrap", trap, al));
GeoIntrusivePtr<GeoLogVol> logTrd(new GeoLogVol("LogTrd", trd, al));
GeoIntrusivePtr<GeoLogVol> logPoly(new GeoLogVol("LogPoly", poly, al));

// create physvols
auto fphysXY = new GeoFullPhysVol(logXY);
auto physTube = new GeoFullPhysVol(logTube);
auto physSurface = new GeoFullPhysVol(logSurface);
GeoIntrusivePtr<GeoFullPhysVol> fphysXY(new GeoFullPhysVol(logXY));
GeoIntrusivePtr<GeoFullPhysVol> physTube(new GeoFullPhysVol(logTube));
GeoIntrusivePtr<GeoFullPhysVol> physSurface(new GeoFullPhysVol(logSurface));
GeoIntrusivePtr<GeoFullPhysVol> physTrap(new GeoFullPhysVol(logTrap));
GeoIntrusivePtr<GeoFullPhysVol> physTrd(new GeoFullPhysVol(logTrd));
GeoIntrusivePtr<GeoFullPhysVol> physPoly(new GeoFullPhysVol(logPoly));

// build hierarchy
fphysXY->add(physTube);
fphysXY->add(physSurface);
fphysXY->add(physTrap);
fphysXY->add(physTrd);
fphysXY->add(physPoly);

PVConstLink physVol{fphysXY};
auto rBounds = std::make_shared<Acts::RectangleBounds>(100, 200);
Expand All @@ -73,29 +108,50 @@ BOOST_AUTO_TEST_CASE(GeoModelDetectorObjectFactory) {
// checking the dimension of the converted bounding boxes
for (const auto& box : gmCache.boundingBoxes) {
const Acts::VolumeBounds& bounds = box->volumeBounds();
BOOST_CHECK(gmhlx == bounds.values()[0]);
BOOST_CHECK(gmhly == bounds.values()[1]);
BOOST_CHECK(gmhlz == bounds.values()[2]);
BOOST_CHECK(gmBoxHlx == bounds.values()[0]);
BOOST_CHECK(gmBoxHly == bounds.values()[1]);
BOOST_CHECK(gmBoxHlz == bounds.values()[2]);
std::vector<const Acts::Surface*> surfaces = box->surfaces();

for (auto surface : surfaces) {
const Acts::SurfaceBounds& sbounds = surface->bounds();
// Straw check outer radius and length without trf
// check straws
if (surface->type() == Acts::Surface::SurfaceType::Straw) {
BOOST_CHECK(sbounds.values()[0] == gmrmax);
BOOST_CHECK(sbounds.values()[1] == gmhlzt);
const auto* lineBounds =
dynamic_cast<const Acts::LineBounds*>(&sbounds);
BOOST_CHECK(gmTubeRmax == lineBounds->get(Acts::LineBounds::eR));
BOOST_CHECK(gmTubeHlz ==
lineBounds->get(Acts::LineBounds::eHalfLengthZ));
}

// plane Surface check corner position without trf
if (surface->type() == Acts::Surface::SurfaceType::Plane) {
// rectangle Surface check corner position without trf
if (sbounds.type() == Acts::SurfaceBounds::eRectangle) {
double csxmin = sbounds.values()[0];
double csymin = sbounds.values()[1];
double csxmax = sbounds.values()[2];
double csymax = sbounds.values()[3];
BOOST_CHECK(gmhlxs == -csxmin);
BOOST_CHECK(gmhlys == -csymin);
BOOST_CHECK(gmhlxs == csxmax);
BOOST_CHECK(gmhlys == csymax);
BOOST_CHECK(gmRsurfHlx == -csxmin);
BOOST_CHECK(gmRsurfHly == -csymin);
BOOST_CHECK(gmRsurfHlx == csxmax);
BOOST_CHECK(gmRsurfHly == csymax);
}
// trap Surface without trf
if (sbounds.type() == Acts::SurfaceBounds::eTrapezoid) {
const auto* trapBounds =
dynamic_cast<const Acts::TrapezoidBounds*>(&sbounds);
std::vector<Acts::Vector2> trapVerts = trapBounds->vertices();
for (long unsigned int i = 0; i < trapVerts.size(); i++) {
BOOST_CHECK(trapVerts[i][0] == trapXVerts[i]);
BOOST_CHECK(trapVerts[i][1] == trapYVerts[i]);
}
}
if (sbounds.type() == Acts::SurfaceBounds::eDiamond) {
const auto* polyBounds =
dynamic_cast<const Acts::DiamondBounds*>(&sbounds);
std::vector<Acts::Vector2> polyVerts = polyBounds->vertices();
for (long unsigned int i = 0; i < polyVerts.size(); i++) {
BOOST_CHECK(polyVerts[i][0] == polyXVerts[i]);
BOOST_CHECK(polyVerts[i][1] == polyYVerts[i]);
}
}
}
}
Expand Down
Loading