File indexing completed on 2025-12-11 09:40:23
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Material/TrackingGeometryMaterial.hpp"
0012 #include "Acts/Utilities/Logger.hpp"
0013
0014 #include <map>
0015 #include <memory>
0016 #include <string>
0017 #include <tuple>
0018
0019 class TTree;
0020 class TFile;
0021 class TDirectory;
0022
0023 namespace Acts {
0024 class GeometryIdentifier;
0025 class ISurfaceMaterial;
0026 class IVolumeMaterial;
0027 class HomogeneousSurfaceMaterial;
0028 class MaterialSlab;
0029 class BinnedSurfaceMaterial;
0030 }
0031
0032 namespace ActsPlugins {
0033
0034
0035
0036 class RootMaterialMapIo {
0037 public:
0038
0039
0040
0041 struct Config {
0042
0043 std::string volumePrefix = "_vol";
0044
0045 std::string portalPrefix = "_bou";
0046
0047 std::string layerPrefix = "_lay";
0048
0049 std::string passivePrefix = "_app";
0050
0051 std::string sensitivePrefix = "_sen";
0052
0053 std::string nBinsHistName = "n";
0054
0055 std::string axisDirHistName = "v";
0056
0057 std::string axisBoundaryTypeHistName = "o";
0058
0059 std::string minRangeHistName = "min";
0060
0061 std::string maxRangeHistName = "max";
0062
0063 std::string thicknessHistName = "t";
0064
0065 std::string x0HistName = "x0";
0066
0067 std::string l0HistName = "l0";
0068
0069 std::string aHistName = "A";
0070
0071 std::string zHistName = "Z";
0072
0073 std::string rhoHistName = "rho";
0074
0075 std::string indexHistName = "i";
0076 };
0077
0078
0079
0080
0081 struct Options {
0082
0083 std::string homogeneousMaterialTreeName = "HomogeneousMaterial";
0084
0085 std::string indexedMaterialTreeName = "IndexedMaterial";
0086
0087 std::string folderSurfaceNameBase = "SurfaceMaterial";
0088
0089 std::string folderVolumeNameBase = "VolumeMaterial";
0090
0091 bool indexedMaterial = false;
0092 };
0093
0094 struct MaterialTreePayload {
0095 std::size_t index = 0;
0096
0097 std::int64_t hGeoId = 0;
0098
0099 float ht = 0.0f;
0100
0101 float hX0 = 0.0f;
0102
0103 float hL0 = 0.0f;
0104
0105 float hA = 0.0f;
0106
0107 float hZ = 0.0f;
0108
0109 float hRho = 0.0f;
0110 };
0111
0112
0113
0114
0115 explicit RootMaterialMapIo(const Config& cfg,
0116 std::unique_ptr<const Acts::Logger> mLogger =
0117 Acts::getDefaultLogger("RootMaterialMapIo",
0118 Acts::Logging::INFO))
0119 : m_cfg(cfg), m_logger(std::move(mLogger)) {}
0120
0121
0122 ~RootMaterialMapIo() = default;
0123
0124
0125
0126
0127
0128 void write(TFile& rFile,
0129 const Acts::TrackingGeometryMaterial& detectorMaterial,
0130 const Options& options);
0131
0132
0133
0134
0135
0136
0137 void write(TFile& rFile, const Acts::GeometryIdentifier& geoID,
0138 const Acts::ISurfaceMaterial& surfaceMaterial,
0139 const Options& options);
0140
0141
0142
0143
0144 Acts::TrackingGeometryMaterial read(TFile& rFile, const Options& options);
0145
0146
0147 private:
0148
0149
0150
0151 void connectForWrite(TTree& rTree, MaterialTreePayload& treePayload);
0152
0153
0154
0155
0156 void connectForRead(TTree& rTree, MaterialTreePayload& treePayload);
0157
0158
0159
0160
0161 void fillMaterialSlab(MaterialTreePayload& payload,
0162 const Acts::MaterialSlab& materialSlab);
0163
0164
0165
0166 void fillBinnedSurfaceMaterial(const Acts::BinnedSurfaceMaterial& bsMaterial);
0167
0168
0169
0170
0171 void fillBinnedSurfaceMaterial(MaterialTreePayload& payload,
0172 const Acts::BinnedSurfaceMaterial& bsMaterial);
0173
0174
0175
0176
0177
0178
0179 std::shared_ptr<const Acts::ISurfaceMaterial> readTextureSurfaceMaterial(
0180 TFile& rFile, const std::string& tdName,
0181 TTree* indexedMaterialTree = nullptr);
0182
0183
0184 const Acts::Logger& logger() const { return *m_logger; }
0185
0186
0187 Config m_cfg;
0188
0189
0190 std::unique_ptr<const Acts::Logger> m_logger;
0191
0192
0193 TTree* m_hTree = nullptr;
0194 MaterialTreePayload m_homogenousMaterialTreePayload;
0195
0196
0197 TTree* m_gTree = nullptr;
0198 MaterialTreePayload m_indexedMaterialTreePayload;
0199 };
0200
0201 }