19 #include "DD4hep/DD4hepUnits.h"
20 #include "DD4hep/Filter.h"
23 #include "G4PhysicalVolumeStore.hh"
24 #include "G4LogicalVolumeStore.hh"
25 #include "G4VPhysicalVolume.hh"
26 #include "G4LogicalVolume.hh"
27 #include "G4VSolid.hh"
28 #include "G4Material.hh"
30 #include "G4VisAttributes.hh"
31 #include "G4UserLimits.hh"
32 #include "G4TransportationManager.hh"
43 dumpSummary_ =
p.getUntrackedParameter<
bool>(
"DumpSummary",
true);
44 dumpLVTree_ =
p.getUntrackedParameter<
bool>(
"DumpLVTree",
true);
45 dumpLVList_ =
p.getUntrackedParameter<
bool>(
"DumpLVList",
false);
46 dumpMaterial_ =
p.getUntrackedParameter<
bool>(
"DumpMaterial",
false);
47 dumpLV_ =
p.getUntrackedParameter<
bool>(
"DumpLV",
false);
48 dumpSolid_ =
p.getUntrackedParameter<
bool>(
"DumpSolid",
false);
49 dumpAtts_ =
p.getUntrackedParameter<
bool>(
"DumpAttributes",
false);
50 dumpPV_ =
p.getUntrackedParameter<
bool>(
"DumpPV",
false);
51 dumpRotation_ =
p.getUntrackedParameter<
bool>(
"DumpRotation",
false);
52 dumpReplica_ =
p.getUntrackedParameter<
bool>(
"DumpReplica",
false);
53 dumpTouch_ =
p.getUntrackedParameter<
bool>(
"DumpTouch",
false);
54 dumpSense_ =
p.getUntrackedParameter<
bool>(
"DumpSense",
false);
55 dd4hep_ =
p.getUntrackedParameter<
bool>(
"DD4Hep",
false);
59 names_ =
p.getUntrackedParameter<std::vector<std::string> >(
"Names");
65 fileDetail_ =
p.getUntrackedParameter<
bool>(
"FileDetail",
false);
66 G4cout <<
"PrintGeomInfoAction:: initialised for dd4hep " <<
dd4hep_ <<
" with verbosity levels:"
77 <<
"\n for " <<
names_.size() <<
" names:";
78 for (
unsigned int i = 0;
i <
names_.size();
i++)
89 (*job)()->get<IdealGeometryRecord>().get(pDD);
91 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes "
92 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
93 for (
unsigned int i = 0;
i <
names_.size();
i++) {
97 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for ReadOutName = " <<
sd << G4endl;
98 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
105 auto lvname = fv.
name();
106 unsigned int leafDepth =
copy.size();
107 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
108 for (
unsigned int k = 0;
k < leafDepth; ++
k)
110 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")"
116 (*job)()->get<IdealGeometryRecord>().get(pDD);
118 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes "
119 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
120 for (
unsigned int i = 0;
i <
names_.size();
i++) {
125 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for " << attribute <<
" = " <<
sd << G4endl;
126 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
137 unsigned int leafDepth =
copy.size();
138 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
139 for (
int k = leafDepth - 1;
k >= 0;
k--)
141 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")"
173 out <<
" @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
175 out <<
" No volume created " << G4endl;
178 out <<
" @@@ Geometry built inside world volume: " <<
theTopPV_->GetName() << G4endl;
180 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
181 std::vector<G4LogicalVolume *>::const_iterator lvcite;
182 std::set<G4VSolid *> theSolids;
183 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
184 theSolids.insert((*lvcite)->GetSolid());
185 out <<
" Number of G4VSolid's: " << theSolids.size() << G4endl;
186 out <<
" Number of G4LogicalVolume's: " << lvs->size() << G4endl;
187 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
188 out <<
" Number of G4VPhysicalVolume's: " <<
pvs->size() << G4endl;
190 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
191 out <<
" Number of G4Material's: " << matTab->size() << G4endl;
195 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List " << G4endl;
196 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
197 std::vector<G4LogicalVolume *>::const_iterator lvcite;
198 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
199 out <<
"LV:" << (*lvcite)->GetName() <<
"\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << G4endl;
203 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << G4endl;
209 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
210 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
211 out <<
" with " << matTab->size() <<
" materials " << G4endl;
212 std::vector<G4Material *>::const_iterator matite;
213 for (matite = matTab->begin(); matite != matTab->end(); matite++)
214 out <<
"Material: " << (*matite) << G4endl;
218 unsigned int leafDepth,
221 for (
unsigned int ii = 0;
ii < leafDepth;
ii++)
223 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" <<
count <<
")" << G4endl;
225 std::map<G4LogicalVolume *, unsigned int> lvCount;
226 std::map<G4LogicalVolume *, unsigned int>::const_iterator cite;
227 int siz = lv->GetNoDaughters();
228 for (
int ii = 0;
ii < siz;
ii++) {
229 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
230 if (cite != lvCount.end())
231 lvCount[cite->first] = (cite->second) + 1;
233 lvCount.insert(std::pair<G4LogicalVolume *, unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(), 1));
235 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
247 int siz = lv->GetNoDaughters();
248 for (
int ii = 0;
ii < siz;
ii++)
259 G4LogicalVolume *topLV =
getTopLV();
276 std::set<G4LogicalVolume *> lvDaughters;
277 int NoDaughters = lv->GetNoDaughters();
278 while ((NoDaughters--) > 0) {
279 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
281 lvDaughters.insert(pvD->GetLogicalVolume());
284 std::set<G4LogicalVolume *>::const_iterator scite;
285 mmlvpv::const_iterator mmcite;
288 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
289 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
291 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
292 dumpPV((*mmcite).second, leafDepth + 1,
out);
303 out << leafDepth << spaces <<
"$$$ VOLUME = " << lv->GetName() <<
" Solid: " << lv->GetSolid()->GetName()
304 <<
" MATERIAL: " << lv->GetMaterial()->GetName() << G4endl;
312 const G4VisAttributes *fVA = lv->GetVisAttributes();
313 if (fVA !=
nullptr) {
314 out << spaces <<
" VISUALISATION ATTRIBUTES: " << G4endl;
315 out << spaces <<
" IsVisible " << fVA->IsVisible() << G4endl;
316 out << spaces <<
" IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << G4endl;
317 out << spaces <<
" Colour " << fVA->GetColour() << G4endl;
318 out << spaces <<
" LineStyle " << fVA->GetLineStyle() << G4endl;
319 out << spaces <<
" LineWidth " << fVA->GetLineWidth() << G4endl;
320 out << spaces <<
" IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << G4endl;
321 out << spaces <<
" ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << G4endl;
325 G4UserLimits *fUL = lv->GetUserLimits();
327 if (fUL !=
nullptr) {
328 out << spaces <<
" MaxAllowedStep " << fUL->GetMaxAllowedStep(
dummy) << G4endl;
329 out << spaces <<
" UserMaxTrackLength " << fUL->GetUserMaxTrackLength(
dummy) << G4endl;
330 out << spaces <<
" UserMaxTime " << fUL->GetUserMaxTime(
dummy) << G4endl;
331 out << spaces <<
" UserMinEkine " << fUL->GetUserMinEkine(
dummy) << G4endl;
332 out << spaces <<
" UserMinRange " << fUL->GetUserMinRange(
dummy) << G4endl;
336 if (lv->GetSensitiveDetector())
337 out << spaces <<
" IS SENSITIVE DETECTOR " << G4endl;
338 if (lv->GetFieldManager())
339 out << spaces <<
" FIELD ON " << G4endl;
342 out << spaces <<
" Quality for optimisation, average number of voxels to be spent per content "
343 << lv->GetSmartless() << G4endl;
346 if (lv->GetFastSimulationManager())
347 out << spaces <<
" Logical Volume is an envelope for a FastSimulationManager " << G4endl;
348 out << spaces <<
" Weight used in the event biasing technique = " << lv->GetBiasWeight() << G4endl;
359 if (
pv->GetMotherLogical())
360 mother =
pv->GetMotherLogical()->GetName();
361 out << leafDepth << spaces <<
"### VOLUME = " <<
pv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
362 <<
" at " <<
pv->GetTranslation();
364 if (!
pv->IsReplicated()) {
366 if (
pv->GetRotation() ==
nullptr)
367 out <<
" with no rotation" << G4endl;
369 out <<
" with rotation" << G4endl;
371 out <<
" with rotation " << *(
pv->GetRotation()) << G4endl;
375 out << spaces <<
" It is replica: " << G4endl;
381 pv->GetReplicationData(axis, nReplicas,
width,
offset, consuming);
382 out << spaces <<
" axis " << axis << G4endl << spaces <<
" nReplicas " << nReplicas << G4endl;
383 if (
pv->GetParameterisation() !=
nullptr)
384 out << spaces <<
" It is parameterisation " << G4endl;
386 out << spaces <<
" width " <<
width << G4endl << spaces <<
" offset " <<
offset << G4endl << spaces
387 <<
" consuming" << consuming << G4endl;
388 if (
pv->GetParameterisation() !=
nullptr)
389 out << spaces <<
" It is parameterisation " << G4endl;
396 out << spaces << *(sol) << G4endl;
406 G4ThreeVector globalpoint =
fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
407 G4LogicalVolume *lv =
pv->GetLogicalVolume();
410 if (
pv->GetMotherLogical())
411 mother =
pv->GetMotherLogical()->GetName();
413 lvname.assign(lvname, 0,
nchar_);
415 out << leafDepth << spaces <<
"### VOLUME = " << lv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
416 <<
" global position of centre " << globalpoint <<
" (r = " << globalpoint.perp()
419 int NoDaughters = lv->GetNoDaughters();
420 while ((NoDaughters--) > 0) {
421 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
422 if (!pvD->IsReplicated())
434 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
436 for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++) {
438 fout << (*matite)->GetName() <<
"\n";
440 fout << (*matite)->GetName() <<
" " << (*matite)->GetRadlen() <<
" " << (*matite)->GetNuclearInterLength()
445 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
448 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
450 fout << (*lvcite)->GetSolid()->GetName() <<
"\n";
452 fout << (*lvcite)->GetSolid()->GetName() <<
" " << (*lvcite)->GetSolid()->GetCubicVolume() <<
"\n";
457 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
459 fout << (*lvcite)->GetName() <<
"\n";
461 fout << (*lvcite)->GetName() <<
" " << (*lvcite)->GetMass(
false,
false) <<
"\n";
465 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
467 for (std::vector<G4VPhysicalVolume *>::const_iterator pvcite =
pvs->begin(); pvcite !=
pvs->end(); pvcite++) {
470 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetTranslation().x() <<
" "
471 << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() <<
"\n";
473 fout << (*pvcite)->GetName() <<
"_" << (*pvcite)->GetCopyNo() <<
" " << (*pvcite)->GetTranslation().x()
474 <<
" " << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() <<
"\n";
477 fout << (*pvcite)->GetName() <<
"\n";
479 fout << (*pvcite)->GetName() <<
"_" << (*pvcite)->GetCopyNo() <<
"\n";
486 std::vector<std::string> touches;
488 std::sort(touches.begin(), touches.end());
489 for (
const auto &touch : touches)
490 fout << touch <<
"\n";
497 unsigned int leafDepth,
499 std::vector<std::string> &touches) {
506 if (
pv->GetMotherLogical())
507 mother = static_cast<std::string>(dd4hep::dd::noNamespace(
pv->GetMotherLogical()->GetName()));
509 G4LogicalVolume *lv =
pv->GetLogicalVolume();
510 std::string lvname = static_cast<std::string>(dd4hep::dd::noNamespace(lv->GetName()));
511 unsigned int copy = static_cast<unsigned int>(
pv->GetCopyNo());
513 std::string name = lvname +
":" + std::to_string(
copy) +
"_" + mother +
":" + std::to_string(copym);
514 touches.emplace_back(
name);
516 int NoDaughters = lv->GetNoDaughters();
517 while ((NoDaughters--) > 0) {
518 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
519 if (!pvD->IsReplicated())
530 for (
ii = 0;
ii < leafDepth;
ii++) {
537 return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();