20 std::vector<std::string> nodeNames
21 =
p.getParameter<std::vector<std::string> >(
"NodeNames");
25 =
p.getUntrackedParameter<
double>(
"Tolerance", 0.0)*CLHEP::mm;
26 int nPoints =
p.getUntrackedParameter<
int>(
"Resolution", 10000);
27 bool verbose =
p.getUntrackedParameter<
bool>(
"Verbose",
true);
28 bool regionFlag =
p.getUntrackedParameter<
bool>(
"RegionFlag",
true);
29 bool gdmlFlag =
p.getUntrackedParameter<
bool>(
"gdmlFlag",
false);
30 int nPrints =
p.getUntrackedParameter<
int>(
"ErrorThreshold", 1);
31 int level =
p.getUntrackedParameter<
int>(
"Level", 0);
32 int depth =
p.getUntrackedParameter<
int>(
"Depth", -1);
34 const G4RegionStore* regStore = G4RegionStore::GetInstance();
37 const G4PhysicalVolumeStore * pvs = G4PhysicalVolumeStore::GetInstance();
38 unsigned int numPV = pvs->size();
39 unsigned int nn = nodeNames.size();
41 std::vector<G4String> savedgdml;
43 G4cout <<
"G4OverlapCheck is initialised with "
44 << nodeNames.size() <<
" nodes; " <<
" nPoints= " << nPoints
45 <<
"; tolerance= " << tolerance/mm <<
" mm; verbose: "
47 <<
" RegionFlag: " << regionFlag
48 <<
" PVname: " << PVname <<
" LVname: " << LVname << G4endl;
51 for (
unsigned int ii=0;
ii<nn; ++
ii) {
52 if(
"" == nodeNames[
ii] ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii] ) {
53 nodeNames[
ii] =
"DDDWorld";
54 G4cout <<
"### Check overlaps for DDDWorld " << G4endl;
55 G4VPhysicalVolume*
pv = pvs->GetVolume(
"DDDWorld");
56 G4GeomTestVolume
test(pv, tolerance, nPoints,
verbose);
57 test.SetErrorsThreshold(nPrints);
59 }
else if(regionFlag) {
60 G4cout <<
"---------------------------------------------------------------" << G4endl;
61 G4cout <<
"### Check overlaps for G4Region Node[" << ii <<
"] : " << nodeNames[
ii]
63 G4Region* reg = regStore->GetRegion((G4String)nodeNames[ii]);
65 G4cout <<
"### NO G4Region found - EXIT" << G4endl;
68 std::vector<G4LogicalVolume*>::iterator rootLVItr
69 = reg->GetRootLogicalVolumeIterator();
70 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
71 G4cout <<
" " << numRootLV <<
" Root Logical Volumes in this region" << G4endl;
73 for(
unsigned int iLV=0; iLV < numRootLV; ++iLV, ++rootLVItr ) {
76 G4cout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() << G4endl;
77 for(
unsigned int i=0;
i<numPV; ++
i) {
78 if(((*pvs)[
i])->GetLogicalVolume() == lv) {
79 G4String pvname = ((*pvs)[
i])->GetName();
81 for(
unsigned int k=0;
k<savedgdml.size(); ++
k) {
82 if(pvname == savedgdml[
k]) {
88 G4cout <<
"### Check overlaps for PhysVolume " << pvname
89 <<
" is skipted because was already done" << G4endl;
92 savedgdml.push_back(pvname);
93 G4cout <<
"### Check overlaps for PhysVolume " << pvname
98 gdml.Write(pvname+
".gdml", (*pvs)[i],
true);
100 G4GeomTestVolume
test(((*pvs)[i]), tolerance, nPoints,
verbose);
101 test.SetErrorsThreshold(nPrints);
108 G4cout <<
"### Check overlaps for PhysVolume Node[" << ii <<
"] : " << nodeNames[
ii]
110 G4VPhysicalVolume* pv = pvs->GetVolume((G4String)nodeNames[ii]);
111 G4GeomTestVolume
test(pv, tolerance, nPoints,
verbose);
112 test.SetErrorsThreshold(nPrints);
118 G4cout <<
"----------- List of PhysVolumes by name -----------------" << G4endl;
119 for (
unsigned int i=0; i<numPV; ++
i) {
120 if(PVname == ((*pvs)[i])->GetName()) {
121 G4cout <<
" ##### PhysVolume " << PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
122 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
123 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName() << G4endl;
124 G4cout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() << G4endl;
125 G4cout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() << G4endl;
130 G4cout <<
"---------- List of Logical Volumes by name ------------------" << G4endl;
131 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
132 unsigned int numLV = lvs->size();
133 for (
unsigned int i=0; i<numLV; ++
i) {
134 if(LVname == ((*lvs)[i])->GetName()) {
135 G4int
np = ((*lvs)[
i])->GetNoDaughters();
136 G4cout <<
" ##### LogVolume " << LVname <<
" " << np <<
" daughters" << G4endl;
137 for (G4int
j=0;
j<
np; ++
j) {
138 G4VPhysicalVolume* pv = ((*lvs)[
i])->GetDaughter(
j);
140 G4cout <<
" PV: " << pv->GetName() <<
" [" << pv->GetCopyNo() <<
"]"
141 <<
" type: " << pv->VolumeType() <<
" multiplicity: "
142 << pv->GetMultiplicity() <<
" LV: "
143 << pv->GetLogicalVolume()->GetName() << G4endl;
144 G4cout <<
" Translation: " << pv->GetObjectTranslation() << G4endl;
145 G4cout <<
" Rotation: " << pv->GetObjectRotationValue() << G4endl;
151 G4cout <<
"---------------- End of overlap checks ---------------------" << G4endl;