19 std::vector<std::string> nodeNames =
p.getParameter<std::vector<std::string>>(
"NodeNames");
22 double tolerance =
p.getUntrackedParameter<
double>(
"Tolerance", 0.0) * CLHEP::mm;
23 int nPoints =
p.getUntrackedParameter<
int>(
"Resolution", 10000);
24 bool verbose =
p.getUntrackedParameter<
bool>(
"Verbose",
true);
25 bool regionFlag =
p.getUntrackedParameter<
bool>(
"RegionFlag",
true);
26 bool gdmlFlag =
p.getUntrackedParameter<
bool>(
"gdmlFlag",
false);
27 int nPrints =
p.getUntrackedParameter<
int>(
"ErrorThreshold", 1);
28 int level =
p.getUntrackedParameter<
int>(
"Level", 0);
29 int depth =
p.getUntrackedParameter<
int>(
"Depth", -1);
31 const G4RegionStore *regStore = G4RegionStore::GetInstance();
34 const G4PhysicalVolumeStore *pvs = G4PhysicalVolumeStore::GetInstance();
35 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
36 unsigned int numPV = pvs->size();
37 unsigned int numLV = lvs->size();
38 unsigned int nn = nodeNames.size();
40 std::vector<G4String> savedgdml;
42 G4cout <<
"G4OverlapCheck is initialised with " << nodeNames.size() <<
" nodes; " 43 <<
" nPoints= " << nPoints <<
"; tolerance= " <<
tolerance / mm <<
" mm; verbose: " <<
verbose <<
"\n" 44 <<
" RegionFlag: " << regionFlag <<
" PVname: " <<
PVname <<
" LVname: " <<
LVname <<
"\n" 45 <<
" Nlv= " << numLV <<
" Npv= " << numPV << G4endl;
48 for (
unsigned int ii = 0;
ii <
nn; ++
ii) {
49 if (nodeNames[
ii].
empty() ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii]) {
50 nodeNames[
ii] =
"DDDWorld";
51 G4cout <<
"### Check overlaps for DDDWorld " << G4endl;
52 G4VPhysicalVolume *
pv = pvs->GetVolume(
"DDDWorld");
54 test.SetErrorsThreshold(nPrints);
56 }
else if (regionFlag) {
57 G4cout <<
"---------------------------------------------------------------" << G4endl;
58 G4cout <<
"### Check overlaps for G4Region Node[" << ii <<
"] : " << nodeNames[
ii] << G4endl;
59 G4Region *reg = regStore->GetRegion((G4String)nodeNames[ii]);
61 G4cout <<
"### NO G4Region found - EXIT" << G4endl;
64 std::vector<G4LogicalVolume *>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
65 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
66 G4cout <<
" " << numRootLV <<
" Root Logical Volumes in this region" << G4endl;
68 for (
unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
71 G4cout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() << G4endl;
72 for (
unsigned int i = 0;
i < numPV; ++
i) {
73 if (((*pvs)[
i])->GetLogicalVolume() == lv) {
74 G4String pvname = ((*pvs)[
i])->GetName();
76 for (
unsigned int k = 0;
k < savedgdml.size(); ++
k) {
77 if (pvname == savedgdml[
k]) {
83 G4cout <<
"### Check overlaps for PhysVolume " << pvname <<
" is skipted because was already done" 87 savedgdml.push_back(pvname);
88 G4cout <<
"### Check overlaps for PhysVolume " << pvname << G4endl;
92 gdml.Write(pvname +
".gdml", (*pvs)[i],
true);
95 test.SetErrorsThreshold(nPrints);
102 G4cout <<
"### Check overlaps for PhysVolume Node[" << ii <<
"] : " << nodeNames[
ii] << G4endl;
103 G4VPhysicalVolume *pv = pvs->GetVolume((G4String)nodeNames[ii]);
105 test.SetErrorsThreshold(nPrints);
111 G4cout <<
"----------- List of PhysVolumes by name -----------------" << G4endl;
112 for (
unsigned int i = 0; i < numPV; ++
i) {
113 if (
PVname == ((*pvs)[i])->GetName()) {
114 G4cout <<
" ##### PhysVolume " <<
PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
115 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
116 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
117 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName() << G4endl;
118 G4cout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() << G4endl;
119 G4cout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() << G4endl;
122 gdml.Write(
PVname +
".gdml", (*pvs)[i],
true);
128 G4cout <<
"---------- List of Logical Volumes by name ------------------" << G4endl;
129 for (
unsigned int i = 0; i < numLV; ++
i) {
130 if (
LVname == ((*lvs)[i])->GetName()) {
131 G4int
np = ((*lvs)[
i])->GetNoDaughters();
132 G4cout <<
" ##### LogVolume " <<
LVname <<
" " << np <<
" daughters" 133 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName() << G4endl;
134 G4cout << *(((*lvs)[
i])->GetSolid()) << G4endl;
135 for (G4int j = 0; j <
np; ++j) {
136 G4VPhysicalVolume *pv = ((*lvs)[
i])->GetDaughter(j);
138 G4cout <<
" PV: " << pv->GetName() <<
" [" << pv->GetCopyNo() <<
"]" 139 <<
" type: " << pv->VolumeType() <<
" multiplicity: " << pv->GetMultiplicity()
140 <<
" LV: " << pv->GetLogicalVolume()->GetName() << G4endl;
141 G4cout <<
" Translation: " << pv->GetObjectTranslation() << G4endl;
142 G4cout <<
" Rotation: " << pv->GetObjectRotationValue() << G4endl;
143 G4cout << *(pv->GetLogicalVolume()->GetSolid()) << G4endl;
149 G4cout <<
"---------------- End of overlap checks ---------------------" << G4endl;