EIC 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 
16 
17 #include <algorithm>
18 #include <cmath>
19 
22 
23 namespace Acts {
24 
26  const std::vector<const Surface*>& surfaces)
27  : m_surfaces(surfaces) {
28  measure(gctx, surfaces);
29 }
30 
32  const GeometryContext& gctx,
33  const std::vector<std::shared_ptr<const Surface>>& surfaces)
34  : m_surfaces(unpack_shared_vector(surfaces)) {
35  measure(gctx, m_surfaces);
36 }
37 
38 double ProtoLayer::min(BinningValue bval, bool addenv) const {
39  if (addenv) {
40  return extent.min(bval) - envelope[bval].first;
41  }
42  return extent.min(bval);
43 }
44 
45 double ProtoLayer::max(BinningValue bval, bool addenv) const {
46  if (addenv) {
47  return extent.max(bval) + envelope[bval].second;
48  }
49  return extent.max(bval);
50 }
51 
52 double ProtoLayer::medium(BinningValue bval, bool addenv) const {
53  return 0.5 * (min(bval, addenv) + max(bval, addenv));
54 }
55 
56 double ProtoLayer::range(BinningValue bval, bool addenv) const {
57  return std::abs(max(bval, addenv) - min(bval, addenv));
58 }
59 
60 std::ostream& ProtoLayer::toStream(std::ostream& sl) const {
61  sl << "ProtoLayer with dimensions (min/max)" << std::endl;
62  extent.toStream(sl);
63  return sl;
64 }
65 
67  const std::vector<const Surface*>& surfaces) {
68  for (const auto& sf : surfaces) {
69  auto sfPolyhedron = sf->polyhedronRepresentation(gctx, 1);
70  const DetectorElementBase* element = sf->associatedDetectorElement();
71  if (element != nullptr) {
72  // Take the thickness in account if necessary
73  double thickness = element->thickness();
74  // We need a translation along and opposite half thickness
75  Vector3D sfNormal = sf->normal(gctx, sf->center(gctx));
76  std::vector<double> deltaT = {-0.5 * thickness, 0.5 * thickness};
77  for (const auto& dT : deltaT) {
78  Transform3D dtransform = Transform3D::Identity();
79  dtransform.pretranslate(dT * sfNormal);
80  extent.extend(sfPolyhedron.extent(dtransform));
81  }
82  continue;
83  }
84  extent.extend(sfPolyhedron.extent());
85  }
86 }
87 
89  m_surfaces.push_back(&surface);
90  measure(gctx, m_surfaces);
91 }
92 
93 } // namespace Acts