9 #include "G4LogicalVolume.hh"
11 #include "G4PVPlacement.hh"
12 #include "G4ReflectionFactory.hh"
13 #include "G4VPVParameterisation.hh"
14 #include "G4PVParameterised.hh"
19 #include "GeoModelKernel/GeoAccessVolAndSTAction.h"
20 #include "GeoModelKernel/GeoVolumeCursor.h"
21 #include "GeoModelKernel/GeoMaterial.h"
22 #include "GeoModelKernel/GeoLogVol.h"
23 #include "GeoModelKernel/GeoSerialTransformer.h"
37 m_G4AssemblyFactory(G4AssemblyFactory)
43 PVConstLink theGeoPhysChild;
44 const GeoSerialTransformer* serialTransformerChild{
nullptr};
45 G4LogicalVolume* theG4LogChild{
nullptr};
46 unsigned int numChildNodes;
48 bool serialExists =
false;
49 std::string nameChild;
55 G4LogicalVolume* theG4LogVolume = LVFactory.Build(theGeoPhysVolume,
descend);
57 if(!
descend)
return theG4LogVolume;
59 numChildNodes = theGeoPhysVolume->getNChildVolAndST();
69 for(
size_t counter1=0; counter1<numChildNodes; counter1++)
71 GeoAccessVolAndSTAction actionVolAndST(counter1);
72 theGeoPhysVolume->exec(&actionVolAndST);
74 if((serialTransformerChild=actionVolAndST.getSerialTransformer()))
76 nameChild = actionVolAndST.getName();
93 if(serialExists && (numChildNodes==1))
95 theGeoPhysChild = serialTransformerChild->getVolume();
98 if(!(theG4LogChild =
Build(theGeoPhysChild,optical_volumes)))
return nullptr;
100 if (nameChild ==
"ANON") nameChild=theG4LogChild->GetName();
101 nameChild +=
"_Param";
104 serialTransformerChild->getNCopies());
106 [[maybe_unused]] G4VPhysicalVolume* pvParametrised =
new G4PVParameterised(nameChild,
110 serialTransformerChild->getNCopies(),
117 std::string volName = theGeoPhysVolume->getLogVol()->getName();
121 GeoVolumeCursor av(theGeoPhysVolume);
127 theGeoPhysChild = av.getVolume();
131 Query<int> Qint = av.getId();
132 if(Qint.isValid())
id = Qint;
134 bool isEther = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare(
"special::Ether")==0;
135 bool isHypUr = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare(
"special::HyperUranium")==0;
141 assembly->
MakeImprint(theG4LogVolume,theG4Position,
id);
144 assembly->
MakeImprint(theG4LogVolume,theG4Position);
151 assembly->
MakeImprint(theG4LogVolume,theG4Position,
id,
true);
154 assembly->
MakeImprint(theG4LogVolume,theG4Position,0,
true);
158 nameChild = av.getName();
161 if(!(theG4LogChild =
Build(theGeoPhysChild,optical_volumes)))
return nullptr;
163 if (nameChild ==
"ANON") nameChild=theG4LogChild->GetName();
165 G4PhysicalVolumesPair pvPair = G4ReflectionFactory::Instance()->Place(theG4Position
173 if(optical_volumes!=0) {
176 if(opticalGeoPhysChild)
177 (*optical_volumes)[opticalGeoPhysChild] = pvPair.first;
185 return theG4LogVolume;
190 PVConstLink theGeoPhysChild;
191 G4LogicalVolume* theG4LogChild{
nullptr};
199 if(!
descend)
return assemblyVolume;
202 GeoVolumeCursor av(
pv);
205 theGeoPhysChild = av.getVolume();
206 std::string nameChild = av.getName();
208 std::string strVolume = std::string(
"Volume ") + nameChild +
" ("
209 + theGeoPhysChild->getLogVol()->getName() +
")";
212 bool isEther = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare(
"special::Ether")==0;
213 bool isHypUr = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare(
"special::HyperUranium")==0;
215 if(isEther || isHypUr) {
217 if(!(theG4AssemblyChild =
BuildAssembly(theGeoPhysChild)))
return nullptr;
225 Query<int> Qint = av.getId();
228 if(!(theG4LogChild =
Build(theGeoPhysChild)))
return nullptr;
234 if(Qint.isValid()) placedID = Qint;
236 std::string placedName = nameChild==
"ANON" ?
"" : nameChild;
238 assemblyVolume->
AddPlacedVolume(theG4LogChild,theG4Position,placedID,placedName);
244 return assemblyVolume;
249 ATH_MSG_INFO (
"**********************************************" );
252 ATH_MSG_INFO (
"** Has children of two different types" );
253 ATH_MSG_INFO (
"** PeoPhysVolume and GeoSerialTransformer" );
254 ATH_MSG_INFO (
"** In this case GeoSerialTransformer will be " );
255 ATH_MSG_INFO (
"** translated into G4 placement but not in " );
258 ATH_MSG_INFO (
"********************************************** " );
263 SmartIF<IService> smartDetStore = Gaudi::svcLocator()->service(
"DetectorStore");
266 ATH_MSG_ERROR (
"ExtParameterisedVolumeBuilder: Unable to access Detector Store" );
270 if (theMaterialManager) {