42{
43 PVConstLink theGeoPhysChild;
44 const GeoSerialTransformer* serialTransformerChild{nullptr};
45 G4LogicalVolume* theG4LogChild{nullptr};
46 unsigned int numChildNodes;
48 bool serialExists = false;
49 std::string nameChild;
50
52
53 static Geo2G4LVFactory LVFactory;
54
55 G4LogicalVolume* theG4LogVolume = LVFactory.Build(theGeoPhysVolume,
descend);
56
57 if(!
descend)
return theG4LogVolume;
58
59 numChildNodes = theGeoPhysVolume->getNChildVolAndST();
60
61
62
63
64
65
66
67
69 for(size_t counter1=0; counter1<numChildNodes; counter1++)
70 {
71 GeoAccessVolAndSTAction actionVolAndST(counter1);
72 theGeoPhysVolume->exec(&actionVolAndST);
73
74 if((serialTransformerChild=actionVolAndST.getSerialTransformer()))
75 {
76 nameChild = actionVolAndST.getName();
77 serialExists = true;
78 break;
79 }
80 }
81
82
83
84
85
86
87
88
89
90
91
92
93 if(serialExists && (numChildNodes==1))
94 {
95 theGeoPhysChild = serialTransformerChild->getVolume();
96
97
98 if(!(theG4LogChild =
Build(theGeoPhysChild,optical_volumes)))
return nullptr;
99
100 if (nameChild == "ANON") nameChild=theG4LogChild->GetName();
101 nameChild += "_Param";
102
103 Geo2G4STParameterisation* stParameterisation = new Geo2G4STParameterisation(serialTransformerChild->getFunction(),
104 serialTransformerChild->getNCopies());
105
106 [[maybe_unused]] G4VPhysicalVolume* pvParametrised = new G4PVParameterised(nameChild,
107 theG4LogChild,
108 theG4LogVolume,
109 kUndefined,
110 serialTransformerChild->getNCopies(),
111 stParameterisation);
112 }
113 else
114 {
115 if(serialExists)
116 {
117 std::string volName = theGeoPhysVolume->getLogVol()->getName();
119 }
120
121 GeoVolumeCursor av(theGeoPhysVolume);
122 while (!av.atEnd())
123 {
124 int id = 16969;
125
126
127 theGeoPhysChild = av.getVolume();
128
130
131 std::optional<int> Qint = av.getId();
132 if(Qint) id = *Qint;
133
134 bool isEther = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::Ether")==0;
135 bool isHypUr = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::HyperUranium")==0;
136
137 if(isEther) {
138 Geo2G4AssemblyVolume* assembly =
BuildAssembly(theGeoPhysChild);
139
140 if(Qint) {
141 assembly->
MakeImprint(theG4LogVolume,theG4Position,
id);
142 }
143 else {
144 assembly->
MakeImprint(theG4LogVolume,theG4Position);
145 }
146 }
147 else if(isHypUr) {
148 Geo2G4AssemblyVolume* assembly =
BuildAssembly(theGeoPhysChild);
149
150 if(Qint) {
151 assembly->
MakeImprint(theG4LogVolume,theG4Position,
id,
true);
152 }
153 else {
154 assembly->
MakeImprint(theG4LogVolume,theG4Position,0,
true);
155 }
156 }
157 else {
158 nameChild = av.getName();
159
160
161 if(!(theG4LogChild =
Build(theGeoPhysChild,optical_volumes)))
return nullptr;
162
163 if (nameChild == "ANON") nameChild=theG4LogChild->GetName();
164
165 G4PhysicalVolumesPair pvPair = G4ReflectionFactory::Instance()->Place(theG4Position
166 , nameChild
167 , theG4LogChild
168 , theG4LogVolume
169 , false
170 , id);
171
172
173 if(optical_volumes!=0) {
174 const GeoOpticalPhysVol* opticalGeoPhysChild =
175 dynamic_cast < const GeoOpticalPhysVol* >(theGeoPhysChild.operator->());
176 if(opticalGeoPhysChild)
177 (*optical_volumes)[opticalGeoPhysChild] = pvPair.first;
178 }
179 }
180
181 av.next();
182 }
183 }
184
185 return theG4LogVolume;
186}
void descend(TDirectory *d, int level, int maxdepth, const std::vector< std::string > &labels)
void PrintSTInfo(const std::string &volume) const
Prints info when some PhysVol contains both types (PV and ST) of daughters.
virtual G4LogicalVolume * Build(PVConstLink pv, OpticalVolumesMap *optical_volumes=0) override
Geo2G4AssemblyVolume * BuildAssembly(const PVConstLink &pv)
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.