EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Layer.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Layer.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 // Layer.cpp, Acts project
12 
13 // Geometry module
14 #include "Acts/Geometry/Layer.hpp"
15 
19 
20 Acts::Layer::Layer(std::unique_ptr<SurfaceArray> surfaceArray, double thickness,
21  std::unique_ptr<ApproachDescriptor> ades, LayerType laytyp)
22  : m_nextLayers(NextLayers(nullptr, nullptr)),
23  m_surfaceArray(surfaceArray.release()),
24  m_layerThickness(thickness),
25  m_approachDescriptor(nullptr),
26  m_representingVolume(nullptr),
27  m_layerType(laytyp),
28  m_ssRepresentingSurface(1) {
29  if (ades) {
30  ades->registerLayer(*this);
31  m_approachDescriptor = std::move(ades);
32  m_ssApproachSurfaces = 1; // indicates existence
33  }
34  // indicates existence of sensitive surfaces
35  if (m_surfaceArray) {
37  }
38 }
39 
41  return m_approachDescriptor.get();
42 }
43 
45  return const_cast<ApproachDescriptor*>(m_approachDescriptor.get());
46 }
47 
48 void Acts::Layer::closeGeometry(const IMaterialDecorator* materialDecorator,
49  const GeometryIdentifier& layerID) {
50  // set the volumeID of this
51  assignGeometryId(layerID);
52  // assign to the representing surface
53  Surface* rSurface = const_cast<Surface*>(&surfaceRepresentation());
54  if (materialDecorator != nullptr) {
55  materialDecorator->decorate(*rSurface);
56  }
57 
58  // also find out how the sub structure is defined
59  if (surfaceRepresentation().surfaceMaterial() != nullptr) {
60  m_ssRepresentingSurface = 2;
61  }
62  // loop over the approach surfaces
63  if (m_approachDescriptor) {
64  // indicates the existance of approach surfaces
65  m_ssApproachSurfaces = 1;
66  // loop through the approachSurfaces and assign unique GeomeryID
67  GeometryIdentifier::Value iasurface = 0;
68  for (auto& aSurface : m_approachDescriptor->containedSurfaces()) {
69  auto asurfaceID = GeometryIdentifier(layerID).setApproach(++iasurface);
70  auto mutableASurface = const_cast<Surface*>(aSurface);
71  mutableASurface->assignGeometryId(asurfaceID);
72  if (materialDecorator != nullptr) {
73  materialDecorator->decorate(*mutableASurface);
74  }
75  // if any of the approach surfaces has material
76  if (aSurface->surfaceMaterial() != nullptr) {
77  m_ssApproachSurfaces = 2;
78  }
79  }
80  }
81  // check if you have sensitive surfaces
82  if (m_surfaceArray) {
83  // indicates the existance of sensitive surfaces
84  m_ssSensitiveSurfaces = 1;
85  // loop sensitive surfaces and assign unique GeometryIdentifier
86  GeometryIdentifier::Value issurface = 0;
87  for (auto& sSurface : m_surfaceArray->surfaces()) {
88  auto ssurfaceID = GeometryIdentifier(layerID).setSensitive(++issurface);
89  auto mutableSSurface = const_cast<Surface*>(sSurface);
90  mutableSSurface->assignGeometryId(ssurfaceID);
91  if (materialDecorator != nullptr) {
92  materialDecorator->decorate(*mutableSSurface);
93  }
94  // if any of the sensitive surfaces has material
95  if (sSurface->surfaceMaterial() != nullptr) {
96  m_ssSensitiveSurfaces = 2;
97  }
98  }
99  }
100 }