Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProtoLayer.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ProtoLayer.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-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 
15 
16 #include <algorithm>
17 #include <array>
18 #include <string>
19 #include <utility>
20 
23 
24 namespace Acts {
25 
27  const std::vector<const Surface*>& surfaces)
28  : m_surfaces(surfaces) {
29  measure(gctx, surfaces);
30 }
31 
33  const GeometryContext& gctx,
34  const std::vector<std::shared_ptr<const Surface>>& surfaces)
35  : m_surfaces(unpack_shared_vector(surfaces)) {
36  measure(gctx, m_surfaces);
37 }
38 
39 double ProtoLayer::min(BinningValue bval, bool addenv) const {
40  if (addenv) {
41  return extent.min(bval) - envelope[bval][0u];
42  }
43  return extent.min(bval);
44 }
45 
46 double ProtoLayer::max(BinningValue bval, bool addenv) const {
47  if (addenv) {
48  return extent.max(bval) + envelope[bval][1u];
49  }
50  return extent.max(bval);
51 }
52 
53 double ProtoLayer::medium(BinningValue bval, bool addenv) const {
54  return 0.5 * (min(bval, addenv) + max(bval, addenv));
55 }
56 
57 double ProtoLayer::range(BinningValue bval, bool addenv) const {
58  return std::abs(max(bval, addenv) - min(bval, addenv));
59 }
60 
61 std::ostream& ProtoLayer::toStream(std::ostream& sl) const {
62  sl << "ProtoLayer with dimensions (min/max)" << std::endl;
63  sl << extent.toString();
64  return sl;
65 }
66 
68  const std::vector<const Surface*>& surfaces) {
69  for (const auto& sf : surfaces) {
70  auto sfPolyhedron = sf->polyhedronRepresentation(gctx, 1);
71  const DetectorElementBase* element = sf->associatedDetectorElement();
72  if (element != nullptr) {
73  // Take the thickness in account if necessary
74  double thickness = element->thickness();
75  // We need a translation along and opposite half thickness
76  Vector3 sfNormal = sf->normal(gctx, sf->center(gctx));
77  std::vector<double> deltaT = {-0.5 * thickness, 0.5 * thickness};
78  for (const auto& dT : deltaT) {
79  Transform3 dtransform = Transform3::Identity();
80  dtransform.pretranslate(dT * sfNormal);
81  extent.extend(sfPolyhedron.extent(dtransform));
82  }
83  continue;
84  }
85  extent.extend(sfPolyhedron.extent());
86  }
87 }
88 
90  m_surfaces.push_back(&surface);
91  measure(gctx, m_surfaces);
92 }
93 
94 } // namespace Acts