ATLAS Offline Software
Loading...
Searching...
No Matches
DetachedTrackingVolume.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6// DetachedTrackingVolume.cxx, (c) ATLAS Detector software
8
9// Trk
11
12#include <utility>
13
14#include "TrkGeometry/Layer.h"
16
18 std::unique_ptr<Trk::TrackingVolume> volume)
19 : m_trkVolume(std::move(volume))
20 , m_name(std::move(name))
21{}
22
24 std::string name,
25 std::unique_ptr<Trk::TrackingVolume> volume,
26 std::unique_ptr<Trk::Layer> lay,
27 std::unique_ptr<const std::vector<Trk::Layer*>> multilay)
28 : m_trkVolume(std::move(volume))
31 , m_name(std::move(name))
32 , m_baseTransform(nullptr)
33{}
34
36 //These we have to delete manually
38 for (auto *layer : *m_multilayerRepresentation)
39 delete layer;
40 }
41}
42
43void
45{
46 m_trkVolume->moveTV(shift);
48 m_layerRepresentation->moveLayer(shift);
49 }
51 for (auto* layer : *m_multilayerRepresentation) {
52 layer->moveLayer(shift);
53 }
54 }
55}
56
59 Amg::Transform3D& shift) const
60{
61 auto newTV = std::make_unique<TrackingVolume>(*(this->trackingVolume()), shift);
62 TrackingVolumeArray* confinedVolumes = newTV->confinedVolumes();
63 LayerArray* confinedLayers= newTV->confinedLayers();
64 Trk::ArraySpan<Trk::Layer* const> confinedArbitraryLayers = newTV->confinedArbitraryLayers();
65 //
66 Trk::DetachedTrackingVolume* newStat = nullptr;
67 // layer representation ?
68 std::unique_ptr<Trk::PlaneLayer> newLay = nullptr;
69 if (this->layerRepresentation()) {
70 std::unique_ptr<std::vector<Trk::Layer*>> newMulti = nullptr;
71 const Trk::PlaneLayer* pl = dynamic_cast<const Trk::PlaneLayer*>(this->layerRepresentation());
72 if (pl) {
73 newLay = std::make_unique<Trk::PlaneLayer>(*pl);
74 newLay->moveLayer(shift);
75 if (!this->multilayerRepresentation().empty()) {
76 newMulti = std::make_unique<std::vector<Trk::Layer*>>();
77 for (unsigned int i = 0; i < this->multilayerRepresentation().size(); i++) {
78 const Trk::PlaneLayer* mpl = dynamic_cast<const Trk::PlaneLayer*>((this->multilayerRepresentation())[i]);
79 if (mpl) {
80 Trk::PlaneLayer* newPl = new Trk::PlaneLayer(*mpl);
81 newPl->moveLayer(shift);
82 newMulti->push_back(newPl);
83 } else
84 std::cout << "WARNING Trk::DetachedTrackingVolume::clone() "
85 "dynamic cast to 'const Trk::PlaneLayer* mpl' failed!"
86 << std::endl;
87 }
88 }
89 newStat = new Trk::DetachedTrackingVolume(name, std::move(newTV), std::move(newLay), std::move(newMulti));
90 } else {
91 std::cout << "WARNING Trk::DetachedTrackingVolume::clone() dynamic "
92 "cast to 'const Trk::PlaneLayer* pl' failed!"
93 << std::endl;
94 newStat = new Trk::DetachedTrackingVolume(name, std::move(newTV));
95 }
96 } else {
97 newStat = new Trk::DetachedTrackingVolume(name, std::move(newTV));
98 }
99 //
100 // enclose layers
101 if (confinedVolumes) {
102 std::span<Trk::TrackingVolume * const> vols = confinedVolumes->arrayObjects();
103 for (auto *vol : vols) {
104 Trk::LayerArray* layAr = vol->confinedLayers();
105 Trk::ArraySpan<Trk::Layer* const> alays = vol->confinedArbitraryLayers();
106 if (layAr) {
107 std::span<Trk::Layer* const> lays = layAr->arrayObjects();
108 for (auto *lay : lays) {
109 lay->encloseDetachedTrackingVolume(*newStat);
110 }
111 }
112 if (!alays.empty()) {
113 for (auto *alay : alays) {
114 alay->encloseDetachedTrackingVolume(*newStat);
115 }
116 }
117 }
118 }
119 if (confinedLayers) {
120 std::span<Trk::Layer* const> lays = confinedLayers->arrayObjects();
121 for (auto *lay : lays){
122 lay->encloseDetachedTrackingVolume(*newStat);
123 }
124 }
125 if (!confinedArbitraryLayers.empty()) {
126 for (auto *alay : confinedArbitraryLayers) {
127 alay->encloseDetachedTrackingVolume(*newStat);
128 }
129 }
130 return newStat;
131}
132
133void
134Trk::DetachedTrackingVolume::compactify(size_t& cSurfaces, size_t& tSurfaces)
135{
136 // deal with the Tracking Volume representation
137 if (m_trkVolume){
138 m_trkVolume->compactify(cSurfaces, tSurfaces);
139 }
140
141 // deal with the layer representation
142 if (layerRepresentation()) {
143 ++tSurfaces;
144 if (layerRepresentation()->surfaceRepresentation().owner() == Trk::noOwn) {
145 layerRepresentation()->surfaceRepresentation().setOwner(Trk::TGOwn);
146 ++cSurfaces;
147 }
148 }
149 // deal with the multi-layer representation
151 tSurfaces += m_multilayerRepresentation->size();
152 for (const auto& mLayerIter : (*m_multilayerRepresentation)) {
153 if ((*mLayerIter).surfaceRepresentation().owner() == Trk::noOwn) {
154 (*mLayerIter).surfaceRepresentation().setOwner(Trk::TGOwn);
155 ++cSurfaces;
156 }
157 }
158 }
159}
160
161void
163 GeometryType geotype)
164{
165 m_trkVolume->sign(signat, geotype);
166}
167
171
175
176void Trk::DetachedTrackingVolume::setBaseTransform(std::unique_ptr<Amg::Transform3D> transf) {
177 if (transf){
178 m_baseTransform = std::move(transf);
179 }
180 else {
181 m_baseTransform = std::make_unique<Amg::Transform3D>(this->trackingVolume()->transform());
182 }
183}
184
static const Attributes_t empty
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Base Class for a navigation object (active/passive) in the Tracking realm.
std::unique_ptr< Layer > m_layerRepresentation
void move(Amg::Transform3D &shift)
moving object around
DetachedTrackingVolume * clone(const std::string &name, Amg::Transform3D &shift) const
clone with transform
GeometrySignature geometrySignature() const
return the Signature
DetachedTrackingVolume()
Default Constructor.
void sign(GeometrySignature signat, GeometryType geotype)
sign the volume - the geometry builder has to do that
const std::string & name() const
returns the Name
GeometryType geometryType() const
return the Type
const Layer * layerRepresentation() const
returns layer representation
std::unique_ptr< Amg::Transform3D > m_baseTransform
std::unique_ptr< const std::vector< Layer * > > m_multilayerRepresentation
const TrackingVolume * trackingVolume() const
returns the TrackingVolume
void setBaseTransform(std::unique_ptr< Amg::Transform3D > transf=nullptr)
alignment methods: set base transform / default argument to current transform
std::unique_ptr< TrackingVolume > m_trkVolume
void compactify(size_t &cSurfaces, size_t &tSurfaces)
Compactify – set TG as owner to surfaces.
std::span< Layer const *const > multilayerRepresentation() const
returns (multi)layer representation
Class to describe a planar detector layer for tracking, it inhertis from both, Layer base class and P...
Definition PlaneLayer.h:40
virtual void moveLayer(Amg::Transform3D &shift) override final
move the Layer
Eigen::Affine3d Transform3D
BinnedArray< Layer > LayerArray
simply for the eye
std::span< T > ArraySpan
BinnedArray< TrackingVolume > TrackingVolumeArray
simply for the eye
STL namespace.