34 #include <type_traits>
39 std::shared_ptr<PlaneSurface>
surface;
47 surface = Surface::makeShared<PlaneSurface>(
51 surface = Surface::makeShared<PlaneSurface>(trafo, cfg.
rBounds);
53 surface->assignSurfaceMaterial(cfg.
surMat);
61 throw std::runtime_error{
62 "Neither surfaces nor config to build surfaces was provided. Cannot "
69 cfg.
surfaces.push_back(buildSurface(gctx, sCfg));
76 centroid +=
surface->transform(gctx).translation();
85 trafo.translation() = centroid;
89 trafo.linear() = cfg.
surfaces.front()->transform(gctx).rotation();
106 using namespace UnitLiterals;
108 std::pair<double, double> minMax = std::make_pair(
109 std::numeric_limits<double>::max(), -std::numeric_limits<double>::max());
121 for (
const auto& layercfg : cfg.
layerCfg) {
124 pl.envelope[
binX] = layercfg.envelopeX;
126 double surfacePosMin = pl.min(
binX);
127 double surfacePosMax = pl.max(
binX);
130 if (surfacePosMin < minMax.first) {
131 minMax.first = surfacePosMin;
133 if (surfacePosMax > minMax.second) {
134 minMax.second = surfacePosMax;
139 minMax.first =
std::min(minMax.first, minVolumeBoundaries(
binX));
140 minMax.second = std::max(minMax.second, maxVolumeBoundaries(
binX));
152 auto bounds = std::make_shared<const CuboidVolumeBounds>(
167 sCfg.
rBounds = std::make_shared<const RectangleBounds>(
184 for (
auto& layerCfg : cfg.
layerCfg) {
185 cfg.
layers.push_back(buildLayer(gctx, layerCfg));
186 layVec.push_back(cfg.
layers.back());
189 for (
auto& lay : cfg.
layers) {
190 layVec.push_back(lay);
195 std::pair<double, double> minMax = binningRange(gctx, cfg);
199 std::unique_ptr<const LayerArray> layArr(
200 layArrCreator.
layerArray(gctx, layVec, minMax.first, minMax.second,
210 std::shared_ptr<TrackingVolume> trackVolume;
211 if (layVec.empty()) {
229 std::vector<std::shared_ptr<TrackingVolume>>
volumes;
230 volumes.reserve(
m_cfg.volumeCfg.size());
232 volumes.push_back(buildVolume(gctx, volCfg));
237 std::sort(volumes.begin(), volumes.end(),
239 return lhs->center().x() <
rhs->center().x();
243 for (
unsigned int i = 0;
i < volumes.size() - 1;
i++) {
244 volumes[
i + 1]->glueTrackingVolume(
248 volumes[
i + 1].
get(),
254 trafo.translation() =
m_cfg.position;
257 auto volume = std::make_shared<const CuboidVolumeBounds>(
258 m_cfg.length.x() * 0.5,
m_cfg.length.y() * 0.5,
m_cfg.length.z() * 0.5);
261 std::vector<std::pair<TrackingVolumePtr, Vector3>> tapVec;
262 tapVec.reserve(
m_cfg.volumeCfg.size());
263 for (
auto& tVol : volumes) {
264 tapVec.push_back(std::make_pair(tVol, tVol->center()));
268 std::vector<float> binBoundaries;
269 binBoundaries.push_back(volumes[0]->center().
x() -
270 m_cfg.volumeCfg[0].length.x() * 0.5);
271 for (
size_t i = 0;
i < volumes.size();
i++) {
272 binBoundaries.push_back(volumes[
i]->center().
x() +
273 m_cfg.volumeCfg[
i].length.x() * 0.5);
278 auto bu = std::make_unique<const BinUtility>(binData);
281 std::shared_ptr<const TrackingVolumeArray> trVolArr(