forked from sPHENIX-Collaboration/acts
/
DD4hepLayerBuilder.hpp
174 lines (149 loc) · 6.5 KB
/
DD4hepLayerBuilder.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// This file is part of the Acts project.
//
// Copyright (C) 2017-2018 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "Acts/Geometry/ILayerBuilder.hpp"
#include "Acts/Geometry/LayerCreator.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/BinUtility.hpp"
#include "Acts/Utilities/Definitions.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Units.hpp"
class TGeoMatrix;
namespace dd4hep {
class DetElement;
}
namespace Acts {
/// @brief build layers of one cylinder-endcap setup from DD4hep input
///
/// This class is an implementation of the Acts::ILayerBuilder,
/// creating the central (layers of barrel), the negative and positive layers
/// (layers of endcaps) of one hierarchy (e.g. PixelDetector, StripDetector,...)
/// with input from DD4hep.
class DD4hepLayerBuilder : public ILayerBuilder {
public:
/// @struct Config
/// nested configuration struct for steering of the layer builder
struct Config {
/// string based identification
std::string configurationName = "undefined";
/// layer creator which is internally used to build layers
std::shared_ptr<const LayerCreator> layerCreator = nullptr;
/// the binning type of the contained surfaces in phi
/// (equidistant/arbitrary)
BinningType bTypePhi = equidistant;
/// the binning type of the contained surfaces in r
/// (equidistant/arbitrary)
BinningType bTypeR = equidistant;
/// the binning type of the contained surfaces in z
/// (equidistant/arbitrary)
BinningType bTypeZ = equidistant;
/// the DD4hep::DetElements of the layers of the negative volume (negative
/// endcap)
/// @note if the current volume has no endcaps or no layers this parameter
/// will not be set
std::vector<dd4hep::DetElement> negativeLayers;
/// the DD4hep::DetElements of the layers of the central volume (barrel)
/// @note if the current volume has no layers this parameter will not be set
std::vector<dd4hep::DetElement> centralLayers;
/// the DD4hep::DetElements of the layers of the positive volume (positive
/// endcap)
/// @note if the current volume has no endcaps or no layers this parameter
/// will not be set
std::vector<dd4hep::DetElement> positiveLayers;
/// In case no surfaces (to be contained by the layer) are handed over, the
/// layer thickness will be set to this value
/// @note Layers containing surfaces per default are not allowed to be
/// attached to each other (navigation will bail at this point).
/// However, to allow material layers (not containing surfaces) to be
/// attached to each other, this default thickness is needed. In this
/// way, the layer will be thin (with space to the next layer), but
/// the material will have the'real' thickness.
/// @attention The default thickness should be set thin enough that no
/// touching or overlapping with the next layer can happen.
double defaultThickness = UnitConstants::fm;
};
/// Constructor
/// @param config is the configuration struct
/// @param logger is the logging instance
DD4hepLayerBuilder(const Acts::DD4hepLayerBuilder::Config& config,
std::unique_ptr<const Logger> logger);
/// Destructor
~DD4hepLayerBuilder() override;
/// LayerBuilder interface method
///
/// @param gctx the geometry context for this build call
///
/// @return the layers at negative side
const LayerVector negativeLayers(const GeometryContext& gctx) const final;
/// LayerBuilder interface method
///
/// @param gctx the geometry context for this build call
///
/// @return the layers at the central sector
const LayerVector centralLayers(const GeometryContext& gctx) const final;
/// LayerBuilder interface method
///
/// @param gctx the geometry context for this build call
///
/// @return the layers at positive side
const LayerVector positiveLayers(const GeometryContext& gctx) const final;
/// Name identification
/// @return the string based identification of this configuration
const std::string& identification() const final;
/// set the configuration object
/// @param config is the configuration struct
void setConfiguration(const Config& config);
/// get the configuration object
Config getConfiguration() const;
/// set logging instance
void setLogger(std::unique_ptr<const Logger> logger);
private:
/// configruation object
Config m_cfg;
/// logging instance
std::unique_ptr<const Logger> m_logger;
/// Private access to the logger
const Logger& logger() const { return *m_logger; }
/// Private helper method to be called for endcap layers
///
/// @param gctx the geometry context for this build call
///
/// @return the layers for either endcap side
const LayerVector endcapLayers(
const GeometryContext& gctx,
const std::vector<dd4hep::DetElement>& dendcapLayers,
const std::string& side) const;
/// Private helper function collecting all sensitive detector elements of a
/// layer
/// @param gctx the geometry context of this call
/// @param detElement the DD4hep::DetElement of the layer
/// @param surfaces the vector of surfaces which should be filled with the
/// sensitive detector elements
void resolveSensitive(
const dd4hep::DetElement& detElement,
std::vector<std::shared_ptr<const Acts::Surface>>& surfaces) const;
/// Private helper function to create a sensitive surface from a given
/// detector element
/// @param detElement the DD4hep::DetElement of sensitive surface to be
/// created
/// @param isDisc in case the sensitive detector module should be translated
/// as disc (e.g. for endcaps) this flag should be set to true
std::shared_ptr<const Acts::Surface> createSensitiveSurface(
const dd4hep::DetElement& detElement, bool isDisc = false) const;
// Private helper function to convert the TGeo transformation matrix into
// an Acts transformation matrix
// @param tGeoTrans TGeo transformation matrix which should be converted
Acts::Transform3D convertTransform(const TGeoMatrix* tGeoTrans) const;
};
inline const std::string& DD4hepLayerBuilder::identification() const {
return m_cfg.configurationName;
}
inline DD4hepLayerBuilder::Config DD4hepLayerBuilder::getConfiguration() const {
return m_cfg;
}
} // namespace Acts