189 std::vector<std::string> nodeNames =
p.getParameter<std::vector<std::string>>(
"NodeNames");
192 double tolerance =
p.getParameter<
double>(
"Tolerance") * CLHEP::mm;
193 int nPoints =
p.getParameter<
int>(
"Resolution");
194 bool verbose =
p.getParameter<
bool>(
"Verbose");
195 bool regionFlag =
p.getParameter<
bool>(
"RegionFlag");
196 bool gdmlFlag =
p.getParameter<
bool>(
"gdmlFlag");
197 int nPrints =
p.getParameter<
int>(
"ErrorThreshold");
199 const G4RegionStore* regStore = G4RegionStore::GetInstance();
202 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
203 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
204 unsigned int numPV =
pvs->size();
205 unsigned int numLV = lvs->size();
206 unsigned int nn = nodeNames.size();
208 std::vector<G4String> savedgdml;
210 fout <<
"=====================================================================" 212 fout <<
"CMSG4OverlapCheck is initialised with " << nodeNames.size() <<
" nodes; " 213 <<
" nPoints= " << nPoints <<
"; tolerance= " <<
tolerance / mm <<
" mm; verbose: " <<
verbose <<
"\n" 214 <<
" RegionFlag: " << regionFlag <<
" PVname: " <<
PVname <<
" LVname: " <<
LVname <<
"\n" 215 <<
" Nlv= " << numLV <<
" Npv= " << numPV <<
"\n";
216 fout <<
"=====================================================================" 219 G4GDMLParser* gdml =
nullptr;
221 gdml =
new G4GDMLParser();
222 gdml->SetRegionExport(
true);
223 gdml->SetEnergyCutsExport(
true);
224 gdml->SetSDExport(
true);
227 for (
unsigned int ii = 0;
ii <
nn; ++
ii) {
228 if (nodeNames[
ii].
empty() ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii]) {
229 nodeNames[
ii] = world->GetName();
230 fout <<
"### Check overlaps for World " 233 test.SetErrorsThreshold(nPrints);
234 test.TestOverlapInTree();
235 }
else if (regionFlag) {
236 fout <<
"---------------------------------------------------------------" 238 fout <<
"### Check overlaps for G4Region Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
239 G4Region* reg = regStore->GetRegion((G4String)nodeNames[
ii]);
241 fout <<
"### NO G4Region found - EXIT" 245 std::vector<G4LogicalVolume*>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
246 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
247 fout <<
" " << numRootLV <<
" Root Logical Volumes in this region" 250 for (
unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
253 fout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() <<
"\n";
254 for (
unsigned int i = 0;
i < numPV; ++
i) {
255 if (((*
pvs)[
i])->GetLogicalVolume() == lv) {
256 G4String pvname = ((*pvs)[
i])->GetName();
258 for (
unsigned int k = 0;
k < savedgdml.size(); ++
k) {
259 if (pvname == savedgdml[
k]) {
265 fout <<
"### Check overlaps for PhysVolume " << pvname <<
" is skipted because was already done" 269 savedgdml.push_back(pvname);
270 fout <<
"### Check overlaps for PhysVolume " << pvname <<
"\n";
273 gdml->Write(pvname +
".gdml", (*
pvs)[
i],
true);
276 test.SetErrorsThreshold(nPrints);
277 test.TestOverlapInTree();
282 fout <<
"### Check overlaps for PhysVolume Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
283 G4VPhysicalVolume*
pv =
pvs->GetVolume((G4String)nodeNames[
ii]);
285 test.SetErrorsThreshold(nPrints);
286 test.TestOverlapInTree();
291 fout <<
"----------- List of PhysVolumes by name -----------------" 293 for (
unsigned int i = 0;
i < numPV; ++
i) {
295 fout <<
" ##### PhysVolume " <<
PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
296 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
297 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
298 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName() <<
"\n";
299 fout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() <<
"\n";
300 fout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() <<
"\n";
302 gdml->Write(
PVname +
".gdml", (*
pvs)[
i],
true);
308 fout <<
"---------- List of Logical Volumes by name ------------------" 310 for (
unsigned int i = 0;
i < numLV; ++
i) {
311 if (
LVname == ((*lvs)[
i])->GetName()) {
312 G4int
np = ((*lvs)[
i])->GetNoDaughters();
313 fout <<
" ##### LogVolume " <<
LVname <<
" " <<
np <<
" daughters" 314 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName() <<
"\n";
315 fout << *(((*lvs)[
i])->GetSolid()) <<
"\n";
316 for (G4int
j = 0;
j <
np; ++
j) {
317 G4VPhysicalVolume*
pv = ((*lvs)[
i])->GetDaughter(
j);
319 fout <<
" PV: " <<
pv->GetName() <<
" [" <<
pv->GetCopyNo() <<
"]" 320 <<
" type: " <<
pv->VolumeType() <<
" multiplicity: " <<
pv->GetMultiplicity()
321 <<
" LV: " <<
pv->GetLogicalVolume()->GetName() <<
"\n";
322 fout <<
" Translation: " <<
pv->GetObjectTranslation() <<
"\n";
323 fout <<
" Rotation: " <<
pv->GetObjectRotationValue() <<
"\n";
324 fout << *(
pv->GetLogicalVolume()->GetSolid()) <<
"\n";
330 fout <<
"---------------- End of overlap checks ---------------------"