36 class DetecorElementBase;
39 namespace ActsExamples {
47 using SurfacePosition = std::pair<const Acts::Surface*, Acts::Vector3D>;
51 std::vector<std::shared_ptr<const Acts::Surface>>
surfaces;
61 template <
typename detector_element_t>
64 using LayerStore = std::vector<std::shared_ptr<detector_element_t>>;
102 std::vector<std::shared_ptr<const Acts::ISurfaceMaterial>>
139 std::vector<std::vector<std::shared_ptr<const Acts::ISurfaceMaterial>>>
153 std::unique_ptr<const Acts::Logger>
logger =
199 template <
typename detector_element_t>
200 std::vector<ProtoLayerSurfaces>
204 std::vector<ProtoLayerSurfaces> cpLayers;
210 for (
auto& eLayers : detectorStore) {
211 imodule += eLayers.size();
217 size_t numcLayers = m_cfg.centralLayerRadii.size();
219 ACTS_DEBUG(
"Configured to build " << numcLayers
220 <<
" active central layers.");
221 cpLayers.reserve(numcLayers);
223 for (
size_t icl = 0; icl < numcLayers; ++icl) {
225 double layerR = m_cfg.centralLayerRadii.at(icl);
227 ACTS_DEBUG(
"Build layer " << icl <<
" with target radius = " << layerR);
230 std::vector<std::shared_ptr<const Acts::Surface>> sVector;
232 double layerEnvelopeCoverZ =
233 m_cfg.centralLayerEnvelopes.size()
234 ? m_cfg.centralLayerEnvelopes.at(icl).second
237 double modulePhiTilt = m_cfg.centralModuleTiltPhi.at(icl);
238 double moduleHalfX = m_cfg.centralModuleHalfX.at(icl);
239 double moduleHalfY = m_cfg.centralModuleHalfY.at(icl);
240 double moduleThickness = m_cfg.centralModuleThickness.at(icl);
244 size_t nCentralModules = m_cfg.centralModuleBinningSchema.at(icl).first *
245 m_cfg.centralModuleBinningSchema.at(icl).second;
248 << nCentralModules <<
" ( from "
249 << m_cfg.centralModuleBinningSchema.at(icl).first <<
" x "
250 << m_cfg.centralModuleBinningSchema.at(icl).second <<
" )");
252 sVector.reserve(nCentralModules);
256 std::shared_ptr<const Acts::DigitizationModule> moduleDigitizationPtr =
258 if (m_cfg.centralModuleReadoutBinsX.size()) {
260 std::shared_ptr<const Acts::Segmentation> moduleSegmentation =
261 std::make_shared<const Acts::CartesianSegmentation>(
263 m_cfg.centralModuleReadoutBinsY.at(icl));
265 moduleDigitizationPtr =
266 std::make_shared<const Acts::DigitizationModule>(
267 moduleSegmentation, 0.5 * m_cfg.centralModuleThickness.at(icl),
268 m_cfg.centralModuleReadoutSide.at(icl),
269 m_cfg.centralModuleLorentzAngle.at(icl));
274 std::shared_ptr<const Acts::ISurfaceMaterial> moduleMaterialPtr =
nullptr;
275 if (m_cfg.centralModuleMaterial.size()) {
277 moduleMaterialPtr = m_cfg.centralModuleMaterial.at(icl);
281 if (m_cfg.centralModulePositions.at(icl).size() != nCentralModules) {
282 ACTS_WARNING(
"Mismatching module numbers, configuration error!");
283 ACTS_WARNING(
"- Binning schema suggests : " << nCentralModules);
285 << m_cfg.centralModulePositions.at(icl).size());
288 for (
auto& moduleCenter : m_cfg.centralModulePositions.at(icl)) {
290 double modulePhi =
phi(moduleCenter);
293 sin(modulePhi + modulePhiTilt), 0.);
298 cos(modulePhi + modulePhiTilt), 0.);
301 moduleRotation.col(0) = moduleLocalX;
302 moduleRotation.col(1) = moduleLocalY;
303 moduleRotation.col(2) = moduleLocalZ;
305 std::shared_ptr<Acts::Transform3D> mutableModuleTransform =
306 std::make_shared<Acts::Transform3D>(
309 if (m_cfg.centralModuleFrontsideStereo.size() &&
310 m_cfg.centralModuleFrontsideStereo.at(icl) != 0.) {
312 double stereo = m_cfg.centralModuleFrontsideStereo.at(icl);
313 (*mutableModuleTransform.get()) *=
320 mutableModuleTransform);
322 auto module = std::make_shared<detector_element_t>(
323 moduleIdentifier, moduleTransform,
moduleBounds, moduleThickness,
324 moduleMaterialPtr, moduleDigitizationPtr);
327 layerStore.push_back(module);
329 sVector.push_back(module->surface().getSharedPtr());
332 if (m_cfg.centralModuleBacksideGap.size()) {
337 m_cfg.centralModuleBacksideGap.at(icl) * moduleLocalZ;
338 mutableModuleTransform = std::make_shared<Acts::Transform3D>(
341 if (m_cfg.centralModuleBacksideStereo.size()) {
343 double stereoBackSide = m_cfg.centralModuleBacksideStereo.at(icl);
344 (*mutableModuleTransform.get()) *=
349 mutableModuleTransform);
351 auto bsmodule = std::make_shared<detector_element_t>(
352 moduleIdentifier, moduleTransform,
moduleBounds, moduleThickness,
353 moduleMaterialPtr, moduleDigitizationPtr);
355 layerStore.push_back(std::move(bsmodule));
359 size_t phiBins = m_cfg.centralModuleBinningSchema.at(icl).first;
360 phiBins *= m_cfg.centralLayerBinMultipliers.first;
361 size_t zBins = m_cfg.centralModuleBinningSchema.at(icl).second;
362 zBins *= m_cfg.centralLayerBinMultipliers.second;
367 m_cfg.approachSurfaceEnvelope};
372 cpLayers.push_back(std::move(pls));
374 detectorStore.push_back(std::move(layerStore));
380 template <
typename detector_element_t>
381 std::vector<ProtoLayerSurfaces>
384 return createProtoLayers(gctx, detectorStore, -1);
387 template <
typename detector_element_t>
388 std::vector<ProtoLayerSurfaces>
391 return createProtoLayers(gctx, detectorStore, 1);
394 template <
typename detector_element_t>
397 std::unique_ptr<const Acts::Logger> log)
398 : m_cfg(cfg), m_logger(std::move(log)) {}
400 template <
typename detector_element_t>
401 std::vector<ProtoLayerSurfaces>
407 for (
auto& eLayers : detectorStore) {
408 imodule += eLayers.size();
412 std::vector<ProtoLayerSurfaces> epLayers;
417 size_t numpnLayers = m_cfg.posnegLayerPositionsZ.size();
420 << numpnLayers <<
" passive positive/negative side layers.");
421 epLayers.reserve(numpnLayers);
424 for (
size_t ipnl = 0; ipnl < numpnLayers; ++ipnl) {
427 << ipnl <<
" and " << numpnLayers + ipnl <<
" at z = "
428 << side * m_cfg.posnegLayerPositionsZ.at(ipnl));
431 double layerEnvelopeR = m_cfg.posnegLayerEnvelopeR.at(ipnl);
433 std::vector<std::shared_ptr<const Acts::Surface>> esVector;
436 for (
auto& discModulePositions : m_cfg.posnegModulePositions.at(ipnl)) {
437 ACTS_VERBOSE(
"- building ring " << ipnR <<
" for this layer.");
440 double moduleThickness = m_cfg.posnegModuleThickness.at(ipnl).at(ipnR);
441 double moduleMinHalfX = m_cfg.posnegModuleMinHalfX.at(ipnl).at(ipnR);
442 double moduleMaxHalfX = 0.;
443 if (m_cfg.posnegModuleMaxHalfX.size() > ipnl &&
444 m_cfg.posnegModuleMaxHalfX.at(ipnl).size() > ipnR) {
445 moduleMaxHalfX = m_cfg.posnegModuleMaxHalfX.at(ipnl).at(ipnR);
447 double moduleHalfY = m_cfg.posnegModuleHalfY.at(ipnl).at(ipnR);
451 if (moduleMaxHalfX != 0. && moduleMinHalfX != moduleMaxHalfX)
457 std::shared_ptr<const Acts::PlanarBounds>
moduleBounds(pBounds);
459 std::shared_ptr<const Acts::DigitizationModule> moduleDigitizationPtr =
461 if (m_cfg.posnegModuleReadoutBinsX.size()) {
463 std::shared_ptr<const Acts::Segmentation> moduleSegmentation =
464 std::make_shared<const Acts::CartesianSegmentation>(
466 m_cfg.posnegModuleReadoutBinsX.at(ipnl).at(ipnR),
467 m_cfg.posnegModuleReadoutBinsY.at(ipnl).at(ipnR));
469 moduleDigitizationPtr =
470 std::make_shared<const Acts::DigitizationModule>(
471 moduleSegmentation, 0.5 * moduleThickness,
472 m_cfg.posnegModuleReadoutSide.at(ipnl).at(ipnR),
473 m_cfg.posnegModuleLorentzAngle.at(ipnl).at(ipnR));
477 std::shared_ptr<const Acts::ISurfaceMaterial> moduleMaterialPtr =
479 if (m_cfg.posnegModuleMaterial.size()) {
481 moduleMaterialPtr = m_cfg.posnegModuleMaterial.at(ipnl).at(ipnR);
485 for (
auto& ringModulePosition : discModulePositions) {
487 double modulePhi =
phi(ringModulePosition);
498 moduleRotation.col(0) = moduleLocalX;
499 moduleRotation.col(1) = moduleLocalY;
500 moduleRotation.col(2) = moduleLocalZ;
502 std::shared_ptr<const Acts::Transform3D> moduleTransform =
503 std::make_shared<const Acts::Transform3D>(
510 auto module = std::make_shared<detector_element_t>(
511 moduleIdentifier, moduleTransform,
moduleBounds, moduleThickness,
512 moduleMaterialPtr, moduleDigitizationPtr);
513 layerStore.push_back(module);
516 if (m_cfg.posnegModuleBacksideGap.size()) {
522 m_cfg.posnegModuleBacksideGap.at(ipnl).at(ipnR) * moduleLocalZ;
524 auto mutableModuleTransform = std::make_shared<Acts::Transform3D>(
527 if (m_cfg.posnegModuleBacksideStereo.size()) {
529 double stereoBackSide =
530 m_cfg.posnegModuleBacksideStereo.at(ipnl).at(ipnR);
531 (*mutableModuleTransform.get()) *=
536 mutableModuleTransform);
538 auto bsmodule = std::make_shared<detector_element_t>(
540 moduleThickness, moduleMaterialPtr, moduleDigitizationPtr);
542 layerStore.push_back(std::move(bsmodule));
545 esVector.push_back(module->surface().getSharedPtr());
551 size_t layerBinsR = m_cfg.posnegModulePhiBins.at(ipnl).size();
553 if (layerBinsR > 1) {
555 layerBinsR *= m_cfg.posnegLayerBinMultipliers.first;
557 size_t layerBinsPhi = 0;
559 for (
unsigned int phiBins : m_cfg.posnegModulePhiBins.at(ipnl)) {
560 layerBinsPhi = phiBins < layerBinsPhi ? phiBins : layerBinsPhi;
561 layerBinsPhi *= m_cfg.posnegLayerBinMultipliers.second;
567 m_cfg.approachSurfaceEnvelope};
572 epLayers.push_back(std::move(ples));
574 detectorStore.push_back(std::move(layerStore));