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 / CLHEP::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]);
240 std::vector<G4LogicalVolume*>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
241 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
242 fout <<
" " << numRootLV <<
" Root Logical Volumes in this region" 245 for (
unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
248 fout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() <<
"\n";
249 for (
unsigned int i = 0;
i < numPV; ++
i) {
250 if (((*
pvs)[
i])->GetLogicalVolume() == lv) {
251 G4String pvname = ((*pvs)[
i])->GetName();
253 for (
unsigned int k = 0;
k < savedgdml.size(); ++
k) {
254 if (pvname == savedgdml[
k]) {
260 fout <<
"### Check overlaps for PhysVolume " << pvname <<
" is skipted because was already done" 264 savedgdml.push_back(pvname);
265 fout <<
"### Check overlaps for PhysVolume " << pvname <<
"\n";
268 gdml->Write(pvname +
".gdml", (*
pvs)[
i],
true);
271 test.SetErrorsThreshold(nPrints);
272 test.TestOverlapInTree();
277 fout <<
"### Check overlaps for PhysVolume Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
278 G4VPhysicalVolume*
pv =
pvs->GetVolume((G4String)nodeNames[
ii]);
280 test.SetErrorsThreshold(nPrints);
281 test.TestOverlapInTree();
286 fout <<
"----------- List of PhysVolumes by name -----------------" 288 for (
unsigned int i = 0;
i < numPV; ++
i) {
290 fout <<
" ##### PhysVolume " <<
PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
291 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
292 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
293 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName() <<
"\n";
294 fout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() <<
"\n";
295 fout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() <<
"\n";
297 gdml->Write(
PVname +
".gdml", (*
pvs)[
i],
true);
303 fout <<
"---------- List of Logical Volumes by name ------------------" 305 for (
unsigned int i = 0;
i < numLV; ++
i) {
306 if (
LVname == ((*lvs)[
i])->GetName()) {
307 G4int
np = ((*lvs)[
i])->GetNoDaughters();
308 fout <<
" ##### LogVolume " <<
LVname <<
" " <<
np <<
" daughters" 309 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName() <<
"\n";
310 fout << *(((*lvs)[
i])->GetSolid()) <<
"\n";
311 for (G4int
j = 0;
j <
np; ++
j) {
312 G4VPhysicalVolume*
pv = ((*lvs)[
i])->GetDaughter(
j);
314 fout <<
" PV: " <<
pv->GetName() <<
" [" <<
pv->GetCopyNo() <<
"]" 315 <<
" type: " <<
pv->VolumeType() <<
" multiplicity: " <<
pv->GetMultiplicity()
316 <<
" LV: " <<
pv->GetLogicalVolume()->GetName() <<
"\n";
317 fout <<
" Translation: " <<
pv->GetObjectTranslation() <<
"\n";
318 fout <<
" Rotation: " <<
pv->GetObjectRotationValue() <<
"\n";
319 fout << *(
pv->GetLogicalVolume()->GetSolid()) <<
"\n";
325 fout <<
"---------------- End of overlap checks ---------------------"