ATLAS Offline Software
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  : m_trkVolume()
19  , m_name("undefined")
20  , m_layerRepresentation(nullptr)
21  , m_multilayerRepresentation(nullptr)
22  , m_baseTransform(nullptr)
23  , m_constituents(nullptr)
24 {}
25 
27  Trk::TrackingVolume* volume)
28  : m_trkVolume(volume)
29  , m_name(std::move(name))
30  , m_layerRepresentation(nullptr)
31  , m_multilayerRepresentation(nullptr)
32  , m_baseTransform(nullptr)
33  , m_constituents(nullptr)
34 {}
35 
37  std::string name,
38  Trk::TrackingVolume* volume,
39  Trk::Layer* lay,
40  const std::vector<Trk::Layer*>* multilay)
41  : m_trkVolume(volume)
42  , m_name(std::move(name))
43  , m_layerRepresentation(lay)
44  , m_multilayerRepresentation(multilay)
45  , m_baseTransform(nullptr)
46  , m_constituents(nullptr)
47 {}
48 
50  delete m_trkVolume;
51  if (m_layerRepresentation) delete m_layerRepresentation;
52  if (m_multilayerRepresentation) {
53  for (auto *layer : *m_multilayerRepresentation)
54  delete layer;
55  delete m_multilayerRepresentation;
56  }
57  delete m_baseTransform;
58 }
59 
60 void
62 {
63  m_trkVolume->moveTV(shift);
64  if (m_layerRepresentation) {
65  m_layerRepresentation->moveLayer(shift);
66  }
67  if (m_multilayerRepresentation) {
68  for (auto *layer : *m_multilayerRepresentation) {
69  layer->moveLayer(shift);
70  }
71  }
72 }
73 
76  Amg::Transform3D& shift) const
77 {
78  Trk::TrackingVolume* newTV =
79  new TrackingVolume(*(this->trackingVolume()), shift);
80  Trk::DetachedTrackingVolume* newStat = nullptr;
81  // layer representation ?
82  Trk::PlaneLayer* newLay = nullptr;
83  if (this->layerRepresentation()) {
84  std::vector<Trk::Layer*>* newMulti = nullptr;
85  const Trk::PlaneLayer* pl =
86  dynamic_cast<const Trk::PlaneLayer*>(this->layerRepresentation());
87  if (pl) {
88  newLay = new Trk::PlaneLayer(*pl);
89  newLay->moveLayer(shift);
90  if (!this->multilayerRepresentation().empty()) {
91  newMulti = new std::vector<Trk::Layer*>;
92  for (unsigned int i = 0; i < this->multilayerRepresentation().size();
93  i++) {
94  const Trk::PlaneLayer* mpl = dynamic_cast<const Trk::PlaneLayer*>(
95  (this->multilayerRepresentation())[i]);
96  if (mpl) {
97  Trk::PlaneLayer* newPl = new Trk::PlaneLayer(*mpl);
98  newPl->moveLayer(shift);
99  newMulti->push_back(newPl);
100  } else
101  std::cout << "WARNING Trk::DetachedTrackingVolume::clone() "
102  "dynamic cast to 'const Trk::PlaneLayer* mpl' failed!"
103  << std::endl;
104  }
105  }
106  newStat = new Trk::DetachedTrackingVolume(name, newTV, newLay, newMulti);
107  } else {
108  std::cout << "WARNING Trk::DetachedTrackingVolume::clone() dynamic "
109  "cast to 'const Trk::PlaneLayer* pl' failed!"
110  << std::endl;
111  newStat = new Trk::DetachedTrackingVolume(name, newTV);
112  }
113  } else {
114  newStat = new Trk::DetachedTrackingVolume(name, newTV);
115  }
116  //
117  // enclose layers
118  if (newTV->confinedVolumes()) {
120  newTV->confinedVolumes()->arrayObjects();
121  for (auto *vol : vols) {
122  Trk::LayerArray* layAr = vol->confinedLayers();
124  vol->confinedArbitraryLayers();
125  if (layAr) {
127  for (auto *lay : lays) {
128  lay->encloseDetachedTrackingVolume(*newStat);
129  }
130  }
131  if (!alays.empty()) {
132  for (auto *alay : alays) {
133  alay->encloseDetachedTrackingVolume(*newStat);
134  }
135  }
136  }
137  }
138  if (newTV->confinedLayers()) {
140  newTV->confinedLayers()->arrayObjects();
141  for (auto *lay : lays){
142  lay->encloseDetachedTrackingVolume(*newStat);
143  }
144  }
145  if (!newTV->confinedArbitraryLayers().empty()) {
147  newTV->confinedArbitraryLayers();
148  for (auto *alay : alays) {
149  alay->encloseDetachedTrackingVolume(*newStat);
150  }
151  }
152  //
153  newStat->saveConstituents(this->constituents());
154  return newStat;
155 }
156 
157 void
158 Trk::DetachedTrackingVolume::compactify(size_t& cSurfaces, size_t& tSurfaces)
159 {
160  // deal with the Tracking Volume representation
161  if (m_trkVolume)
162  m_trkVolume->compactify(cSurfaces, tSurfaces);
163 
164  // deal with the layer representation
165  if (layerRepresentation()) {
166  ++tSurfaces;
167  if (layerRepresentation()->surfaceRepresentation().owner() == Trk::noOwn) {
168  layerRepresentation()->surfaceRepresentation().setOwner(Trk::TGOwn);
169  ++cSurfaces;
170  }
171  }
172  // deal with the multi-layer representation
173  if (!multilayerRepresentation().empty()) {
174  tSurfaces += m_multilayerRepresentation->size();
175  for (const auto& mLayerIter : (*m_multilayerRepresentation)) {
176  if ((*mLayerIter).surfaceRepresentation().owner() == Trk::noOwn) {
177  (*mLayerIter).surfaceRepresentation().setOwner(Trk::TGOwn);
178  ++cSurfaces;
179  }
180  }
181  }
182  //<< !@ TODO include volumes
183 }
184 
185 void
187  GeometryType geotype)
188 {
189  m_trkVolume->sign(signat, geotype);
190 }
191 
193  return m_trkVolume->geometrySignature();
194 }
195 
197  return m_trkVolume->geometryType();
198 }
199 
201  if (transf)
202  m_baseTransform = transf;
203  else {
204  delete m_baseTransform;
205  m_baseTransform = new Amg::Transform3D(this->trackingVolume()->transform());
206  }
207 }
208 
Trk::DetachedTrackingVolume::sign
void sign(GeometrySignature signat, GeometryType geotype)
sign the volume - the geometry builder has to do that
Definition: DetachedTrackingVolume.cxx:186
GeometrySignature
Trk::noOwn
@ noOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:54
Trk::DetachedTrackingVolume::DetachedTrackingVolume
DetachedTrackingVolume()
Default Constructor.
Definition: DetachedTrackingVolume.cxx:17
Trk::DetachedTrackingVolume::compactify
void compactify(size_t &cSurfaces, size_t &tSurfaces)
Compactify – set TG as owner to surfaces.
Definition: DetachedTrackingVolume.cxx:158
Layer.h
Trk::DetachedTrackingVolume::~DetachedTrackingVolume
~DetachedTrackingVolume()
Destructor.
Definition: DetachedTrackingVolume.cxx:49
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
Trk::TrackingVolume::confinedLayers
const LayerArray * confinedLayers() const
Return the subLayer array.
Trk::DetachedTrackingVolume::move
void move(Amg::Transform3D &shift)
moving object around
Definition: DetachedTrackingVolume.cxx:61
Trk::GeometrySignature
GeometrySignature
Definition: GeometrySignature.h:24
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::ArraySpan
std::span< T > ArraySpan
Definition: DetachedTrackingVolume.h:34
Trk::TrackingVolume::confinedArbitraryLayers
ArraySpan< Layer const *const > confinedArbitraryLayers() const
Return the confined subLayer array.
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Trk::DetachedTrackingVolume::saveConstituents
void saveConstituents(const std::vector< std::pair< std::unique_ptr< const Trk::Volume >, float >> *)
set the simplified calculable components
Definition: DetachedTrackingVolume.h:164
Trk::PlaneLayer
Definition: PlaneLayer.h:40
Trk::PlaneLayer::moveLayer
virtual void moveLayer(Amg::Transform3D &shift) override final
move the Layer
Definition: PlaneLayer.cxx:83
DetachedTrackingVolume.h
Trk::TGOwn
@ TGOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:55
Trk::DetachedTrackingVolume::clone
DetachedTrackingVolume * clone(const std::string &name, Amg::Transform3D &shift) const
clone with transform
Definition: DetachedTrackingVolume.cxx:75
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Trk::BinnedArray::arrayObjects
virtual BinnedArraySpan< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
TrackingVolume.h
Trk::TrackingVolume::confinedVolumes
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
Trk::DetachedTrackingVolume::setBaseTransform
void setBaseTransform(Amg::Transform3D *transf=nullptr)
alignment methods: set base transform / default argument to current transform
Definition: DetachedTrackingVolume.cxx:200
Trk::GeometryType
GeometryType
Definition: GeometrySignature.h:37
Trk::DetachedTrackingVolume::geometryType
GeometryType geometryType() const
return the Type
Definition: DetachedTrackingVolume.cxx:196
Trk::BinnedArray
Definition: BinnedArray.h:38
Trk::DetachedTrackingVolume
Definition: DetachedTrackingVolume.h:46
Trk::DetachedTrackingVolume::geometrySignature
GeometrySignature geometrySignature() const
return the Signature
Definition: DetachedTrackingVolume.cxx:192
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::BinnedArraySpan
std::span< T > BinnedArraySpan
Definition: BinnedArray.h:34
Trk::Layer
Definition: Layer.h:73