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 G4cout <<
"PrintGeomInfoAction:: initialised for dd4hep " <<
dd4hep_ <<
" with verbosity levels:"
76 <<
"for " <<
names_.size() <<
" names:";
77 for (
unsigned int i = 0;
i <
names_.size();
i++)
88 (*job)()->get<IdealGeometryRecord>().get(pDD);
90 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes "
91 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
92 for (
unsigned int i = 0;
i <
names_.size();
i++) {
96 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for ReadOutName = " <<
sd << G4endl;
97 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
104 auto lvname = fv.
name();
105 unsigned int leafDepth =
copy.size();
106 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
107 for (
unsigned int k = 0;
k < leafDepth; ++
k)
109 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")"
115 (*job)()->get<IdealGeometryRecord>().get(pDD);
117 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes "
118 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
119 for (
unsigned int i = 0;
i <
names_.size();
i++) {
124 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for " << attribute <<
" = " <<
sd << G4endl;
125 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
136 unsigned int leafDepth =
copy.size();
137 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
138 for (
int k = leafDepth - 1;
k >= 0;
k--)
140 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")"
172 out <<
" @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
174 out <<
" No volume created " << G4endl;
177 out <<
" @@@ Geometry built inside world volume: " <<
theTopPV_->GetName() << G4endl;
179 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
180 std::vector<G4LogicalVolume *>::const_iterator lvcite;
181 std::set<G4VSolid *> theSolids;
182 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
183 theSolids.insert((*lvcite)->GetSolid());
184 out <<
" Number of G4VSolid's: " << theSolids.size() << G4endl;
185 out <<
" Number of G4LogicalVolume's: " << lvs->size() << G4endl;
186 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
187 out <<
" Number of G4VPhysicalVolume's: " <<
pvs->size() << G4endl;
189 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
190 out <<
" Number of G4Material's: " << matTab->size() << G4endl;
194 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List " << G4endl;
195 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
196 std::vector<G4LogicalVolume *>::const_iterator lvcite;
197 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
198 out <<
"LV:" << (*lvcite)->GetName() <<
"\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << G4endl;
202 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << G4endl;
208 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
209 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
210 out <<
" with " << matTab->size() <<
" materials " << G4endl;
211 std::vector<G4Material *>::const_iterator matite;
212 for (matite = matTab->begin(); matite != matTab->end(); matite++)
213 out <<
"Material: " << (*matite) << G4endl;
217 unsigned int leafDepth,
220 for (
unsigned int ii = 0;
ii < leafDepth;
ii++)
222 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" <<
count <<
")" << G4endl;
224 std::map<G4LogicalVolume *, unsigned int> lvCount;
225 std::map<G4LogicalVolume *, unsigned int>::const_iterator cite;
226 int siz = lv->GetNoDaughters();
227 for (
int ii = 0;
ii < siz;
ii++) {
228 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
229 if (cite != lvCount.end())
230 lvCount[cite->first] = (cite->second) + 1;
232 lvCount.insert(std::pair<G4LogicalVolume *, unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(), 1));
234 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
246 int siz = lv->GetNoDaughters();
247 for (
int ii = 0;
ii < siz;
ii++)
258 G4LogicalVolume *topLV =
getTopLV();
275 std::set<G4LogicalVolume *> lvDaughters;
276 int NoDaughters = lv->GetNoDaughters();
277 while ((NoDaughters--) > 0) {
278 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
280 lvDaughters.insert(pvD->GetLogicalVolume());
283 std::set<G4LogicalVolume *>::const_iterator scite;
284 mmlvpv::const_iterator mmcite;
287 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
288 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
290 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
291 dumpPV((*mmcite).second, leafDepth + 1,
out);
302 out << leafDepth << spaces <<
"$$$ VOLUME = " << lv->GetName() <<
" Solid: " << lv->GetSolid()->GetName()
303 <<
" MATERIAL: " << lv->GetMaterial()->GetName() << G4endl;
311 const G4VisAttributes *fVA = lv->GetVisAttributes();
312 if (fVA !=
nullptr) {
313 out << spaces <<
" VISUALISATION ATTRIBUTES: " << G4endl;
314 out << spaces <<
" IsVisible " << fVA->IsVisible() << G4endl;
315 out << spaces <<
" IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << G4endl;
316 out << spaces <<
" Colour " << fVA->GetColour() << G4endl;
317 out << spaces <<
" LineStyle " << fVA->GetLineStyle() << G4endl;
318 out << spaces <<
" LineWidth " << fVA->GetLineWidth() << G4endl;
319 out << spaces <<
" IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << G4endl;
320 out << spaces <<
" ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << G4endl;
324 G4UserLimits *fUL = lv->GetUserLimits();
326 if (fUL !=
nullptr) {
327 out << spaces <<
" MaxAllowedStep " << fUL->GetMaxAllowedStep(
dummy) << G4endl;
328 out << spaces <<
" UserMaxTrackLength " << fUL->GetUserMaxTrackLength(
dummy) << G4endl;
329 out << spaces <<
" UserMaxTime " << fUL->GetUserMaxTime(
dummy) << G4endl;
330 out << spaces <<
" UserMinEkine " << fUL->GetUserMinEkine(
dummy) << G4endl;
331 out << spaces <<
" UserMinRange " << fUL->GetUserMinRange(
dummy) << G4endl;
335 if (lv->GetSensitiveDetector())
336 out << spaces <<
" IS SENSITIVE DETECTOR " << G4endl;
337 if (lv->GetFieldManager())
338 out << spaces <<
" FIELD ON " << G4endl;
341 out << spaces <<
" Quality for optimisation, average number of voxels to be spent per content "
342 << lv->GetSmartless() << G4endl;
345 if (lv->GetFastSimulationManager())
346 out << spaces <<
" Logical Volume is an envelope for a FastSimulationManager " << G4endl;
347 out << spaces <<
" Weight used in the event biasing technique = " << lv->GetBiasWeight() << G4endl;
358 if (
pv->GetMotherLogical())
359 mother =
pv->GetMotherLogical()->GetName();
360 out << leafDepth << spaces <<
"### VOLUME = " <<
pv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
361 <<
" at " <<
pv->GetTranslation();
363 if (!
pv->IsReplicated()) {
365 if (
pv->GetRotation() ==
nullptr)
366 out <<
" with no rotation" << G4endl;
368 out <<
" with rotation" << G4endl;
370 out <<
" with rotation " << *(
pv->GetRotation()) << G4endl;
374 out << spaces <<
" It is replica: " << G4endl;
380 pv->GetReplicationData(axis, nReplicas,
width,
offset, consuming);
381 out << spaces <<
" axis " << axis << G4endl << spaces <<
" nReplicas " << nReplicas << G4endl;
382 if (
pv->GetParameterisation() !=
nullptr)
383 out << spaces <<
" It is parameterisation " << G4endl;
385 out << spaces <<
" width " <<
width << G4endl << spaces <<
" offset " <<
offset << G4endl << spaces
386 <<
" consuming" << consuming << G4endl;
387 if (
pv->GetParameterisation() !=
nullptr)
388 out << spaces <<
" It is parameterisation " << G4endl;
395 out << spaces << *(sol) << G4endl;
405 G4ThreeVector globalpoint =
fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
406 G4LogicalVolume *lv =
pv->GetLogicalVolume();
409 if (
pv->GetMotherLogical())
410 mother =
pv->GetMotherLogical()->GetName();
412 lvname.assign(lvname, 0,
nchar_);
414 out << leafDepth << spaces <<
"### VOLUME = " << lv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
415 <<
" global position of centre " << globalpoint <<
" (r = " << globalpoint.perp()
418 int NoDaughters = lv->GetNoDaughters();
419 while ((NoDaughters--) > 0) {
420 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
421 if (!pvD->IsReplicated())
433 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
435 for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++)
436 fout << (*matite)->GetName() <<
"\n";
439 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
442 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
443 fout << (*lvcite)->GetSolid()->GetName() <<
"\n";
448 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
449 fout << (*lvcite)->GetName() <<
"\n";
453 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
455 for (std::vector<G4VPhysicalVolume *>::const_iterator pvcite =
pvs->begin(); pvcite !=
pvs->end(); pvcite++) {
457 fout << (*pvcite)->GetName() <<
"\n";
459 fout << (*pvcite)->GetName() <<
"_" << (*pvcite)->GetCopyNo() <<
"\n";
465 std::vector<std::string> touches;
467 std::sort(touches.begin(), touches.end());
468 for (
const auto &touch : touches)
469 fout << touch <<
"\n";
476 unsigned int leafDepth,
478 std::vector<std::string> &touches) {
485 if (
pv->GetMotherLogical())
486 mother = static_cast<std::string>(dd4hep::dd::noNamespace(
pv->GetMotherLogical()->GetName()));
488 G4LogicalVolume *lv =
pv->GetLogicalVolume();
489 std::string lvname = static_cast<std::string>(dd4hep::dd::noNamespace(lv->GetName()));
490 unsigned int copy = static_cast<unsigned int>(
pv->GetCopyNo());
492 std::string name = lvname +
":" + std::to_string(
copy) +
"_" + mother +
":" + std::to_string(copym);
493 touches.emplace_back(
name);
495 int NoDaughters = lv->GetNoDaughters();
496 while ((NoDaughters--) > 0) {
497 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
498 if (!pvD->IsReplicated())
509 for (
ii = 0;
ii < leafDepth;
ii++) {
516 return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();