ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ActsHGTDLayerBuilder Class Reference

#include <ActsHGTDLayerBuilder.h>

Inheritance diagram for ActsHGTDLayerBuilder:
Collaboration diagram for ActsHGTDLayerBuilder:

Classes

struct  Config
 

Public Types

using ElementVector = ActsElementVector
 

Public Member Functions

 ActsHGTDLayerBuilder (const Config &cfg, std::unique_ptr< const Acts::Logger > logger)
 Constructor. More...
 
virtual ~ActsHGTDLayerBuilder ()=default
 Destructor. More...
 
virtual const Acts::LayerVector negativeLayers (const Acts::GeometryContext &gctx) const override
 
virtual const Acts::LayerVector centralLayers (const Acts::GeometryContext &gctx) const override
 
virtual const Acts::LayerVector positiveLayers (const Acts::GeometryContext &gctx) const override
 
virtual const std::string & identification () const override
 

Private Member Functions

const Acts::Logger & logger () const
 Private access to the logger. More...
 
std::vector< std::shared_ptr< const ActsDetectorElement > > getDetectorElements () const
 
void buildEndcap (const Acts::GeometryContext &gctx, Acts::LayerVector &layersOutput, int type=0) const
 

Private Attributes

Config m_cfg
 configuration object More...
 
std::unique_ptr< const Acts::Logger > m_logger
 logging instance More...
 

Detailed Description

Definition at line 35 of file ActsHGTDLayerBuilder.h.

Member Typedef Documentation

◆ ElementVector

Definition at line 39 of file ActsHGTDLayerBuilder.h.

Constructor & Destructor Documentation

◆ ActsHGTDLayerBuilder()

ActsHGTDLayerBuilder::ActsHGTDLayerBuilder ( const Config cfg,
std::unique_ptr< const Acts::Logger >  logger 
)

Constructor.

Parameters
cfgis the configuration struct
loggerthe local logging instance

Definition at line 40 of file ActsHGTDLayerBuilder.cxx.

42  : m_cfg (cfg),
43  m_logger(std::move(logger))
44 {
45 }

◆ ~ActsHGTDLayerBuilder()

virtual ActsHGTDLayerBuilder::~ActsHGTDLayerBuilder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ buildEndcap()

void ActsHGTDLayerBuilder::buildEndcap ( const Acts::GeometryContext &  gctx,
Acts::LayerVector &  layersOutput,
int  type = 0 
) const
private

Definition at line 70 of file ActsHGTDLayerBuilder.cxx.

72 {
73 
74  ACTS_VERBOSE("Build layers: " << (type < 0 ? "NEGATIVE" : "POSITIVE")
75  << " ENDCAP");
76 
77  std::vector<std::shared_ptr<const ActsDetectorElement>> elements =
79  std::map<int, std::vector<const Acts::Surface *>>
80  initialLayers{};
81 
82  for (const auto &element : elements) {
83 
84  Identifier currentId(element->identify());
85  // Check if the element is in the correct endcap (type -1 or 1)
86  if (m_cfg.idHelper->endcap(currentId) * type <= 0) {
87  continue;
88  }
89 
90  m_cfg.elementStore->push_back(element);
91  int currentLayer {m_cfg.idHelper->layer(currentId)};
92 
93  initialLayers[currentLayer].push_back(&element->surface());
94  }
95 
96  ACTS_VERBOSE("Found " << initialLayers.size() << " "
97  << (type < 0 ? "NEGATIVE" : "POSITIVE")
98  << " ENDCAP inital layers");
99 
100  // Loops over a provided vector of surface and calculates the various
101  // min/max values in one go. Also takes into account the thickness
102  // of an associated DetectorElement, if it exists.
103  //
104  // @param gctx The current geometry context object, e.g. alignment
105  // @param surfaces The vector of surfaces to consider
106 
107  std::vector<Acts::ProtoLayer> protoLayers;
108  protoLayers.reserve(initialLayers.size());
109 
110  for (const auto &[key, surfaces] : initialLayers) {
111  auto &pl = protoLayers.emplace_back(gctx, surfaces);
114  }
115 
116 
117  // sort proto layers by their medium z position
118  std::sort(protoLayers.begin(), protoLayers.end(),
119  [type](const Acts::ProtoLayer &a, const Acts::ProtoLayer &b) {
120  double midA = (a.min(Acts::BinningValue::binZ) + a.max(Acts::BinningValue::binZ)) / 2.0;
121  double midB = (b.min(Acts::BinningValue::binZ) + b.max(Acts::BinningValue::binZ)) / 2.0;
122  if (type < 0) {
123  return midA < midB;
124  } else {
125  return midA > midB;
126  }
127  });
128 
129  std::vector<std::shared_ptr<const Surface>> ownedSurfaces;
130  for (const auto &pl : protoLayers) {
131 
132  std::unique_ptr<Acts::ApproachDescriptor> approachDescriptor = nullptr;
133  std::shared_ptr<const Acts::ProtoSurfaceMaterial> materialProxy = nullptr;
134 
135  double layerZ = pl.medium(Acts::BinningValue::binZ);
136  double layerHalfZ = 0.5 * pl.range(Acts::BinningValue::binZ);
137 
138  double layerZInner = layerZ - layerHalfZ;
139  double layerZOuter = layerZ + layerHalfZ;
140 
141  if (std::abs(layerZInner) > std::abs(layerZOuter))
142  std::swap(layerZInner, layerZOuter);
143 
144  std::vector<std::shared_ptr<const Acts::Surface>> aSurfaces;
145 
146  Acts::Transform3 transformNominal(Translation3(0., 0., layerZ));
147  Acts::Transform3 transformInner(Translation3(0., 0., layerZInner));
148  Acts::Transform3 transformOuter(Translation3(0., 0., layerZOuter));
149 
150  std::shared_ptr<Acts::DiscSurface> innerBoundary =
151  Acts::Surface::makeShared<Acts::DiscSurface>(
152  transformInner, pl.min(Acts::BinningValue::binR), pl.max(Acts::BinningValue::binR));
153  aSurfaces.push_back(innerBoundary);
154 
155  std::shared_ptr<Acts::DiscSurface> nominalSurface =
156  Acts::Surface::makeShared<Acts::DiscSurface>(
157  transformNominal, pl.min(Acts::BinningValue::binR), pl.max(Acts::BinningValue::binR));
158  aSurfaces.push_back(nominalSurface);
159 
160  std::shared_ptr<Acts::DiscSurface> outerBoundary =
161  Acts::Surface::makeShared<Acts::DiscSurface>(
162  transformOuter, pl.min(Acts::BinningValue::binR), pl.max(Acts::BinningValue::binR));
163  aSurfaces.push_back(outerBoundary);
164 
165  size_t matBinsPhi = m_cfg.endcapMaterialBins.first;
166  size_t matBinsR = m_cfg.endcapMaterialBins.second;
167 
168  Acts::BinUtility materialBinUtil(matBinsPhi, -M_PI, M_PI, Acts::closed,
170  materialBinUtil +=
171  Acts::BinUtility(matBinsR, pl.min(Acts::BinningValue::binR), pl.max(Acts::BinningValue::binR),
172  Acts::open, Acts::BinningValue::binR, transformNominal);
173 
174  materialProxy =
175  std::make_shared<const Acts::ProtoSurfaceMaterial>(materialBinUtil);
176 
177  ACTS_VERBOSE("[L] Layer is marked to carry support material on Surface ( "
178  "inner=0 / center=1 / outer=2 ) : "
179  << "inner");
180  ACTS_VERBOSE("with binning: [" << matBinsPhi << ", " << matBinsR << "]");
181 
182  ACTS_VERBOSE("Created ApproachSurfaces for disc layer at:");
183  ACTS_VERBOSE(" - inner: Z=" << layerZInner);
184  ACTS_VERBOSE(" - central: Z=" << layerZ);
185  ACTS_VERBOSE(" - outer: Z=" << layerZOuter);
186 
187  // set material on inner
188  innerBoundary->assignSurfaceMaterial(materialProxy);
189 
190  std::set<int> phiModuleByRing;
191  // want to figure out bins in phi
192  for (const auto &srf : pl.surfaces()) {
193  auto elm = dynamic_cast<const ActsDetectorElement *>(
194  srf->associatedDetectorElement());
195  if (elm) {
196  auto id = elm->identify();
197  phiModuleByRing.insert(m_cfg.idHelper->phi_module(id));
198  }
199  }
200 
201  size_t nModPhi = 50; //phiModuleByRing.size();
202  size_t nModR = 1;// pl.surfaces().size()/nModPhi;
203 
204  ACTS_VERBOSE("Identifier reports: " << nModPhi << " is lowest for " << nModR
205  << " r-rings");
206 
207  size_t nBinsPhi = nModPhi;
208  size_t nBinsR = nModR;
209 
210 
211  ACTS_VERBOSE("Creating r x phi binned layer with " << nBinsR << " x "
212  << nBinsPhi << " bins");
213 
214 
215  approachDescriptor =
216  std::make_unique<Acts::GenericApproachDescriptor>(aSurfaces);
217 
218  // get ownership of pl surfaces
219  ownedSurfaces.clear();
220  ownedSurfaces.reserve(pl.surfaces().size());
221  std::transform(pl.surfaces().begin(), pl.surfaces().end(),
222  std::back_inserter(ownedSurfaces),
223  [](const auto &s) { return s->getSharedPtr(); });
224 
225  auto layer = m_cfg.layerCreator->discLayer(gctx, ownedSurfaces, nBinsR,
226  nBinsPhi, pl, transformNominal,
227  std::move(approachDescriptor));
228 
229  layersOutput.push_back( std::move(layer) );
230  }
231 }

◆ centralLayers()

const Acts::LayerVector ActsHGTDLayerBuilder::centralLayers ( const Acts::GeometryContext &  gctx) const
overridevirtual

Definition at line 56 of file ActsHGTDLayerBuilder.cxx.

56  {
57  ACTS_VERBOSE("HGTD has no central layers");
58  Acts::LayerVector layers;
59  return layers;
60 }

◆ getDetectorElements()

std::vector< std::shared_ptr< const ActsDetectorElement > > ActsHGTDLayerBuilder::getDetectorElements ( ) const
private

Definition at line 234 of file ActsHGTDLayerBuilder.cxx.

234  {
235  ACTS_VERBOSE("Retrieving detector elements from detector manager");
236  if ( not m_cfg.mng ) {
237  ACTS_ERROR("Manager is null");
238  throw std::runtime_error{"Detector manager is null"};
239  }
240  auto hgtdDetMng = static_cast<const HGTD_DetectorManager *>(m_cfg.mng);
241  ACTS_VERBOSE("Detector manager has "
242  << std::distance(hgtdDetMng->getDetectorElementBegin(),
243  hgtdDetMng->getDetectorElementEnd())
244  << " elements");
245 
246  std::vector<std::shared_ptr<const ActsDetectorElement>> elements;
247 
248  InDetDD::HGTD_DetectorElementCollection::const_iterator iter;
249  for (iter = hgtdDetMng->getDetectorElementBegin();
250  iter != hgtdDetMng->getDetectorElementEnd(); ++iter) {
251  const InDetDD::HGTD_DetectorElement *detElement =
252  dynamic_cast<InDetDD::HGTD_DetectorElement *>(*iter);
253 
254  if (not detElement) {
255  ACTS_ERROR("Detector element was nullptr");
256  throw std::runtime_error{"Corrupt detector element collection"};
257  }
258  elements.push_back(
259  std::make_shared<const ActsDetectorElement>(*detElement, (*iter)->identify()));
260  }
261  ACTS_VERBOSE("Retrieved " << elements.size() << " elements");
262 
263  return elements;
264 }

◆ identification()

virtual const std::string& ActsHGTDLayerBuilder::identification ( ) const
inlineoverridevirtual

Definition at line 92 of file ActsHGTDLayerBuilder.h.

93  {
94  return m_cfg.configurationName;
95  }

◆ logger()

const Acts::Logger& ActsHGTDLayerBuilder::logger ( ) const
inlineprivate

Private access to the logger.

Definition at line 103 of file ActsHGTDLayerBuilder.h.

104  {
105  return *m_logger;
106  }

◆ negativeLayers()

const Acts::LayerVector ActsHGTDLayerBuilder::negativeLayers ( const Acts::GeometryContext &  gctx) const
overridevirtual

Definition at line 48 of file ActsHGTDLayerBuilder.cxx.

48  {
49  ACTS_VERBOSE("Building negative layers");
50  Acts::LayerVector nVector;
51  buildEndcap(gctx, nVector, -1);
52  return nVector;
53 }

◆ positiveLayers()

const Acts::LayerVector ActsHGTDLayerBuilder::positiveLayers ( const Acts::GeometryContext &  gctx) const
overridevirtual

Definition at line 63 of file ActsHGTDLayerBuilder.cxx.

63  {
64  ACTS_VERBOSE("Building positive layers");
65  Acts::LayerVector pVector;
66  buildEndcap(gctx, pVector, 1);
67  return pVector;
68 }

Member Data Documentation

◆ m_cfg

Config ActsHGTDLayerBuilder::m_cfg
private

configuration object

Definition at line 99 of file ActsHGTDLayerBuilder.h.

◆ m_logger

std::unique_ptr<const Acts::Logger> ActsHGTDLayerBuilder::m_logger
private

logging instance

Definition at line 112 of file ActsHGTDLayerBuilder.h.


The documentation for this class was generated from the following files:
ActsHGTDLayerBuilder::Config::endcapEnvelopeZ
std::array< double, 2 > endcapEnvelopeZ
Definition: ActsHGTDLayerBuilder.h:63
ActsHGTDLayerBuilder::Config::layerCreator
std::shared_ptr< const Acts::LayerCreator > layerCreator
Definition: ActsHGTDLayerBuilder.h:50
ActsHGTDLayerBuilder::getDetectorElements
std::vector< std::shared_ptr< const ActsDetectorElement > > getDetectorElements() const
Definition: ActsHGTDLayerBuilder.cxx:234
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ActsHGTDLayerBuilder::logger
const Acts::Logger & logger() const
Private access to the logger.
Definition: ActsHGTDLayerBuilder.h:103
Trk::binZ
@ binZ
Definition: BinningType.h:49
HGTD_ID::endcap
int endcap(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: HGTD_ID.h:468
ActsHGTDLayerBuilder::buildEndcap
void buildEndcap(const Acts::GeometryContext &gctx, Acts::LayerVector &layersOutput, int type=0) const
Definition: ActsHGTDLayerBuilder.cxx:70
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
InDetDD::HGTD_DetectorElement
Definition: HGTD_DetectorElement.h:40
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::closed
@ closed
Definition: BinningType.h:41
HGTD_ID::layer
int layer(const Identifier &id) const
Definition: HGTD_ID.h:475
ActsHGTDLayerBuilder::m_logger
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Definition: ActsHGTDLayerBuilder.h:112
ActsHGTDLayerBuilder::Config::idHelper
const HGTD_ID * idHelper
Definition: ActsHGTDLayerBuilder.h:49
ActsHGTDLayerBuilder::Config::configurationName
std::string configurationName
string based identification
Definition: ActsHGTDLayerBuilder.h:47
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
ActsDetectorElement
Definition: ActsDetectorElement.h:42
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
ActsDetectorElement::identify
Identifier identify() const override final
Identifier.
Definition: ActsDetectorElement.cxx:271
ActsHGTDLayerBuilder::Config::endcapEnvelopeR
std::array< double, 2 > endcapEnvelopeR
Definition: ActsHGTDLayerBuilder.h:61
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
Trk::open
@ open
Definition: BinningType.h:40
ActsHGTDLayerBuilder::Config::mng
const HGTD_DetectorManager * mng
Definition: ActsHGTDLayerBuilder.h:48
Trk::binR
@ binR
Definition: BinningType.h:50
ActsHGTDLayerBuilder::Config::elementStore
std::shared_ptr< ElementVector > elementStore
Definition: ActsHGTDLayerBuilder.h:59
a
TList * a
Definition: liststreamerinfos.cxx:10
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HGTD_ID::phi_module
int phi_module(const Identifier &id) const
Definition: HGTD_ID.h:482
HGTD_DetectorManager
Definition: HGTD_DetectorManager.h:33
ActsHGTDLayerBuilder::Config::endcapMaterialBins
std::pair< size_t, size_t > endcapMaterialBins
Definition: ActsHGTDLayerBuilder.h:66
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
ActsHGTDLayerBuilder::m_cfg
Config m_cfg
configuration object
Definition: ActsHGTDLayerBuilder.h:99
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Trk::binPhi
@ binPhi
Definition: BinningType.h:51
Identifier
Definition: IdentifierFieldParser.cxx:14