17 #include "CaloDetDescr/CaloDetDescrElement.h"
19 #include "GeoModelKernel/GeoFullPhysVol.h"
20 #include "GeoModelKernel/GeoLogVol.h"
21 #include "GeoModelKernel/GeoShape.h"
22 #include "GeoModelKernel/GeoTubs.h"
23 #include "GeoModelKernel/GeoTube.h"
24 #include "GeoModelKernel/GeoPcon.h"
25 #include "GeoModelKernel/GeoTrd.h"
26 #include "GeoModelKernel/GeoMaterial.h"
27 #include "GeoModelKernel/GeoVPhysVol.h"
28 #include "GeoModelKernel/GeoVolumeCursor.h"
29 #include "GeoModelKernel/Units.h"
51 #include "GaudiKernel/MsgStream.h"
52 #include "GaudiKernel/SystemOfUnits.h"
63 m_tileMgrLocation(
"Tile"),
64 m_trackingVolumeHelper(
"Trk::TrackingVolumeHelper/TrackingVolumeHelper"),
65 m_trackingVolumeCreator(
"Trk::CylinderVolumeCreator/TrackingVolumeCreator"),
66 m_tileBarrelEnvelope(25.*
mm),
67 m_useCaloSurfBuilder(true),
68 m_tileBarrelLayersPerSampling(1),
69 m_surfBuilder(
"CaloSurfaceBuilder"),
73 declareInterface<Trk::ICaloTrackingVolumeBuilder>(
this);
88 Tile::TileVolumeBuilder::~ TileVolumeBuilder()
98 ATH_MSG_FATAL(
"Could not get TileDetDescrManager! Tile TrackingVolumes will not be built" );
99 return StatusCode::FAILURE;
103 if (m_trackingVolumeHelper.retrieve().isFailure())
105 ATH_MSG_FATAL(
"Failed to retrieve tool " << m_trackingVolumeHelper );
106 return StatusCode::FAILURE;
108 ATH_MSG_INFO(
"Retrieved tool " << m_trackingVolumeHelper );
111 if (m_trackingVolumeCreator.retrieve().isFailure()){
112 ATH_MSG_FATAL(
"Failed to retrieve tool " << m_trackingVolumeCreator );
113 return StatusCode::FAILURE;
115 ATH_MSG_INFO(
"Retrieved tool " << m_trackingVolumeCreator );
117 if(m_surfBuilder.retrieve().isFailure())
119 ATH_MSG_FATAL(
"Failed to retrieve tool " << m_surfBuilder );
120 return StatusCode::FAILURE;
125 return StatusCode::SUCCESS;
132 auto tileTrackingVolumes = std::vector<Trk::TrackingVolume*>();
143 double plug1Z = 3405.;
144 double plug2Z = 3512.075;
145 double plug1R = 3440.;
146 double plug2R = 2959.;
147 double plug1hZ = 154.5;
148 double plug2hZ = 47.425;
164 std::shared_ptr<Trk::CylinderVolumeBounds> tileBarrelBounds;
165 std::unique_ptr<Trk::CylinderVolumeBounds> tileBarrelGirderBounds;
168 std::shared_ptr<Trk::CylinderVolumeBounds> itcPlug1Bounds;
169 std::shared_ptr<Trk::CylinderVolumeBounds> itcPlug2Bounds;
170 std::shared_ptr<Trk::CylinderVolumeBounds> gapBounds;
176 std::vector<std::pair<const Trk::Surface*, const Trk::Surface*>> entrySurf =
177 m_surfBuilder->entrySurfaces(&caloDDM);
178 std::vector<std::pair<const Trk::Surface*, const Trk::Surface*>> exitSurf =
179 m_surfBuilder->exitSurfaces(&caloDDM);
182 auto barrelProperties = std::make_shared<Trk::Material>(22.7, 212., 45.8, 21.4, 0.0062);
183 auto extendedBarrelProperties = std::make_shared<Trk::Material>(22.7, 210., 45.8, 21.4, 0.0062);
192 unsigned int numTreeTops = m_tileMgr->getNumTreeTops();
193 ATH_MSG_DEBUG(
"Retrieved " << numTreeTops <<
" tree tops from the TileDetDescrManager. " );
196 std::vector<Trk::IdentifiedMaterial> matTB;
198 matTB.emplace_back(barrelProperties,0);
199 matTB.emplace_back(barrelProperties,baseID);
200 matTB.emplace_back(barrelProperties,baseID+1);
201 matTB.emplace_back(barrelProperties,baseID+2);
204 std::vector<size_t> ltb{0,1,2,3};
207 std::vector<Trk::IdentifiedMaterial> matETB;
209 matETB.emplace_back(extendedBarrelProperties,0);
210 matETB.emplace_back(extendedBarrelProperties,baseID);
211 matETB.emplace_back(extendedBarrelProperties,baseID+1);
212 matETB.emplace_back(extendedBarrelProperties,baseID+2);
216 Trk::Material barrelFingerGapProperties(353., 2254., 20.7, 10., 0.00057);
219 Trk::Material fingerGapProperties(552., 3925., 16.4, 8.1, 0.00034);
221 for (
unsigned int itreetop = 0; itreetop<numTreeTops; ++itreetop){
222 PVConstLink currentVPhysVolLink = m_tileMgr->getTreeTop(itreetop);
231 const GeoLogVol* currentLogVol = currentVPhysVolLink->getLogVol();
233 unsigned int currentChilds = currentVPhysVolLink->getNChildVols();
235 ATH_MSG_DEBUG(
"Processing " << currentLogVol->getName() <<
"... has "
236 << currentChilds <<
" childs." );
237 const GeoShape* currentShape = currentLogVol->getShape();
239 std::vector<double> zboundaries;
243 for (
unsigned int ichild = 0; ichild < currentChilds; ++ichild){
245 PVConstLink currentChildLink = currentVPhysVolLink->getChildVol(ichild);
247 const GeoLogVol* childLogVol = currentChildLink->getLogVol();
248 const GeoShape* childShape = childLogVol->getShape();
249 ATH_MSG_VERBOSE(
" Child: " << childLogVol->getName() <<
" has shape " << childShape->type() );
251 const GeoTubs* currentTubs =
dynamic_cast<const GeoTubs*
>(childShape);
255 double childZposition = childTransform.translation().z();
257 if (childCylVolBounds){
260 ATH_MSG_VERBOSE(
" ---> Position in z: " << childTransform.translation().z() );
271 if ( fabs(childZposition)< 100.*
mm ){
273 tileBarrelBounds = std::make_shared<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),
depth,childCylVolBounds->
halflengthZ());
276 tileBarrelGirderBounds = make_unique<Trk::CylinderVolumeBounds>(
depth,childCylVolBounds->
outerRadius(),childCylVolBounds->
halflengthZ());
279 std::vector<float>
steps;
290 nullptr, tileBarrelBounds, barrelMaterialBinned, 12,
291 "Calo::Detectors::Tile::Barrel");
297 std::string volumeName;
298 std::string girderName;
299 std::vector<double> girderLayerRadius;
300 std::vector<double> layerRadius;
301 std::vector<double> layerEnvelope;
302 std::shared_ptr<Trk::CylinderVolumeBounds> tileExtendedBounds =
nullptr;
303 std::unique_ptr<Trk::CylinderVolumeBounds> gapVolBounds;
307 volumeName = childZposition > 0. ?
308 "Calo::Detectors::Tile::PositiveExtendedBarrel" :
"Calo::Detectors::Tile::NegativeExtendedBarrel";
311 tileExtendedBounds = std::make_shared<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),
depth,childCylVolBounds->
halflengthZ());
313 }
else if (childCylVolBounds->
halflengthZ() > 100.){
317 }
else if ( childLogVol->getName()==
"Gap" && !gapBounds ) {
319 gapVolBounds = make_unique<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),childCylVolBounds->
outerRadius(),
322 gapZ = fabs(childZposition);
333 if(m_useCaloSurfBuilder && childCylVolBounds->
halflengthZ() > 1000.){
339 std::vector<float>
steps;
352 extendedMaterialBinned, 18, volumeName);
355 if ( gapVolBounds ) {
356 gapBounds = std::move(gapVolBounds);
358 }
else if (tileExtendedBounds) {
361 std::vector<float>
steps;
369 extendedMaterialBinned =
Trk::BinnedMaterial(*extendedBarrelProperties.get(),eBU,ltb,matETB);
374 extendedMaterialBinned,
381 if (childZposition > 0.) {
382 tilePositiveExtendedBarrel = tileExtendedTrackingVolume;
383 tilePositiveExtendedBarrelBounds = *tileExtendedBounds;
385 tileNegativeExtendedBarrel = tileExtendedTrackingVolume;
387 }
else if (childCylVolBounds->
halflengthZ() > 100.) {
388 tileZ = fabs(childZposition)+childCylVolBounds->
halflengthZ();
396 if (!gapBounds) std::abort();
397 if (!tileBarrelGirderBounds) std::abort();
398 if (!tilePositiveExtendedBarrel) std::abort();
399 if (!tileNegativeExtendedBarrel) std::abort();
401 ATH_MSG_DEBUG(
"TileDetDescrManager parsed successfully! " );
405 auto tileGirderBounds = std::make_shared<Trk::CylinderVolumeBounds>
411 std::move(tileGirderBounds),
413 dummyLayers, dummyVolumes,
414 "Calo::Girder::TileCombined");
418 double tileExtZ = tilePositiveExtendedBarrel->
center().z()-tilePositiveExtendedBarrelBounds.
halflengthZ();
421 std::vector<Trk::IdentifiedMaterial> matITC;
424 matITC.emplace_back(barrelProperties,baseID+15);
425 matITC.emplace_back(barrelProperties,baseID+16);
426 matITC.emplace_back(barrelProperties,baseID+17);
429 double p1Z = 0.5*(plug1Z-plug1hZ+tileExtZ);
430 double hp1Z = 0.5*(tileExtZ-plug1Z+plug1hZ);
431 itcPlug1Bounds = std::make_shared<Trk::CylinderVolumeBounds>(
438 auto itcP1PosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP1Pos));
439 auto itcP1NegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP1Neg));
442 std::vector<size_t> dummylay(1,1);
450 std::move(itcP1PosTransform),
454 "Calo::Detectors::Tile::ITCPlug1Pos");
457 std::move(itcP1NegTransform),
458 std::shared_ptr<Trk::CylinderVolumeBounds>(itcPlug1Bounds->
clone()),
459 plug1MatNeg, 16,
"Calo::Detectors::Tile::ITCPlug1Neg");
462 double p2Z = 0.5*(plug2Z-plug2hZ+tileExtZ);
463 double hp2Z = 0.5*(tileExtZ-plug2Z+plug2hZ);
465 std::make_shared<Trk::CylinderVolumeBounds>(plug2R, plug1R, hp2Z);
469 auto itcP2PosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP2Pos));
470 auto itcP2NegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP2Neg));
472 std::vector<size_t> p2lay(1,0);
473 std::vector<float> p2steps{
float(plug2R),
float(plug1R)};
480 std::move(itcP2PosTransform),
484 "Calo::Detectors::Tile::ITCPlug2Pos");
487 std::move(itcP2NegTransform),
488 std::shared_ptr<Trk::CylinderVolumeBounds> (itcPlug2Bounds->
clone()),
490 "Calo::Detectors::Tile::ITCPlug2Neg");
495 float gapi = 0.5*(gapZ-gapBounds->
halflengthZ()+tileExtZ);
496 double hgZ = 0.5*(tileExtZ-gapZ+gapBounds->
halflengthZ());
497 gapBounds = std::make_shared<Trk::CylinderVolumeBounds>(
505 std::vector<size_t> glay(1,2);
512 std::move(gapPosTransform),
514 17,
"Calo::Detectors::Tile::GapPos");
521 std::move(gapNegTransform),
522 std::shared_ptr<Trk::CylinderVolumeBounds>(gapBounds->
clone()),
524 "Calo::Detectors::Tile::GapNeg");
530 float zgBuff = 0.5*(p1i+
gi);
531 float hgBuff = 0.5*(
gi-p1i);
534 auto gBuffPosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(gBuffPos));
535 auto gBuffNegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(gBuffNeg));
537 auto gapBuffBounds = std::make_shared<Trk::CylinderVolumeBounds>(
543 std::move(gBuffPosTransform), gapBuffBounds, fingerProperties,
544 dummyLayers, dummyVolumes,
"Calo::GapVolumes::Tile::GapBufferPos");
547 std::move(gBuffNegTransform),
548 std::shared_ptr<Trk::CylinderVolumeBounds>(gapBuffBounds->clone()),
549 fingerProperties, dummyLayers, dummyVolumes,
550 "Calo::GapVolumes::Tile::GapBufferNeg");
554 std::vector<Trk::TrackingVolume*> volsPosGap;
555 volsPosGap.push_back(gBufferPos);
556 volsPosGap.push_back(gapPos);
557 positiveGapSector = m_trackingVolumeCreator->createContainerTrackingVolume
560 "Calo::Container::PositiveGap");
564 std::vector<Trk::TrackingVolume*> volsNegGap;
565 volsNegGap.push_back(gapNeg);
566 volsNegGap.push_back(gBufferNeg);
567 negativeGapSector = m_trackingVolumeCreator->createContainerTrackingVolume
570 "Calo::Container::NegativeGap");
574 float z2Buff = 0.5*(p1i+p2i);
575 float h2Buff = 0.5*(p2i-p1i);
578 auto p2BuffPosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(p2BuffPos));
579 auto p2BuffNegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(p2BuffNeg));
581 auto p2BuffBounds = std::make_shared<Trk::CylinderVolumeBounds>(
585 std::move(p2BuffPosTransform), p2BuffBounds, fingerProperties, dummyLayers,
586 dummyVolumes,
"Calo::GapVolumes::Tile::Plug2BufferPos");
589 std::move(p2BuffNegTransform),
590 std::shared_ptr<Trk::CylinderVolumeBounds>(p2BuffBounds->clone()),
591 fingerProperties, dummyLayers,
592 dummyVolumes,
"Calo::GapVolumes::Tile::Plug2BufferNeg");
596 std::vector<Trk::TrackingVolume*> volsPosP2;
597 volsPosP2.push_back(p2BufferPos);
598 volsPosP2.push_back(itcPlug2Pos);
599 positiveP2Sector = m_trackingVolumeCreator->createContainerTrackingVolume
602 "Calo::Container::PositiveP2");
606 std::vector<Trk::TrackingVolume*> volsNegP2;
607 volsNegP2.push_back(itcPlug2Neg);
608 volsNegP2.push_back(p2BufferNeg);
609 negativeP2Sector = m_trackingVolumeCreator->createContainerTrackingVolume
612 "Calo::Container::NegativeP2");
617 if (positiveGapSector && positiveP2Sector) {
618 std::vector<Trk::TrackingVolume*> volsITCPos;
619 volsITCPos.push_back(positiveGapSector);
620 volsITCPos.push_back(positiveP2Sector);
621 volsITCPos.push_back(itcPlug1Pos);
622 positiveITCSector = m_trackingVolumeCreator->createContainerTrackingVolume
625 "Calo::Container::ITCPos");
628 if (negativeGapSector && negativeP2Sector) {
629 std::vector<Trk::TrackingVolume*> volsITCNeg;
630 volsITCNeg.push_back(negativeGapSector);
631 volsITCNeg.push_back(negativeP2Sector);
632 volsITCNeg.push_back(itcPlug1Neg);
633 negativeITCSector = m_trackingVolumeCreator->createContainerTrackingVolume
636 "Calo::Container::ITCNeg");
647 double zFG = 0.5*(tileBarrelBounds->
halflengthZ()+p1i);
648 double hZ = 0.5*(p1i-tileBarrelBounds->
halflengthZ());
649 auto tileBarrelFingerGapBounds = std::make_shared<Trk::CylinderVolumeBounds>(rMin,rMax,hZ);
657 std::move(bfPosTransform), tileBarrelFingerGapBounds, barrelFingerGapProperties,
658 dummyLayers, dummyVolumes,
659 "Calo::GapVolumes::Tile::BarrelPositiveFingerGap");
662 std::move(bfNegTransform),
663 std::shared_ptr<Trk::CylinderVolumeBounds>(
664 tileBarrelFingerGapBounds->clone()),
665 barrelFingerGapProperties, dummyLayers, dummyVolumes,
666 "Calo::GapVolumes::Tile::BarrelNegativeFingerGap");
670 double zBE = tilePositiveExtendedBarrel->
center().z()+tilePositiveExtendedBarrelBounds.
halflengthZ();
671 zFG = 0.5*(tileZ + zBE);
672 hZ = 0.5*(tileZ - zBE);
674 auto tilePositiveFingerGapBounds = std::make_shared<Trk::CylinderVolumeBounds>(
685 std::move(efPosTransform), tilePositiveFingerGapBounds, fingerGapProperties,
686 dummyLayers, dummyVolumes,
"Calo::GapVolumes::Tile::PositiveFingerGap");
689 std::move(efNegTransform),
690 std::shared_ptr<Trk::CylinderVolumeBounds>(tilePositiveFingerGapBounds->clone()),
691 fingerGapProperties, dummyLayers, dummyVolumes,
"Calo::GapVolumes::Tile::NegativeFingerGap");
711 std::vector<Trk::TrackingVolume*> tileVols;
712 tileVols.push_back(tileNegativeFingerGap);
713 tileVols.push_back(tileNegativeExtendedBarrel);
714 tileVols.push_back(negativeITCSector);
715 tileVols.push_back(tileBarrelNegativeFingerGap);
716 tileVols.push_back(tileBarrel);
717 tileVols.push_back(tileBarrelPositiveFingerGap);
718 tileVols.push_back(positiveITCSector);
719 tileVols.push_back(tilePositiveExtendedBarrel);
720 tileVols.push_back(tilePositiveFingerGap);
721 Trk::TrackingVolume* tileCombinedSector = m_trackingVolumeCreator->createContainerTrackingVolume
724 "Calo::Container::Tile::InnerSector");
727 std::vector<Trk::TrackingVolume*> tileVolumes;
728 tileVolumes.push_back(tileCombinedSector);
729 tileVolumes.push_back(tileGirder);
733 "Calo::Container::Tile::Combined");
737 tileTrackingVolumes.push_back(
tile);
738 tileTrackingVolumes.push_back(tilePositiveExtendedBarrel);
740 if (msgLvl(MSG::INFO)) {
741 ATH_MSG_DEBUG(
"Checking the existence of all Tracking Volumes:" );
745 printCheckResult(
msg(
MSG::DEBUG), tilePositiveExtendedBarrel);
747 printCheckResult(
msg(
MSG::DEBUG), tileNegativeExtendedBarrel);
749 printCheckResult(
msg(
MSG::DEBUG), tileBarrelPositiveFingerGap);
751 printCheckResult(
msg(
MSG::DEBUG), tileBarrelNegativeFingerGap);
760 return tileTrackingVolumes;
770 const GeoLogVol* lv =
pv->getLogVol();
771 std::cout <<
"New Tile Object:" << lv->getName() <<
", made of"
772 << lv->getMaterial()->getName() <<
"," << lv->getShape()->type()
777 printChildren(
pv, igen, transf);
783 unsigned int nc =
pv->getNChildVols();
786 for (
unsigned int ic = 0;
ic <
nc;
ic++) {
789 const PVConstLink cv =
pv->getChildVol(
ic);
790 const GeoLogVol* clv = cv->getLogVol();
792 std::cout <<
"subcomponent:" << igen <<
":" <<
ic <<
":" << clv->getName()
793 <<
", made of" << clv->getMaterial()->getName() <<
","
794 << clv->getShape()->type() << std::endl;
795 std::cout <<
"position:" <<
"R:" << transf.translation().perp()
796 <<
",phi:" << transf.translation().phi()
797 <<
",x:" << transf.translation().x()
798 <<
",y:" << transf.translation().y()
799 <<
",z:" << transf.translation().z() << std::endl;
800 const GeoTrd* trd =
dynamic_cast<const GeoTrd*
>(clv->getShape());
802 std::cout <<
"trddim:" << trd->getXHalfLength1() <<
","
803 << trd->getXHalfLength2() <<
"," << trd->getYHalfLength1()
804 <<
"," << trd->getYHalfLength2() <<
"," << trd->getZHalfLength()
806 const GeoTubs* tub =
dynamic_cast<const GeoTubs*
>(clv->getShape());
808 std::cout <<
"tubdim:" << tub->getRMin() <<
"," << tub->getRMax() <<
","
809 << tub->getZHalfLength() << std::endl;
810 const GeoPcon* con =
dynamic_cast<const GeoPcon*
>(clv->getShape());
812 const unsigned int nPlanes = con->getNPlanes();
813 for (
unsigned int i = 0;
i < nPlanes;
i++) {
814 std::cout <<
"polycone:" <<
i <<
":" << con->getRMinPlane(
i) <<
","
815 << con->getRMaxPlane(
i) <<
"," << con->getZPlane(
i)
820 if (
ic == 0 || cname != clv->getName()) {
822 printChildren(cv, igen, transf);
823 cname = clv->getName();