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;
128 std::vector<Trk::TrackingVolume*>*
132 std::vector<Trk::TrackingVolume*>* tileTrackingVolumes =
new 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;
165 std::unique_ptr<Trk::CylinderVolumeBounds> tileBarrelGirderBounds;
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_unique<Trk::Material>(22.7, 212., 45.8, 21.4, 0.0062);
183 auto extendedBarrelProperties = std::make_unique<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.get(),0);
199 matTB.emplace_back(barrelProperties.get(),baseID);
200 matTB.emplace_back(barrelProperties.get(),baseID+1);
201 matTB.emplace_back(barrelProperties.get(),baseID+2);
204 std::vector<size_t> ltb{0,1,2,3};
207 std::vector<Trk::IdentifiedMaterial> matETB;
209 matETB.emplace_back(extendedBarrelProperties.get(),0);
210 matETB.emplace_back(extendedBarrelProperties.get(),baseID);
211 matETB.emplace_back(extendedBarrelProperties.get(),baseID+1);
212 matETB.emplace_back(extendedBarrelProperties.get(),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 ){
276 tileBarrelGirderBounds = make_unique<Trk::CylinderVolumeBounds>(
depth,childCylVolBounds->
outerRadius(),childCylVolBounds->
halflengthZ());
281 std::vector<float>
steps;
293 barrelMaterialBinned,
295 "Calo::Detectors::Tile::Barrel");
301 std::string volumeName;
302 std::string girderName;
303 std::vector<double> girderLayerRadius;
304 std::vector<double> layerRadius;
305 std::vector<double> layerEnvelope;
307 bool tileExtendedBoundsUsed =
false;
308 std::unique_ptr<Trk::CylinderVolumeBounds> gapVolBounds;
312 volumeName = childZposition > 0. ?
313 "Calo::Detectors::Tile::PositiveExtendedBarrel" :
"Calo::Detectors::Tile::NegativeExtendedBarrel";
318 }
else if (childCylVolBounds->
halflengthZ() > 100.){
322 }
else if ( childLogVol->getName()==
"Gap" && !gapBounds ) {
324 gapVolBounds = make_unique<Trk::CylinderVolumeBounds>(childCylVolBounds->
innerRadius(),childCylVolBounds->
outerRadius(),
327 gapZ = fabs(childZposition);
339 if(m_useCaloSurfBuilder && childCylVolBounds->
halflengthZ() > 1000.){
345 std::vector<float>
steps;
353 extendedMaterialBinned =
new Trk::BinnedMaterial(extendedBarrelProperties.get(),eBU,ltb,matETB);
358 extendedMaterialBinned,
361 tileExtendedBoundsUsed =
true;
364 if ( gapVolBounds ) {
365 gapBounds = gapVolBounds.release();
367 }
else if (tileExtendedBounds) {
370 std::vector<float>
steps;
378 extendedMaterialBinned =
new Trk::BinnedMaterial(extendedBarrelProperties.get(),eBU,ltb,matETB);
383 extendedMaterialBinned,
386 tileExtendedBoundsUsed =
true;
391 if (childZposition > 0.) {
392 tilePositiveExtendedBarrel = tileExtendedTrackingVolume;
393 tilePositiveExtendedBarrelBounds = *tileExtendedBounds;
396 tileNegativeExtendedBarrel = tileExtendedTrackingVolume;
398 }
else if (childCylVolBounds->
halflengthZ() > 100.) {
399 tileZ = fabs(childZposition)+childCylVolBounds->
halflengthZ();
401 if (!tileExtendedBoundsUsed)
402 delete tileExtendedBounds;
406 delete childCylVolBounds;
410 if (!gapBounds) std::abort();
411 if (!tileBarrelGirderBounds) std::abort();
412 if (!tilePositiveExtendedBarrel) std::abort();
413 if (!tileNegativeExtendedBarrel) std::abort();
415 ATH_MSG_DEBUG(
"TileDetDescrManager parsed successfully! " );
419 auto tileGirderBounds = std::make_unique<Trk::CylinderVolumeBounds>
425 tileGirderBounds.release(),
427 dummyLayers, dummyVolumes,
428 "Calo::Girder::TileCombined");
432 double tileExtZ = tilePositiveExtendedBarrel->
center().z()-tilePositiveExtendedBarrelBounds.
halflengthZ();
435 std::vector<Trk::IdentifiedMaterial> matITC;
438 matITC.emplace_back(barrelProperties.get(),baseID+15);
439 matITC.emplace_back(barrelProperties.get(),baseID+16);
440 matITC.emplace_back(barrelProperties.get(),baseID+17);
443 double p1Z = 0.5*(plug1Z-plug1hZ+tileExtZ);
444 double hp1Z = 0.5*(tileExtZ-plug1Z+plug1hZ);
455 std::vector<size_t> dummylay(1,1);
468 "Calo::Detectors::Tile::ITCPlug1Pos");
471 itcPlug1Bounds->
clone(),
474 "Calo::Detectors::Tile::ITCPlug1Neg");
479 double p2Z = 0.5*(plug2Z-plug2hZ+tileExtZ);
480 double hp2Z = 0.5*(tileExtZ-plug2Z+plug2hZ);
490 std::vector<size_t> p2lay(1,0);
491 std::vector<float> p2steps{
float(plug2R),
float(plug1R)};
501 "Calo::Detectors::Tile::ITCPlug2Pos");
504 itcPlug2Bounds->
clone(),
507 "Calo::Detectors::Tile::ITCPlug2Neg");
512 float gapi = 0.5*(gapZ-gapBounds->
halflengthZ()+tileExtZ);
513 double hgZ = 0.5*(tileExtZ-gapZ+gapBounds->
halflengthZ());
524 std::vector<size_t> glay(1,2);
533 "Calo::Detectors::Tile::GapPos");
543 "Calo::Detectors::Tile::GapNeg");
549 float zgBuff = 0.5*(p1i+
gi);
550 float hgBuff = 0.5*(
gi-p1i);
564 dummyLayers, dummyVolumes,
565 "Calo::GapVolumes::Tile::GapBufferPos");
569 gapBuffBounds->
clone(),
571 dummyLayers, dummyVolumes,
572 "Calo::GapVolumes::Tile::GapBufferNeg");
576 std::vector<Trk::TrackingVolume*> volsPosGap;
577 volsPosGap.push_back(gBufferPos);
578 volsPosGap.push_back(gapPos);
579 positiveGapSector = m_trackingVolumeCreator->createContainerTrackingVolume
582 "Calo::Container::PositiveGap");
586 std::vector<Trk::TrackingVolume*> volsNegGap;
587 volsNegGap.push_back(gapNeg);
588 volsNegGap.push_back(gBufferNeg);
589 negativeGapSector = m_trackingVolumeCreator->createContainerTrackingVolume
592 "Calo::Container::NegativeGap");
596 float z2Buff = 0.5*(p1i+p2i);
597 float h2Buff = 0.5*(p2i-p1i);
611 dummyLayers, dummyVolumes,
612 "Calo::GapVolumes::Tile::Plug2BufferPos");
616 p2BuffBounds->
clone(),
618 dummyLayers, dummyVolumes,
619 "Calo::GapVolumes::Tile::Plug2BufferNeg");
623 std::vector<Trk::TrackingVolume*> volsPosP2;
624 volsPosP2.push_back(p2BufferPos);
625 volsPosP2.push_back(itcPlug2Pos);
626 positiveP2Sector = m_trackingVolumeCreator->createContainerTrackingVolume
629 "Calo::Container::PositiveP2");
633 std::vector<Trk::TrackingVolume*> volsNegP2;
634 volsNegP2.push_back(itcPlug2Neg);
635 volsNegP2.push_back(p2BufferNeg);
636 negativeP2Sector = m_trackingVolumeCreator->createContainerTrackingVolume
639 "Calo::Container::NegativeP2");
644 if (positiveGapSector && positiveP2Sector) {
645 std::vector<Trk::TrackingVolume*> volsITCPos;
646 volsITCPos.push_back(positiveGapSector);
647 volsITCPos.push_back(positiveP2Sector);
648 volsITCPos.push_back(itcPlug1Pos);
649 positiveITCSector = m_trackingVolumeCreator->createContainerTrackingVolume
652 "Calo::Container::ITCPos");
655 if (negativeGapSector && negativeP2Sector) {
656 std::vector<Trk::TrackingVolume*> volsITCNeg;
657 volsITCNeg.push_back(negativeGapSector);
658 volsITCNeg.push_back(negativeP2Sector);
659 volsITCNeg.push_back(itcPlug1Neg);
660 negativeITCSector = m_trackingVolumeCreator->createContainerTrackingVolume
663 "Calo::Container::ITCNeg");
674 double zFG = 0.5*(tileBarrelBounds->
halflengthZ()+p1i);
675 double hZ = 0.5*(p1i-tileBarrelBounds->
halflengthZ());
684 tileBarrelFingerGapBounds,
685 barrelFingerGapProperties,
686 dummyLayers, dummyVolumes,
687 "Calo::GapVolumes::Tile::BarrelPositiveFingerGap");
690 tileBarrelFingerGapBounds->
clone(),
691 barrelFingerGapProperties,
692 dummyLayers, dummyVolumes,
693 "Calo::GapVolumes::Tile::BarrelNegativeFingerGap");
698 double zBE = tilePositiveExtendedBarrel->
center().z()+tilePositiveExtendedBarrelBounds.
halflengthZ();
699 zFG = 0.5*(tileZ + zBE);
700 hZ = 0.5*(tileZ - zBE);
713 tilePositiveFingerGapBounds,
715 dummyLayers, dummyVolumes,
716 "Calo::GapVolumes::Tile::PositiveFingerGap");
719 tilePositiveFingerGapBounds->
clone(),
721 dummyLayers, dummyVolumes,
722 "Calo::GapVolumes::Tile::NegativeFingerGap");
743 std::vector<Trk::TrackingVolume*> tileVols;
744 tileVols.push_back(tileNegativeFingerGap);
745 tileVols.push_back(tileNegativeExtendedBarrel);
746 tileVols.push_back(negativeITCSector);
747 tileVols.push_back(tileBarrelNegativeFingerGap);
748 tileVols.push_back(tileBarrel);
749 tileVols.push_back(tileBarrelPositiveFingerGap);
750 tileVols.push_back(positiveITCSector);
751 tileVols.push_back(tilePositiveExtendedBarrel);
752 tileVols.push_back(tilePositiveFingerGap);
753 Trk::TrackingVolume* tileCombinedSector = m_trackingVolumeCreator->createContainerTrackingVolume
756 "Calo::Container::Tile::InnerSector");
759 std::vector<Trk::TrackingVolume*> tileVolumes;
760 tileVolumes.push_back(tileCombinedSector);
761 tileVolumes.push_back(tileGirder);
765 "Calo::Container::Tile::Combined");
769 tileTrackingVolumes->push_back(
tile);
770 tileTrackingVolumes->push_back(tilePositiveExtendedBarrel);
772 if (msgLvl(MSG::INFO)) {
773 ATH_MSG_DEBUG(
"Checking the existence of all Tracking Volumes:" );
777 printCheckResult(
msg(
MSG::DEBUG), tilePositiveExtendedBarrel);
779 printCheckResult(
msg(
MSG::DEBUG), tileNegativeExtendedBarrel);
781 printCheckResult(
msg(
MSG::DEBUG), tileBarrelPositiveFingerGap);
783 printCheckResult(
msg(
MSG::DEBUG), tileBarrelNegativeFingerGap);
792 throwIntoGarbage (std::move (barrelProperties));
793 throwIntoGarbage (std::move (extendedBarrelProperties));
795 return tileTrackingVolumes;
808 const GeoLogVol* lv =
pv->getLogVol();
809 std::cout <<
"New Tile Object:"<<lv->getName()<<
", made of"<<lv->getMaterial()->getName()<<
","<<lv->getShape()->type()<<std::endl;
813 printChildren(
pv,igen,transf);
819 unsigned int nc =
pv->getNChildVols();
822 for (
unsigned int ic=0;
ic<
nc;
ic++) {
831 const PVConstLink cv =
pv->getChildVol(
ic);
832 const GeoLogVol* clv = cv->getLogVol();
834 std::cout <<
"subcomponent:"<<igen<<
":"<<
ic<<
":"<<clv->getName()<<
", made of"<<clv->getMaterial()->getName()<<
","<<clv->getShape()->type()
836 std::cout <<
"position:"<<
"R:"<<transf.translation().perp()<<
",phi:"<< transf.translation().phi()<<
",x:"<<transf.translation().x()<<
",y:"<<transf.translation().y()<<
",z:"<<transf.translation().z()<<std::endl;
837 const GeoTrd* trd=
dynamic_cast<const GeoTrd*
> (clv->getShape());
838 if (trd) std::cout<<
"trddim:"<< trd->getXHalfLength1()<<
","<<trd->getXHalfLength2()<<
","<<trd->getYHalfLength1()<<
","<<trd->getYHalfLength2()<<
","<<trd->getZHalfLength()<< std::endl;
839 const GeoTubs* tub=
dynamic_cast<const GeoTubs*
> (clv->getShape());
840 if (tub) std::cout<<
"tubdim:"<< tub->getRMin()<<
","<<tub->getRMax()<<
","<<tub->getZHalfLength()<< std::endl;
841 const GeoPcon* con=
dynamic_cast<const GeoPcon*
> (clv->getShape());
843 const unsigned int nPlanes=con->getNPlanes();
844 for (
unsigned int i=0;
i<nPlanes;
i++) {
845 std::cout<<
"polycone:"<<
i<<
":"<< con->getRMinPlane(
i)<<
","<<con->getRMaxPlane(
i)<<
","<<con->getZPlane(
i)<< std::endl;
849 if (
ic==0 || cname != clv->getName() ) {
851 printChildren(cv,igen,transf);
852 cname = clv->getName();
861 std::scoped_lock lock (m_garbageMutex);
862 m_garbage.push_back (std::move (
mat));