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{};
73 auto envelope = std::make_unique<TrackingVolume>(Amg::Transform3D::Identity(),
74 std::make_shared<CylinderVolumeBounds>(0., 100.0, 100.0),
"ITkCalo");
75 envelope->assignGeometryId(Acts::GeometryIdentifier{}.withVolume(
s_caloEnvelopeID));
76 itkCaloNode = std::make_shared<StaticBlueprintNode>(std::move(envelope));
79 itkCaloNode->addChild(std::move(childNode));
84 auto caloNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisZ);
85 CylinderContainerBlueprintNode& caloBarrelCylinderNode = caloNode->addCylinderContainer(
"CaloBarrelSymmetricZZeroCylinders", AxisDirection::AxisR);
86 caloBarrelCylinderNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
87 caloBarrelCylinderNode.setResizeStrategy(ResizeStrategy::Gap);
99 CylinderContainerBlueprintNode& caloBarrelCylinderNegativeZNode = caloNode->addCylinderContainer(
"CaloBarrelNegativeZAsymmetricCylinders", AxisDirection::AxisR);
100 caloBarrelCylinderNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
101 caloBarrelCylinderNegativeZNode.setResizeStrategy(ResizeStrategy::Gap);
104 CylinderContainerBlueprintNode& caloBarrelCylinderPositiveZNode = caloNode->addCylinderContainer(
"CaloBarrelPositiveZAsymmetricCylinders", AxisDirection::AxisR);
105 caloBarrelCylinderPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
106 caloBarrelCylinderPositiveZNode.setResizeStrategy(ResizeStrategy::Gap);
112 if (sampleIndex < 2){
120 itkCaloNode->addLayer(sampleName+
"NegZ" +
"_Layer", [&](
auto& layer) {
122 layer.setEnvelope(Acts::ExtentEnvelope{{
123 .z = {0.1_mm, 0.1_mm},
127 itkCaloNode->addLayer(sampleName+
"PosZ" +
"_Layer", [&](
auto& layer) {
129 layer.setEnvelope(Acts::ExtentEnvelope{{
130 .z = {0.1_mm, 0.1_mm},
138 CylinderContainerBlueprintNode& caloEndCapDiscNegativeZNode = caloNode->addCylinderContainer(
"CaloEndCapDiscNegativeZ", AxisDirection::AxisZ);
139 caloEndCapDiscNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
140 caloEndCapDiscNegativeZNode.setResizeStrategy(ResizeStrategy::Gap);
142 CylinderContainerBlueprintNode& caloEndCapDiscPositiveZNode = caloNode->addCylinderContainer(
"CaloEndCapDiscPositiveZ", AxisDirection::AxisZ);
143 caloEndCapDiscPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
144 caloEndCapDiscPositiveZNode.setResizeStrategy(ResizeStrategy::Gap);
152 ATH_MSG_DEBUG(
"Have added all Barrel layers to caloBarrelCylinderNode");
155 itkCaloNode->addChild(caloNode);
167 std::map<caloRegion, caloSampleDDEElementsMap_t>& caloRegionSampleDDEElementsMap)
const {
207 std::pair <std::string, CaloCell_ID::CaloSample> samplePair = std::make_pair(
getSampleName(currentSample), currentSample);
216 if (theDDE->z() < 0.0) {
227 if (theDDE->z() < 0.0) {
237 auto sortAllLayersInZ = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
238 for (
const auto & currentSample : caloSampleList) {
239 std::vector<const CaloDetDescrElement*> currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
241 caloRegionSampleDDEElementsMap[region][currentSample] = std::move(currentElements);
250 auto sortAllLayersInR = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
251 for (
const auto& currentSample : caloSampleList) {
252 std::vector<const CaloDetDescrElement*> currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
254 caloRegionSampleDDEElementsMap[region][currentSample] = std::move(currentElements);
266 std::vector<std::pair<std::string, CaloCell_ID::CaloSample>> sampleList;
270 for (
const auto & currentSample : sampleList) {
272 std::vector<const CaloDetDescrElement*> currentElements = caloSampleDDEElementsMap[currentSample];
274 double maxLArBRadius = 0.0, minLArBRadius = std::numeric_limits<double>::max();
275 double lowZLarB = 0.0, highZLarB = 0.0;
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 if (cellRingRadius > maxLArBRadius) maxLArBRadius = radius;
332 if (cellRingRadius < minLArBRadius) minLArBRadius = radius;
337 ATH_MSG_DEBUG(
"Values of cellRingRadius, initialRadius, highZLarB and lowZLarB are " << cellRingRadius <<
", " << initialRadius <<
", " << highZLarB <<
" and " << lowZLarB);
338 if (std::abs(cellRingRadius - initialRadius) >
m_radiusTolerance && highZLarB - lowZLarB > 0.0) {
339 ATH_MSG_DEBUG(
"CYLINDER: Create cylinder for layer " << currentSample.first);
340 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
341 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
343 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB, asymmetricZ));
348 minLArBRadius = std::numeric_limits<double>::max();
358 if (0 == caloSampleSurfaceMap[currentSample].
size()){
364 highZLarB = initialZ+0.001;
365 if (phiCounter > 0) {
366 maxLArBRadius = totalRadiusFixedPhi / phiCounter;
370 ATH_MSG_DEBUG(
"CYLINDER: Zero size Vector: Create cylinder for layer " << currentSample.first);
371 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
372 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
373 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB, asymmetricZ));
399 const std::vector<const CaloDetDescrElement*> & currentElements = caloSampleDDEElementsMap[currentSample];
401 double totalZFixedPhi = 0.0;
402 bool firstCellInPhiRing =
true;
403 unsigned int phiCounter = 0;
405 bool firstPhiRing =
true;
406 double initialRadius = 0.0;
407 double initialZ = -std::numeric_limits<double>::max();
412 double minDiscRadius = std::numeric_limits<double>::max(), maxDiscRadius = 0.0;
414 unsigned int currentElementsSize = currentElements.size();
415 unsigned int DDECounter = 0;
419 bool isLastDDE = (DDECounter == (currentElementsSize-1));
421 ATH_MSG_DEBUG(
"Disc DDE with sampling, r and z of " << currentSample <<
", " << theDDE->r() <<
", " << theDDE->z());
424 double z = theDDE->z();
425 double radius = theDDE->r();
427 if (firstCellInPhiRing) {
428 initialRadius = radius;
429 firstCellInPhiRing =
false;
434 firstPhiRing =
false;
435 minDiscRadius = radius;
440 if (std::abs(radius - initialRadius) < 0.0001 && !isLastDDE) {
447 firstCellInPhiRing =
true;
448 if (phiCounter > 0) {
449 double cellRingZ = totalZFixedPhi / phiCounter;
450 totalZFixedPhi = 0.0;
456 maxDiscRadius = radius;
458 if (std::abs(cellRingZ - initialZ) >
m_zTolerance || isLastDDE) {
459 ATH_MSG_DEBUG(
"DISC: About to create disc surface for sampling " << currentSample);
460 caloSampleSurfaceMap[currentSample].push_back(
generateDiscSurface(cellRingZ,maxDiscRadius, minDiscRadius));
463 minDiscRadius = std::numeric_limits<double>::max();
487 Acts::Experimental::GeometryIdentifierBlueprintNode& geoIdNode = containerNode.withGeometryIdentifier();
491 AxisDirection axis = AxisDirection::AxisZ;
492 if (isDisc) axis = AxisDirection::AxisR;
493 CylinderContainerBlueprintNode& cylinder = geoIdNode.addCylinderContainer(volumeName,
496 cylinder.addLayer(volumeName +
"_Layer", [&](
auto& layer) {
497 layer.setSurfaces(surfaces);
498 layer.setEnvelope(Acts::ExtentEnvelope{{
499 .z = {0.1_mm, 0.1_mm},