Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 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/DD4hepDetector/DD4hepDetectorHelper.hpp"
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Digitization/CartesianSegmentation.hpp"
0013 #include "Acts/Digitization/DigitizationModule.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0016 
0017 #include <cstddef>
0018 
0019 #include "DD4hep/CartesianGridXY.h"
0020 #include "DD4hep/Segmentations.h"
0021 
0022 using namespace ActsExamples::DD4hep;
0023 
0024 std::shared_ptr<const Acts::DigitizationModule>
0025 DD4hepDetectorHelper::rectangleDigiModule(
0026     double halflengthX, double halflengthY, double thickness,
0027     const dd4hep::Segmentation& segmentation) {
0028   // convert to Acts units
0029   double scalor = Acts::UnitConstants::cm;
0030   halflengthX *= scalor;
0031   halflengthY *= scalor;
0032   thickness *= scalor;
0033 
0034   auto bounds =
0035       std::make_shared<const Acts::RectangleBounds>(halflengthX, halflengthY);
0036   dd4hep::CartesianGridXY cartesianGrid = segmentation;
0037   if (cartesianGrid.isValid()) {
0038     // the Acts segmentation of the DigitizationModule
0039     double gridSizeX = cartesianGrid.gridSizeX() * scalor;
0040     double gridSizeY = cartesianGrid.gridSizeY() * scalor;
0041     std::size_t bins0 =
0042         (cartesianGrid.gridSizeX() != 0)
0043             ? static_cast<std::size_t>((2 * halflengthX) / gridSizeX)
0044             : 0;
0045     std::size_t bins1 =
0046         (cartesianGrid.gridSizeY() != 0)
0047             ? static_cast<std::size_t>((2 * halflengthY) / gridSizeY)
0048             : 0;
0049 
0050     std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
0051         std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
0052                                                             bins1);
0053     // finally create the digitization module
0054     // @todo set lorentz angle
0055     return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
0056                                                              thickness, 1, 0));
0057   }
0058   return nullptr;
0059 }
0060 
0061 std::shared_ptr<const Acts::DigitizationModule>
0062 DD4hepDetectorHelper::trapezoidalDigiModule(
0063     double minHalflengthX, double maxHalflengthX, double halflengthY,
0064     double thickness, const dd4hep::Segmentation& segmentation) {
0065   // convert to Acts units
0066   double scalor = Acts::UnitConstants::cm;
0067   minHalflengthX *= scalor;
0068   maxHalflengthX *= scalor;
0069   halflengthY *= scalor;
0070   thickness *= scalor;
0071 
0072   auto bounds = std::make_shared<const Acts::TrapezoidBounds>(
0073       minHalflengthX, maxHalflengthX, halflengthY);
0074   ;
0075   dd4hep::CartesianGridXY cartesianGrid = segmentation;
0076   if (cartesianGrid.isValid()) {
0077     // the Acts segmentation of the DigitizationModule
0078     double gridSizeX = cartesianGrid.gridSizeX() * scalor;
0079     double gridSizeY = cartesianGrid.gridSizeY() * scalor;
0080     std::size_t bins0 =
0081         (cartesianGrid.gridSizeX() != 0)
0082             ? static_cast<std::size_t>((2 * maxHalflengthX) / gridSizeX)
0083             : 0;
0084     std::size_t bins1 =
0085         (cartesianGrid.gridSizeY() != 0)
0086             ? static_cast<std::size_t>((2 * halflengthY) / gridSizeY)
0087             : 0;
0088 
0089     std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
0090         std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
0091                                                             bins1);
0092     // finally create the digitization module
0093     // @todo set lorentz angle
0094     return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
0095                                                              thickness, 1, 0));
0096   }
0097   return nullptr;
0098 }