18 #include "DD4hep/DD4hepUnits.h" 19 #include "DD4hep/Filter.h" 21 #include "G4LogicalVolumeStore.hh" 22 #include "G4LogicalVolume.hh" 23 #include "G4VSolid.hh" 24 #include "G4Material.hh" 25 #include "G4NavigationHistory.hh" 26 #include "G4PhysicalVolumeStore.hh" 29 #include "G4TransportationManager.hh" 30 #include "G4UserLimits.hh" 31 #include "G4VisAttributes.hh" 32 #include "G4VPhysicalVolume.hh" 43 typedef std::multimap<G4LogicalVolume *, G4VPhysicalVolume *, std::less<G4LogicalVolume *> >
mmlvpv;
64 void dumpLV(G4LogicalVolume *lv,
unsigned int leafDepth, std::ostream &
out =
G4cout);
65 void dumpPV(G4VPhysicalVolume *
pv,
unsigned int leafDepth, std::ostream &
out =
G4cout);
69 void getTouch(G4VPhysicalVolume *
pv,
unsigned int leafDepth,
unsigned int copym, std::vector<std::string> &touches);
92 dumpSummary_ =
p.getUntrackedParameter<
bool>(
"DumpSummary",
true);
93 dumpLVTree_ =
p.getUntrackedParameter<
bool>(
"DumpLVTree",
true);
94 dumpLVList_ =
p.getUntrackedParameter<
bool>(
"DumpLVList",
false);
95 dumpMaterial_ =
p.getUntrackedParameter<
bool>(
"DumpMaterial",
false);
96 dumpLV_ =
p.getUntrackedParameter<
bool>(
"DumpLV",
false);
97 dumpSolid_ =
p.getUntrackedParameter<
bool>(
"DumpSolid",
false);
98 dumpAtts_ =
p.getUntrackedParameter<
bool>(
"DumpAttributes",
false);
99 dumpPV_ =
p.getUntrackedParameter<
bool>(
"DumpPV",
false);
100 dumpRotation_ =
p.getUntrackedParameter<
bool>(
"DumpRotation",
false);
101 dumpReplica_ =
p.getUntrackedParameter<
bool>(
"DumpReplica",
false);
102 dumpTouch_ =
p.getUntrackedParameter<
bool>(
"DumpTouch",
false);
103 dumpSense_ =
p.getUntrackedParameter<
bool>(
"DumpSense",
false);
104 dd4hep_ =
p.getUntrackedParameter<
bool>(
"DD4hep",
false);
108 names_ =
p.getUntrackedParameter<std::vector<std::string> >(
"Names");
114 fileDetail_ =
p.getUntrackedParameter<
bool>(
"FileDetail",
false);
115 G4cout <<
"PrintGeomInfoAction:: initialised for dd4hep " <<
dd4hep_ <<
" with verbosity levels:" 126 <<
" for " <<
names_.size() <<
" names:";
127 for (
unsigned int i = 0;
i <
names_.size();
i++)
135 G4cout <<
"PrintGeomInfoAction::Initialize ESGetToken for cms::DDCompactView" << G4endl;
138 G4cout <<
"PrintGeomInfoAction::Initialize ESGetToken for DDCompactView" << G4endl;
147 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes " 148 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
149 for (
unsigned int i = 0;
i <
names_.size();
i++) {
153 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for ReadOutName = " << sd << G4endl;
154 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
161 auto lvname = fv.
name();
162 unsigned int leafDepth =
copy.size();
163 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
164 for (
unsigned int k = 0;
k < leafDepth; ++
k)
166 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")" 173 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes " 174 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
175 for (
unsigned int i = 0;
i <
names_.size();
i++) {
180 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for " << attribute <<
" = " << sd << G4endl;
181 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
192 unsigned int leafDepth =
copy.size();
193 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
194 for (
int k = leafDepth - 1;
k >= 0;
k--)
196 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")" 229 out <<
" @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
231 out <<
" No volume created " << G4endl;
234 out <<
" @@@ Geometry built inside world volume: " <<
theTopPV_->GetName() << G4endl;
236 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
237 std::vector<G4LogicalVolume *>::const_iterator lvcite;
238 std::set<G4VSolid *> theSolids;
239 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
240 theSolids.insert((*lvcite)->GetSolid());
241 out <<
" Number of G4VSolid's: " << theSolids.size() << G4endl;
242 out <<
" Number of G4LogicalVolume's: " << lvs->size() << G4endl;
243 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
244 out <<
" Number of G4VPhysicalVolume's: " <<
pvs->size() << G4endl;
246 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
247 out <<
" Number of G4Material's: " << matTab->size() << G4endl;
251 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List " << G4endl;
252 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
253 std::vector<G4LogicalVolume *>::const_iterator lvcite;
254 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
255 out <<
"LV:" << (*lvcite)->GetName() <<
"\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << G4endl;
259 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << G4endl;
265 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
266 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
267 out <<
" with " << matTab->size() <<
" materials " << G4endl;
268 std::vector<G4Material *>::const_iterator matite;
269 for (matite = matTab->begin(); matite != matTab->end(); matite++)
270 out <<
"Material: " << (*matite) << G4endl;
274 unsigned int leafDepth,
277 for (
unsigned int ii = 0;
ii < leafDepth;
ii++)
279 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" <<
count <<
")" << G4endl;
281 std::map<G4LogicalVolume *, unsigned int> lvCount;
282 std::map<G4LogicalVolume *, unsigned int>::const_iterator cite;
283 int siz = lv->GetNoDaughters();
284 for (
int ii = 0;
ii < siz;
ii++) {
285 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
286 if (cite != lvCount.end())
287 lvCount[cite->first] = (cite->second) + 1;
289 lvCount.insert(std::pair<G4LogicalVolume *, unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(), 1));
291 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
303 int siz = lv->GetNoDaughters();
304 for (
int ii = 0;
ii < siz;
ii++)
315 G4LogicalVolume *topLV =
getTopLV();
332 std::set<G4LogicalVolume *> lvDaughters;
333 int NoDaughters = lv->GetNoDaughters();
334 while ((NoDaughters--) > 0) {
335 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
337 lvDaughters.insert(pvD->GetLogicalVolume());
340 std::set<G4LogicalVolume *>::const_iterator scite;
341 mmlvpv::const_iterator mmcite;
344 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
345 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
347 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
348 dumpPV((*mmcite).second, leafDepth + 1,
out);
359 out << leafDepth << spaces <<
"$$$ VOLUME = " << lv->GetName() <<
" Solid: " << lv->GetSolid()->GetName()
360 <<
" MATERIAL: " << lv->GetMaterial()->GetName() << G4endl;
368 const G4VisAttributes *fVA = lv->GetVisAttributes();
369 if (fVA !=
nullptr) {
370 out << spaces <<
" VISUALISATION ATTRIBUTES: " << G4endl;
371 out << spaces <<
" IsVisible " << fVA->IsVisible() << G4endl;
372 out << spaces <<
" IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << G4endl;
373 out << spaces <<
" Colour " << fVA->GetColour() << G4endl;
374 out << spaces <<
" LineStyle " << fVA->GetLineStyle() << G4endl;
375 out << spaces <<
" LineWidth " << fVA->GetLineWidth() << G4endl;
376 out << spaces <<
" IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << G4endl;
377 out << spaces <<
" ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << G4endl;
381 G4UserLimits *fUL = lv->GetUserLimits();
383 if (fUL !=
nullptr) {
384 out << spaces <<
" MaxAllowedStep " << fUL->GetMaxAllowedStep(
dummy) << G4endl;
385 out << spaces <<
" UserMaxTrackLength " << fUL->GetUserMaxTrackLength(
dummy) << G4endl;
386 out << spaces <<
" UserMaxTime " << fUL->GetUserMaxTime(
dummy) << G4endl;
387 out << spaces <<
" UserMinEkine " << fUL->GetUserMinEkine(
dummy) << G4endl;
388 out << spaces <<
" UserMinRange " << fUL->GetUserMinRange(
dummy) << G4endl;
392 if (lv->GetSensitiveDetector())
393 out << spaces <<
" IS SENSITIVE DETECTOR " << G4endl;
394 if (lv->GetFieldManager())
395 out << spaces <<
" FIELD ON " << G4endl;
398 out << spaces <<
" Quality for optimisation, average number of voxels to be spent per content " 399 << lv->GetSmartless() << G4endl;
402 if (lv->GetFastSimulationManager())
403 out << spaces <<
" Logical Volume is an envelope for a FastSimulationManager " << G4endl;
404 out << spaces <<
" Weight used in the event biasing technique = " << lv->GetBiasWeight() << G4endl;
415 if (
pv->GetMotherLogical())
416 mother =
pv->GetMotherLogical()->GetName();
417 out << leafDepth << spaces <<
"### VOLUME = " <<
pv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
418 <<
" at " <<
pv->GetTranslation();
420 if (!
pv->IsReplicated()) {
422 if (
pv->GetRotation() ==
nullptr)
423 out <<
" with no rotation" << G4endl;
425 out <<
" with rotation" << G4endl;
427 out <<
" with rotation " << *(
pv->GetRotation()) << G4endl;
431 out << spaces <<
" It is replica: " << G4endl;
437 pv->GetReplicationData(axis, nReplicas,
width,
offset, consuming);
438 out << spaces <<
" axis " << axis << G4endl << spaces <<
" nReplicas " << nReplicas << G4endl;
439 if (
pv->GetParameterisation() !=
nullptr)
440 out << spaces <<
" It is parameterisation " << G4endl;
442 out << spaces <<
" width " <<
width << G4endl << spaces <<
" offset " <<
offset << G4endl << spaces
443 <<
" consuming" << consuming << G4endl;
444 if (
pv->GetParameterisation() !=
nullptr)
445 out << spaces <<
" It is parameterisation " << G4endl;
452 out << spaces << *(
sol) << G4endl;
462 G4ThreeVector globalpoint =
fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
463 G4LogicalVolume *lv =
pv->GetLogicalVolume();
466 if (
pv->GetMotherLogical())
467 mother =
pv->GetMotherLogical()->GetName();
469 lvname.assign(lvname, 0,
nchar_);
471 out << leafDepth << spaces <<
"### VOLUME = " << lv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
472 <<
" global position of centre " << globalpoint <<
" (r = " << globalpoint.perp()
475 int NoDaughters = lv->GetNoDaughters();
476 while ((NoDaughters--) > 0) {
477 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
478 if (!pvD->IsReplicated())
490 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
492 for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++) {
494 fout << (*matite)->GetName() << G4endl;
496 fout << (*matite)->GetName() <<
" " << (*matite)->GetRadlen() <<
" " << (*matite)->GetNuclearInterLength()
501 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
504 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
506 fout << (*lvcite)->GetSolid()->GetName() << G4endl;
508 fout << (*lvcite)->GetSolid()->GetName() <<
" " << (*lvcite)->GetSolid()->GetCubicVolume() << G4endl;
513 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
515 fout << (*lvcite)->GetName() << G4endl;
517 fout << (*lvcite)->GetName() <<
" " << (*lvcite)->GetMass(
false,
false) << G4endl;
521 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
523 for (std::vector<G4VPhysicalVolume *>::const_iterator pvcite =
pvs->begin(); pvcite !=
pvs->end(); pvcite++) {
526 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetTranslation().x() <<
" " 527 << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() << G4endl;
529 fout << (*pvcite)->GetName() <<
"_" << (*pvcite)->GetCopyNo() <<
" " << (*pvcite)->GetTranslation().x()
530 <<
" " << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() << G4endl;
533 fout << (*pvcite)->GetName() << G4endl;
535 fout << (*pvcite)->GetName() <<
"_" << (*pvcite)->GetCopyNo() << G4endl;
542 std::vector<std::string> touches;
544 std::sort(touches.begin(), touches.end());
545 for (
const auto &touch : touches)
546 fout << touch << G4endl;
553 unsigned int leafDepth,
555 std::vector<std::string> &touches) {
562 if (
pv->GetMotherLogical())
563 mother = static_cast<std::string>(dd4hep::dd::noNamespace(
pv->GetMotherLogical()->GetName()));
565 G4LogicalVolume *lv =
pv->GetLogicalVolume();
567 unsigned int copy =
static_cast<unsigned int>(
pv->GetCopyNo());
570 touches.emplace_back(
name);
572 int NoDaughters = lv->GetNoDaughters();
573 while ((NoDaughters--) > 0) {
574 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
575 if (!pvD->IsReplicated())
586 for (
ii = 0;
ii < leafDepth;
ii++) {
593 return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
void add1touchable(G4LogicalVolume *lv, int &nTouch)
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
#define DEFINE_SIMWATCHER(type)
PrintGeomInfoAction(edm::ParameterSet const &p)
nav_type copyNumbers() const
return the stack of copy numbers
G4VPhysicalVolume * theTopPV_
void dumpSolid(G4VSolid *sol, unsigned int leafDepth, std::ostream &out=G4cout)
const std::vector< int > copyNos() const
The list of the volume copy numbers.
void getTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, unsigned int copym, std::vector< std::string > &touches)
constexpr NumType convertRadToDeg(NumType radians)
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
std::string to_string(const V &value)
void dumpG4LVLeaf(G4LogicalVolume *lv, unsigned int leafDepth, unsigned int count, std::ostream &out=G4cout)
G4NavigationHistory fHistory_
Compact representation of the geometrical detector hierarchy.
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
std::vector< std::string > names_
std::string_view name() const
void dumpG4LVTree(std::ostream &out=G4cout)
Container::value_type value_type
bool next()
set current node to the next node in the filtered tree
void dumpPV(G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=G4cout)
void dumpSummary(std::ostream &out=G4cout)
void registerConsumes(edm::ConsumesCollector) override
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
std::string spacesFromLeafDepth(unsigned int leafDepth)
bool getData(T &iHolder) const
bool firstChild()
set the current node to the first child
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=G4cout)
G4VPhysicalVolume * getTopPV()
void dumpLV(G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &out=G4cout)
G4LogicalVolume * getTopLV()
bool firstChild()
set the current node to the first child ...
void beginRun(edm::EventSetup const &) override
void dumpMaterialList(std::ostream &out=G4cout)
void dumpHierarchyLeafPVLV(G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &out=G4cout)
void dumpG4LVList(std::ostream &out=G4cout)
const DDTranslation & translation() const
The absolute translation of the current node.
~PrintGeomInfoAction() override=default
void dumpHierarchyTreePVLV(std::ostream &out=G4cout)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
edm::ESGetToken< DDCompactView, IdealGeometryRecord > dddToken_
const Translation translation() const