35 class DetecorElementBase;
38 namespace ActsExamples {
50 std::vector<std::shared_ptr<const Acts::Surface>>
surfaces;
60 template <
typename detector_element_t>
63 using LayerStore = std::vector<std::shared_ptr<detector_element_t>>;
101 std::vector<std::shared_ptr<const Acts::ISurfaceMaterial>>
138 std::vector<std::vector<std::shared_ptr<const Acts::ISurfaceMaterial>>>
152 std::unique_ptr<const Acts::Logger>
logger =
198 template <
typename detector_element_t>
199 std::vector<ProtoLayerSurfaces>
203 std::vector<ProtoLayerSurfaces> cpLayers;
209 for (
auto& eLayers : detectorStore) {
210 imodule += eLayers.size();
216 size_t numcLayers =
m_cfg.centralLayerRadii.size();
217 if (numcLayers != 0
u) {
218 ACTS_DEBUG(
"Configured to build " << numcLayers
219 <<
" active central layers.");
220 cpLayers.reserve(numcLayers);
222 for (
size_t icl = 0; icl < numcLayers; ++icl) {
224 double layerR =
m_cfg.centralLayerRadii.at(icl);
226 ACTS_DEBUG(
"Build layer " << icl <<
" with target radius = " << layerR);
229 std::vector<std::shared_ptr<const Acts::Surface>> sVector;
231 double layerEnvelopeCoverZ =
232 !
m_cfg.centralLayerEnvelopes.empty()
233 ?
m_cfg.centralLayerEnvelopes.at(icl).second
236 double modulePhiTilt =
m_cfg.centralModuleTiltPhi.at(icl);
237 double moduleHalfX =
m_cfg.centralModuleHalfX.at(icl);
238 double moduleHalfY =
m_cfg.centralModuleHalfY.at(icl);
239 double moduleThickness =
m_cfg.centralModuleThickness.at(icl);
243 size_t nCentralModules =
m_cfg.centralModuleBinningSchema.at(icl).first *
244 m_cfg.centralModuleBinningSchema.at(icl).second;
247 << nCentralModules <<
" ( from "
248 <<
m_cfg.centralModuleBinningSchema.at(icl).first <<
" x "
249 <<
m_cfg.centralModuleBinningSchema.at(icl).second <<
" )");
251 sVector.reserve(nCentralModules);
255 std::shared_ptr<const Acts::DigitizationModule> moduleDigitizationPtr =
257 if (!
m_cfg.centralModuleReadoutBinsX.empty()) {
259 std::shared_ptr<const Acts::Segmentation> moduleSegmentation =
260 std::make_shared<const Acts::CartesianSegmentation>(
262 m_cfg.centralModuleReadoutBinsY.at(icl));
264 moduleDigitizationPtr =
265 std::make_shared<const Acts::DigitizationModule>(
266 moduleSegmentation, 0.5 *
m_cfg.centralModuleThickness.at(icl),
267 m_cfg.centralModuleReadoutSide.at(icl),
268 m_cfg.centralModuleLorentzAngle.at(icl));
273 std::shared_ptr<const Acts::ISurfaceMaterial> moduleMaterialPtr =
nullptr;
274 if (!
m_cfg.centralModuleMaterial.empty()) {
276 moduleMaterialPtr =
m_cfg.centralModuleMaterial.at(icl);
280 if (
m_cfg.centralModulePositions.at(icl).size() != nCentralModules) {
281 ACTS_WARNING(
"Mismatching module numbers, configuration error!");
282 ACTS_WARNING(
"- Binning schema suggests : " << nCentralModules);
284 <<
m_cfg.centralModulePositions.at(icl).size());
287 for (
auto& moduleCenter :
m_cfg.centralModulePositions.at(icl)) {
289 double modulePhi =
phi(moduleCenter);
292 sin(modulePhi + modulePhiTilt), 0.);
297 cos(modulePhi + modulePhiTilt), 0.);
300 moduleRotation.col(0) = moduleLocalX;
301 moduleRotation.col(1) = moduleLocalY;
302 moduleRotation.col(2) = moduleLocalZ;
304 std::shared_ptr<Acts::Transform3> mutableModuleTransform =
305 std::make_shared<Acts::Transform3>(
308 if (!
m_cfg.centralModuleFrontsideStereo.empty() &&
309 m_cfg.centralModuleFrontsideStereo.at(icl) != 0.) {
311 double stereo =
m_cfg.centralModuleFrontsideStereo.at(icl);
312 (*mutableModuleTransform.get()) *=
319 mutableModuleTransform);
321 auto module = std::make_shared<detector_element_t>(
322 moduleIdentifier, moduleTransform,
moduleBounds, moduleThickness,
323 moduleMaterialPtr, moduleDigitizationPtr);
326 layerStore.push_back(module);
328 sVector.push_back(module->surface().getSharedPtr());
331 if (!
m_cfg.centralModuleBacksideGap.empty()) {
336 m_cfg.centralModuleBacksideGap.at(icl) * moduleLocalZ;
337 mutableModuleTransform = std::make_shared<Acts::Transform3>(
340 if (!
m_cfg.centralModuleBacksideStereo.empty()) {
342 double stereoBackSide =
m_cfg.centralModuleBacksideStereo.at(icl);
343 (*mutableModuleTransform.get()) *=
348 mutableModuleTransform);
350 auto bsmodule = std::make_shared<detector_element_t>(
351 moduleIdentifier, moduleTransform,
moduleBounds, moduleThickness,
352 moduleMaterialPtr, moduleDigitizationPtr);
354 layerStore.push_back(
std::move(bsmodule));
358 size_t phiBins =
m_cfg.centralModuleBinningSchema.at(icl).first;
359 phiBins *=
m_cfg.centralLayerBinMultipliers.first;
360 size_t zBins =
m_cfg.centralModuleBinningSchema.at(icl).second;
361 zBins *=
m_cfg.centralLayerBinMultipliers.second;
366 m_cfg.approachSurfaceEnvelope};
373 detectorStore.push_back(
std::move(layerStore));
379 template <
typename detector_element_t>
380 std::vector<ProtoLayerSurfaces>
383 return createProtoLayers(gctx, detectorStore, -1);
386 template <
typename detector_element_t>
387 std::vector<ProtoLayerSurfaces>
390 return createProtoLayers(gctx, detectorStore, 1);
393 template <
typename detector_element_t>
396 std::unique_ptr<const Acts::Logger> log)
399 template <
typename detector_element_t>
400 std::vector<ProtoLayerSurfaces>
406 for (
auto& eLayers : detectorStore) {
407 imodule += eLayers.size();
411 std::vector<ProtoLayerSurfaces> epLayers;
416 size_t numpnLayers =
m_cfg.posnegLayerPositionsZ.size();
417 if (numpnLayers != 0
u) {
419 << numpnLayers <<
" passive positive/negative side layers.");
420 epLayers.reserve(numpnLayers);
423 for (
size_t ipnl = 0; ipnl < numpnLayers; ++ipnl) {
426 << ipnl <<
" and " << numpnLayers + ipnl <<
" at z = "
427 << side *
m_cfg.posnegLayerPositionsZ.at(ipnl));
430 double layerEnvelopeR =
m_cfg.posnegLayerEnvelopeR.at(ipnl);
432 std::vector<std::shared_ptr<const Acts::Surface>> esVector;
435 for (
auto& discModulePositions :
m_cfg.posnegModulePositions.at(ipnl)) {
436 ACTS_VERBOSE(
"- building ring " << ipnR <<
" for this layer.");
439 double moduleThickness =
m_cfg.posnegModuleThickness.at(ipnl).at(ipnR);
440 double moduleMinHalfX =
m_cfg.posnegModuleMinHalfX.at(ipnl).at(ipnR);
441 double moduleMaxHalfX = 0.;
442 if (
m_cfg.posnegModuleMaxHalfX.size() > ipnl &&
443 m_cfg.posnegModuleMaxHalfX.at(ipnl).size() > ipnR) {
444 moduleMaxHalfX =
m_cfg.posnegModuleMaxHalfX.at(ipnl).at(ipnR);
446 double moduleHalfY =
m_cfg.posnegModuleHalfY.at(ipnl).at(ipnR);
450 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.empty()) {
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.empty()) {
481 moduleMaterialPtr =
m_cfg.posnegModuleMaterial.at(ipnl).at(ipnR);
485 for (
auto& ringModulePosition : discModulePositions) {
487 double modulePhi =
phi(ringModulePosition);
490 moduleCenter.z() *= side;
492 Acts::Vector3 moduleLocalY(cos(modulePhi), sin(modulePhi), 0.);
495 Acts::Vector3 moduleLocalX = moduleLocalY.cross(moduleLocalZ);
499 moduleRotation.col(0) = moduleLocalX;
500 moduleRotation.col(1) = moduleLocalY;
501 moduleRotation.col(2) = moduleLocalZ;
503 std::shared_ptr<const Acts::Transform3> moduleTransform =
504 std::make_shared<const Acts::Transform3>(
511 auto module = std::make_shared<detector_element_t>(
512 moduleIdentifier, moduleTransform,
moduleBounds, moduleThickness,
513 moduleMaterialPtr, moduleDigitizationPtr);
514 layerStore.push_back(module);
517 if (!
m_cfg.posnegModuleBacksideGap.empty()) {
523 m_cfg.posnegModuleBacksideGap.at(ipnl).at(ipnR) * moduleLocalZ;
525 auto mutableModuleTransform = std::make_shared<Acts::Transform3>(
528 if (!
m_cfg.posnegModuleBacksideStereo.empty()) {
530 double stereoBackSide =
531 m_cfg.posnegModuleBacksideStereo.at(ipnl).at(ipnR);
532 (*mutableModuleTransform.get()) *=
537 mutableModuleTransform);
539 auto bsmodule = std::make_shared<detector_element_t>(
541 moduleThickness, moduleMaterialPtr, moduleDigitizationPtr);
543 layerStore.push_back(
std::move(bsmodule));
546 esVector.push_back(module->surface().getSharedPtr());
552 size_t layerBinsR =
m_cfg.posnegModulePhiBins.at(ipnl).size();
554 if (layerBinsR > 1) {
556 layerBinsR *=
m_cfg.posnegLayerBinMultipliers.first;
558 size_t layerBinsPhi = 0;
560 for (
unsigned int phiBins :
m_cfg.posnegModulePhiBins.at(ipnl)) {
561 layerBinsPhi = phiBins < layerBinsPhi ? phiBins : layerBinsPhi;
562 layerBinsPhi *=
m_cfg.posnegLayerBinMultipliers.second;
568 m_cfg.approachSurfaceEnvelope};
575 detectorStore.push_back(
std::move(layerStore));