7 #include "G4GDMLParser.hh" 8 #include "G4GeomTestVolume.hh" 9 #include "G4LogicalVolume.hh" 10 #include "G4LogicalVolumeStore.hh" 11 #include "G4PhysicalVolumeStore.hh" 12 #include "G4GeometryManager.hh" 13 #include "G4Region.hh" 14 #include "G4RegionStore.hh" 15 #include "G4Element.hh" 16 #include "G4ElementTable.hh" 17 #include "G4Material.hh" 18 #include "G4MaterialTable.hh" 19 #include "G4ProductionCutsTable.hh" 20 #include "G4MaterialCutsCouple.hh" 21 #include "G4SystemOfUnits.hh" 22 #include "G4VPhysicalVolume.hh" 23 #include "G4UnitsTable.hh" 35 G4VPhysicalVolume* world) {
36 bool mat =
p.getParameter<
bool>(
"MaterialFlag");
40 <<
"CMSG4CheckOverlap: OutputFileBaseName is not provided - no check is performed";
48 <<
"CMSG4CheckOverlap: file <" << sss <<
"> is not opened - no report provided";
50 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"CMSG4CheckOverlap: output file <" << sss <<
"> is opened";
56 bool reg =
p.getParameter<
bool>(
"RegionFlag");
64 bool geom =
p.getParameter<
bool>(
"GeomFlag");
70 <<
"CMSG4CheckOverlap: file <" << sss <<
"> is not opened - no report provided";
72 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"CMSG4CheckOverlap: output file <" << sss <<
"> is opened";
79 bool oFlag =
p.getParameter<
bool>(
"OverlapFlag");
85 <<
"CMSG4CheckOverlap: file <" << sss <<
"> is not opened - no report provided";
87 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"CMSG4CheckOverlap: output file <" <<
ss <<
"> is opened";
97 int nelm = G4Element::GetNumberOfElements();
98 int nmat = G4Material::GetNumberOfMaterials();
99 G4ProductionCutsTable* theCoupleTable = G4ProductionCutsTable::GetProductionCutsTable();
100 int ncouples = theCoupleTable->GetTableSize();
101 fout <<
"=====================================================================" 103 fout <<
"NumberOfElements " << nelm <<
"\n";
104 fout <<
"NumberOfMaterials " << nmat <<
"\n";
105 fout <<
"NumberOfCouples " << ncouples <<
"\n";
106 fout <<
"=====================================================================" 108 fout <<
"ElementsDump:" 110 G4ElementTable* elmtab = G4Element::GetElementTable();
112 fout <<
"=====================================================================" 114 G4MaterialTable* mattab = G4Material::GetMaterialTable();
115 fout <<
"MaterialsDump:" 118 for (
int i = 0;
i < nmat; ++
i) {
119 fout <<
"### Material " <<
i <<
" " << ((*mattab)[
i])->GetNumberOfElements() <<
" elements\n";
120 fout << (*mattab)[
i] <<
"\n";
122 fout <<
"=====================================================================" 124 fout <<
"MaterialsCutsCoupleDump:" 126 const std::vector<G4double>* gcut = theCoupleTable->GetEnergyCutsVector(0);
127 const std::vector<G4double>*
ecut = theCoupleTable->GetEnergyCutsVector(1);
128 const std::vector<G4double>* pcut = theCoupleTable->GetEnergyCutsVector(2);
129 const std::vector<G4double>* icut = theCoupleTable->GetEnergyCutsVector(3);
130 for (
int i = 0;
i < ncouples; ++
i) {
131 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(
i);
132 const G4ProductionCuts* aCut = couple->GetProductionCuts();
133 fout <<
"Index : " <<
i <<
" used in the geometry : ";
134 if (couple->IsUsed()) {
139 fout <<
" Material : " << couple->GetMaterial()->GetName() <<
"\n";
140 fout <<
" Range cuts : " 141 <<
" gamma " << G4BestUnit(aCut->GetProductionCut(0),
"Length") <<
" e- " 142 << G4BestUnit(aCut->GetProductionCut(1),
"Length") <<
" e+ " 143 << G4BestUnit(aCut->GetProductionCut(2),
"Length") <<
" proton " 144 << G4BestUnit(aCut->GetProductionCut(3),
"Length") <<
"\n";
145 fout <<
" Energy thresholds : ";
146 fout <<
" gamma " << G4BestUnit((*gcut)[
i],
"Energy") <<
" e- " << G4BestUnit((*
ecut)[
i],
"Energy")
147 <<
" e+ " << G4BestUnit((*pcut)[
i],
"Energy") <<
" proton " << G4BestUnit((*icut)[
i],
"Energy") <<
"\n";
149 fout <<
"======================================================================" 154 const G4RegionStore* regs = G4RegionStore::GetInstance();
155 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
156 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
157 int numPV =
pvs->size();
158 int numLV = lvs->size();
159 int nreg = regs->size();
160 fout <<
"=====================================================================" 162 fout <<
"NumberOfRegions " << nreg <<
"\n";
163 fout <<
"NumberOfLogicalVolumes " << numLV <<
"\n";
164 fout <<
"NumberOfPhysicalVolumes " << numPV <<
"\n";
165 fout <<
"=====================================================================" 167 G4GeometryManager::GetInstance()->CloseGeometry(
true,
true, world);
168 fout <<
"=====================================================================" 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");
183 const G4RegionStore* regStore = G4RegionStore::GetInstance();
186 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
187 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
188 unsigned int numPV =
pvs->size();
189 unsigned int numLV = lvs->size();
190 unsigned int nn = nodeNames.size();
192 std::vector<G4String> savedgdml;
194 fout <<
"=====================================================================" 196 fout <<
"CMSG4OverlapCheck is initialised with " << nodeNames.size() <<
" nodes; " 197 <<
" nPoints= " << nPoints <<
"; tolerance= " <<
tolerance / mm <<
" mm; verbose: " <<
verbose <<
"\n" 198 <<
" RegionFlag: " << regionFlag <<
" PVname: " <<
PVname <<
" LVname: " <<
LVname <<
"\n" 199 <<
" Nlv= " << numLV <<
" Npv= " << numPV <<
"\n";
200 fout <<
"=====================================================================" 204 for (
unsigned int ii = 0;
ii <
nn; ++
ii) {
205 if (nodeNames[
ii].
empty() ||
"world" == nodeNames[
ii] ||
"World" == nodeNames[
ii]) {
206 nodeNames[
ii] =
"DDDWorld";
207 fout <<
"### Check overlaps for DDDWorld " 209 G4VPhysicalVolume*
pv =
pvs->GetVolume(
"DDDWorld");
211 test.SetErrorsThreshold(nPrints);
212 test.TestOverlapInTree();
213 }
else if (regionFlag) {
214 fout <<
"---------------------------------------------------------------" 216 fout <<
"### Check overlaps for G4Region Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
217 G4Region* reg = regStore->GetRegion((G4String)nodeNames[
ii]);
219 fout <<
"### NO G4Region found - EXIT" 223 std::vector<G4LogicalVolume*>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
224 unsigned int numRootLV = reg->GetNumberOfRootVolumes();
225 fout <<
" " << numRootLV <<
" Root Logical Volumes in this region" 228 for (
unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
231 fout <<
"### Check overlaps for G4LogicalVolume " << lv->GetName() <<
"\n";
232 for (
unsigned int i = 0;
i < numPV; ++
i) {
233 if (((*
pvs)[
i])->GetLogicalVolume() == lv) {
234 G4String pvname = ((*pvs)[
i])->GetName();
236 for (
unsigned int k = 0;
k < savedgdml.size(); ++
k) {
237 if (pvname == savedgdml[
k]) {
243 fout <<
"### Check overlaps for PhysVolume " << pvname <<
" is skipted because was already done" 247 savedgdml.push_back(pvname);
248 fout <<
"### Check overlaps for PhysVolume " << pvname <<
"\n";
252 gdml.Write(pvname +
".gdml", (*
pvs)[
i],
true);
255 test.SetErrorsThreshold(nPrints);
256 test.TestOverlapInTree();
261 fout <<
"### Check overlaps for PhysVolume Node[" <<
ii <<
"] : " << nodeNames[
ii] <<
"\n";
262 G4VPhysicalVolume*
pv =
pvs->GetVolume((G4String)nodeNames[
ii]);
264 test.SetErrorsThreshold(nPrints);
265 test.TestOverlapInTree();
270 fout <<
"----------- List of PhysVolumes by name -----------------" 272 for (
unsigned int i = 0;
i < numPV; ++
i) {
274 fout <<
" ##### PhysVolume " <<
PVname <<
" [" << ((*pvs)[
i])->GetCopyNo()
275 <<
"] LV: " << ((*pvs)[
i])->GetLogicalVolume()->GetName()
276 <<
" Mother LV: " << ((*pvs)[
i])->GetMotherLogical()->GetName()
277 <<
" Region: " << ((*pvs)[
i])->GetLogicalVolume()->GetRegion()->GetName() <<
"\n";
278 fout <<
" Translation: " << ((*pvs)[
i])->GetObjectTranslation() <<
"\n";
279 fout <<
" Rotation: " << ((*pvs)[
i])->GetObjectRotationValue() <<
"\n";
282 gdml.Write(
PVname +
".gdml", (*
pvs)[
i],
true);
288 fout <<
"---------- List of Logical Volumes by name ------------------" 290 for (
unsigned int i = 0;
i < numLV; ++
i) {
291 if (
LVname == ((*lvs)[
i])->GetName()) {
292 G4int
np = ((*lvs)[
i])->GetNoDaughters();
293 fout <<
" ##### LogVolume " <<
LVname <<
" " <<
np <<
" daughters" 294 <<
" Region: " << ((*lvs)[
i])->GetRegion()->GetName() <<
"\n";
295 fout << *(((*lvs)[
i])->GetSolid()) <<
"\n";
296 for (G4int
j = 0;
j <
np; ++
j) {
297 G4VPhysicalVolume*
pv = ((*lvs)[
i])->GetDaughter(
j);
299 fout <<
" PV: " <<
pv->GetName() <<
" [" <<
pv->GetCopyNo() <<
"]" 300 <<
" type: " <<
pv->VolumeType() <<
" multiplicity: " <<
pv->GetMultiplicity()
301 <<
" LV: " <<
pv->GetLogicalVolume()->GetName() <<
"\n";
302 fout <<
" Translation: " <<
pv->GetObjectTranslation() <<
"\n";
303 fout <<
" Rotation: " <<
pv->GetObjectRotationValue() <<
"\n";
304 fout << *(
pv->GetLogicalVolume()->GetSolid()) <<
"\n";
310 fout <<
"---------------- End of overlap checks ---------------------" void makeReportForGeometry(std::ofstream &fout, G4VPhysicalVolume *world)
Log< level::Info, true > LogVerbatim
void sendToFile(std::ofstream *)
void makeReportForMaterials(std::ofstream &fout)
void makeReportForOverlaps(std::ofstream &fout, const edm::ParameterSet &p)
void ReportRegions(const std::string &ss)
Log< level::Warning, false > LogWarning
CMSG4CheckOverlap(edm::ParameterSet const &p, std::string ®File, CustomUIsession *, G4VPhysicalVolume *world)