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"
49 #include "GaudiKernel/MsgStream.h"
50 #include "GaudiKernel/SystemOfUnits.h"
61 m_tileMgrLocation(
"Tile"),
62 m_trackingVolumeCreator(
"Trk::CylinderVolumeCreator/TrackingVolumeCreator"),
63 m_tileBarrelEnvelope(25.*
mm),
64 m_useCaloSurfBuilder(true),
65 m_tileBarrelLayersPerSampling(1),
66 m_surfBuilder(
"CaloSurfaceBuilder"),
70 declareInterface<Trk::ICaloTrackingVolumeBuilder>(
this);
84 Tile::TileVolumeBuilder::~ TileVolumeBuilder()
96 ATH_CHECK(m_trackingVolumeCreator.retrieve());
97 ATH_MSG_INFO(
"Retrieved tool " << m_trackingVolumeCreator );
103 return StatusCode::SUCCESS;
110 auto tileTrackingVolumes = std::vector<Trk::TrackingVolume*>();
121 double plug1Z = 3405.;
122 double plug2Z = 3512.075;
123 double plug1R = 3440.;
124 double plug2R = 2959.;
125 double plug1hZ = 154.5;
126 double plug2hZ = 47.425;
142 std::shared_ptr<Trk::CylinderVolumeBounds> tileBarrelBounds;
143 std::unique_ptr<Trk::CylinderVolumeBounds> tileBarrelGirderBounds;
146 std::shared_ptr<Trk::CylinderVolumeBounds> itcPlug1Bounds;
147 std::shared_ptr<Trk::CylinderVolumeBounds> itcPlug2Bounds;
148 std::shared_ptr<Trk::CylinderVolumeBounds> gapBounds;
150 std::vector<std::pair<const Trk::Surface*, const Trk::Surface*>> entrySurf =
151 m_surfBuilder->entrySurfaces(&caloDDM);
152 std::vector<std::pair<const Trk::Surface*, const Trk::Surface*>> exitSurf =
153 m_surfBuilder->exitSurfaces(&caloDDM);
156 auto barrelProperties = std::make_shared<Trk::Material>(22.7, 212., 45.8, 21.4, 0.0062);
157 auto extendedBarrelProperties = std::make_shared<Trk::Material>(22.7, 210., 45.8, 21.4, 0.0062);
166 unsigned int numTreeTops = m_tileMgr->getNumTreeTops();
167 ATH_MSG_DEBUG(
"Retrieved " << numTreeTops <<
" tree tops from the TileDetDescrManager. " );
170 std::vector<Trk::IdentifiedMaterial> matTB;
172 matTB.emplace_back(barrelProperties,0);
173 matTB.emplace_back(barrelProperties,baseID);
174 matTB.emplace_back(barrelProperties,baseID+1);
175 matTB.emplace_back(barrelProperties,baseID+2);
178 std::vector<size_t> ltb{0,1,2,3};
181 std::vector<Trk::IdentifiedMaterial> matETB;
183 matETB.emplace_back(extendedBarrelProperties,0);
184 matETB.emplace_back(extendedBarrelProperties,baseID);
185 matETB.emplace_back(extendedBarrelProperties,baseID+1);
186 matETB.emplace_back(extendedBarrelProperties,baseID+2);
190 Trk::Material barrelFingerGapProperties(353., 2254., 20.7, 10., 0.00057);
193 Trk::Material fingerGapProperties(552., 3925., 16.4, 8.1, 0.00034);
195 for (
unsigned int itreetop = 0; itreetop<numTreeTops; ++itreetop){
196 PVConstLink currentVPhysVolLink = m_tileMgr->getTreeTop(itreetop);
205 const GeoLogVol* currentLogVol = currentVPhysVolLink->getLogVol();
207 unsigned int currentChilds = currentVPhysVolLink->getNChildVols();
209 ATH_MSG_DEBUG(
"Processing " << currentLogVol->getName() <<
"... has "
210 << currentChilds <<
" childs." );
211 const GeoShape* currentShape = currentLogVol->getShape();
213 std::vector<double> zboundaries;
217 for (
unsigned int ichild = 0; ichild < currentChilds; ++ichild){
219 PVConstLink currentChildLink = currentVPhysVolLink->getChildVol(ichild);
221 const GeoLogVol* childLogVol = currentChildLink->getLogVol();
222 const GeoShape* childShape = childLogVol->getShape();
223 ATH_MSG_VERBOSE(
" Child: " << childLogVol->getName() <<
" has shape " << childShape->type() );
225 const GeoTubs* currentTubs =
dynamic_cast<const GeoTubs*
>(childShape);
229 double childZposition = childTransform.translation().z();
231 if (childCylVolBounds){
234 ATH_MSG_VERBOSE(
" ---> Position in z: " << childTransform.translation().z() );
245 if ( fabs(childZposition)< 100.*
mm ){
247 tileBarrelBounds = std::make_shared<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),
depth,childCylVolBounds->
halflengthZ());
250 tileBarrelGirderBounds = make_unique<Trk::CylinderVolumeBounds>(
depth,childCylVolBounds->
outerRadius(),childCylVolBounds->
halflengthZ());
253 std::vector<float>
steps;
264 nullptr, tileBarrelBounds, barrelMaterialBinned, 12,
265 "Calo::Detectors::Tile::Barrel");
271 std::string volumeName;
272 std::string girderName;
273 std::vector<double> girderLayerRadius;
274 std::vector<double> layerRadius;
275 std::vector<double> layerEnvelope;
276 std::shared_ptr<Trk::CylinderVolumeBounds> tileExtendedBounds =
nullptr;
277 std::unique_ptr<Trk::CylinderVolumeBounds> gapVolBounds;
281 volumeName = childZposition > 0. ?
282 "Calo::Detectors::Tile::PositiveExtendedBarrel" :
"Calo::Detectors::Tile::NegativeExtendedBarrel";
285 tileExtendedBounds = std::make_shared<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),
depth,childCylVolBounds->
halflengthZ());
287 }
else if (childCylVolBounds->
halflengthZ() > 100.){
291 }
else if ( childLogVol->getName()==
"Gap" && !gapBounds ) {
293 gapVolBounds = make_unique<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),childCylVolBounds->
outerRadius(),
296 gapZ = fabs(childZposition);
307 if(m_useCaloSurfBuilder && childCylVolBounds->
halflengthZ() > 1000.){
313 std::vector<float>
steps;
326 extendedMaterialBinned, 18, volumeName);
329 if ( gapVolBounds ) {
330 gapBounds = std::move(gapVolBounds);
332 }
else if (tileExtendedBounds) {
335 std::vector<float>
steps;
343 extendedMaterialBinned =
Trk::BinnedMaterial(*extendedBarrelProperties.get(),eBU,ltb,matETB);
348 extendedMaterialBinned,
355 if (childZposition > 0.) {
356 tilePositiveExtendedBarrel = tileExtendedTrackingVolume;
357 tilePositiveExtendedBarrelBounds = *tileExtendedBounds;
359 tileNegativeExtendedBarrel = tileExtendedTrackingVolume;
361 }
else if (childCylVolBounds->
halflengthZ() > 100.) {
362 tileZ = fabs(childZposition)+childCylVolBounds->
halflengthZ();
370 if (!gapBounds) std::abort();
371 if (!tileBarrelGirderBounds) std::abort();
372 if (!tilePositiveExtendedBarrel) std::abort();
373 if (!tileNegativeExtendedBarrel) std::abort();
375 ATH_MSG_DEBUG(
"TileDetDescrManager parsed successfully! " );
379 auto tileGirderBounds = std::make_shared<Trk::CylinderVolumeBounds>
385 std::move(tileGirderBounds),
388 "Calo::Girder::TileCombined");
392 double tileExtZ = tilePositiveExtendedBarrel->
center().z()-tilePositiveExtendedBarrelBounds.
halflengthZ();
395 std::vector<Trk::IdentifiedMaterial> matITC;
398 matITC.emplace_back(barrelProperties,baseID+15);
399 matITC.emplace_back(barrelProperties,baseID+16);
400 matITC.emplace_back(barrelProperties,baseID+17);
403 double p1Z = 0.5*(plug1Z-plug1hZ+tileExtZ);
404 double hp1Z = 0.5*(tileExtZ-plug1Z+plug1hZ);
405 itcPlug1Bounds = std::make_shared<Trk::CylinderVolumeBounds>(
412 auto itcP1PosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP1Pos));
413 auto itcP1NegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP1Neg));
416 std::vector<size_t> dummylay(1,1);
424 std::move(itcP1PosTransform),
428 "Calo::Detectors::Tile::ITCPlug1Pos");
431 std::move(itcP1NegTransform),
432 std::shared_ptr<Trk::CylinderVolumeBounds>(itcPlug1Bounds->
clone()),
433 plug1MatNeg, 16,
"Calo::Detectors::Tile::ITCPlug1Neg");
436 double p2Z = 0.5*(plug2Z-plug2hZ+tileExtZ);
437 double hp2Z = 0.5*(tileExtZ-plug2Z+plug2hZ);
439 std::make_shared<Trk::CylinderVolumeBounds>(plug2R, plug1R, hp2Z);
443 auto itcP2PosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP2Pos));
444 auto itcP2NegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(itcP2Neg));
446 std::vector<size_t> p2lay(1,0);
447 std::vector<float> p2steps{
float(plug2R),
float(plug1R)};
454 std::move(itcP2PosTransform),
458 "Calo::Detectors::Tile::ITCPlug2Pos");
461 std::move(itcP2NegTransform),
462 std::shared_ptr<Trk::CylinderVolumeBounds> (itcPlug2Bounds->
clone()),
464 "Calo::Detectors::Tile::ITCPlug2Neg");
469 float gapi = 0.5*(gapZ-gapBounds->
halflengthZ()+tileExtZ);
470 double hgZ = 0.5*(tileExtZ-gapZ+gapBounds->
halflengthZ());
471 gapBounds = std::make_shared<Trk::CylinderVolumeBounds>(
479 std::vector<size_t> glay(1,2);
486 std::move(gapPosTransform),
488 17,
"Calo::Detectors::Tile::GapPos");
495 std::move(gapNegTransform),
496 std::shared_ptr<Trk::CylinderVolumeBounds>(gapBounds->
clone()),
498 "Calo::Detectors::Tile::GapNeg");
504 float zgBuff = 0.5*(p1i+
gi);
505 float hgBuff = 0.5*(
gi-p1i);
508 auto gBuffPosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(gBuffPos));
509 auto gBuffNegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(gBuffNeg));
511 auto gapBuffBounds = std::make_shared<Trk::CylinderVolumeBounds>(
517 std::move(gBuffPosTransform), gapBuffBounds, fingerProperties,
518 nullptr,
nullptr,
"Calo::GapVolumes::Tile::GapBufferPos");
521 std::move(gBuffNegTransform),
522 std::shared_ptr<Trk::CylinderVolumeBounds>(gapBuffBounds->clone()),
523 fingerProperties,
nullptr,
nullptr,
524 "Calo::GapVolumes::Tile::GapBufferNeg");
528 std::vector<Trk::TrackingVolume*> volsPosGap;
529 volsPosGap.push_back(gBufferPos);
530 volsPosGap.push_back(gapPos);
531 positiveGapSector = m_trackingVolumeCreator->createContainerTrackingVolume
534 "Calo::Container::PositiveGap");
538 std::vector<Trk::TrackingVolume*> volsNegGap;
539 volsNegGap.push_back(gapNeg);
540 volsNegGap.push_back(gBufferNeg);
541 negativeGapSector = m_trackingVolumeCreator->createContainerTrackingVolume
544 "Calo::Container::NegativeGap");
548 float z2Buff = 0.5*(p1i+p2i);
549 float h2Buff = 0.5*(p2i-p1i);
552 auto p2BuffPosTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(p2BuffPos));
553 auto p2BuffNegTransform = std::make_unique<Amg::Transform3D>(
Amg::Translation3D(p2BuffNeg));
555 auto p2BuffBounds = std::make_shared<Trk::CylinderVolumeBounds>(
559 std::move(p2BuffPosTransform), p2BuffBounds, fingerProperties,
nullptr,
560 nullptr,
"Calo::GapVolumes::Tile::Plug2BufferPos");
563 std::move(p2BuffNegTransform),
564 std::shared_ptr<Trk::CylinderVolumeBounds>(p2BuffBounds->clone()),
565 fingerProperties,
nullptr,
566 nullptr,
"Calo::GapVolumes::Tile::Plug2BufferNeg");
570 std::vector<Trk::TrackingVolume*> volsPosP2;
571 volsPosP2.push_back(p2BufferPos);
572 volsPosP2.push_back(itcPlug2Pos);
573 positiveP2Sector = m_trackingVolumeCreator->createContainerTrackingVolume
576 "Calo::Container::PositiveP2");
580 std::vector<Trk::TrackingVolume*> volsNegP2;
581 volsNegP2.push_back(itcPlug2Neg);
582 volsNegP2.push_back(p2BufferNeg);
583 negativeP2Sector = m_trackingVolumeCreator->createContainerTrackingVolume
586 "Calo::Container::NegativeP2");
591 if (positiveGapSector && positiveP2Sector) {
592 std::vector<Trk::TrackingVolume*> volsITCPos;
593 volsITCPos.push_back(positiveGapSector);
594 volsITCPos.push_back(positiveP2Sector);
595 volsITCPos.push_back(itcPlug1Pos);
596 positiveITCSector = m_trackingVolumeCreator->createContainerTrackingVolume
599 "Calo::Container::ITCPos");
602 if (negativeGapSector && negativeP2Sector) {
603 std::vector<Trk::TrackingVolume*> volsITCNeg;
604 volsITCNeg.push_back(negativeGapSector);
605 volsITCNeg.push_back(negativeP2Sector);
606 volsITCNeg.push_back(itcPlug1Neg);
607 negativeITCSector = m_trackingVolumeCreator->createContainerTrackingVolume
610 "Calo::Container::ITCNeg");
621 double zFG = 0.5*(tileBarrelBounds->
halflengthZ()+p1i);
622 double hZ = 0.5*(p1i-tileBarrelBounds->
halflengthZ());
623 auto tileBarrelFingerGapBounds = std::make_shared<Trk::CylinderVolumeBounds>(rMin,rMax,hZ);
631 std::move(bfPosTransform), tileBarrelFingerGapBounds, barrelFingerGapProperties,
633 "Calo::GapVolumes::Tile::BarrelPositiveFingerGap");
636 std::move(bfNegTransform),
637 std::shared_ptr<Trk::CylinderVolumeBounds>(
638 tileBarrelFingerGapBounds->clone()),
639 barrelFingerGapProperties,
nullptr,
nullptr,
640 "Calo::GapVolumes::Tile::BarrelNegativeFingerGap");
644 double zBE = tilePositiveExtendedBarrel->
center().z()+tilePositiveExtendedBarrelBounds.
halflengthZ();
645 zFG = 0.5*(tileZ + zBE);
646 hZ = 0.5*(tileZ - zBE);
648 auto tilePositiveFingerGapBounds = std::make_shared<Trk::CylinderVolumeBounds>(
659 std::move(efPosTransform), tilePositiveFingerGapBounds, fingerGapProperties,
660 nullptr,
nullptr,
"Calo::GapVolumes::Tile::PositiveFingerGap");
663 std::move(efNegTransform),
664 std::shared_ptr<Trk::CylinderVolumeBounds>(tilePositiveFingerGapBounds->clone()),
665 fingerGapProperties,
nullptr,
nullptr,
"Calo::GapVolumes::Tile::NegativeFingerGap");
685 std::vector<Trk::TrackingVolume*> tileVols;
686 tileVols.push_back(tileNegativeFingerGap);
687 tileVols.push_back(tileNegativeExtendedBarrel);
688 tileVols.push_back(negativeITCSector);
689 tileVols.push_back(tileBarrelNegativeFingerGap);
690 tileVols.push_back(tileBarrel);
691 tileVols.push_back(tileBarrelPositiveFingerGap);
692 tileVols.push_back(positiveITCSector);
693 tileVols.push_back(tilePositiveExtendedBarrel);
694 tileVols.push_back(tilePositiveFingerGap);
695 Trk::TrackingVolume* tileCombinedSector = m_trackingVolumeCreator->createContainerTrackingVolume
698 "Calo::Container::Tile::InnerSector");
701 std::vector<Trk::TrackingVolume*> tileVolumes;
702 tileVolumes.push_back(tileCombinedSector);
703 tileVolumes.push_back(tileGirder);
707 "Calo::Container::Tile::Combined");
711 tileTrackingVolumes.push_back(
tile);
712 tileTrackingVolumes.push_back(tilePositiveExtendedBarrel);
714 if (msgLvl(MSG::INFO)) {
715 ATH_MSG_DEBUG(
"Checking the existence of all Tracking Volumes:" );
719 printCheckResult(
msg(
MSG::DEBUG), tilePositiveExtendedBarrel);
721 printCheckResult(
msg(
MSG::DEBUG), tileNegativeExtendedBarrel);
723 printCheckResult(
msg(
MSG::DEBUG), tileBarrelPositiveFingerGap);
725 printCheckResult(
msg(
MSG::DEBUG), tileBarrelNegativeFingerGap);
734 return tileTrackingVolumes;
744 const GeoLogVol* lv =
pv->getLogVol();
745 std::cout <<
"New Tile Object:" << lv->getName() <<
", made of"
746 << lv->getMaterial()->getName() <<
"," << lv->getShape()->type()
751 printChildren(
pv, igen, transf);
757 unsigned int nc =
pv->getNChildVols();
760 for (
unsigned int ic = 0;
ic <
nc;
ic++) {
763 const PVConstLink cv =
pv->getChildVol(
ic);
764 const GeoLogVol* clv = cv->getLogVol();
766 std::cout <<
"subcomponent:" << igen <<
":" <<
ic <<
":" << clv->getName()
767 <<
", made of" << clv->getMaterial()->getName() <<
","
768 << clv->getShape()->type() << std::endl;
769 std::cout <<
"position:" <<
"R:" << transf.translation().perp()
770 <<
",phi:" << transf.translation().phi()
771 <<
",x:" << transf.translation().x()
772 <<
",y:" << transf.translation().y()
773 <<
",z:" << transf.translation().z() << std::endl;
774 const GeoTrd* trd =
dynamic_cast<const GeoTrd*
>(clv->getShape());
776 std::cout <<
"trddim:" << trd->getXHalfLength1() <<
","
777 << trd->getXHalfLength2() <<
"," << trd->getYHalfLength1()
778 <<
"," << trd->getYHalfLength2() <<
"," << trd->getZHalfLength()
780 const GeoTubs* tub =
dynamic_cast<const GeoTubs*
>(clv->getShape());
782 std::cout <<
"tubdim:" << tub->getRMin() <<
"," << tub->getRMax() <<
","
783 << tub->getZHalfLength() << std::endl;
784 const GeoPcon* con =
dynamic_cast<const GeoPcon*
>(clv->getShape());
786 const unsigned int nPlanes = con->getNPlanes();
787 for (
unsigned int i = 0;
i < nPlanes;
i++) {
788 std::cout <<
"polycone:" <<
i <<
":" << con->getRMinPlane(
i) <<
","
789 << con->getRMaxPlane(
i) <<
"," << con->getZPlane(
i)
794 if (
ic == 0 || cname != clv->getName()) {
796 printChildren(cv, igen, transf);
797 cname = clv->getName();