5 #include "G4RegionStore.hh" 7 #include "G4LogicalVolumeStore.hh" 8 #include "G4PhysicalVolumeStore.hh" 9 #include "G4VPhysicalVolume.hh" 10 #include "G4LogicalVolume.hh" 11 #include "G4GeomTestVolume.hh" 13 #include "G4SystemOfUnits.hh" 14 #include "G4GDMLParser.hh" 20 std::vector<std::string> nodeNames
21 = p.
getParameter<std::vector<std::string> >(
"NodeNames");
34 const G4RegionStore* regStore = G4RegionStore::GetInstance();
37 const G4PhysicalVolumeStore * pvs = G4PhysicalVolumeStore::GetInstance();
38 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
39 unsigned int numPV = pvs->size();
40 unsigned int numLV = lvs->size();
41 unsigned int nn = nodeNames.size();
43 std::vector<G4String> savedgdml;
45 G4cout <<
"G4OverlapCheck is initialised with " 46 << nodeNames.size() <<
" nodes; " <<
" nPoints= " << nPoints
47 <<
"; tolerance= " << tolerance/mm <<
" mm; verbose: " 49 <<
" RegionFlag: " << regionFlag
50 <<
" PVname: " << PVname <<
" LVname: " << LVname <<
"\n" 51 <<
" Nlv= " << numLV <<
" Npv= " << numPV << G4endl;
54 for (
unsigned int ii=0;
ii<
nn; ++
ii) {
55 if(
"" == nodeNames[
ii] ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii] ) {
56 nodeNames[
ii] =
"DDDWorld";
57 G4cout <<
"### Check overlaps for DDDWorld " << G4endl;
58 G4VPhysicalVolume*
pv = pvs->GetVolume(
"DDDWorld");
59 G4GeomTestVolume
test(pv, tolerance, nPoints, verbose);
60 test.SetErrorsThreshold(nPrints);
61 test.TestRecursiveOverlap(level, depth);
62 }
else if(regionFlag) {
63 G4cout <<
"---------------------------------------------------------------" << G4endl;
64 G4cout <<
"### Check overlaps for G4Region Node[" << ii <<
"] : " << nodeNames[
ii]
66 G4Region* reg = regStore->GetRegion((G4String)nodeNames[ii]);
68 G4cout <<
"### NO G4Region found - EXIT" << G4endl;
71 std::vector<G4LogicalVolume*>::iterator rootLVItr
72 = reg->GetRootLogicalVolumeIterator();
73 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
74 G4cout <<
" " << numRootLV <<
" Root Logical Volumes in this region" << G4endl;
76 for(
unsigned int iLV=0; iLV < numRootLV; ++iLV, ++rootLVItr ) {
79 G4cout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() << G4endl;
80 for(
unsigned int i=0;
i<numPV; ++
i) {
81 if(((*pvs)[
i])->GetLogicalVolume() == lv) {
82 G4String pvname = ((*pvs)[
i])->GetName();
84 for(
unsigned int k=0;
k<savedgdml.size(); ++
k) {
85 if(pvname == savedgdml[
k]) {
91 G4cout <<
"### Check overlaps for PhysVolume " << pvname
92 <<
" is skipted because was already done" << G4endl;
95 savedgdml.push_back(pvname);
96 G4cout <<
"### Check overlaps for PhysVolume " << pvname
101 gdml.Write(pvname+
".gdml", (*pvs)[i],
true);
103 G4GeomTestVolume
test(((*pvs)[i]), tolerance, nPoints, verbose);
104 test.SetErrorsThreshold(nPrints);
105 test.TestRecursiveOverlap(level, depth);
111 G4cout <<
"### Check overlaps for PhysVolume Node[" << ii <<
"] : " << nodeNames[
ii]
113 G4VPhysicalVolume*
pv = pvs->GetVolume((G4String)nodeNames[ii]);
114 G4GeomTestVolume
test(pv, tolerance, nPoints, verbose);
115 test.SetErrorsThreshold(nPrints);
116 test.TestRecursiveOverlap(level, depth);
121 G4cout <<
"----------- List of PhysVolumes by name -----------------" << G4endl;
122 for (
unsigned int i=0;
i<numPV; ++
i) {
123 if(PVname == ((*pvs)[
i])->GetName()) {
124 G4cout <<
" ##### PhysVolume " << PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
125 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
126 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
127 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName()
129 G4cout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() << G4endl;
130 G4cout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() << G4endl;
133 gdml.Write(PVname+
".gdml", (*pvs)[i],
true);
139 G4cout <<
"---------- List of Logical Volumes by name ------------------" << G4endl;
140 for (
unsigned int i=0;
i<numLV; ++
i) {
141 if(LVname == ((*lvs)[
i])->GetName()) {
142 G4int
np = ((*lvs)[
i])->GetNoDaughters();
143 G4cout <<
" ##### LogVolume " << LVname <<
" " << np <<
" daughters" 144 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName()
146 G4cout << *(((*lvs)[
i])->GetSolid()) << G4endl;
147 for (G4int j=0; j<
np; ++j) {
148 G4VPhysicalVolume*
pv = ((*lvs)[
i])->GetDaughter(j);
150 G4cout <<
" PV: " << pv->GetName() <<
" [" << pv->GetCopyNo() <<
"]" 151 <<
" type: " << pv->VolumeType() <<
" multiplicity: " 152 << pv->GetMultiplicity() <<
" LV: " 153 << pv->GetLogicalVolume()->GetName() << G4endl;
154 G4cout <<
" Translation: " << pv->GetObjectTranslation() << G4endl;
155 G4cout <<
" Rotation: " << pv->GetObjectRotationValue() << G4endl;
156 G4cout << *(pv->GetLogicalVolume()->GetSolid()) << G4endl;
162 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)