48 std::shared_ptr<BlueprintNode>&& childNode) {
51 std::map<caloRegion, caloSampleSurfaceMap_t> caloRegionSampleSurfaceMap;
52 std::map<caloRegion, caloSampleDDEElementsMap_t> caloRegionSampleDDEElementsMap;
53 std::map<std::string, double> caloDimensions;
55 fillMaps(caloRegionSampleDDEElementsMap, caloDimensions);
65 ATH_MSG_DEBUG(
"Have generated calorimeter cylindrical surfaces");
73 double caloEvelopeMaxR = caloDimensions.at(
"maxR") + 5._mm;
74 double caloEnvelopeHalfLenghtZ = (caloDimensions.at(
"maxPosZ") - caloDimensions.at(
"minNegZ"))/2.0 + 5._mm;
76 ATH_MSG_INFO(
"Calo envelope dimensions: maxR = " << caloEvelopeMaxR <<
", halfLengthZ = " << caloEnvelopeHalfLenghtZ);
77 std::shared_ptr<StaticBlueprintNode> itkCaloNode{};
79 auto envelope = std::make_unique<TrackingVolume>(Amg::Transform3D::Identity(),
80 std::make_shared<CylinderVolumeBounds>(0., caloEvelopeMaxR, caloEnvelopeHalfLenghtZ),
"ITkCalo");
81 envelope->assignGeometryId(Acts::GeometryIdentifier{}.withVolume(
s_caloEnvelopeID));
82 itkCaloNode = std::make_shared<StaticBlueprintNode>(std::move(envelope));
85 itkCaloNode->addChild(std::move(childNode));
90 auto caloNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisZ);
91 CylinderContainerBlueprintNode& caloBarrelCylinderNode = caloNode->addCylinderContainer(
"CaloBarrelSymmetricZZeroCylinders", AxisDirection::AxisR);
92 caloBarrelCylinderNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
93 caloBarrelCylinderNode.setResizeStrategy(ResizeStrategy::Gap);
97 unsigned int volumeCounter = 0;
112 itkCaloNode->addLayer(sampleName+
"NegZ_Layer", [&](
auto& layer) {
114 layer.setEnvelope(Acts::ExtentEnvelope{{
115 .z = {0.1_mm, 0.1_mm},
119 itkCaloNode->addLayer(sampleName+
"PosZ_Layer", [&](
auto& layer) {
121 layer.setEnvelope(Acts::ExtentEnvelope{{
122 .z = {0.1_mm, 0.1_mm},
128 auto caloEndCapNegativeNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisZ);
130 CylinderContainerBlueprintNode& caloEndCapDiscNegativeZNode = caloEndCapNegativeNode->addCylinderContainer(
"CaloEndCapDiscNegativeZ", AxisDirection::AxisZ);
131 caloEndCapDiscNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
139 caloEndCapDiscNegativeZNode.setResizeStrategies(ResizeStrategy::Expand, ResizeStrategy::Gap);
141 auto caloEndCapPositiveNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisZ);
142 CylinderContainerBlueprintNode& caloEndCapDiscPositiveZNode = caloEndCapPositiveNode->addCylinderContainer(
"CaloEndCapDiscPositiveZ", AxisDirection::AxisZ);
143 caloEndCapDiscPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
146 caloEndCapDiscPositiveZNode.setResizeStrategies(ResizeStrategy::Gap, ResizeStrategy::Expand);
156 ATH_MSG_DEBUG(
"Have added all Barrel layers to caloBarrelCylinderNode");
159 itkCaloNode->addChild(caloNode);
160 itkCaloNode->addChild(caloEndCapNegativeNode);
161 itkCaloNode->addChild(caloEndCapPositiveNode);
173 std::map<caloRegion, caloSampleDDEElementsMap_t>& caloRegionSampleDDEElementsMap, std::map<std::string, double>& caloDimensions)
const {
185 float maxR{0.}, maxPosZ{-std::numeric_limits<float>::max()}, minNegZ{std::numeric_limits<float>::max()};
194 maxR = std::max(theDDE->r(), maxR);
195 maxPosZ = std::max(maxPosZ, theDDE->z());
196 minNegZ = std::min(minNegZ, theDDE->z());
199 std::pair <std::string, CaloCell_ID::CaloSample> samplePair = std::make_pair(
getSampleName(currentSample), currentSample);
208 if (theDDE->z() < 0.0) {
219 if (theDDE->z() < 0.0) {
227 caloDimensions[
"maxR"] = maxR;
228 caloDimensions[
"maxPosZ"] = maxPosZ;
229 caloDimensions[
"minNegZ"] = minNegZ;
231 auto sortAllLayersInZ = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
232 for (
const auto & currentSample : caloSampleList) {
233 std::vector<const CaloDetDescrElement*>& currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
234 std::ranges::sort(currentElements,
237 return a->z() < b->z();
247 auto sortAllLayersInR = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
248 for (
const auto& currentSample : caloSampleList) {
249 std::vector<const CaloDetDescrElement*>& currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
250 std::ranges::sort(currentElements,
253 return a->r() < b->r();
266 const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& sampleList{asymmetricZ ?
269 for (
const auto & currentSample : sampleList) {
271 const std::vector<const CaloDetDescrElement*>& currentElements = caloSampleDDEElementsMap[currentSample];
273 double maxLArBRadius = 0.0, minLArBRadius = std::numeric_limits<double>::max();
274 double lowZLarB = std::numeric_limits<double>::max(),
275 highZLarB = -std::numeric_limits<double>::max();
280 double totalRadiusFixedPhi = 0.0;
281 bool firstCellInPhiRing =
true;
282 unsigned int phiCounter = 0;
286 bool firstPhiRing =
true;
287 double initialRadius = 0.0;
288 double initialZ = -std::numeric_limits<double>::max();
291 bool movedInZ =
false;
295 double z = theDDE->z();
296 double radius = theDDE->r();
300 if (firstCellInPhiRing) {
301 ATH_MSG_DEBUG(
"First Cell in phi ring " << currentSample.first <<
" has z = " <<
z <<
" and r = " << radius);
303 firstCellInPhiRing =
false;
307 ATH_MSG_DEBUG(
"First Cell in layer " << currentSample.first <<
" has z = " <<
z <<
" and r = " << radius);
308 initialRadius = theDDE->r();
309 firstPhiRing =
false;
317 if (std::abs(
z - initialZ) < 0.0001) {
318 ATH_MSG_DEBUG(
"phiCounter is " << phiCounter <<
" and radius is " << radius <<
" and totalRadiusFixedPhi is " << totalRadiusFixedPhi <<
" and hash is " << theDDE->calo_hash());
319 totalRadiusFixedPhi += radius;
325 firstCellInPhiRing =
true;
326 if (phiCounter > 0) {
327 double cellRingRadius = totalRadiusFixedPhi / phiCounter;
328 totalRadiusFixedPhi = 0.0;
331 maxLArBRadius = std::max(maxLArBRadius, cellRingRadius);
332 minLArBRadius = std::min(minLArBRadius, cellRingRadius);
337 ATH_MSG_DEBUG(
"Values of cellRingRadius, initialRadius, highZLarB and lowZLarB are " << cellRingRadius <<
", " << initialRadius <<
", " << highZLarB <<
" and " << lowZLarB);
339 highZLarB - lowZLarB > 0.0) {
340 ATH_MSG_DEBUG(
"CYLINDER: Create cylinder for layer " << currentSample.first);
341 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
342 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
344 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB));
349 minLArBRadius = std::numeric_limits<double>::max();
359 if (0 == caloSampleSurfaceMap[currentSample].
size()){
365 highZLarB = initialZ+0.001;
366 if (phiCounter > 0) {
367 maxLArBRadius = totalRadiusFixedPhi / phiCounter;
371 ATH_MSG_DEBUG(
"CYLINDER: Zero size Vector: Create cylinder for layer " << currentSample.first);
372 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
373 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
374 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB));
399 const std::vector<const CaloDetDescrElement*> & currentElements = caloSampleDDEElementsMap[currentSample];
403 if (CaloCell_ID::FCAL0 == currentSample.second || CaloCell_ID::FCAL1 == currentSample.second || CaloCell_ID::FCAL2 == currentSample.second) {
404 ATH_MSG_DEBUG(
"TOM3: FCAL sampling " << currentSample.second);
406 double fcalRMin = std::numeric_limits<double>::max();
407 double fcalRMax = std::numeric_limits<double>::min();
409 size_t cellCount = 0;
412 double r = theDDE->r();
413 fcalRMin = std::min(fcalRMin,
r);
414 fcalRMax = std::max(fcalRMax,
r);
415 fcalZSum += theDDE->z();
419 ATH_MSG_WARNING(
"cellCount is zero in CaloBlueprintNodeBuilder::generateDiscSurfaces");
422 double fcalZ = fcalZSum / cellCount;
423 caloSampleSurfaceMap[currentSample].push_back(
generateDiscSurface(fcalZ,fcalRMax, fcalRMin));
429 double totalZFixedPhi = 0.0;
430 bool firstCellInPhiRing =
true;
431 unsigned int phiCounter = 0;
433 bool firstPhiRing =
true;
434 double initialRadius = 0.0;
435 double initialZ = -std::numeric_limits<double>::max();
440 double minDiscRadius = std::numeric_limits<double>::max(), maxDiscRadius = 0.0;
442 unsigned int currentElementsSize = currentElements.size();
443 unsigned int DDECounter = 0;
447 bool isLastDDE = (DDECounter == (currentElementsSize-1));
449 ATH_MSG_DEBUG(
"Disc DDE with sampling, r and z of " << currentSample <<
", " << theDDE->r() <<
", " << theDDE->z());
452 double z = theDDE->z();
453 double radius = theDDE->r();
455 if (firstCellInPhiRing) {
456 initialRadius = radius;
457 firstCellInPhiRing =
false;
462 firstPhiRing =
false;
463 minDiscRadius = radius;
468 if (std::abs(radius - initialRadius) < 0.0001 && !isLastDDE) {
475 firstCellInPhiRing =
true;
476 if (phiCounter > 0) {
477 double cellRingZ = totalZFixedPhi / phiCounter;
478 totalZFixedPhi = 0.0;
484 maxDiscRadius = radius;
486 if (std::abs(cellRingZ - initialZ) >
m_zTolerance || isLastDDE) {
487 ATH_MSG_DEBUG(
"DISC: About to create disc surface for sampling " << currentSample);
488 caloSampleSurfaceMap[currentSample].push_back(
generateDiscSurface(cellRingZ,maxDiscRadius, minDiscRadius));
491 minDiscRadius = std::numeric_limits<double>::max();
515 Acts::GeometryIdentifierBlueprintNode& geoIdNode = containerNode.withGeometryIdentifier();
519 AxisDirection axis = AxisDirection::AxisZ;
520 if (isDisc) axis = AxisDirection::AxisR;
521 CylinderContainerBlueprintNode& cylinder = geoIdNode.addCylinderContainer(volumeName,
524 cylinder.addLayer(volumeName +
"_Layer", [&](
auto& layer) {
525 layer.setSurfaces(surfaces);
526 layer.setEnvelope(Acts::ExtentEnvelope{{
527 .z = {0.1_mm, 0.1_mm},