48 std::shared_ptr<BlueprintNode>&& childNode) {
51 std::map<caloRegion, caloSampleSurfaceMap_t> caloRegionSampleSurfaceMap;
52 std::map<caloRegion, caloSampleDDEElementsMap_t> caloRegionSampleDDEElementsMap;
54 fillMaps(caloRegionSampleSurfaceMap, caloRegionSampleDDEElementsMap);
64 ATH_MSG_DEBUG(
"Have generated calorimeter cylindrical surfaces");
71 std::shared_ptr<StaticBlueprintNode> itkCaloNode{};
74 auto envelope = std::make_unique<TrackingVolume>(Amg::Transform3D::Identity(),
75 std::make_shared<CylinderVolumeBounds>(0., 4250.0, 6779.0),
"ITkCalo");
76 envelope->assignGeometryId(Acts::GeometryIdentifier{}.withVolume(
s_caloEnvelopeID));
77 itkCaloNode = std::make_shared<StaticBlueprintNode>(std::move(envelope));
80 itkCaloNode->addChild(std::move(childNode));
85 auto caloNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisZ);
86 CylinderContainerBlueprintNode& caloBarrelCylinderNode = caloNode->addCylinderContainer(
"CaloBarrelSymmetricZZeroCylinders", AxisDirection::AxisR);
87 caloBarrelCylinderNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
88 caloBarrelCylinderNode.setResizeStrategy(ResizeStrategy::Gap);
100 CylinderContainerBlueprintNode& caloBarrelCylinderNegativeZNode = caloNode->addCylinderContainer(
"CaloBarrelNegativeZAsymmetricCylinders", AxisDirection::AxisR);
101 caloBarrelCylinderNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
102 caloBarrelCylinderNegativeZNode.setResizeStrategy(ResizeStrategy::Gap);
105 CylinderContainerBlueprintNode& caloBarrelCylinderPositiveZNode = caloNode->addCylinderContainer(
"CaloBarrelPositiveZAsymmetricCylinders", AxisDirection::AxisR);
106 caloBarrelCylinderPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
107 caloBarrelCylinderPositiveZNode.setResizeStrategy(ResizeStrategy::Gap);
113 if (sampleIndex < 2){
121 itkCaloNode->addLayer(sampleName+
"NegZ" +
"_Layer", [&](
auto& layer) {
123 layer.setEnvelope(Acts::ExtentEnvelope{{
124 .z = {0.1_mm, 0.1_mm},
128 itkCaloNode->addLayer(sampleName+
"PosZ" +
"_Layer", [&](
auto& layer) {
130 layer.setEnvelope(Acts::ExtentEnvelope{{
131 .z = {0.1_mm, 0.1_mm},
139 CylinderContainerBlueprintNode& caloEndCapDiscNegativeZNode = caloNode->addCylinderContainer(
"CaloEndCapDiscNegativeZ", AxisDirection::AxisZ);
140 caloEndCapDiscNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
148 caloEndCapDiscNegativeZNode.setResizeStrategies(ResizeStrategy::Expand, ResizeStrategy::Gap);
150 CylinderContainerBlueprintNode& caloEndCapDiscPositiveZNode = caloNode->addCylinderContainer(
"CaloEndCapDiscPositiveZ", AxisDirection::AxisZ);
151 caloEndCapDiscPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
154 caloEndCapDiscPositiveZNode.setResizeStrategies(ResizeStrategy::Gap, ResizeStrategy::Expand);
162 ATH_MSG_DEBUG(
"Have added all Barrel layers to caloBarrelCylinderNode");
165 itkCaloNode->addChild(caloNode);
177 std::map<caloRegion, caloSampleDDEElementsMap_t>& caloRegionSampleDDEElementsMap)
const {
217 std::pair <std::string, CaloCell_ID::CaloSample> samplePair = std::make_pair(
getSampleName(currentSample), currentSample);
226 if (theDDE->z() < 0.0) {
237 if (theDDE->z() < 0.0) {
247 auto sortAllLayersInZ = [&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];
251 caloRegionSampleDDEElementsMap[region][currentSample] = std::move(currentElements);
260 auto sortAllLayersInR = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
261 for (
const auto& currentSample : caloSampleList) {
262 std::vector<const CaloDetDescrElement*> currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
264 caloRegionSampleDDEElementsMap[region][currentSample] = std::move(currentElements);
276 std::vector<std::pair<std::string, CaloCell_ID::CaloSample>> sampleList;
280 for (
const auto & currentSample : sampleList) {
282 std::vector<const CaloDetDescrElement*> currentElements = caloSampleDDEElementsMap[currentSample];
284 double maxLArBRadius = 0.0, minLArBRadius = std::numeric_limits<double>::max();
285 double lowZLarB = 0.0, highZLarB = 0.0;
290 double totalRadiusFixedPhi = 0.0;
291 bool firstCellInPhiRing =
true;
292 unsigned int phiCounter = 0;
296 bool firstPhiRing =
true;
297 double initialRadius = 0.0;
298 double initialZ = -std::numeric_limits<double>::max();
301 bool movedInZ =
false;
305 double z = theDDE->z();
306 double radius = theDDE->r();
310 if (firstCellInPhiRing) {
311 ATH_MSG_DEBUG(
"First Cell in phi ring " << currentSample.first <<
" has z = " <<
z <<
" and r = " << radius);
313 firstCellInPhiRing =
false;
317 ATH_MSG_DEBUG(
"First Cell in layer " << currentSample.first <<
" has z = " <<
z <<
" and r = " << radius);
318 initialRadius = theDDE->r();
319 firstPhiRing =
false;
327 if (std::abs(
z - initialZ) < 0.0001) {
328 ATH_MSG_DEBUG(
"phiCounter is " << phiCounter <<
" and radius is " << radius <<
" and totalRadiusFixedPhi is " << totalRadiusFixedPhi <<
" and hash is " << theDDE->calo_hash());
329 totalRadiusFixedPhi += radius;
335 firstCellInPhiRing =
true;
336 if (phiCounter > 0) {
337 double cellRingRadius = totalRadiusFixedPhi / phiCounter;
338 totalRadiusFixedPhi = 0.0;
341 if (cellRingRadius > maxLArBRadius) maxLArBRadius = radius;
342 if (cellRingRadius < minLArBRadius) minLArBRadius = radius;
347 ATH_MSG_DEBUG(
"Values of cellRingRadius, initialRadius, highZLarB and lowZLarB are " << cellRingRadius <<
", " << initialRadius <<
", " << highZLarB <<
" and " << lowZLarB);
348 if (std::abs(cellRingRadius - initialRadius) >
m_radiusTolerance && highZLarB - lowZLarB > 0.0) {
349 ATH_MSG_DEBUG(
"CYLINDER: Create cylinder for layer " << currentSample.first);
350 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
351 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
353 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB, asymmetricZ));
358 minLArBRadius = std::numeric_limits<double>::max();
368 if (0 == caloSampleSurfaceMap[currentSample].
size()){
374 highZLarB = initialZ+0.001;
375 if (phiCounter > 0) {
376 maxLArBRadius = totalRadiusFixedPhi / phiCounter;
380 ATH_MSG_DEBUG(
"CYLINDER: Zero size Vector: Create cylinder for layer " << currentSample.first);
381 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
382 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
383 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB, asymmetricZ));
409 const std::vector<const CaloDetDescrElement*> & currentElements = caloSampleDDEElementsMap[currentSample];
411 double totalZFixedPhi = 0.0;
412 bool firstCellInPhiRing =
true;
413 unsigned int phiCounter = 0;
415 bool firstPhiRing =
true;
416 double initialRadius = 0.0;
417 double initialZ = -std::numeric_limits<double>::max();
422 double minDiscRadius = std::numeric_limits<double>::max(), maxDiscRadius = 0.0;
424 unsigned int currentElementsSize = currentElements.size();
425 unsigned int DDECounter = 0;
429 bool isLastDDE = (DDECounter == (currentElementsSize-1));
431 ATH_MSG_DEBUG(
"Disc DDE with sampling, r and z of " << currentSample <<
", " << theDDE->r() <<
", " << theDDE->z());
434 double z = theDDE->z();
435 double radius = theDDE->r();
437 if (firstCellInPhiRing) {
438 initialRadius = radius;
439 firstCellInPhiRing =
false;
444 firstPhiRing =
false;
445 minDiscRadius = radius;
450 if (std::abs(radius - initialRadius) < 0.0001 && !isLastDDE) {
457 firstCellInPhiRing =
true;
458 if (phiCounter > 0) {
459 double cellRingZ = totalZFixedPhi / phiCounter;
460 totalZFixedPhi = 0.0;
466 maxDiscRadius = radius;
468 if (std::abs(cellRingZ - initialZ) >
m_zTolerance || isLastDDE) {
469 ATH_MSG_DEBUG(
"DISC: About to create disc surface for sampling " << currentSample);
470 caloSampleSurfaceMap[currentSample].push_back(
generateDiscSurface(cellRingZ,maxDiscRadius, minDiscRadius));
473 minDiscRadius = std::numeric_limits<double>::max();
497 Acts::Experimental::GeometryIdentifierBlueprintNode& geoIdNode = containerNode.withGeometryIdentifier();
501 AxisDirection axis = AxisDirection::AxisZ;
502 if (isDisc) axis = AxisDirection::AxisR;
503 CylinderContainerBlueprintNode& cylinder = geoIdNode.addCylinderContainer(volumeName,
506 cylinder.addLayer(volumeName +
"_Layer", [&](
auto& layer) {
507 layer.setSurfaces(surfaces);
508 layer.setEnvelope(Acts::ExtentEnvelope{{
509 .z = {0.1_mm, 0.1_mm},