File indexing completed on 2025-01-18 09:12:18
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/DD4hep/DD4hepMaterialHelpers.hpp"
0010
0011 #include "Acts/Geometry/ApproachDescriptor.hpp"
0012 #include "Acts/Geometry/Layer.hpp"
0013 #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Utilities/BinUtility.hpp"
0016 #include "Acts/Utilities/BinningType.hpp"
0017
0018 #include <algorithm>
0019 #include <cmath>
0020 #include <cstddef>
0021 #include <iterator>
0022 #include <numbers>
0023 #include <ostream>
0024
0025 #include <boost/foreach.hpp>
0026 #include <boost/tokenizer.hpp>
0027
0028 std::shared_ptr<Acts::ProtoSurfaceMaterial> Acts::createProtoMaterial(
0029 const dd4hep::rec::VariantParameters& params, const std::string& valueTag,
0030 const std::vector<std::pair<const std::string, Acts::BinningOption> >&
0031 binning,
0032 const Logger& logger) {
0033 using namespace std::string_literals;
0034
0035
0036 Acts::BinUtility bu;
0037
0038 for (auto& bin : binning) {
0039 AxisDirection bval = axisDirectionFromName(bin.first);
0040 Acts::BinningOption bopt = bin.second;
0041 double min = 0.;
0042 double max = 0.;
0043 if (bopt == Acts::closed) {
0044 min = -std::numbers::pi;
0045 max = std::numbers::pi;
0046 }
0047 int bins = params.get<int>(valueTag + "_"s + bin.first);
0048 ACTS_VERBOSE(" - material binning for " << bin.first << " on " << valueTag
0049 << ": " << bins);
0050 if (bins >= 1) {
0051 bu += Acts::BinUtility(bins, min, max, bopt, bval);
0052 }
0053 }
0054 return std::make_shared<Acts::ProtoSurfaceMaterial>(bu);
0055 }
0056
0057 void Acts::addLayerProtoMaterial(
0058 const dd4hep::rec::VariantParameters& params, Layer& layer,
0059 const std::vector<std::pair<const std::string, Acts::BinningOption> >&
0060 binning,
0061 const Logger& logger) {
0062 ACTS_VERBOSE("addLayerProtoMaterial");
0063
0064 std::vector<std::string> materialOptions = {"layer_material_representing"};
0065 std::vector<const Surface*> materialSurfaces = {
0066 &(layer.surfaceRepresentation())};
0067
0068 auto aDescriptor = layer.approachDescriptor();
0069 if (aDescriptor != nullptr && aDescriptor->containedSurfaces().size() >= 2) {
0070
0071 const std::vector<const Surface*>& aSurfaces =
0072 aDescriptor->containedSurfaces();
0073 materialOptions.push_back("layer_material_inner");
0074 materialSurfaces.push_back(aSurfaces[0]);
0075 materialOptions.push_back("layer_material_outer");
0076 materialSurfaces.push_back(aSurfaces[1]);
0077 }
0078
0079
0080 for (unsigned int is = 0; is < materialOptions.size(); ++is) {
0081
0082 ACTS_VERBOSE(" - checking material for: " << materialOptions[is]);
0083 if (params.contains(materialOptions[is])) {
0084 ACTS_VERBOSE(" - have material");
0085
0086 auto psMaterial =
0087 createProtoMaterial(params, materialOptions[is], binning, logger);
0088
0089
0090 Surface* surface = const_cast<Surface*>(materialSurfaces[is]);
0091 surface->assignSurfaceMaterial(psMaterial);
0092 }
0093 }
0094 }
0095
0096 void Acts::addCylinderLayerProtoMaterial(dd4hep::DetElement detElement,
0097 Layer& cylinderLayer,
0098 const Logger& logger) {
0099 ACTS_VERBOSE(
0100 "Translating DD4hep material into Acts material for CylinderLayer : "
0101 << detElement.name());
0102 if (hasParams(detElement)) {
0103 ACTS_VERBOSE(" params: " << getParams(detElement));
0104 } else {
0105 ACTS_VERBOSE(" NO params");
0106 }
0107 if (getParamOr<bool>("layer_material", detElement, false)) {
0108 addLayerProtoMaterial(getParams(detElement), cylinderLayer,
0109 {{"binPhi", Acts::closed}, {"binZ", Acts::open}},
0110 logger);
0111 }
0112 }
0113
0114 void Acts::addDiscLayerProtoMaterial(dd4hep::DetElement detElement,
0115 Layer& discLayer, const Logger& logger) {
0116 ACTS_VERBOSE("Translating DD4hep material into Acts material for DiscLayer : "
0117 << detElement.name());
0118
0119 if (hasParams(detElement)) {
0120 ACTS_VERBOSE(" params: " << getParams(detElement));
0121 } else {
0122 ACTS_VERBOSE(" NO params");
0123 }
0124 if (getParamOr<bool>("layer_material", detElement, false)) {
0125 addLayerProtoMaterial(getParams(detElement), discLayer,
0126 {{"binPhi", Acts::closed}, {"binR", Acts::open}},
0127 logger);
0128 }
0129 }