7 #include "Acts/Geometry/Blueprint.hpp"
8 #include "Acts/Geometry/PortalShell.hpp"
9 #include "Acts/Geometry/Volume.hpp"
10 #include "Acts/Geometry/StaticBlueprintNode.hpp"
12 #include <Acts/Utilities/AxisDefinitions.hpp>
13 #include <Acts/Geometry/ContainerBlueprintNode.hpp>
17 #include "Acts/Surfaces/Surface.hpp"
29 return StatusCode::SUCCESS;
33 std::shared_ptr<BlueprintNode>&& childNode) {
37 fillMaps(caloSampleSurfaceMap, caloSampleDDEElementsMap);
42 fillCaloDimensionsMap(caloDimensionMap, caloSampleDDEElementsMap);
46 generateCylinderSurfaces(caloSampleSurfaceMap, caloSampleDDEElementsMap);
48 ATH_MSG_DEBUG(
"Have generated calorimeter cylindrical surfaces");
51 auto caloNode = std::make_shared<CylinderContainerBlueprintNode>(
"CaloNode", AxisDirection::AxisR);
52 if (childNode) caloNode->addChild(std::move(childNode));
56 CylinderContainerBlueprintNode& EMBarrelCylinder = caloNode->addCylinderContainer(
"EMBarrel", AxisDirection::AxisR);
58 EMBarrelCylinder.setAttachmentStrategy(VolumeAttachmentStrategy::Gap);
63 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"PreSamplerB", caloSampleSurfaceMap[
CaloCell_ID::PreSamplerB]);
64 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"EMB1", caloSampleSurfaceMap[
CaloCell_ID::EMB1]);
65 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"EMB2", caloSampleSurfaceMap[
CaloCell_ID::EMB2]);
66 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"EMB3", caloSampleSurfaceMap[
CaloCell_ID::EMB3]);
67 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"TileBar0", caloSampleSurfaceMap[
CaloCell_ID::TileBar0]);
68 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"TileBar1", caloSampleSurfaceMap[
CaloCell_ID::TileBar1]);
69 addCylindricalTrackingVolumeToCaloNode(EMBarrelCylinder, caloDimensionMap,
"TileBar2", caloSampleSurfaceMap[
CaloCell_ID::TileBar2]);
71 ATH_MSG_DEBUG(
"Have added all Barrel layers to EMBarrelCylinder node");
78 return StatusCode::SUCCESS;
94 for (
auto currentSample : m_caloCylinderSampleList) {
95 caloSampleSurfaceMap[currentSample] = std::vector<std::shared_ptr<Surface> >();
96 caloSampleDDEElementsMap[currentSample] = std::vector<const CaloDetDescrElement*>();
99 for (
auto currentSample : m_caloDiscSampleList) {
100 caloSampleSurfaceMap[currentSample] = std::vector<std::shared_ptr<Surface> >();
101 caloSampleDDEElementsMap[currentSample] = std::vector<const CaloDetDescrElement*>();
111 caloSampleDDEElementsMap[currentSample].push_back(theDDE);
114 auto sortAllLayersInZ = [&caloSampleDDEElementsMap](
const std::vector<CaloCell_ID::CaloSample>& caloSampleList) {
115 for (
auto currentSample : caloSampleList) {
116 std::vector<const CaloDetDescrElement*> currentElements = caloSampleDDEElementsMap[currentSample];
118 caloSampleDDEElementsMap[currentSample] = std::move(currentElements);
123 sortAllLayersInZ(m_caloCylinderSampleList);
124 sortAllLayersInZ(m_caloDiscSampleList);
130 for (
auto currentSample : m_caloCylinderSampleList) {
132 std::vector<const CaloDetDescrElement*> currentElements = caloSampleDDEElementsMap[currentSample];
134 double maxLArBRadius = 0.0, minLArBRadius = 999999.0;
135 double lowZLarB = 0.0, highZLarB = 0.0;
140 double totalRadiusFixedPhi = 0.0;
141 bool firstCellInPhiRing =
true;
142 unsigned int phiCounter = 0;
146 bool firstPhiRing =
true;
147 double initialRadius = 0.0;
148 double initialZ = -999999.0;
152 double z = theDDE->z();
153 double radius = theDDE->r();
157 if (firstCellInPhiRing) {
158 ATH_MSG_DEBUG(
"First Cell in phi ring " << currentSample <<
" has z = " <<
z <<
" and r = " <<
radius);
160 firstCellInPhiRing =
false;
164 ATH_MSG_DEBUG(
"First Cell in layer " << currentSample <<
" has z = " <<
z <<
" and r = " <<
radius);
165 initialRadius = theDDE->r();
166 firstPhiRing =
false;
174 if (std::abs(
z - initialZ) < 0.0001) {
175 ATH_MSG_DEBUG(
"phiCounter is " << phiCounter <<
" and radius is " <<
radius <<
" and totalRadiusFixedPhi is " << totalRadiusFixedPhi <<
" and hash is " << theDDE->calo_hash());
176 totalRadiusFixedPhi +=
radius;
181 firstCellInPhiRing =
true;
182 if (phiCounter > 0) {
183 double cellRingRadius = totalRadiusFixedPhi / phiCounter;
184 totalRadiusFixedPhi = 0.0;
187 if (cellRingRadius > maxLArBRadius) maxLArBRadius =
radius;
188 if (cellRingRadius < minLArBRadius) minLArBRadius =
radius;
193 ATH_MSG_DEBUG(
"Values of cellRingRadius, initialRadius, highZLarB and lowZLarB are " << cellRingRadius <<
", " << initialRadius <<
", " << highZLarB <<
" and " << lowZLarB);
194 if (std::abs(cellRingRadius - initialRadius) > m_radiusTolerance && highZLarB - lowZLarB > 0.0) {
195 ATH_MSG_DEBUG(
"CYLINDER: Create cylinder for layer " << currentSample);
196 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
197 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
199 caloSampleSurfaceMap[currentSample].push_back(generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB));
204 minLArBRadius = 999999.0;
214 if (0 == caloSampleSurfaceMap[currentSample].
size()){
215 ATH_MSG_DEBUG(
"CYLINDER: Zero size Vector: Create cylinder for layer " << currentSample);
216 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B radius are " << minLArBRadius <<
" " << maxLArBRadius);
217 ATH_MSG_DEBUG(
"CYLINDER: Create Cylinder: Min and Max LAr B z are " << lowZLarB <<
" " << highZLarB);
218 caloSampleSurfaceMap[currentSample].push_back(generateCylinderSurface(maxLArBRadius, minLArBRadius, lowZLarB, highZLarB));
226 double LArBRadius = (maxLArBRadius + minLArBRadius) / 2.0;
227 double LArBLength = std::abs(highZLarB - lowZLarB);
229 ATH_MSG_DEBUG(
"Cylinder radius and length are " << LArBRadius <<
" and " << LArBLength);
234 auto transform = Transform3(Translation3(0.0,0.0,lowZLarB + (lowZLarB + highZLarB) / 2.0));
235 auto surface = Surface::makeShared<CylinderSurface>(
transform,LArBRadius, LArBLength);
244 double minR = 99999999999999;
246 double minZ = 99999999999999;
247 double maxZ = -99999999999999;
250 auto checkMinR = [&minR](
const CaloDetDescrElement* theDDE){
double r = theDDE->r();
if (
r < minR) minR =
r;};
251 auto checkMaxR = [&maxR](
const CaloDetDescrElement* theDDE){
double r = theDDE->r();
if (
r > maxR) maxR =
r;};
252 auto checkMinMaxZ = [&minZ,&maxZ](
const CaloDetDescrElement* theDDE){
double z = theDDE->z();
if (
z > maxZ) maxZ =
z;
if (
z < minZ) minZ =
z;};
253 auto calcHalfLengthZ = [&minZ, &maxZ](){
return (maxZ - minZ) / 2.0;};
256 auto getMinRMaxRHalfLengthZ = [&minR, &maxR, &minZ, &maxZ, &caloSampleDDEElementsMap, &checkMinR, &checkMaxR, &checkMinMaxZ, &calcHalfLengthZ](
CaloCell_ID::CaloSample currentSample) {
258 minR = 99999999999999;
260 minZ = 99999999999999;
261 maxZ = -99999999999999;
266 checkMinMaxZ(theDDE);
269 return calcHalfLengthZ();
276 std::vector<const CaloDetDescrElement*> DDE_TileBar2 = caloSampleDDEElementsMap[
CaloCell_ID::TileBar2];
277 std::vector<const CaloDetDescrElement*> DDE_TileGap2 = caloSampleDDEElementsMap[
CaloCell_ID::TileGap2];
278 std::vector<const CaloDetDescrElement*> DDE_TileExt2 = caloSampleDDEElementsMap[
CaloCell_ID::TileExt2];
281 for (
const CaloDetDescrElement* theDDE : caloSampleDDEElementsMap[currentSample]) checkMaxR(theDDE);
285 ATH_MSG_DEBUG(
"Max R in TileBar2, TileGap2 and TileExt2 is " << maxR);
287 caloDimensionsMap[
"CaloMinR"] = minR;
288 caloDimensionsMap[
"CaloMaxR"] = maxR;
291 for (
auto currentSample : {
CaloCell_ID::PreSamplerB,
CaloCell_ID::EMB1,
CaloCell_ID::EMB2,
CaloCell_ID::EMB3,
CaloCell_ID::TileBar0,
CaloCell_ID::TileBar1,
CaloCell_ID::TileBar2,
CaloCell_ID::TileGap1,
CaloCell_ID::TileGap2,
CaloCell_ID::TileExt0,
CaloCell_ID::TileExt1,
CaloCell_ID::TileExt2}) {
292 for (
const CaloDetDescrElement* theDDE : caloSampleDDEElementsMap[currentSample]) checkMinMaxZ(theDDE);
295 caloDimensionsMap[
"CaloMinZ"] = minZ;
296 caloDimensionsMap[
"CaloMaxZ"] = maxZ;
298 double halfLengthZ = calcHalfLengthZ();
299 ATH_MSG_DEBUG(
"Half length in Z for entire barrel is " << halfLengthZ);
300 caloDimensionsMap[
"CaloHalfLengthZ"] = halfLengthZ;
302 auto putMinRMaxRHalfLengthZInMap = [&caloDimensionsMap,&minR,&maxR,&halfLengthZ](
const std::string& sampleString){
305 float smallOffset = 0.1;
306 if (std::fabs((maxR - minR)) < smallOffset) maxR = minR + smallOffset;
307 caloDimensionsMap[sampleString +
"MinR"] = minR;
308 caloDimensionsMap[sampleString +
"MaxR"] = maxR;
309 caloDimensionsMap[sampleString +
"HalfLengthZ"] = halfLengthZ;
313 putMinRMaxRHalfLengthZInMap(
"PreSamplerB");
315 putMinRMaxRHalfLengthZInMap(
"EMB1");
317 putMinRMaxRHalfLengthZInMap(
"EMB2");
319 putMinRMaxRHalfLengthZInMap(
"EMB3");
321 putMinRMaxRHalfLengthZInMap(
"TileBar0");
323 putMinRMaxRHalfLengthZInMap(
"TileBar1");
325 putMinRMaxRHalfLengthZInMap(
"TileBar2");
332 CylinderContainerBlueprintNode& cylinder = containerNode.addCylinderContainer(volumeName, AxisDirection::AxisZ);
334 ATH_MSG_DEBUG(
"Creating TrackingVolume for " << volumeName <<
" with minR, maxR and halfLengthZ of " << caloDimensionMap[volumeName+
"MinR"] <<
", " << caloDimensionMap[volumeName+
"MaxR"] <<
" and " << caloDimensionMap[volumeName+
"HalfLengthZ"]);
336 auto trackingVolume = std::make_unique<TrackingVolume>(
337 Transform3::Identity(),
338 std::make_shared<CylinderVolumeBounds>(caloDimensionMap[volumeName+
"MinR"], caloDimensionMap[volumeName+
"MaxR"], caloDimensionMap[volumeName+
"HalfLengthZ"]),
341 for (
auto surface : surfaces) trackingVolume->addSurface(std::move(surface));
344 cylinder.addStaticVolume(std::move(trackingVolume));