173 std::vector<std::string> nodeNames = p.
getParameter<std::vector<std::string>>(
"NodeNames");
183 const G4RegionStore* regStore = G4RegionStore::GetInstance();
186 const G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance();
187 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
188 unsigned int numPV = pvs->size();
189 unsigned int numLV = lvs->size();
190 unsigned int nn = nodeNames.size();
192 std::vector<G4String> savedgdml;
194 fout <<
"====================================================================="
196 fout <<
"CMSG4OverlapCheck is initialised with " << nodeNames.size() <<
" nodes; "
197 <<
" nPoints= " << nPoints <<
"; tolerance= " << tolerance / mm <<
" mm; verbose: " << verbose <<
"\n"
198 <<
" RegionFlag: " << regionFlag <<
" PVname: " << PVname <<
" LVname: " << LVname <<
"\n"
199 <<
" Nlv= " << numLV <<
" Npv= " << numPV <<
"\n";
200 fout <<
"====================================================================="
204 for (
unsigned int ii = 0;
ii <
nn; ++
ii) {
205 if (nodeNames[
ii].
empty() ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii]) {
206 nodeNames[
ii] =
"DDDWorld";
207 fout <<
"### Check overlaps for DDDWorld "
209 G4VPhysicalVolume*
pv = pvs->GetVolume(
"DDDWorld");
210 G4GeomTestVolume
test(pv, tolerance, nPoints, verbose);
211 test.SetErrorsThreshold(nPrints);
212 test.TestOverlapInTree();
213 }
else if (regionFlag) {
214 fout <<
"---------------------------------------------------------------"
216 fout <<
"### Check overlaps for G4Region Node[" << ii <<
"] : " << nodeNames[
ii] <<
"\n";
217 G4Region* reg = regStore->GetRegion((G4String)nodeNames[ii]);
219 fout <<
"### NO G4Region found - EXIT"
223 std::vector<G4LogicalVolume*>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
224 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
225 fout <<
" " << numRootLV <<
" Root Logical Volumes in this region"
228 for (
unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
231 fout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() <<
"\n";
232 for (
unsigned int i = 0;
i < numPV; ++
i) {
233 if (((*pvs)[
i])->GetLogicalVolume() == lv) {
234 G4String pvname = ((*pvs)[
i])->GetName();
236 for (
unsigned int k = 0;
k < savedgdml.size(); ++
k) {
237 if (pvname == savedgdml[
k]) {
243 fout <<
"### Check overlaps for PhysVolume " << pvname <<
" is skipted because was already done"
247 savedgdml.push_back(pvname);
248 fout <<
"### Check overlaps for PhysVolume " << pvname <<
"\n";
252 gdml.Write(pvname +
".gdml", (*pvs)[i],
true);
254 G4GeomTestVolume
test(((*pvs)[i]), tolerance, nPoints, verbose);
255 test.SetErrorsThreshold(nPrints);
256 test.TestOverlapInTree();
261 fout <<
"### Check overlaps for PhysVolume Node[" << ii <<
"] : " << nodeNames[
ii] <<
"\n";
262 G4VPhysicalVolume* pv = pvs->GetVolume((G4String)nodeNames[ii]);
263 G4GeomTestVolume
test(pv, tolerance, nPoints, verbose);
264 test.SetErrorsThreshold(nPrints);
265 test.TestOverlapInTree();
269 if (!PVname.empty()) {
270 fout <<
"----------- List of PhysVolumes by name -----------------"
272 for (
unsigned int i = 0; i < numPV; ++
i) {
273 if (PVname == ((*pvs)[i])->GetName()) {
274 fout <<
" ##### PhysVolume " << PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
275 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
276 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
277 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName() <<
"\n";
278 fout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() <<
"\n";
279 fout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() <<
"\n";
282 gdml.Write(PVname +
".gdml", (*pvs)[i],
true);
287 if (!LVname.empty()) {
288 fout <<
"---------- List of Logical Volumes by name ------------------"
290 for (
unsigned int i = 0; i < numLV; ++
i) {
291 if (LVname == ((*lvs)[i])->GetName()) {
292 G4int
np = ((*lvs)[
i])->GetNoDaughters();
293 fout <<
" ##### LogVolume " << LVname <<
" " << np <<
" daughters"
294 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName() <<
"\n";
295 fout << *(((*lvs)[
i])->GetSolid()) <<
"\n";
296 for (G4int
j = 0;
j <
np; ++
j) {
297 G4VPhysicalVolume* pv = ((*lvs)[
i])->GetDaughter(
j);
299 fout <<
" PV: " << pv->GetName() <<
" [" << pv->GetCopyNo() <<
"]"
300 <<
" type: " << pv->VolumeType() <<
" multiplicity: " << pv->GetMultiplicity()
301 <<
" LV: " << pv->GetLogicalVolume()->GetName() <<
"\n";
302 fout <<
" Translation: " << pv->GetObjectTranslation() <<
"\n";
303 fout <<
" Rotation: " << pv->GetObjectRotationValue() <<
"\n";
304 fout << *(pv->GetLogicalVolume()->GetSolid()) <<
"\n";
310 fout <<
"---------------- End of overlap checks ---------------------"
static constexpr int verbose
T getParameter(std::string const &) const