5 #include "G4GDMLParser.hh" 6 #include "G4GeomTestVolume.hh" 7 #include "G4LogicalVolume.hh" 8 #include "G4LogicalVolumeStore.hh" 9 #include "G4PhysicalVolumeStore.hh" 10 #include "G4Region.hh" 11 #include "G4RegionStore.hh" 12 #include "G4SystemOfUnits.hh" 13 #include "G4VPhysicalVolume.hh" 19 std::vector<std::string> nodeNames = p.
getParameter<std::vector<std::string>>(
"NodeNames");
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");
53 G4GeomTestVolume
test(pv, tolerance, nPoints, verbose);
54 test.SetErrorsThreshold(nPrints);
55 test.TestRecursiveOverlap(level, depth);
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);
94 G4GeomTestVolume
test(((*pvs)[i]), tolerance, nPoints, verbose);
95 test.SetErrorsThreshold(nPrints);
96 test.TestRecursiveOverlap(level, depth);
102 G4cout <<
"### Check overlaps for PhysVolume Node[" << ii <<
"] : " << nodeNames[
ii] << G4endl;
103 G4VPhysicalVolume *
pv = pvs->GetVolume((G4String)nodeNames[ii]);
104 G4GeomTestVolume
test(pv, tolerance, nPoints, verbose);
105 test.SetErrorsThreshold(nPrints);
106 test.TestRecursiveOverlap(level, depth);
110 if (!PVname.empty()) {
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);
127 if (!LVname.empty()) {
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;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
G4CheckOverlap(edm::ParameterSet const &p)