Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:10:42

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020-2021 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/TelescopeDetector/TelescopeDetector.hpp"
0010 
0011 #include "Acts/Geometry/TrackingGeometry.hpp"
0012 #include "Acts/Utilities/BinningType.hpp"
0013 #include "ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp"
0014 #include "ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp"
0015 
0016 #include <algorithm>
0017 #include <stdexcept>
0018 
0019 auto ActsExamples::Telescope::TelescopeDetector::finalize(
0020     const Config& cfg, const std::shared_ptr<const Acts::IMaterialDecorator>&
0021     /*mdecorator*/) -> std::pair<TrackingGeometryPtr, ContextDecorators> {
0022   DetectorElement::ContextType nominalContext;
0023 
0024   if (cfg.surfaceType > 1) {
0025     throw std::invalid_argument(
0026         "The surface type could either be 0 for plane surface or 1 for disc "
0027         "surface.");
0028   }
0029   if (cfg.binValue > 2) {
0030     throw std::invalid_argument("The axis value could only be 0, 1, or 2.");
0031   }
0032   // Check if the bounds values are valid
0033   if (cfg.surfaceType == 1 && cfg.bounds[0] >= cfg.bounds[1]) {
0034     throw std::invalid_argument(
0035         "The minR should be smaller than the maxR for disc surface bounds.");
0036   }
0037 
0038   if (cfg.positions.size() != cfg.stereos.size()) {
0039     throw std::invalid_argument(
0040         "The number of provided positions must match the number of "
0041         "provided stereo angles.");
0042   }
0043 
0044   config = cfg;
0045 
0046   // Sort the provided distances
0047   std::vector<double> positions = cfg.positions;
0048   std::vector<double> stereos = cfg.stereos;
0049   std::sort(positions.begin(), positions.end());
0050 
0051   /// Return the telescope detector
0052   TrackingGeometryPtr gGeometry = ActsExamples::Telescope::buildDetector(
0053       nominalContext, detectorStore, positions, stereos, cfg.offsets,
0054       cfg.bounds, cfg.thickness,
0055       static_cast<ActsExamples::Telescope::TelescopeSurfaceType>(
0056           cfg.surfaceType),
0057       static_cast<Acts::BinningValue>(cfg.binValue));
0058   ContextDecorators gContextDecorators = {};
0059   // return the pair of geometry and empty decorators
0060   return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
0061       std::move(gGeometry), std::move(gContextDecorators));
0062 }