47 std::shared_ptr<BlueprintNode>&& childNode) {
50 std::map<caloRegion, caloSampleSurfaceMap_t> caloRegionSampleSurfaceMap;
51 std::map<caloRegion, caloSampleDDEElementsMap_t> caloRegionSampleDDEElementsMap;
52 std::map<std::string, double> caloDimensions;
54 fillMaps(caloRegionSampleSurfaceMap, caloRegionSampleDDEElementsMap, caloDimensions);
64 ATH_MSG_DEBUG(
"Have generated calorimeter cylindrical surfaces");
72 double caloEvelopeMaxR = caloDimensions.at(
"maxR");
73 double caloEnvelopeHalfLenghtZ = (caloDimensions.at(
"maxPosZ") - caloDimensions.at(
"minNegZ"))/2.0;
75 ATH_MSG_INFO(
"Calo envelope dimensions: maxR = " << caloEvelopeMaxR <<
", halfLengthZ = " << caloEnvelopeHalfLenghtZ);
76 std::shared_ptr<StaticBlueprintNode> itkCaloNode{};
78 auto envelope = std::make_unique<TrackingVolume>(Amg::Transform3D::Identity(),
79 std::make_shared<CylinderVolumeBounds>(0., caloEvelopeMaxR, caloEnvelopeHalfLenghtZ),
"ITkCalo");
80 envelope->assignGeometryId(Acts::GeometryIdentifier{}.withVolume(
s_caloEnvelopeID));
81 itkCaloNode = std::make_shared<StaticBlueprintNode>(std::move(envelope));
84 itkCaloNode->addChild(std::move(childNode));
89 auto caloNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisZ);
90 CylinderContainerBlueprintNode& caloBarrelCylinderNode = caloNode->addCylinderContainer(
"CaloBarrelSymmetricZZeroCylinders", AxisDirection::AxisR);
91 caloBarrelCylinderNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
92 caloBarrelCylinderNode.setResizeStrategy(ResizeStrategy::Gap);
96 unsigned int volumeCounter = 0;
107 CylinderContainerBlueprintNode& caloBarrelCylinderNegativeZNode = caloNode->addCylinderContainer(
"CaloBarrelNegativeZAsymmetricCylinders", AxisDirection::AxisR);
108 caloBarrelCylinderNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
109 caloBarrelCylinderNegativeZNode.setResizeStrategy(ResizeStrategy::Gap);
112 CylinderContainerBlueprintNode& caloBarrelCylinderPositiveZNode = caloNode->addCylinderContainer(
"CaloBarrelPositiveZAsymmetricCylinders", AxisDirection::AxisR);
113 caloBarrelCylinderPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
114 caloBarrelCylinderPositiveZNode.setResizeStrategy(ResizeStrategy::Gap);
120 if (sampleIndex < 2){
130 itkCaloNode->addLayer(sampleName+
"NegZ" +
"_Layer", [&](
auto& layer) {
132 layer.setEnvelope(Acts::ExtentEnvelope{{
133 .z = {0.1_mm, 0.1_mm},
137 itkCaloNode->addLayer(sampleName+
"PosZ" +
"_Layer", [&](
auto& layer) {
139 layer.setEnvelope(Acts::ExtentEnvelope{{
140 .z = {0.1_mm, 0.1_mm},
148 CylinderContainerBlueprintNode& caloEndCapDiscNegativeZNode = caloNode->addCylinderContainer(
"CaloEndCapDiscNegativeZ", AxisDirection::AxisZ);
149 caloEndCapDiscNegativeZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
157 caloEndCapDiscNegativeZNode.setResizeStrategies(ResizeStrategy::Expand, ResizeStrategy::Gap);
159 CylinderContainerBlueprintNode& caloEndCapDiscPositiveZNode = caloNode->addCylinderContainer(
"CaloEndCapDiscPositiveZ", AxisDirection::AxisZ);
160 caloEndCapDiscPositiveZNode.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
163 caloEndCapDiscPositiveZNode.setResizeStrategies(ResizeStrategy::Gap, ResizeStrategy::Expand);
173 ATH_MSG_DEBUG(
"Have added all Barrel layers to caloBarrelCylinderNode");
176 itkCaloNode->addChild(caloNode);
188 std::map<caloRegion, caloSampleDDEElementsMap_t>& caloRegionSampleDDEElementsMap, std::map<std::string, double>& caloDimensions)
const {
221 double maxPosZ = 0.0;
222 double minNegZ = 0.0;
231 if (theDDE->r() > maxR) maxR = theDDE->r();
232 if (theDDE->z() > maxPosZ) maxPosZ = theDDE->z();
233 if (theDDE->z() < minNegZ) minNegZ = theDDE->z();
236 std::pair <std::string, CaloCell_ID::CaloSample> samplePair = std::make_pair(
getSampleName(currentSample), currentSample);
245 if (theDDE->z() < 0.0) {
256 if (theDDE->z() < 0.0) {
266 caloDimensions[
"maxR"] = maxR;
267 caloDimensions[
"maxPosZ"] = maxPosZ;
268 caloDimensions[
"minNegZ"] = minNegZ;
270 auto sortAllLayersInZ = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
271 for (
const auto & currentSample : caloSampleList) {
272 std::vector<const CaloDetDescrElement*> currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
274 caloRegionSampleDDEElementsMap[region][currentSample] = std::move(currentElements);
283 auto sortAllLayersInR = [&caloRegionSampleDDEElementsMap](
const std::vector<std::pair<std::string, CaloCell_ID::CaloSample>>& caloSampleList,
const caloRegion& region) {
284 for (
const auto& currentSample : caloSampleList) {
285 std::vector<const CaloDetDescrElement*> currentElements = caloRegionSampleDDEElementsMap[region][currentSample];
287 caloRegionSampleDDEElementsMap[region][currentSample] = std::move(currentElements);
299 std::vector<std::pair<std::string, CaloCell_ID::CaloSample>> sampleList;
303 for (
const auto & currentSample : sampleList) {
305 std::vector<const CaloDetDescrElement*> currentElements = caloSampleDDEElementsMap[currentSample];
307 double maxLArBRadius = 0.0, minLArBRadius = std::numeric_limits<double>::max();
308 double lowZLarB = 0.0, highZLarB = 0.0;
313 double totalRadiusFixedPhi = 0.0;
314 bool firstCellInPhiRing =
true;
315 unsigned int phiCounter = 0;
319 bool firstPhiRing =
true;
320 double initialRadius = 0.0;
321 double initialZ = -std::numeric_limits<double>::max();
324 bool movedInZ =
false;
328 double z = theDDE->z();
329 double radius = theDDE->r();
333 if (firstCellInPhiRing) {
334 ATH_MSG_DEBUG(
"First Cell in phi ring " << currentSample.first <<
" has z = " <<
z <<
" and r = " << radius);
336 firstCellInPhiRing =
false;
340 ATH_MSG_DEBUG(
"First Cell in layer " << currentSample.first <<
" has z = " <<
z <<
" and r = " << radius);
341 initialRadius = theDDE->r();
342 firstPhiRing =
false;
350 if (std::abs(
z - initialZ) < 0.0001) {
351 ATH_MSG_DEBUG(
"phiCounter is " << phiCounter <<
" and radius is " << radius <<
" and totalRadiusFixedPhi is " << totalRadiusFixedPhi <<
" and hash is " << theDDE->calo_hash());
352 totalRadiusFixedPhi += radius;
358 firstCellInPhiRing =
true;
359 if (phiCounter > 0) {
360 double cellRingRadius = totalRadiusFixedPhi / phiCounter;
361 totalRadiusFixedPhi = 0.0;
364 if (cellRingRadius > maxLArBRadius) maxLArBRadius = radius;
365 if (cellRingRadius < minLArBRadius) minLArBRadius = radius;
370 ATH_MSG_DEBUG(
"Values of cellRingRadius, initialRadius, highZLarB and lowZLarB are " << cellRingRadius <<
", " << initialRadius <<
", " << highZLarB <<
" and " << lowZLarB);
371 if (std::abs(cellRingRadius - initialRadius) >
m_radiusTolerance && highZLarB - lowZLarB > 0.0) {
372 ATH_MSG_DEBUG(
"CYLINDER: Create cylinder for layer " << currentSample.first);
373 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
374 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
376 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB, asymmetricZ));
381 minLArBRadius = std::numeric_limits<double>::max();
391 if (0 == caloSampleSurfaceMap[currentSample].
size()){
397 highZLarB = initialZ+0.001;
398 if (phiCounter > 0) {
399 maxLArBRadius = totalRadiusFixedPhi / phiCounter;
403 ATH_MSG_DEBUG(
"CYLINDER: Zero size Vector: Create cylinder for layer " << currentSample.first);
404 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
405 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
406 caloSampleSurfaceMap[currentSample].push_back(
generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB, asymmetricZ));
432 const std::vector<const CaloDetDescrElement*> & currentElements = caloSampleDDEElementsMap[currentSample];
436 if (CaloCell_ID::FCAL0 == currentSample.second || CaloCell_ID::FCAL1 == currentSample.second || CaloCell_ID::FCAL2 == currentSample.second) {
437 ATH_MSG_DEBUG(
"TOM3: FCAL sampling " << currentSample.second);
439 double fcalRMin = std::numeric_limits<double>::max();
440 double fcalRMax = std::numeric_limits<double>::min();
442 size_t cellCount = 0;
445 double r = theDDE->r();
446 if (
r < fcalRMin) fcalRMin =
r;
447 if (
r > fcalRMax) fcalRMax =
r;
448 fcalZSum += theDDE->z();
452 ATH_MSG_WARNING(
"cellCount is zero in CaloBlueprintNodeBuilder::generateDiscSurfaces");
455 double fcalZ = fcalZSum / cellCount;
456 caloSampleSurfaceMap[currentSample].push_back(
generateDiscSurface(fcalZ,fcalRMax, fcalRMin));
462 double totalZFixedPhi = 0.0;
463 bool firstCellInPhiRing =
true;
464 unsigned int phiCounter = 0;
466 bool firstPhiRing =
true;
467 double initialRadius = 0.0;
468 double initialZ = -std::numeric_limits<double>::max();
473 double minDiscRadius = std::numeric_limits<double>::max(), maxDiscRadius = 0.0;
475 unsigned int currentElementsSize = currentElements.size();
476 unsigned int DDECounter = 0;
480 bool isLastDDE = (DDECounter == (currentElementsSize-1));
482 ATH_MSG_DEBUG(
"Disc DDE with sampling, r and z of " << currentSample <<
", " << theDDE->r() <<
", " << theDDE->z());
485 double z = theDDE->z();
486 double radius = theDDE->r();
488 if (firstCellInPhiRing) {
489 initialRadius = radius;
490 firstCellInPhiRing =
false;
495 firstPhiRing =
false;
496 minDiscRadius = radius;
501 if (std::abs(radius - initialRadius) < 0.0001 && !isLastDDE) {
508 firstCellInPhiRing =
true;
509 if (phiCounter > 0) {
510 double cellRingZ = totalZFixedPhi / phiCounter;
511 totalZFixedPhi = 0.0;
517 maxDiscRadius = radius;
519 if (std::abs(cellRingZ - initialZ) >
m_zTolerance || isLastDDE) {
520 ATH_MSG_DEBUG(
"DISC: About to create disc surface for sampling " << currentSample);
521 caloSampleSurfaceMap[currentSample].push_back(
generateDiscSurface(cellRingZ,maxDiscRadius, minDiscRadius));
524 minDiscRadius = std::numeric_limits<double>::max();