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

perf: Add option of stereo angle when building telescope detector #2240

Merged
merged 8 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ 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
/// @param positions is the offset of different layers in the longitudinal
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
/// @param stereos is the stereo angle of different layers around the longitudinal
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
/// 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
Expand All @@ -46,9 +47,9 @@ enum class TelescopeSurfaceType {
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>& stereos,
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
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,9 @@ 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>& stereos,
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 +80,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 transform (the center defined by trans will be rotated as well with
// the following definition of trafo)
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
Acts::Transform3 trafo(rotation * trans);

// twist around local z axis by stereo angle
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
auto stereo = stereos[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 size of provided positions must be the same as the size of "
"provided stereos.");
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
}

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 for i in range(n_surfaces)],
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
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 "
"longidutinal "
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
"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, 0, 0, 0, 0, 0, 0, 0, 0],
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
)

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()