173 std::vector<std::string> nodeNames =
p.getParameter<std::vector<std::string>>(
"NodeNames");
176 double tolerance =
p.getParameter<
double>(
"Tolerance") * CLHEP::mm;
177 int nPoints =
p.getParameter<
int>(
"Resolution");
178 bool verbose =
p.getParameter<
bool>(
"Verbose");
179 bool regionFlag =
p.getParameter<
bool>(
"RegionFlag");
180 bool gdmlFlag =
p.getParameter<
bool>(
"gdmlFlag");
181 int nPrints =
p.getParameter<
int>(
"ErrorThreshold");
182 int level =
p.getParameter<
int>(
"Level");
183 int depth =
p.getParameter<
int>(
"Depth");
185 const G4RegionStore* regStore = G4RegionStore::GetInstance();
188 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
189 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
190 unsigned int numPV =
pvs->size();
191 unsigned int numLV = lvs->size();
192 unsigned int nn = nodeNames.size();
194 std::vector<G4String> savedgdml;
196 fout <<
"====================================================================="
198 fout <<
"CMSG4OverlapCheck is initialised with " << nodeNames.size() <<
" nodes; "
199 <<
" nPoints= " << nPoints <<
"; tolerance= " <<
tolerance / mm <<
" mm; verbose: " <<
verbose <<
"\n"
200 <<
" RegionFlag: " << regionFlag <<
" PVname: " <<
PVname <<
" LVname: " <<
LVname <<
"\n"
201 <<
" Nlv= " << numLV <<
" Npv= " << numPV <<
"\n";
202 fout <<
"====================================================================="
206 for (
unsigned int ii = 0;
ii <
nn; ++
ii) {
207 if (nodeNames[
ii].
empty() ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii]) {
208 nodeNames[
ii] =
"DDDWorld";
209 fout <<
"### Check overlaps for DDDWorld "
211 G4VPhysicalVolume*
pv =
pvs->GetVolume(
"DDDWorld");
213 test.SetErrorsThreshold(nPrints);
215 }
else if (regionFlag) {
216 fout <<
"---------------------------------------------------------------"
218 fout <<
"### Check overlaps for G4Region Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
219 G4Region* reg = regStore->GetRegion((G4String)nodeNames[
ii]);
221 fout <<
"### NO G4Region found - EXIT"
225 std::vector<G4LogicalVolume*>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
226 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
227 fout <<
" " << numRootLV <<
" Root Logical Volumes in this region"
230 for (
unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
233 fout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() <<
"\n";
234 for (
unsigned int i = 0;
i < numPV; ++
i) {
235 if (((*
pvs)[
i])->GetLogicalVolume() == lv) {
236 G4String pvname = ((*pvs)[
i])->GetName();
238 for (
unsigned int k = 0;
k < savedgdml.size(); ++
k) {
239 if (pvname == savedgdml[
k]) {
245 fout <<
"### Check overlaps for PhysVolume " << pvname <<
" is skipted because was already done"
249 savedgdml.push_back(pvname);
250 fout <<
"### Check overlaps for PhysVolume " << pvname <<
"\n";
254 gdml.Write(pvname +
".gdml", (*
pvs)[
i],
true);
257 test.SetErrorsThreshold(nPrints);
263 fout <<
"### Check overlaps for PhysVolume Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
264 G4VPhysicalVolume*
pv =
pvs->GetVolume((G4String)nodeNames[
ii]);
266 test.SetErrorsThreshold(nPrints);
272 fout <<
"----------- List of PhysVolumes by name -----------------"
274 for (
unsigned int i = 0;
i < numPV; ++
i) {
276 fout <<
" ##### PhysVolume " <<
PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
277 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
278 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
279 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName() <<
"\n";
280 fout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() <<
"\n";
281 fout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() <<
"\n";
284 gdml.Write(
PVname +
".gdml", (*
pvs)[
i],
true);
290 fout <<
"---------- List of Logical Volumes by name ------------------"
292 for (
unsigned int i = 0;
i < numLV; ++
i) {
293 if (
LVname == ((*lvs)[
i])->GetName()) {
294 G4int
np = ((*lvs)[
i])->GetNoDaughters();
295 fout <<
" ##### LogVolume " <<
LVname <<
" " <<
np <<
" daughters"
296 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName() <<
"\n";
297 fout << *(((*lvs)[
i])->GetSolid()) <<
"\n";
298 for (G4int
j = 0;
j <
np; ++
j) {
299 G4VPhysicalVolume*
pv = ((*lvs)[
i])->GetDaughter(
j);
301 fout <<
" PV: " <<
pv->GetName() <<
" [" <<
pv->GetCopyNo() <<
"]"
302 <<
" type: " <<
pv->VolumeType() <<
" multiplicity: " <<
pv->GetMultiplicity()
303 <<
" LV: " <<
pv->GetLogicalVolume()->GetName() <<
"\n";
304 fout <<
" Translation: " <<
pv->GetObjectTranslation() <<
"\n";
305 fout <<
" Rotation: " <<
pv->GetObjectRotationValue() <<
"\n";
306 fout << *(
pv->GetLogicalVolume()->GetSolid()) <<
"\n";
312 fout <<
"---------------- End of overlap checks ---------------------"