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 
10 
14 #include "Acts/Utilities/Units.hpp"
15 
16 #include "DD4hep/CartesianGridXY.h"
17 
18 using namespace ActsExamples::DD4hep;
19 
20 std::shared_ptr<const Acts::DigitizationModule>
22  double halflengthX, double halflengthY, double thickness,
23  const dd4hep::Segmentation& segmentation) {
24  // convert to Acts units
25  double scalor = Acts::UnitConstants::cm;
26  halflengthX *= scalor;
27  halflengthY *= scalor;
28  thickness *= scalor;
29 
30  auto bounds =
31  std::make_shared<const Acts::RectangleBounds>(halflengthX, halflengthY);
32  dd4hep::CartesianGridXY cartesianGrid = segmentation;
33  if (cartesianGrid.isValid()) {
34  // the Acts segmentation of the DigitizationModule
35  double gridSizeX = cartesianGrid.gridSizeX() * scalor;
36  double gridSizeY = cartesianGrid.gridSizeY() * scalor;
37  size_t bins0 =
38  (cartesianGrid.gridSizeX() != 0) ? (2 * halflengthX) / gridSizeX : 0;
39  size_t bins1 =
40  (cartesianGrid.gridSizeY() != 0) ? (2 * halflengthY) / gridSizeY : 0;
41 
42  std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
43  std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
44  bins1);
45  // finally create the digitization module
46  // @todo set lorentz angle
47  return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
48  thickness, 1, 0));
49  }
50  return nullptr;
51 }
52 
53 std::shared_ptr<const Acts::DigitizationModule>
55  double minHalflengthX, double maxHalflengthX, double halflengthY,
56  double thickness, const dd4hep::Segmentation& segmentation) {
57  // convert to Acts units
58  double scalor = Acts::UnitConstants::cm;
59  minHalflengthX *= scalor;
60  maxHalflengthX *= scalor;
61  halflengthY *= scalor;
62  thickness *= scalor;
63 
64  auto bounds = std::make_shared<const Acts::TrapezoidBounds>(
65  minHalflengthX, maxHalflengthX, halflengthY);
66  ;
67  dd4hep::CartesianGridXY cartesianGrid = segmentation;
68  if (cartesianGrid.isValid()) {
69  // the Acts segmentation of the DigitizationModule
70  double gridSizeX = cartesianGrid.gridSizeX() * scalor;
71  double gridSizeY = cartesianGrid.gridSizeY() * scalor;
72  size_t bins0 =
73  (cartesianGrid.gridSizeX() != 0) ? (2 * maxHalflengthX) / gridSizeX : 0;
74  size_t bins1 =
75  (cartesianGrid.gridSizeY() != 0) ? (2 * halflengthY) / gridSizeY : 0;
76 
77  std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
78  std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0,
79  bins1);
80  // finally create the digitization module
81  // @todo set lorentz angle
82  return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation,
83  thickness, 1, 0));
84  }
85  return nullptr;
86 }