Skip to content

Commit

Permalink
perf: Add option of stereo angle when building telescope detector (#2240
Browse files Browse the repository at this point in the history
)

This PR add options for stereo angles of each telescope plane when building the telescope detector, which is helpful in case that the telescope planes are strip detectors with stereo angles.

Co-authored-by: Paul Gessinger <[email protected]>
  • Loading branch information
XiaocongAi and paulgessinger authored Aug 4, 2023
1 parent b5babcb commit 0147d07
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,25 @@ enum class TelescopeSurfaceType {
///
/// @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 positions are the positions of different layers in the longitudinal
/// direction
/// @param stereoAngles are the stereo angles of different layers, which are
/// rotation angles around the longitudinal (normal)
/// direction
/// @param offsets is the offset (u, v) of the layers in the transverse plane
/// @param bounds is the surface bound values, i.e. halfX and halfY if plane
/// surface, and minR and maxR if disc surface
/// surface, and minR and maxR if disc surface
/// @param thickness is the material thickness of each layer
/// @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, const std::array<double, 2>& offsets,
const std::array<double, 2>& bounds, double thickness,
TelescopeSurfaceType surfaceType,
const std::vector<double>& positions,
const std::vector<double>& stereoAngles,
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
Expand Up @@ -45,6 +45,7 @@ struct TelescopeDetector {

struct Config {
std::vector<double> positions{{0, 30, 60, 120, 150, 180}};
std::vector<double> stereos{{0, 0, 0, 0, 0, 0}};
std::array<double, 2> offsets{{0, 0}};
std::array<double, 2> bounds{{25, 100}};
double thickness{80_um};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ ActsExamples::Telescope::buildDetector(
std::vector<
std::shared_ptr<ActsExamples::Telescope::TelescopeDetectorElement>>&
detectorStore,
const std::vector<double>& positions, const std::array<double, 2>& offsets,
const std::array<double, 2>& bounds, double thickness,
ActsExamples::Telescope::TelescopeSurfaceType surfaceType,
const std::vector<double>& positions,
const std::vector<double>& stereoAngles,
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;

Expand Down Expand Up @@ -80,8 +81,14 @@ ActsExamples::Telescope::buildDetector(
for (unsigned int i = 0; i < nLayers; ++i) {
// The translation without rotation yet
Acts::Translation3 trans(offsets[0], offsets[1], positions[i]);
// The transform
// The entire transformation (the coordinate system, whose center is defined
// by trans, will be rotated as well)
Acts::Transform3 trafo(rotation * trans);

// rotate around local z axis by stereo angle
auto stereo = stereoAngles[i];
trafo *= Acts::AngleAxis3(stereo, Acts::Vector3::UnitZ());

// Create the detector element
std::shared_ptr<TelescopeDetectorElement> detElement = nullptr;
if (surfaceType == TelescopeSurfaceType::Plane) {
Expand Down
11 changes: 9 additions & 2 deletions Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@ auto ActsExamples::Telescope::TelescopeDetector::finalize(
"The minR should be smaller than the maxR for disc surface bounds.");
}

if (cfg.positions.size() != cfg.stereos.size()) {
throw std::invalid_argument(
"The number of provided positions must match the number of "
"provided stereo angles.");
}

config = cfg;

// Sort the provided distances
std::vector<double> positions = cfg.positions;
std::vector<double> stereos = cfg.stereos;
std::sort(positions.begin(), positions.end());

/// Return the telescope detector
TrackingGeometryPtr gGeometry = ActsExamples::Telescope::buildDetector(
nominalContext, detectorStore, positions, cfg.offsets, cfg.bounds,
cfg.thickness,
nominalContext, detectorStore, positions, stereos, cfg.offsets,
cfg.bounds, cfg.thickness,
static_cast<ActsExamples::Telescope::TelescopeSurfaceType>(
cfg.surfaceType),
static_cast<Acts::BinningValue>(cfg.binValue));
Expand Down
1 change: 1 addition & 0 deletions Examples/Python/src/Detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void addDetector(Context& ctx) {
py::class_<Config>(td, "Config")
.def(py::init<>())
.def_readwrite("positions", &Config::positions)
.def_readwrite("stereos", &Config::stereos)
.def_readwrite("offsets", &Config::offsets)
.def_readwrite("bounds", &Config::bounds)
.def_readwrite("thickness", &Config::thickness)
Expand Down
1 change: 1 addition & 0 deletions Examples/Python/tests/test_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_telescope_geometry():
detector, geo, contextDecorators = acts.examples.TelescopeDetector.create(
bounds=[100, 100],
positions=[10 * i for i in range(n_surfaces)],
stereos=[0] * n_surfaces,
binValue=0,
)

Expand Down
39 changes: 0 additions & 39 deletions Examples/Run/Common/src/TelescopeDetectorOptions.cpp

This file was deleted.

8 changes: 8 additions & 0 deletions Examples/Run/Common/src/TelescopeDetectorWithOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ void TelescopeDetectorWithOptions::addOptions(
value<VariableReals>()->default_value({{0, 30, 60, 120, 150, 180}}),
"Telescope detector Input: the layers positions in the longidutinal "
"direction in mm");
opt("geo-tele-stereos",
value<VariableReals>()->default_value({{0, 0, 0, 0, 0, 0}}),
"Telescope detector Input: the layers stereo angle around the "
"longitudinal "
"direction in rad");
opt("geo-tele-offsets", value<Reals<2>>()->default_value({{0, 0}}),
"Telescope detector Input: the layers offsets in the transverse plane "
"in "
Expand Down Expand Up @@ -53,6 +58,9 @@ auto TelescopeDetectorWithOptions::finalize(
cfg.positions = vm["geo-tele-positions"]
.template as<ActsExamples::Options::VariableReals>()
.values;
cfg.stereos = vm["geo-tele-stereos"]
.template as<ActsExamples::Options::VariableReals>()
.values;
cfg.offsets =
vm["geo-tele-offsets"].template as<ActsExamples::Options::Reals<2>>();
// The bounds values are taken as (halfX, halfY) for plane surface and
Expand Down
12 changes: 6 additions & 6 deletions Examples/Scripts/Python/truth_tracking_telescope.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

if "__main__" == __name__:
detector, trackingGeometry, decorators = acts.examples.TelescopeDetector.create(
bounds=[200, 200], positions=[30, 60, 90, 120, 150, 180, 210, 240, 270]
bounds=[200, 200],
positions=[30, 60, 90, 120, 150, 180, 210, 240, 270],
stereos=[0] * 9,
)

digiConfigFile = (
Path(__file__).resolve().parent.parent.parent.parent
/ "Examples/Algorithms/Digitization/share/default-smearing-config-telescope.json",
)
srcdir = Path(__file__).resolve().parent.parent.parent.parent

field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T))

runTruthTrackingKalman(
trackingGeometry,
field,
digiConfigFile=digiConfigFile,
digiConfigFile=srcdir
/ "Examples/Algorithms/Digitization/share/default-smearing-config-telescope.json",
outputDir=Path.cwd(),
).run()

0 comments on commit 0147d07

Please sign in to comment.