ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DD4hepDetectorHelper.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DD4hepDetectorHelper.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
13 #include "Acts/Utilities/Units.hpp"
14 #include "DD4hep/CartesianGridXY.h"
15 
16 using namespace FW::DD4hep;
17 
18 std::shared_ptr<const Acts::DigitizationModule>
20  double halflengthX, double halflengthY, double thickness,
21  const dd4hep::Segmentation& segmentation) {
22  // convert to Acts units
23  double scalor = Acts::units::_cm;
24  halflengthX *= scalor;
25  halflengthY *= scalor;
26  thickness *= scalor;
27 
28  auto bounds =
29  std::make_shared<const Acts::RectangleBounds>(halflengthX, halflengthY);
30  dd4hep::CartesianGridXY cartesianGrid = segmentation;
31  if (cartesianGrid.isValid()) {
32  // the Acts segmentation of the DigitizationModule
33  double gridSizeX = cartesianGrid.gridSizeX() * scalor;
34  double gridSizeY = cartesianGrid.gridSizeY() * scalor;
35  size_t bins0 =
36  (cartesianGrid.gridSizeX() != 0) ? (2 * halflengthX) / gridSizeX : 0;
37  size_t bins1 =
38  (cartesianGrid.gridSizeY() != 0) ? (2 * halflengthY) / gridSizeY : 0;
39 
40  std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
41  std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
42  bins1);
43  // finally create the digitization module
44  // @todo set lorentz angle
45  return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
46  thickness, 1, 0));
47  }
48  return nullptr;
49 }
50 
51 std::shared_ptr<const Acts::DigitizationModule>
53  double minHalflengthX, double maxHalflengthX, double halflengthY,
54  double thickness, const dd4hep::Segmentation& segmentation) {
55  // convert to Acts units
56  double scalor = Acts::units::_cm;
57  minHalflengthX *= scalor;
58  maxHalflengthX *= scalor;
59  halflengthY *= scalor;
60  thickness *= scalor;
61 
62  auto bounds = std::make_shared<const Acts::TrapezoidBounds>(
63  minHalflengthX, maxHalflengthX, halflengthY);
64  ;
65  dd4hep::CartesianGridXY cartesianGrid = segmentation;
66  if (cartesianGrid.isValid()) {
67  // the Acts segmentation of the DigitizationModule
68  double gridSizeX = cartesianGrid.gridSizeX() * scalor;
69  double gridSizeY = cartesianGrid.gridSizeY() * scalor;
70  size_t bins0 =
71  (cartesianGrid.gridSizeX() != 0) ? (2 * maxHalflengthX) / gridSizeX : 0;
72  size_t bins1 =
73  (cartesianGrid.gridSizeY() != 0) ? (2 * halflengthY) / gridSizeY : 0;
74 
75  std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
76  std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
77  bins1);
78  // finally create the digitization module
79  // @todo set lorentz angle
80  return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
81  thickness, 1, 0));
82  }
83  return nullptr;
84 }