Skip to content

Commit

Permalink
feat: Extend telescope detector with disc surface (#680)
Browse files Browse the repository at this point in the history
This PR extends the telescope detector to be configurable with either PlaneSurface or DiscSurface. This will allow for reco test with the DiscSurface.
  • Loading branch information
XiaocongAi committed Jan 29, 2021
1 parent 91c52d2 commit 9efc8fc
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-2021 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
Expand All @@ -19,21 +19,31 @@
namespace ActsExamples {
namespace Telescope {

/// The telescope detector surface type
enum class TelescopeSurfaceType {
Plane = 0,
Disc = 1,
};

/// Global method to build the telescope tracking geometry
///
/// @param gctx is the detector element dependent geometry context
/// @param detectorStore is the store for the detector element
/// @param positions is the offset w of different layers in the longitudinal
/// direction
/// @param offsets is the offset (u, v) of the layers in the transverse plane
/// @param pSize is the plane size
/// @param bounds is the surface bound values, i.e. halfX and halfY if plane
/// surface, and minR and maxR if disc surface
/// @param thickness is the material thickness of each layer
/// @param binValue indicates which axis the planes normals are parallel to
/// @param surfaceType is the detector surface type
/// @param binValue indicates which axis the detector surface normals are
/// parallel to
std::unique_ptr<const Acts::TrackingGeometry> buildDetector(
const typename TelescopeDetectorElement::ContextType& gctx,
std::vector<std::shared_ptr<TelescopeDetectorElement>>& detectorStore,
const std::vector<double>& positions, std::array<double, 2> offsets,
std::array<double, 2> pSize, double thickness,
const std::vector<double>& positions, const std::array<double, 2>& offsets,
const std::array<double, 2>& bounds, double thickness,
TelescopeSurfaceType surfaceType,
Acts::BinningValue binValue = Acts::BinningValue::binZ);

} // end of namespace Telescope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-2021 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
Expand All @@ -13,6 +13,7 @@
namespace Acts {
class Surface;
class PlanarBounds;
class DiscBounds;
class ISurfaceMaterial;
} // namespace Acts

Expand Down Expand Up @@ -44,6 +45,18 @@ class TelescopeDetectorElement : public Acts::DetectorElementBase {
std::shared_ptr<const Acts::PlanarBounds> pBounds, double thickness,
std::shared_ptr<const Acts::ISurfaceMaterial> material = nullptr);

/// Constructor for single sided detector element
/// - bound to a Disc Surface
///
/// @param transform is the transform that element the layer in 3D frame
/// @param dBounds is the planar bounds for the disc like detector element
/// @param thickness is the module thickness
/// @param material is the (optional) Surface material associated to it
TelescopeDetectorElement(
std::shared_ptr<const Acts::Transform3> transform,
std::shared_ptr<const Acts::DiscBounds> dBounds, double thickness,
std::shared_ptr<const Acts::ISurfaceMaterial> material = nullptr);

/// Destructor
~TelescopeDetectorElement() override = default;

Expand Down Expand Up @@ -89,6 +102,8 @@ class TelescopeDetectorElement : public Acts::DetectorElementBase {
double m_elementThickness = 0.;
/// the planar bounds
std::shared_ptr<const Acts::PlanarBounds> m_elementPlanarBounds = nullptr;
/// the disc bounds
std::shared_ptr<const Acts::DiscBounds> m_elementDiscBounds = nullptr;
};

inline const Acts::Surface& TelescopeDetectorElement::surface() const {
Expand Down
55 changes: 40 additions & 15 deletions Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-2021 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
Expand All @@ -11,6 +11,8 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/Geometry/CuboidVolumeBounds.hpp"
#include "Acts/Geometry/CylinderVolumeBounds.hpp"
#include "Acts/Geometry/DiscLayer.hpp"
#include "Acts/Geometry/LayerArrayCreator.hpp"
#include "Acts/Geometry/LayerCreator.hpp"
#include "Acts/Geometry/PlaneLayer.hpp"
Expand All @@ -21,7 +23,7 @@
#include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
#include "Acts/Material/Material.hpp"
#include "Acts/Material/ProtoSurfaceMaterial.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"
#include "Acts/Surfaces/RadialBounds.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Surfaces/SurfaceArray.hpp"
#include "Acts/Utilities/Logger.hpp"
Expand All @@ -33,14 +35,18 @@ ActsExamples::Telescope::buildDetector(
std::vector<
std::shared_ptr<ActsExamples::Telescope::TelescopeDetectorElement>>&
detectorStore,
const std::vector<double>& positions, std::array<double, 2> offsets,
std::array<double, 2> pSize, double thickness,
const std::vector<double>& positions, const std::array<double, 2>& offsets,
const std::array<double, 2>& bounds, double thickness,
ActsExamples::Telescope::TelescopeSurfaceType surfaceType,
Acts::BinningValue binValue) {
using namespace Acts::UnitLiterals;

// The rectangle bounds
const auto rBounds = std::make_shared<const Acts::RectangleBounds>(
Acts::RectangleBounds(pSize[0] * 0.5, pSize[1] * 0.5));
// The rectangle bounds for plane surface
const auto pBounds =
std::make_shared<const Acts::RectangleBounds>(bounds[0], bounds[1]);
// The radial bounds for disc surface
const auto rBounds =
std::make_shared<const Acts::RadialBounds>(bounds[0], bounds[1]);

// Material of the surfaces
Acts::Material silicon = Acts::Material::fromMassDensity(
Expand Down Expand Up @@ -73,9 +79,16 @@ ActsExamples::Telescope::buildDetector(
// The transform
Acts::Transform3 trafo(rotation * trans);
// Create the detector element
auto detElement = std::make_shared<TelescopeDetectorElement>(
std::make_shared<const Acts::Transform3>(trafo), rBounds, 1._um,
surfaceMaterial);
std::shared_ptr<TelescopeDetectorElement> detElement = nullptr;
if (surfaceType == TelescopeSurfaceType::Plane) {
detElement = std::make_shared<TelescopeDetectorElement>(
std::make_shared<const Acts::Transform3>(trafo), pBounds, 1._um,
surfaceMaterial);
} else {
detElement = std::make_shared<TelescopeDetectorElement>(
std::make_shared<const Acts::Transform3>(trafo), rBounds, 1._um,
surfaceMaterial);
}
// Get the surface
auto surface = detElement->surface().getSharedPtr();
// Add the detector element to the detector store
Expand All @@ -84,8 +97,13 @@ ActsExamples::Telescope::buildDetector(
std::unique_ptr<Acts::SurfaceArray> surArray(
new Acts::SurfaceArray(surface));
// Construct the layer
layers[i] =
Acts::PlaneLayer::create(trafo, rBounds, std::move(surArray), 1._mm);
if (surfaceType == TelescopeSurfaceType::Plane) {
layers[i] =
Acts::PlaneLayer::create(trafo, pBounds, std::move(surArray), 1._mm);
} else {
layers[i] =
Acts::DiscLayer::create(trafo, rBounds, std::move(surArray), 1._mm);
}
// Associate the layer to the surface
auto mutableSurface = const_cast<Acts::Surface*>(surface.get());
mutableSurface->associateLayer(*layers[i]);
Expand All @@ -96,10 +114,17 @@ ActsExamples::Telescope::buildDetector(
(positions.front() + positions.back()) * 0.5);
Acts::Transform3 trafoVol(rotation * transVol);

// The volume bounds is set to be a bit larger than cubic with planes
// The volume bounds is set to be a bit larger than either cubic with planes
// or cylinder with discs
auto length = positions.back() - positions.front();
auto boundsVol = std::make_shared<const Acts::CuboidVolumeBounds>(
pSize[0] * 0.5 + 5._mm, pSize[1] * 0.5 + 5._mm, length + 10._mm);
Acts::VolumeBoundsPtr boundsVol = nullptr;
if (surfaceType == TelescopeSurfaceType::Plane) {
boundsVol = std::make_shared<const Acts::CuboidVolumeBounds>(
bounds[0] + 5._mm, bounds[1] + 5._mm, length + 10._mm);
} else {
boundsVol = std::make_shared<const Acts::CylinderVolumeBounds>(
std::max(bounds[0] - 5.0_mm, 0.), bounds[1] + 5._mm, length + 10._mm);
}

Acts::LayerArrayCreator::Config lacConfig;
Acts::LayerArrayCreator layArrCreator(
Expand Down
25 changes: 20 additions & 5 deletions Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-2021 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
Expand Down Expand Up @@ -34,20 +34,35 @@ auto TelescopeDetector::finalize(
.values;
auto offsets =
vm["geo-tele-offsets"].template as<ActsExamples::Options::Reals<2>>();
auto pSize =
vm["geo-tele-size"].template as<ActsExamples::Options::Reals<2>>();
// The bounds values are taken as (halfX, halfY) for plane surface and
// (minR, maxR) for disc surface
auto bounds =
vm["geo-tele-bounds"].template as<ActsExamples::Options::Reals<2>>();
// Translate the thickness in unit of mm
auto thickness = vm["geo-tele-thickness"].template as<double>() * 0.001;
auto binValue = vm["geo-tele-alignaxis"].template as<size_t>();
auto surfaceType = vm["geo-tele-surface"].template as<int>();
auto binValue = vm["geo-tele-alignaxis"].template as<int>();
if (surfaceType > 1) {
throw std::invalid_argument(
"The surface type could either be 0 for plane surface or 1 for disc "
"surface.");
}
if (binValue > 2) {
throw std::invalid_argument("The axis value could only be 0, 1, or 2.");
}
// Check if the bounds values are valid
if (surfaceType == 1 and bounds[0] >= bounds[1]) {
throw std::invalid_argument(
"The minR should be smaller than the maxR for disc surface bounds.");
}

// Sort the provided distances
std::sort(positions.begin(), positions.end());

/// Return the telescope detector
TrackingGeometryPtr gGeometry = ActsExamples::Telescope::buildDetector(
nominalContext, detectorStore, positions, offsets, pSize, thickness,
nominalContext, detectorStore, positions, offsets, bounds, thickness,
static_cast<ActsExamples::Telescope::TelescopeSurfaceType>(surfaceType),
static_cast<Acts::BinningValue>(binValue));
ContextDecorators gContextDecorators = {};
// return the pair of geometry and empty decorators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-2021 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/TelescopeDetector/TelescopeDetectorElement.hpp"

#include "Acts/Surfaces/DiscBounds.hpp"
#include "Acts/Surfaces/DiscSurface.hpp"
#include "Acts/Surfaces/PlanarBounds.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"

Expand All @@ -20,7 +22,24 @@ ActsExamples::Telescope::TelescopeDetectorElement::TelescopeDetectorElement(
m_elementSurface(
Acts::Surface::makeShared<Acts::PlaneSurface>(pBounds, *this)),
m_elementThickness(thickness),
m_elementPlanarBounds(std::move(pBounds)) {
m_elementPlanarBounds(std::move(pBounds)),
m_elementDiscBounds(nullptr) {
auto mutableSurface =
std::const_pointer_cast<Acts::Surface>(m_elementSurface);
mutableSurface->assignSurfaceMaterial(material);
}

ActsExamples::Telescope::TelescopeDetectorElement::TelescopeDetectorElement(
std::shared_ptr<const Acts::Transform3> transform,
std::shared_ptr<const Acts::DiscBounds> dBounds, double thickness,
std::shared_ptr<const Acts::ISurfaceMaterial> material)
: Acts::DetectorElementBase(),
m_elementTransform(std::move(transform)),
m_elementSurface(
Acts::Surface::makeShared<Acts::DiscSurface>(dBounds, *this)),
m_elementThickness(thickness),
m_elementPlanarBounds(nullptr),
m_elementDiscBounds(std::move(dBounds)) {
auto mutableSurface =
std::const_pointer_cast<Acts::Surface>(m_elementSurface);
mutableSurface->assignSurfaceMaterial(material);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-2021 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
Expand All @@ -24,13 +24,16 @@ void ActsExamples::Options::addTelescopeGeometryOptions(
"Telescope detector Input: the layers offsets in the transverse plane in "
"mm. Same values for "
"all layers");
opt("geo-tele-size", value<Reals<2>>()->default_value({{50, 25}}),
"Telescope detector Input: the size of each plane in local x and y "
"directions in mm");
opt("geo-tele-bounds", value<Reals<2>>()->default_value({{25, 100}}),
"Telescope detector Input: the values for surface bounds in mm: "
"(halfX, halfY) - plane surface, (minR, maxR) - disc surface");
opt("geo-tele-thickness", value<double>()->default_value(80),
"Telescope detector Input: the silicon material thickness of "
"each layer in um. Same value for all layers");
opt("geo-tele-alignaxis", value<size_t>()->default_value(2),
opt("geo-tele-surface", value<int>()->default_value(0),
"Telescope detector Input: the detector surface type: 0 - plane surface, "
"1 - disc surface");
opt("geo-tele-alignaxis", value<int>()->default_value(2),
"Telescope detector Input: the detector is placed along which "
"axis: 0 - x axis, 1 - y axis, 2 - z aixs");
}

0 comments on commit 9efc8fc

Please sign in to comment.