Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TGeoDetector.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TGeoDetector.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 
9 #pragma once
10 
16 
17 #include <cstddef>
18 #include <map>
19 #include <memory>
20 #include <stdexcept>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 namespace Acts {
26 class TGeoDetectorElement;
27 class TrackingGeometry;
28 class IMaterialDecorator;
29 } // namespace Acts
30 
31 namespace ActsExamples {
32 class IContextDecorator;
33 } // namespace ActsExamples
34 
35 namespace ActsExamples {
36 
37 struct TGeoDetector {
38  using DetectorElementPtr = std::shared_ptr<const Acts::TGeoDetectorElement>;
39  using DetectorStore = std::vector<DetectorElementPtr>;
40 
41  using ContextDecorators =
42  std::vector<std::shared_ptr<ActsExamples::IContextDecorator>>;
43  using TrackingGeometryPtr = std::shared_ptr<const Acts::TrackingGeometry>;
44 
47 
48  struct Config {
52 
53  void readJson(const std::string& jsonFile);
54 
56  bool buildBeamPipe = false;
57  double beamPipeRadius{0};
60  double beamPipeEnvelopeR{1.0};
61  double layerEnvelopeR{1.0};
62 
63  double unitScalor = 1.0;
64 
67 
69  std::shared_ptr<const Acts::GeometryIdentifierHook> geometryIdentifierHook =
70  std::make_shared<Acts::GeometryIdentifierHook>();
71 
72  enum SubVolume : size_t { Negative = 0, Central, Positive };
73 
74  template <typename T>
75  struct LayerTriplet {
76  LayerTriplet() = default;
77 
79  : negative{value}, central{value}, positive{value} {}
80 
81  LayerTriplet(T _negative, T _central, T _positive)
82  : negative{_negative}, central{_central}, positive{_positive} {}
83 
84  T negative;
87 
89  switch (i) {
90  case Negative:
91  return negative;
92  case Central:
93  return central;
94  case Positive:
95  return positive;
96  default:
97  throw std::invalid_argument{"Unknown index"};
98  }
99  }
100 
101  const T& at(SubVolume i) const {
102  switch (i) {
103  case Negative:
104  return negative;
105  case Central:
106  return central;
107  case Positive:
108  return positive;
109  default:
110  throw std::invalid_argument{"Unknown index"};
111  }
112  }
113  };
114 
115  struct Volume {
127 
131 
132  bool cylinderDiscSplit = false;
133  unsigned int cylinderNZSegments = 0;
134  unsigned int cylinderNPhiSegments = 0;
135  unsigned int discNRSegments = 0;
136  unsigned int discNPhiSegments = 0;
137 
138  bool itkModuleSplit = false;
139  std::map<std::string, unsigned int> barrelMap;
140  std::map<std::string, std::vector<std::pair<double, double>>> discMap;
143  std::map<std::string, std::string>
144  splitPatterns; // @TODO in principle vector<pair< > > would be good enough
145  };
146 
147  std::vector<Volume> volumes;
148  };
149 
151  Config& config);
152 
153  std::pair<TrackingGeometryPtr, ContextDecorators> finalize(
154  const Config& cfg,
155  std::shared_ptr<const Acts::IMaterialDecorator> mdecorator);
156 };
157 
158 } // namespace ActsExamples