8#include "GeoModelKernel/GeoVDetectorManager.h"
9#include "GeoModelKernel/GeoShapeUnion.h"
10#include "GeoModelKernel/GeoShapeShift.h"
11#include "GeoModelKernel/GeoMaterial.h"
12#include "GeoModelKernel/GeoLogVol.h"
13#include "GeoModelKernel/GeoPhysVol.h"
14#include "GeoModelKernel/GeoTransform.h"
23#include "G4ReflectionFactory.hh"
24#include "G4LogicalBorderSurface.hh"
25#include "G4OpticalSurface.hh"
26#include "GeoModelKernel/throwExcept.h"
38 THROW_EXCEPTION(
"ERROR: Geo2G4Builder for detector "<< detectorName <<
" could not access the detector store.");
43 THROW_EXCEPTION(detectorName<<
" could not get GeoModelExperiment");
46 const GeoVDetectorManager *theManager = m_theExpt->getManager(detectorName);
48 THROW_EXCEPTION(
"Failed to retrieve manager "<<detectorName);
50 for(
unsigned int i=0; i<theManager->getNumTreeTops(); ++i) {
51 m_treeTops.push_back(theManager->getTreeTop(i));
55 for(
unsigned int i=0; i<
m_treeTops.size();++i) {
62 if(theMaterialManager) {
70 if (
m_g2gSvc.retrieve().isFailure()) {
79 <<
"\n Use 'DefaultBuilder' property of Geo2G4Svc or"
80 <<
"\n 'GetVolumeBuilder' method of Geo2G4Builder");
87 G4LogicalVolume*
result =
nullptr;
94 if(
sc.isSuccess() && surface_container->size()>0) {
108 const GeoShape* shResult = &shFirst;
110 for(
unsigned int i=1; i<
m_treeTops.size(); i++) {
111 shResult = & shResult->add((*(
m_treeTops[i]->getLogVol()->getShape()))<<(
m_treeTops[i]->getX()));
115 GeoPhysVol* pvEnvelope =
new GeoPhysVol(lvEnvelope);
120 PVConstLink world =
m_treeTops[0]->getParent();
123 for(
unsigned int i=0; i<
m_treeTops.size(); i++) {
126 std::optional<unsigned int> childIndx = world->indexOf(pv);
133 std::optional<int> Qint = world->getIdOfChildVol(*childIndx);
137 std::string nameTT = world->getNameOfChildVol(*childIndx);
138 if (nameTT ==
"ANON") nameTT = pv->getLogVol()->getName();
141 G4LogicalVolume* g4LV =
m_theBuilder->Build(pv,optical_volumes);
142 G4ReflectionFactory::Instance()->Place(theG4Position,
153 if(optical_volumes) {
154 if(optical_volumes->size()>0) {
158 ATH_MSG_WARNING(
"Optical volumes apparently requested, but none found! Deleting temps");
160 delete optical_volumes;
181 G4OpticalSurface* g4OptSurface = surfaceFactory.
Build(border_surface.getOptSurface());
183 G4VPhysicalVolume* g4PV1 = 0;
184 G4VPhysicalVolume* g4PV2 = 0;
185 OpticalVolumesMap::const_iterator volIt;
188 volIt = optical_volumes->find(border_surface.getPV1());
189 if(volIt == optical_volumes->end())
191 ATH_MSG_WARNING(
"Unable to find " << border_surface.getPV1()->getLogVol()->getName() <<
" in Optical Volumes map");
194 g4PV1 = volIt.operator->()->second;
197 volIt = optical_volumes->find(border_surface.getPV2());
198 if(volIt == optical_volumes->end())
200 ATH_MSG_WARNING(
"Unable to find " << border_surface.getPV2()->getLogVol()->getName() <<
" in Optical Volumes map");
203 g4PV2 = volIt.operator->()->second;
206 G4LogicalBorderSurface* g4BorderSurface
__attribute__((
unused)) =
new G4LogicalBorderSurface(border_surface.getName(),g4PV1,g4PV2,g4OptSurface);
#define ATH_MSG_WARNING(x)
Eigen::Affine3d Transform3D
std::vector< GeoBorderSurface > GeoBorderSurfaceContainer
std::map< const GeoOpticalPhysVol *, G4VPhysicalVolume *, std::less< const GeoOpticalPhysVol * > > OpticalVolumesMap
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
GeoModelExperiment * m_theExpt
std::vector< PVConstLink > m_treeTops
VolumeBuilder * GetVolumeBuilder(std::string)
const GeoMaterial * m_matAir
Geo2G4Builder(const std::string &detectorName)
void BuildOpticalSurfaces(const GeoBorderSurfaceContainer *surface_container, const OpticalVolumesMap *optical_volumes)
G4LogicalVolume * BuildTree()
std::string m_detectorName
ServiceHandle< IGeo2G4Svc > m_g2gSvc
ServiceHandle< StoreGateSvc > m_pDetStore
VolumeBuilder * m_theBuilder
GeoTrf::Transform3D m_motherTransform
G4OpticalSurface * Build(const GeoOpticalSurface *)
This class holds one or more material managers and makes them storeable, under StoreGate.
virtual const GeoMaterial * getMaterial(const std::string &name)=0
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
#define THROW_EXCEPTION(MESSAGE)