ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_TrackingGeometryBuilderCond.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6// HGTD_TrackingGeometryBuilderCond.cxx, (c) ATLAS Detector software
8
9// HGTD
11// EnvelopeDefinitionService
13// Trk interfaces
26//Gaudi
27#include "GaudiKernel/MsgStream.h"
28#include <algorithm>
29
30// constructor
31HGTD_TrackingGeometryBuilderCond::HGTD_TrackingGeometryBuilderCond(const std::string& t, const std::string& n, const IInterface* p) :
32 base_class(t,n,p),
33 m_enclosingEnvelopeSvc("AtlasEnvelopeDefSvc", n),
34 m_trackingVolumeCreator("Trk::CylinderVolumeCreator/CylinderVolumeCreator"),
40{
41 // envelope definition service
42 declareProperty("EnvelopeDefinitionSvc", m_enclosingEnvelopeSvc );
43 declareProperty("LayerBuilder", m_layerBuilder);
44 declareProperty("TrackingVolumeCreator", m_trackingVolumeCreator);
45
46 declareProperty("IndexStaticLayers", m_indexStaticLayers);
47 declareProperty("BuildBoundaryLayers", m_buildBoundaryLayers);
48 declareProperty("ReplaceAllJointBoundaries", m_replaceJointBoundaries);
49 declareProperty("LayerBinningType", m_layerBinningType);
50 declareProperty("ColorCode", m_colorCodeConfig);
51
52}
53
54// destructor
56= default;
57
58// Athena standard methods
59// initialize
61{
62 // retrieve envelope definition service
64
65 // retrieve the layer provider
66 ATH_CHECK(m_layerBuilder.retrieve());
67
68 // retrieve the volume creator
70
71 ATH_MSG_INFO( "initialize() succesful" );
72 return StatusCode::SUCCESS;
73}
74
75std::unique_ptr<Trk::TrackingGeometry>
77 const EventContext& ctx,
78 Trk::TrackingVolume* innerVol,
80
81{
82
83 ATH_MSG_VERBOSE( "Starting to build HGTD_TrackingGeometry ..." );
84
85 // the enclosed input volume (ID)
86 double enclosedInnerSectorHalflength = std::numeric_limits<float>::max();
87 double enclosedOuterRadius = 0.;
88 double enclosedInnerRadius = 0.;
89
90 if (innerVol) {
91 ATH_MSG_VERBOSE( "Got Inner Detector Volume: " << innerVol->volumeName() );
92 innerVol->screenDump(msg(MSG::VERBOSE));
93
94 // retrieve dimensions
95 const Trk::CylinderVolumeBounds* innerDetectorBounds
96 = dynamic_cast<const Trk::CylinderVolumeBounds*>(&(innerVol->volumeBounds()));
97 if (!innerDetectorBounds) std::abort();
98
99 enclosedInnerSectorHalflength = innerDetectorBounds->halflengthZ();
100 enclosedOuterRadius = innerDetectorBounds->outerRadius();
101 enclosedInnerRadius = innerDetectorBounds->innerRadius();
102 }
103
104 float enclosedOuterSectorHalflength = std::numeric_limits<float>::max();
105 // for the HGTD we only need the first envelope definition
106 for (const auto & bounds : m_enclosingEnvelopeSvc->getCaloRZBoundary()) {
107 if (std::abs(bounds.second) < enclosedOuterSectorHalflength) {
108 enclosedOuterSectorHalflength = std::abs(bounds.second);
109 }
110 }
111
112 // in case you have no inner volume you need to find the
113 // envelope extensions --> beampipe and HGTD
114 if (not innerVol) {
115 // from the beampipe envelope you get the inner z extension
116 for (const auto & bounds : m_enclosingEnvelopeSvc->getBeamPipeRZBoundary()) {
117 if (std::abs(bounds.second) < enclosedInnerSectorHalflength) {
118 enclosedInnerSectorHalflength = std::abs(bounds.second);
119 }
120 }
121 // from the calo envelope you get the outer radius
122 for (const auto & bounds : m_enclosingEnvelopeSvc->getCaloRZBoundary()) {
123 if (std::abs(bounds.second) == enclosedOuterSectorHalflength) {
124 if (bounds.first>enclosedOuterRadius)
125 enclosedOuterRadius=bounds.first;
126 }
127 }
128 }
129
130 ATH_MSG_VERBOSE("Got Dimensions Zmin/Rmin - Zmax/Rmax: "
131 << enclosedInnerSectorHalflength << "/" << enclosedInnerRadius
132 << " - " << enclosedOuterSectorHalflength << "/"
133 << enclosedOuterRadius);
134
135 // prepare the layers
136 std::vector<Trk::Layer*> negativeLayers;
137 std::vector<Trk::Layer*> positiveLayers;
138
139 std::unique_ptr<const std::vector<Trk::DiscLayer*> > discLayers = m_layerBuilder->discLayers(ctx, whandle);
140
141 float maxZ = -9999.;
142 float minZ = 9999.;
143 float thickness = -9999;
144
145 // loop and fill positive and negative Layers
146 if (discLayers && !discLayers->empty()){
147 // loop over and push into the return/cache vector
148 for (const auto & discLayer : (*discLayers) ){
149 // get the center posituion
150 float zpos = discLayer->surfaceRepresentation().center().z();
151 if (zpos > 0) {
152 positiveLayers.push_back(discLayer);
153 // only saving layer info for positive side
154 // as the detector is simmetric
155 maxZ = std::max(maxZ, zpos);
156 minZ = std::min(minZ, zpos);
157 thickness = std::max(thickness, float(discLayer->thickness()));
158 }
159 else {
160 negativeLayers.push_back(discLayer);
161 }
162 }
163 }
164
165 float envelope = thickness*0.5;
166 float minZ_HGTD = minZ-envelope;
167 float maxZ_HGTD = maxZ+envelope;
168 float maxZ_HGTDEnclosure = enclosedOuterSectorHalflength;
169
170 // dummy material property
171 auto materialProperties = std::make_unique<Trk::Material>();
172
173 float zGapPos = 0.5*(minZ_HGTD+enclosedInnerSectorHalflength);
174 float gapHalfLengthZ = 0.5*(minZ_HGTD-enclosedInnerSectorHalflength);
175
176 // create the gap between the ID and the HGTD endcap volumes
177 auto negativeInnerGapTrans = std::make_unique<Amg::Transform3D>(Amg::Translation3D(Amg::Vector3D(0.,0.,-zGapPos)));
178 auto negativeInnerGapBounds = std::make_shared<Trk::CylinderVolumeBounds>(enclosedInnerRadius,enclosedOuterRadius,gapHalfLengthZ);
179
180 Trk::TrackingVolume * negativeInnerGapVolume =
181 new Trk::TrackingVolume(std::move(negativeInnerGapTrans),
182 negativeInnerGapBounds,
183 *materialProperties,
184 nullptr, nullptr,
185 m_layerBuilder->identification()+"::NegativeInnerGap");
186
187 auto positiveInnerGapTrans = std::make_unique<Amg::Transform3D>(Amg::Translation3D(Amg::Vector3D(0.,0.,zGapPos)));
188 auto positiveInnerGapBounds = std::make_shared<Trk::CylinderVolumeBounds>(enclosedInnerRadius,enclosedOuterRadius,gapHalfLengthZ);
189
190 Trk::TrackingVolume * positiveInnerGapVolume =
191 new Trk::TrackingVolume(std::move(positiveInnerGapTrans),
192 std::move(positiveInnerGapBounds),
193 *materialProperties,
194 nullptr, nullptr,
195 m_layerBuilder->identification()+"::PositiveInnerGap");
196
197 // create dummy inner volume if not built already
198 if (not innerVol) {
199 auto idBounds = std::make_shared<Trk::CylinderVolumeBounds>(enclosedInnerRadius,
200 enclosedInnerSectorHalflength);
201 auto idTr = std::make_unique<Amg::Transform3D>(Trk::s_idTransform);
202
203 innerVol = new Trk::TrackingVolume(std::move(idTr), std::move(idBounds), *materialProperties,
204 nullptr, nullptr,
205 "HGTD::GapVolumes::DummyID");
206 }
207
208 std::vector<Trk::TrackingVolume*> inBufferVolumes;
209 inBufferVolumes.push_back(negativeInnerGapVolume);
210 inBufferVolumes.push_back(innerVol);
211 inBufferVolumes.push_back(positiveInnerGapVolume);
212
213 Trk::TrackingVolume* inDetEnclosed =
214 m_trackingVolumeCreator->createContainerTrackingVolume(inBufferVolumes,
215 *materialProperties,
216 "HGTD::Container::EnclosedInnerDetector");
217
218 // create the tracking volumes
219 // create the three volumes
220 Trk::TrackingVolume* negativeVolume =
221 m_trackingVolumeCreator->createTrackingVolume(negativeLayers,
222 *materialProperties,
223 enclosedInnerRadius, enclosedOuterRadius,
224 -maxZ_HGTD, -minZ_HGTD,
225 m_layerBuilder->identification()+"::NegativeEndcap",
227
228
229 Trk::TrackingVolume* positiveVolume =
230 m_trackingVolumeCreator->createTrackingVolume(positiveLayers,
231 *materialProperties,
232 enclosedInnerRadius, enclosedOuterRadius,
233 minZ_HGTD, maxZ_HGTD,
234 m_layerBuilder->identification()+"::PositiveEndcap",
236
237 // the base volumes have been created
238 ATH_MSG_VERBOSE('\t' << '\t'<< "Volumes have been created, now pack them into a triple.");
239 negativeVolume->registerColorCode(m_colorCodeConfig);
240 inDetEnclosed->registerColorCode(m_colorCodeConfig);
241 positiveVolume->registerColorCode(m_colorCodeConfig);
242
243 // pack them together
244 std::vector<Trk::TrackingVolume*> tripleVolumes;
245 tripleVolumes.push_back(negativeVolume);
246 tripleVolumes.push_back(inDetEnclosed);
247 tripleVolumes.push_back(positiveVolume);
248
249 // create the tiple container
250 Trk::TrackingVolume* tripleContainer =
251 m_trackingVolumeCreator->createContainerTrackingVolume(tripleVolumes,
252 *materialProperties,
253 "HGTD::Containers::" + m_layerBuilder->identification(),
256
257 ATH_MSG_VERBOSE( '\t' << '\t'<< "Created container volume with bounds: " << tripleContainer->volumeBounds() );
258
259 // finally create the two endplates: negative
260 Trk::TrackingVolume* negativeEnclosure = m_trackingVolumeCreator->createGapTrackingVolume(
261 *materialProperties,
262 enclosedInnerRadius,
263 enclosedOuterRadius,
264 -maxZ_HGTDEnclosure,
265 -maxZ_HGTD,
266 1,
267 false,
268 "HGTD::Gaps::NegativeEnclosure" + m_layerBuilder->identification());
269
270 // finally create the two endplates: positive
271 Trk::TrackingVolume* positiveEnclosure = m_trackingVolumeCreator->createGapTrackingVolume(
272 *materialProperties,
273 enclosedInnerRadius,
274 enclosedOuterRadius,
275 maxZ_HGTD,
276 maxZ_HGTDEnclosure,
277 1,
278 false,
279 "HGTD::Gaps::PositiveEnclosure" + m_layerBuilder->identification());
280 // and the final tracking volume
281 std::vector<Trk::TrackingVolume*> enclosedVolumes;
282 enclosedVolumes.push_back(negativeEnclosure);
283 enclosedVolumes.push_back(tripleContainer);
284 enclosedVolumes.push_back(positiveEnclosure);
285
286 Trk::TrackingVolume* enclosedDetector =
287 m_trackingVolumeCreator->createContainerTrackingVolume(enclosedVolumes,
288 *materialProperties,
289 "HGTD::Detectors::"+m_layerBuilder->identification(),
292
293 ATH_MSG_VERBOSE( '\t' << '\t'<< "Created enclosed HGTD volume with bounds: " << enclosedDetector->volumeBounds() );
294
295 // create the TrackingGeometry ------------------------------------------------------
296 auto hgtdTrackingGeometry = std::make_unique<Trk::TrackingGeometry>(enclosedDetector);
297
298 if (m_indexStaticLayers and hgtdTrackingGeometry)
299 hgtdTrackingGeometry->indexStaticLayers( geometrySignature() );
300 if (msgLvl(MSG::VERBOSE) && hgtdTrackingGeometry)
301 hgtdTrackingGeometry->printVolumeHierarchy(msg(MSG::VERBOSE));
302
303 return hgtdTrackingGeometry;
304}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
bool m_indexStaticLayers
configurations for the layer builder
unsigned int m_colorCodeConfig
Color code for layers.
ToolHandle< Trk::ILayerBuilderCond > m_layerBuilder
Helper tools for the geometry building.
HGTD_TrackingGeometryBuilderCond(const std::string &, const std::string &, const IInterface *)
Constructor.
virtual Trk::GeometrySignature geometrySignature() const override
The unique signature.
ServiceHandle< IEnvelopeDefSvc > m_enclosingEnvelopeSvc
Service to handle the envelope definition.
virtual StatusCode initialize() override
AlgTool initailize method.
bool m_replaceJointBoundaries
run with replacement of all joint boundaries
virtual std::unique_ptr< Trk::TrackingGeometry > trackingGeometry(const EventContext &ctx, Trk::TrackingVolume *innerVol, SG::WriteCondHandle< Trk::TrackingGeometry > &whandle) const override
TrackingGeometry Interface method.
virtual ~HGTD_TrackingGeometryBuilderCond()
Destructor.
ToolHandle< Trk::ITrackingVolumeCreator > m_trackingVolumeCreator
Helper Tool to create TrackingVolumes.
Bounds for a cylindrical Volume, the decomposeToSurfaces method creates a vector of up to 6 surfaces:
double innerRadius() const
This method returns the inner radius.
double halflengthZ() const
This method returns the halflengthZ.
double outerRadius() const
This method returns the outer radius.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
void registerColorCode(unsigned int icolor)
Register the color code.
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
void screenDump(MsgStream &msg) const
const VolumeBounds & volumeBounds() const
returns the volumeBounds()
Definition Volume.h:96
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
static const Amg::Transform3D s_idTransform
idendity transformation
BinningType
, BinningOption & BinningAccess
Definition BinningType.h:31
MsgStream & msg
Definition testRead.cxx:32