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