ATLAS Offline Software
ActsStrawLayerBuilder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ATHENA
9 #include "Identifier/Identifier.h"
10 
11 // PACKAGE
14 
15 // ACTS
16 #include "Acts/Geometry/ILayerBuilder.hpp"
17 #include "Acts/Surfaces/CylinderSurface.hpp"
18 #include "Acts/Surfaces/StrawSurface.hpp"
19 #include "Acts/Surfaces/DiscSurface.hpp"
20 #include "Acts/Geometry/LayerCreator.hpp"
21 #include "Acts/Definitions/Algebra.hpp"
22 #include "Acts/Geometry/ProtoLayer.hpp"
23 #include "Acts/Geometry/GeometryContext.hpp"
24 #include "Acts/Definitions/Units.hpp"
25 #include "Acts/Utilities/BinningType.hpp"
26 
27 // STL
28 #include <iostream>
29 #include <fstream>
30 
31 using namespace Acts::UnitLiterals;
32 
33 const Acts::LayerVector
34 ActsStrawLayerBuilder::negativeLayers(const Acts::GeometryContext& gctx) const
35 {
36  return endcapLayers(gctx, -1);
37 }
38 
39 const Acts::LayerVector
40 ActsStrawLayerBuilder::positiveLayers(const Acts::GeometryContext& gctx) const
41 {
42  return endcapLayers(gctx, 1);
43 
44 }
45 
46 
47 const Acts::LayerVector
48 ActsStrawLayerBuilder::centralLayers(const Acts::GeometryContext& gctx) const
49 {
50  ACTS_VERBOSE("Building central Straw layers");
51 
52  using LBBV = Acts::LineBounds::BoundValues;
53 
54  const InDetDD::TRT_Numerology* trtNums = m_cfg.mng->getNumerology();
55  size_t nBarrelRings = trtNums->getNBarrelRings();
56  size_t nBarrelPhiSectors = trtNums->getNBarrelPhi();
57 
58 
59  ACTS_VERBOSE("- Numerology reports: - " << nBarrelRings << " barrel rings");
60  ACTS_VERBOSE(" - " << nBarrelPhiSectors << " barrel phi sectors");
61 
62  Acts::LayerVector layers;
63 
64  std::vector<Acts::ProtoLayer> protoLayers;
65 
66  for(size_t iring=0; iring < nBarrelRings;iring++) {
67  ACTS_VERBOSE("- Collecting elements for ring " << iring);
68 
69  // were calculating min/max radius while were at it.
70  Acts::ProtoLayer pl;
71  auto& ext = pl.extent;
73  ext.range(Acts::BinningValue::binR).setMax( std::numeric_limits<double>::lowest() );
75  ext.range(Acts::BinningValue::binZ).setMax( std::numeric_limits<double>::lowest() );
76  ext.range(Acts::BinningValue::binPhi).setMin( -M_PI );
77  ext.range(Acts::BinningValue::binPhi).setMax( M_PI );
78 
79  pl.envelope[Acts::BinningValue::binZ] = {1_mm, 1_mm};
80  pl.envelope[Acts::BinningValue::binR] = {0_mm, 0_mm};
81 
82  double fudge = 0_mm;
83  // RING in TRT speak is translated to Layer in ACTS speak
84  std::vector<std::shared_ptr<const Acts::Surface>> layerSurfaces;
85 
86  size_t nBarrelLayers = trtNums->getNBarrelLayers(iring);
87  ACTS_VERBOSE(" - Numerology reports: " << nBarrelLayers << " layers in ring " << iring);
88  for (size_t ilayer=0;ilayer < nBarrelLayers;ilayer++) {
89  for (size_t iphisec=0;iphisec < nBarrelPhiSectors;iphisec++) {
90  // what is this?
91  for (size_t iposneg=0;iposneg<2;iposneg++) {
92 
93  const InDetDD::TRT_BarrelElement* brlElem
94  = m_cfg.mng->getBarrelElement(iposneg, iring, iphisec, ilayer);
95 
96  unsigned int nStraws = brlElem->nStraws();
97 
98  for(unsigned int istraw=0;istraw<nStraws;istraw++) {
99 
100  Acts::Transform3 trf = brlElem->strawTransform(istraw);
101  // need to convert translation to length unit
102  trf.translation() *= 1_mm;
103  auto code = brlElem->getCode();
104  Identifier straw_id = m_cfg.idHelper->straw_id(code.isPosZ() == 1 ? 1 : -1,
105  code.getPhiIndex(),
106  code.getModuleIndex(),
107  code.getStrawLayerIndex(),
108  istraw);
109 
110  auto elem = std::make_shared<const ActsDetectorElement>(
111  trf, *brlElem, straw_id);
112 
113  m_cfg.elementStore->push_back(elem);
114 
115  auto straw = dynamic_cast<const Acts::StrawSurface*>(&elem->surface());
116  if (not straw) continue;
117  auto strawBounds = dynamic_cast<const Acts::LineBounds*>(&straw->bounds());
118  if (not strawBounds) continue;
119  // units should be fine since they're already converted in det elem construction
120  double radius = strawBounds->get(LBBV::eR);
121  double length = strawBounds->get(LBBV::eHalfLengthZ);
122  fudge = radius / 4.;
123 
124  // calculate min/max R and Z
125  Acts::Vector3 ctr = straw->center(gctx);
130 
131  layerSurfaces.push_back(straw->getSharedPtr());
132  }
133  }
134  }
135  }
136 
137  ACTS_VERBOSE(" - Collected " << layerSurfaces.size() << " straws");
138 
139  if(iring > 0) {
140  // match outer radius of previous ring
141  const Acts::ProtoLayer &prev = protoLayers.at(iring-1);
142  ext.range(Acts::BinningValue::binR).setMin( prev.extent.max(Acts::BinningValue::binR) + prev.envelope[Acts::BinningValue::binR][1] + pl.envelope[Acts::BinningValue::binR][0] + fudge );
143  }
144 
145  std::shared_ptr<Acts::Layer> layer
146  = m_cfg.layerCreator->cylinderLayer(gctx, std::move(layerSurfaces), 100, 1, pl);
147  layers.push_back(layer);
148 
149  protoLayers.push_back(pl);
150 
151  }
152 
153  return layers;
154 }
155 
156 const Acts::LayerVector
157 ActsStrawLayerBuilder::endcapLayers(const Acts::GeometryContext& gctx, int side) const
158 {
159  ACTS_VERBOSE("Building endcap Straw layers");
160  using LBBV = Acts::LineBounds::BoundValues;
161 
162  const InDetDD::TRT_Numerology* trtNums = m_cfg.mng->getNumerology();
163  size_t nEndcapWheels = trtNums->getNEndcapWheels();
164  size_t nEndcapPhiSectors = trtNums->getNEndcapPhi();
165 
166  ACTS_VERBOSE("- Numerology reports: - " << nEndcapWheels<< " endcap wheels");
167  ACTS_VERBOSE(" - " << nEndcapPhiSectors << " endcap phi sectors");
168 
169  Acts::LayerVector layers;
170 
171  for(size_t iwheel=0;iwheel<nEndcapWheels;++iwheel) {
172  ACTS_VERBOSE("- Collecting elements for wheel " << iwheel);
173 
174 
175  size_t nEndcapLayers = trtNums->getNEndcapLayers(iwheel);
176  ACTS_VERBOSE(" - Numerology reports: " << nEndcapLayers << " layers in wheel " << iwheel);
177  for(size_t ilayer=0;ilayer<nEndcapLayers;++ilayer) {
178  std::vector<std::shared_ptr<const Acts::Surface>> wheelSurfaces;
179 
180 
181  Acts::ProtoLayer pl;
182  auto& ext = pl.extent;;
184  ext.range(Acts::BinningValue::binR).setMax( std::numeric_limits<double>::lowest() );
186  ext.range(Acts::BinningValue::binZ).setMax( std::numeric_limits<double>::lowest() );
187  ext.range(Acts::BinningValue::binPhi).setMin( -M_PI );
188  ext.range(Acts::BinningValue::binPhi).setMax( M_PI );
189  pl.envelope[Acts::BinningValue::binR] = {0_mm, 0_mm};
190 
191  for (unsigned int iphisec=0; iphisec<nEndcapPhiSectors; ++iphisec) {
192 
193  size_t iposneg = side < 0 ? 0 : 1;
194  const InDetDD::TRT_EndcapElement* ecElem = m_cfg.mng->getEndcapElement(iposneg, iwheel, ilayer, iphisec);
195  unsigned int nStraws = ecElem->nStraws();
196 
197  for(unsigned int istraw=0;istraw<nStraws;istraw++) {
198 
199  Acts::Transform3 trf = (ecElem->strawTransform(istraw));
200  // need to convert translation to length unit
201  trf.translation() *= 1_mm;
202 
203  auto code = ecElem->getCode();
204  Identifier straw_id = m_cfg.idHelper->straw_id(code.isPosZ() == 1 ? 2 : -2,
205  code.getPhiIndex(),
206  code.getWheelIndex(),
207  code.getStrawLayerIndex(),
208  istraw);
209 
210 
211  auto elem = std::make_shared<const ActsDetectorElement>(
212  trf, *ecElem, straw_id);
213 
214  m_cfg.elementStore->push_back(elem);
215 
216  auto straw = dynamic_cast<const Acts::StrawSurface*>(&elem->surface());
217  if (straw){
218  auto strawBounds = dynamic_cast<const Acts::LineBounds*>(&straw->bounds());
219  if (strawBounds){
220  double radius = strawBounds->get(LBBV::eR);
221  double length = strawBounds->get(LBBV::eHalfLengthZ);
222 
223  Acts::Vector3 ctr = straw->center(gctx);
228  pl.envelope[Acts::BinningValue::binZ] = {radius/2., radius/2.};
229 
230  wheelSurfaces.push_back(straw->getSharedPtr());
231  }
232  }
233  }
234  }
235 
236  std::shared_ptr<Acts::Layer> layer
237  = m_cfg.layerCreator->discLayer(gctx, std::move(wheelSurfaces), 1, 100, pl);
238  layers.push_back(layer);
239  ACTS_VERBOSE(" - Collected " << wheelSurfaces.size() << " straws");
240  }
241 
242  }
243 
244  ACTS_VERBOSE(" - Built " << layers.size() << " straw endcap layers");
245  return layers;
246 }
ActsStrawLayerBuilder::negativeLayers
const Acts::LayerVector negativeLayers(const Acts::GeometryContext &gctx) const override
Definition: ActsStrawLayerBuilder.cxx:34
InDetDD::TRT_BarrelElement
Definition: TRT_BarrelElement.h:44
TRT::Hit::straw
@ straw
Definition: HitInfo.h:82
TRT_DetectorManager.h
Trk::binZ
@ binZ
Definition: BinningType.h:49
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
InDetDD::TRT_BaseElement::nStraws
unsigned int nStraws() const
Number of straws in the element.
ActsStrawLayerBuilder::endcapLayers
const Acts::LayerVector endcapLayers(const Acts::GeometryContext &gctx, int side) const
Definition: ActsStrawLayerBuilder.cxx:157
ActsStrawLayerBuilder.h
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
ActsStrawLayerBuilder::centralLayers
const Acts::LayerVector centralLayers(const Acts::GeometryContext &gctx) const override
Definition: ActsStrawLayerBuilder.cxx:48
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDetDD::TRT_EndcapElement
Definition: TRT_EndcapElement.h:44
TRT::Hit::side
@ side
Definition: HitInfo.h:83
InDetDD::TRT_Numerology::getNEndcapWheels
unsigned int getNEndcapWheels() const
histSizes.code
code
Definition: histSizes.py:129
InDetDD::TRT_Numerology
Definition: TRT_Numerology.h:22
InDetDD::TRT_EndcapElement::getCode
const TRT_EndcapCode & getCode() const
Doomed (??)
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
ActsStrawLayerBuilder::positiveLayers
const Acts::LayerVector positiveLayers(const Acts::GeometryContext &gctx) const override
Definition: ActsStrawLayerBuilder.cxx:40
InDetDD::TRT_Numerology::getNBarrelPhi
unsigned int getNBarrelPhi() const
InDetDD::TRT_Numerology::getNBarrelLayers
unsigned int getNBarrelLayers(unsigned int iMod) const
MakeFileForMJB.ext
string ext
Definition: Moriond2016/MakeFileForMJB.py:41
ActsDetectorElement.h
InDetDD::TRT_BarrelElement::getCode
const TRT_BarrelCode & getCode() const
Doomed (?):
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
Trk::binR
@ binR
Definition: BinningType.h:50
InDetDD::TRT_BaseElement::strawTransform
const Amg::Transform3D & strawTransform(unsigned int straw) const
Straw transform - fast access in array, in Tracking frame: Amg.
Definition: TRT_BaseElement.cxx:89
TRT_Numerology.h
InDetDD::TRT_Numerology::getNEndcapPhi
unsigned int getNEndcapPhi() const
InDetDD::TRT_Numerology::getNEndcapLayers
unsigned int getNEndcapLayers(unsigned int iWheel) const
InDetDD::TRT_Numerology::getNBarrelRings
unsigned int getNBarrelRings() const
CaloLCW_tf.trf
trf
Definition: CaloLCW_tf.py:20
dqt_zlumi_alleff_HIST.ctr
ctr
Definition: dqt_zlumi_alleff_HIST.py:193
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
Trk::binPhi
@ binPhi
Definition: BinningType.h:51
Identifier
Definition: IdentifierFieldParser.cxx:14