ATLAS Offline Software
StagedTrackingGeometryBuilderImpl.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef INDETTRACKINGGEOMETRY_STAGEDTRACKINGGEOMETRYBUILDERIMPL_H
6 #define INDETTRACKINGGEOMETRY_STAGEDTRACKINGGEOMETRYBUILDERIMPL_H
7 
8 //Trk
15 // EnvelopeDefinitionService
17 // Athena
21 // Gaudi
22 #include "GaudiKernel/ToolHandle.h"
23 #include "GaudiKernel/ServiceHandle.h"
24 // STL
25 #include <vector>
26 #include <string>
27 
29 
30 #ifndef TRKDETDESCR_TAKESMALLERBIGGER
31 #define TRKDETDESCR_TAKESMALLERBIGGER
32 #define takeSmaller(current,test) current = current < test ? current : test
33 #define takeBigger(current,test) current = current > test ? current : test
34 #define takeSmallerBigger(cSmallest, cBiggest, test) takeSmaller(cSmallest, test); takeBigger(cBiggest, test)
35 #endif
36 
37 
38 namespace Trk {
39  class Layer;
40  class Material;
41 }
42 
43 namespace InDet {
44 struct LayerSetup
45 {
46 
47  // the layer cache
48  std::vector<Trk::Layer*> negativeLayers;
49  std::vector<Trk::Layer*> centralLayers;
50  std::vector<Trk::Layer*> positiveLayers;
51 
52  // center information
55  double zExtendCenter;
57 
58  // endcap information
65 
66  // full setup information
67  double zSector;
68  double rMin;
69  double rMax;
70  double zMax;
71 
72  std::string identification;
73  int colorCode;
74 
75  LayerSetup(const std::string& idName, int cCode,
76  const std::vector<Trk::Layer*>& negLayers,
77  const std::vector<Trk::Layer*>& cenLayers,
78  const std::vector<Trk::Layer*>& posLayers, double minRc,
79  double maxRc, double zC, int binC, bool bec = false,
80  double minRe = 0., double maxRe = 0., double zMinE = 0.,
81  double zMaxE = 0., int binE = 0)
82  : negativeLayers(negLayers),
83  centralLayers(cenLayers),
84  positiveLayers(posLayers),
85  minRadiusCenter(minRc),
86  maxRadiusCenter(maxRc),
87  zExtendCenter(zC),
88  binningCenter(binC),
90  minRadiusEndcap(minRe),
91  maxRadiusEndcap(maxRe),
92  minZextendEndcap(zMinE),
93  maxZextendEndcap(zMaxE),
94  binningEndcap(binE),
95  identification(idName),
96  colorCode(cCode) {
97  rMin =
99  rMax =
102  zSector =
104  }
105 };
106 
107 
122  public AthAlgTool,
124 
125 
126  public:
128  StagedTrackingGeometryBuilderImpl(const std::string&,const std::string&,const IInterface*);
129 
132 
134  virtual StatusCode initialize() override;
136  virtual StatusCode finalize() override;
137 
138  protected:
139 
140  std::unique_ptr<Trk::TrackingGeometry> trackingGeometryImpl(
141  std::vector<InDet::LayerSetup>& layerSetups,
142  double maximumLayerExtendZ,
143  double maximumLayerRadius,
144  double envelopeVolumeHalfZ,
145  double envelopeVolumeRadius) const;
146 
148  void estimateLayerDimensions(const std::vector<Trk::Layer*>& layers,
149  double& rMin,
150  double& rMax,
151  double& zMin,
152  double& zMax) const;
153 
159  Trk::TrackingVolume* createTrackingVolume(
160  const std::vector<Trk::Layer*>& layers,
161  double innerRadius,
162  double& outerRadius,
163  double zMin,
164  double zMax,
165  const std::string& volumeName,
166  Trk::BinningType btype,
167  bool doAdjustOuterRadius = true) const;
168 
170  Trk::TrackingVolume* packVolumeTriple(
171  const std::vector<Trk::TrackingVolume*>& negVolumes,
172  const std::vector<Trk::TrackingVolume*>& centralVolumes,
173  const std::vector<Trk::TrackingVolume*>& posVolumes,
174  const std::string& baseName = "UndefinedVolume") const;
176  LayerSetup estimateLayerSetup(
177  const std::string& idName,
178  size_t ils,
179  const std::vector<Trk::Layer*>& negLayers,
180  const std::vector<Trk::Layer*>& centralLayers,
181  const std::vector<Trk::Layer*>& posLayers,
182  double maxR,
183  double maxZ) const;
184 
186  bool setupFitsCache(
187  LayerSetup& layerSetup,
188  std::vector<InDet::LayerSetup>& layerSetupCache) const;
189 
192  Trk::TrackingVolume* createFlushVolume
193  (std::vector<InDet::LayerSetup>& layerSetupCache,
194  double innerRadius,
195  double& outerRadius,
196  double extendZ) const;
197 
201  Trk::TrackingVolume* packVolumeTriple
202  (LayerSetup& layerSetup,
203  double rMin,
204  double& rMax,
205  double zMin,
206  double zPosCentral) const;
207 
209  bool ringLayout(const std::vector<Trk::Layer*>& layers, std::vector<double>& rmins, std::vector<double>& rmaxs) const;
210 
212  void checkForInsert(std::vector<double>& radii, double radius) const;
213  void checkForInsert(double rmin, double rmax, std::vector<std::pair<double, double>>& radii) const;
214 
216  std::vector<Trk::Layer*> checkZoverlap(std::vector<Trk::Layer*>& lays) const;
217  Trk::Layer* mergeDiscLayers(std::vector<Trk::Layer*>& dlays) const;
218 
219  // material configuration
221 
222  // Configurable Properties
224  PublicToolHandle<Trk::ITrackingVolumeCreator> m_trackingVolumeCreator{
225  this, "TrackingVolumeCreator",
226  "Trk::CylinderVolumeCreator/CylinderVolumeCreator"};
227  PublicToolHandle<Trk::ILayerArrayCreator> m_layerArrayCreator{
228  this, "LayerArrayCreator",
229  "Trk::LayerArrayCreator/LayerArrayCreator"};
230  // configurations for the layer builders
232  IntegerArrayProperty m_layerBinningTypeCenter{
233  this,
234  "LayerBinningTypeCenter",
235  {}};
236  IntegerArrayProperty m_layerBinningTypeEndcap{
237  this,
238  "LayerBinningTypeEndcap",
239  {}};
240  IntegerArrayProperty m_colorCodesConfig{
241  this, "ColorCodes", {}};
242 
243  // enclosing endcap/cylinder layer
244  ServiceHandle<IEnvelopeDefSvc> m_enclosingEnvelopeSvc{
245  this, "EnvelopeDefinitionSvc",
246  "AtlasEnvelopeDefSvc"};
247  DoubleArrayProperty m_enclosingCylinderRadius{
248  this,
249  "VolumeEnclosureCylinderRadii",
250  {}};
251  DoubleArrayProperty m_enclosingDiscPositionZ{
252  this,
253  "VolumeEnclosureDiscPositions",
254  {}};
255 
256  DoubleProperty m_layerEnvelopeCover{
257  this, "EnvelopeCover",
258  2 * Gaudi::Units::mm};
259  BooleanProperty m_buildBoundaryLayers{this, "BuildBoundaryLayers",
260  true};
261  BooleanProperty m_replaceJointBoundaries{
262  this, "ReplaceAllJointBoundaries",
263  true};
264 
265  // robust layer indexing
266  BooleanProperty m_indexStaticLayers{
267  this, "IndexStaticLayers",
268  true};
269 
270  // check for endcap ring layout
271  BooleanProperty m_checkForRingLayout{
272  this, "CheckForRingLayout",
273  false};
274  DoubleProperty m_ringTolerance{
275  this, "MinimalRadialGapForVolumeSplit",
276  10 * Gaudi::Units::mm};
277 
278  // naming schema
279  StringProperty m_namespace{this, "VolumeNamespace",
280  "InDet::"};
281  // ID container
282  StringProperty m_exitVolume{
283  this, "ExitVolumeName",
284  "InDet::Containers::InnerDetector"};
285 
286  // Make room for HGTD (3420 mm < |z| < 3545 mm) within the ID tracking geometry volume
287  // This will be filled by the dedicated HGTD Tracking Geometry Builder
288  // and volumes will be glued when the combined tracking geometry is built
289  BooleanProperty m_removeHGTD{this, "RemoveHGTD", false};
290  FloatProperty m_zMinHGTD{this, "ZminHGTD", 3420.f};
291  };
292 
293  inline void StagedTrackingGeometryBuilderImpl::checkForInsert(std::vector<double>& radii, double radius) const {
294  bool exists = false;
295  // loop and check
296  for (auto& checkr : radii) {
297  if ( (checkr-radius)*(checkr-radius) < m_ringTolerance*m_ringTolerance ){
298  exists = true; break;
299  }
300  }
301  // insert
302  if (!exists) radii.push_back(radius);
303  // re-sort
304  std::sort(radii.begin(),radii.end());
305  }
306 
307  inline void StagedTrackingGeometryBuilderImpl::checkForInsert(double rmin, double rmax, std::vector<std::pair<double, double>>& radii) const {
308 
309  // range into non-overlapping layers
310 
311  if (!radii.size()) radii.push_back(std::pair<double,double>(rmin,rmax));
312 
313  unsigned int ir=0;
314  while ( ir != radii.size() && rmin > radii[ir].second ) ir++;
315 
316  if (ir==radii.size()) radii.push_back(std::pair<double,double>(rmin,rmax));
317  // insert ?
318  else if (rmax<radii[ir].first) radii.insert(radii.begin()+ir,std::pair<double,double>(rmin,rmax));
319  // overlaps
320  else {
321  // resolve low edge
322  if (rmin<radii[ir].first) radii[ir].first=rmin;
323  // resolve upper edge
324  unsigned int imerge = ir;
325  while (imerge<radii.size()-1 && rmax>radii[imerge+1].first) imerge++;
326  radii[ir].second = rmax > radii[imerge].second ? rmax : radii[imerge].second;
327  if (imerge>ir) radii.erase(radii.begin()+ir+1,radii.begin()+imerge);
328  }
329  }
330 
331 
332 } // end of namespace
333 
334 #endif //INDETTRACKINGGEOMETRY_STAGEDTRACKINGGEOMETRYBUILDERIMPL_H
Trk::TrackingVolumeManipulator
Definition: TrackingVolumeManipulator.h:32
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
InDet::LayerSetup::zSector
double zSector
Definition: StagedTrackingGeometryBuilderImpl.h:67
InDet::LayerSetup
Definition: StagedTrackingGeometryBuilderImpl.h:45
IGeometryBuilderCond.h
InDet::LayerSetup::minRadiusCenter
double minRadiusCenter
Definition: StagedTrackingGeometryBuilderImpl.h:53
IEnvelopeDefSvc.h
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
initialize
void initialize()
Definition: run_EoverP.cxx:894
InDet::LayerSetup::buildEndcap
bool buildEndcap
Definition: StagedTrackingGeometryBuilderImpl.h:59
CxxUtils::CachedUniquePtrT< Trk::Material >
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
BinningType.h
Trk::BinningType
BinningType
Definition: BinningType.h:31
InDet::LayerSetup::rMax
double rMax
Definition: StagedTrackingGeometryBuilderImpl.h:69
python.RingerConstants.Layer
Layer
Definition: RingerConstants.py:42
ILayerArrayCreator.h
InDet::StagedTrackingGeometryBuilderImpl::m_ringTolerance
DoubleProperty m_ringTolerance
the ring tolerance
Definition: StagedTrackingGeometryBuilderImpl.h:274
InDet::LayerSetup::zExtendCenter
double zExtendCenter
Definition: StagedTrackingGeometryBuilderImpl.h:55
InDet::LayerSetup::maxRadiusEndcap
double maxRadiusEndcap
Definition: StagedTrackingGeometryBuilderImpl.h:61
InDet::LayerSetup::maxRadiusCenter
double maxRadiusCenter
Definition: StagedTrackingGeometryBuilderImpl.h:54
InDet::LayerSetup::zMax
double zMax
Definition: StagedTrackingGeometryBuilderImpl.h:70
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
ITrackingVolumeCreator.h
CachedUniquePtr.h
Cached unique_ptr with atomic update.
InDet::LayerSetup::minZextendEndcap
double minZextendEndcap
Definition: StagedTrackingGeometryBuilderImpl.h:62
InDet::LayerSetup::maxZextendEndcap
double maxZextendEndcap
Definition: StagedTrackingGeometryBuilderImpl.h:63
InDet::StagedTrackingGeometryBuilderImpl::checkForInsert
void checkForInsert(std::vector< double > &radii, double radius) const
helper method needed for the Ring layout
Definition: StagedTrackingGeometryBuilderImpl.h:293
InDet::LayerSetup::minRadiusEndcap
double minRadiusEndcap
Definition: StagedTrackingGeometryBuilderImpl.h:60
InDet::StagedTrackingGeometryBuilderImpl::m_materialProperties
CxxUtils::CachedUniquePtrT< Trk::Material > m_materialProperties
overal material properties of the ID
Definition: StagedTrackingGeometryBuilderImpl.h:220
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
InDet::StagedTrackingGeometryBuilderImpl::~StagedTrackingGeometryBuilderImpl
virtual ~StagedTrackingGeometryBuilderImpl()=default
Destructor.
InDet::LayerSetup::colorCode
int colorCode
Definition: StagedTrackingGeometryBuilderImpl.h:73
InDet::StagedTrackingGeometryBuilderImpl
Definition: StagedTrackingGeometryBuilderImpl.h:123
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
InDet::LayerSetup::binningEndcap
int binningEndcap
Definition: StagedTrackingGeometryBuilderImpl.h:64
TrackingVolumeManipulator.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
InDet::LayerSetup::binningCenter
int binningCenter
Definition: StagedTrackingGeometryBuilderImpl.h:56
DeMoScan.first
bool first
Definition: DeMoScan.py:534
InDet::LayerSetup::positiveLayers
std::vector< Trk::Layer * > positiveLayers
Definition: StagedTrackingGeometryBuilderImpl.h:50
InDet::LayerSetup::negativeLayers
std::vector< Trk::Layer * > negativeLayers
Definition: StagedTrackingGeometryBuilderImpl.h:48
TrackingGeometry.h
InDet::LayerSetup::centralLayers
std::vector< Trk::Layer * > centralLayers
Definition: StagedTrackingGeometryBuilderImpl.h:49
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
AthAlgTool
Definition: AthAlgTool.h:26
InDet::LayerSetup::LayerSetup
LayerSetup(const std::string &idName, int cCode, const std::vector< Trk::Layer * > &negLayers, const std::vector< Trk::Layer * > &cenLayers, const std::vector< Trk::Layer * > &posLayers, double minRc, double maxRc, double zC, int binC, bool bec=false, double minRe=0., double maxRe=0., double zMinE=0., double zMaxE=0., int binE=0)
Definition: StagedTrackingGeometryBuilderImpl.h:75
checker_macros.h
Define macros for attributes used to control the static checker.
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Material
@ Material
Definition: MaterialTypes.h:8
InDet::LayerSetup::identification
std::string identification
Definition: StagedTrackingGeometryBuilderImpl.h:72
Trk::Layer
Definition: Layer.h:73
ServiceHandle< IEnvelopeDefSvc >
InDet::LayerSetup::rMin
double rMin
Definition: StagedTrackingGeometryBuilderImpl.h:68