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" 27 #include "G4Region.hh" 28 #include "G4RegionStore.hh" 31 #include "G4TransportationManager.hh" 32 #include "G4UserLimits.hh" 33 #include "G4VisAttributes.hh" 34 #include "G4VPhysicalVolume.hh" 45 typedef std::multimap<G4LogicalVolume *, G4VPhysicalVolume *, std::less<G4LogicalVolume *> >
mmlvpv;
67 void dumpLV(G4LogicalVolume *lv,
unsigned int leafDepth, std::ostream &
out =
G4cout);
68 void dumpPV(G4VPhysicalVolume *
pv,
unsigned int leafDepth, std::ostream &
out =
G4cout);
72 void getTouch(G4VPhysicalVolume *
pv,
unsigned int leafDepth,
unsigned int copym, std::vector<std::string> &touches);
95 dumpSummary_ =
p.getUntrackedParameter<
bool>(
"DumpSummary",
true);
96 dumpLVTree_ =
p.getUntrackedParameter<
bool>(
"DumpLVTree",
true);
97 dumpLVList_ =
p.getUntrackedParameter<
bool>(
"DumpLVList",
false);
98 dumpMaterial_ =
p.getUntrackedParameter<
bool>(
"DumpMaterial",
false);
99 dumpLV_ =
p.getUntrackedParameter<
bool>(
"DumpLV",
false);
100 dumpSolid_ =
p.getUntrackedParameter<
bool>(
"DumpSolid",
false);
101 dumpAtts_ =
p.getUntrackedParameter<
bool>(
"DumpAttributes",
false);
102 dumpPV_ =
p.getUntrackedParameter<
bool>(
"DumpPV",
false);
103 dumpRotation_ =
p.getUntrackedParameter<
bool>(
"DumpRotation",
false);
104 dumpReplica_ =
p.getUntrackedParameter<
bool>(
"DumpReplica",
false);
105 dumpTouch_ =
p.getUntrackedParameter<
bool>(
"DumpTouch",
false);
106 dumpSense_ =
p.getUntrackedParameter<
bool>(
"DumpSense",
false);
107 dumpParams_ =
p.getUntrackedParameter<
bool>(
"DumpParams",
false);
108 dumpRegion_ =
p.getUntrackedParameter<
bool>(
"DumpRegion",
false);
109 dd4hep_ =
p.getUntrackedParameter<
bool>(
"DD4hep",
false);
111 names_ =
p.getUntrackedParameter<std::vector<std::string> >(
"Names");
118 fileDetail_ =
p.getUntrackedParameter<
bool>(
"FileDetail",
false);
121 G4cout <<
"PrintGeomInfoAction:: initialised for dd4hep " <<
dd4hep_ <<
" with verbosity levels:" 132 <<
" for " <<
names_.size() <<
" names:";
133 for (
unsigned int i = 0;
i <
names_.size();
i++)
141 G4cout <<
"PrintGeomInfoAction::Initialize ESGetToken for cms::DDCompactView" << G4endl;
144 G4cout <<
"PrintGeomInfoAction::Initialize ESGetToken for DDCompactView" << G4endl;
153 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes " 154 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
155 for (
unsigned int i = 0;
i <
names_.size();
i++) {
159 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for ReadOutName = " << sd << G4endl;
160 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
167 auto lvname = fv.
name();
168 unsigned int leafDepth =
copy.size();
169 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
170 for (
unsigned int k = 0;
k < leafDepth; ++
k)
176 G4cout << std::setprecision(5);
178 G4cout << std::setprecision(6);
183 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi())
191 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes " 192 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
193 for (
unsigned int i = 0;
i <
names_.size();
i++) {
198 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for " << attribute <<
" = " << sd << G4endl;
199 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
210 unsigned int leafDepth =
copy.size();
211 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
212 for (
int k = leafDepth - 1;
k >= 0;
k--)
214 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")" 251 out <<
" @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
253 out <<
" No volume created " << G4endl;
256 out <<
" @@@ Geometry built inside world volume: " <<
theTopPV_->GetName() << G4endl;
258 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
259 std::vector<G4LogicalVolume *>::const_iterator lvcite;
260 std::set<G4VSolid *> theSolids;
261 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
262 theSolids.insert((*lvcite)->GetSolid());
263 out <<
" Number of G4VSolid's: " << theSolids.size() << G4endl;
264 out <<
" Number of G4LogicalVolume's: " << lvs->size() << G4endl;
265 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
266 out <<
" Number of G4VPhysicalVolume's: " <<
pvs->size() << G4endl;
268 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
269 out <<
" Number of G4Material's: " << matTab->size() << G4endl;
270 const G4RegionStore *regs = G4RegionStore::GetInstance();
271 out <<
" Number of G4Region's: " << regs->size() << G4endl;
275 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List " << G4endl;
276 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
277 std::vector<G4LogicalVolume *>::const_iterator lvcite;
278 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
279 out <<
"LV:" << (*lvcite)->GetName() <<
"\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << G4endl;
283 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << G4endl;
289 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Region Tree " << G4endl;
290 const G4RegionStore *regs = G4RegionStore::GetInstance();
291 std::vector<G4Region *>::const_iterator regite;
292 for (regite = regs->begin(); regite != regs->end(); regite++)
293 out <<
"Region: " << (*regite)->GetName() <<
" with " << (*regite)->GetNumberOfMaterials() <<
" materials and " 294 << (*regite)->GetNumberOfRootVolumes() <<
" root volumes" << G4endl;
298 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
299 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
300 out <<
" with " << matTab->size() <<
" materials " << G4endl;
301 std::vector<G4Material *>::const_iterator matite;
302 for (matite = matTab->begin(); matite != matTab->end(); matite++)
303 out <<
"Material: " << (*matite) << G4endl;
307 unsigned int leafDepth,
310 for (
unsigned int ii = 0;
ii < leafDepth;
ii++)
312 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" <<
count <<
")" << G4endl;
314 std::map<G4LogicalVolume *, unsigned int> lvCount;
315 std::map<G4LogicalVolume *, unsigned int>::const_iterator cite;
316 int siz = lv->GetNoDaughters();
317 for (
int ii = 0;
ii < siz;
ii++) {
318 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
319 if (cite != lvCount.end())
320 lvCount[cite->first] = (cite->second) + 1;
322 lvCount.insert(std::pair<G4LogicalVolume *, unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(), 1));
324 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
336 int siz = lv->GetNoDaughters();
337 for (
int ii = 0;
ii < siz;
ii++)
348 G4LogicalVolume *topLV =
getTopLV();
365 std::set<G4LogicalVolume *> lvDaughters;
366 int NoDaughters = lv->GetNoDaughters();
367 while ((NoDaughters--) > 0) {
368 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
370 lvDaughters.insert(pvD->GetLogicalVolume());
373 std::set<G4LogicalVolume *>::const_iterator scite;
374 mmlvpv::const_iterator mmcite;
377 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
378 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
380 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
381 dumpPV((*mmcite).second, leafDepth + 1,
out);
392 out << leafDepth << spaces <<
"$$$ VOLUME = " << lv->GetName() <<
" Solid: " << lv->GetSolid()->GetName()
393 <<
" MATERIAL: " << lv->GetMaterial()->GetName() << G4endl;
401 const G4VisAttributes *fVA = lv->GetVisAttributes();
402 if (fVA !=
nullptr) {
403 out << spaces <<
" VISUALISATION ATTRIBUTES: " << G4endl;
404 out << spaces <<
" IsVisible " << fVA->IsVisible() << G4endl;
405 out << spaces <<
" IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << G4endl;
406 out << spaces <<
" Colour " << fVA->GetColour() << G4endl;
407 out << spaces <<
" LineStyle " << fVA->GetLineStyle() << G4endl;
408 out << spaces <<
" LineWidth " << fVA->GetLineWidth() << G4endl;
409 out << spaces <<
" IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << G4endl;
410 out << spaces <<
" ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << G4endl;
414 G4UserLimits *fUL = lv->GetUserLimits();
416 if (fUL !=
nullptr) {
417 out << spaces <<
" MaxAllowedStep " << fUL->GetMaxAllowedStep(
dummy) << G4endl;
418 out << spaces <<
" UserMaxTrackLength " << fUL->GetUserMaxTrackLength(
dummy) << G4endl;
419 out << spaces <<
" UserMaxTime " << fUL->GetUserMaxTime(
dummy) << G4endl;
420 out << spaces <<
" UserMinEkine " << fUL->GetUserMinEkine(
dummy) << G4endl;
421 out << spaces <<
" UserMinRange " << fUL->GetUserMinRange(
dummy) << G4endl;
425 if (lv->GetSensitiveDetector())
426 out << spaces <<
" IS SENSITIVE DETECTOR " << G4endl;
427 if (lv->GetFieldManager())
428 out << spaces <<
" FIELD ON " << G4endl;
431 out << spaces <<
" Quality for optimisation, average number of voxels to be spent per content " 432 << lv->GetSmartless() << G4endl;
435 if (lv->GetFastSimulationManager())
436 out << spaces <<
" Logical Volume is an envelope for a FastSimulationManager " << G4endl;
437 out << spaces <<
" Weight used in the event biasing technique = " << lv->GetBiasWeight() << G4endl;
448 if (
pv->GetMotherLogical())
449 mother =
pv->GetMotherLogical()->GetName();
450 out << leafDepth << spaces <<
"### VOLUME = " <<
pv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
451 <<
" at " <<
pv->GetTranslation();
453 if (!
pv->IsReplicated()) {
455 if (
pv->GetRotation() ==
nullptr)
456 out <<
" with no rotation" << G4endl;
458 out <<
" with rotation" << G4endl;
460 out <<
" with rotation " << *(
pv->GetRotation()) << G4endl;
464 out << spaces <<
" It is replica: " << G4endl;
470 pv->GetReplicationData(axis, nReplicas,
width,
offset, consuming);
471 out << spaces <<
" axis " << axis << G4endl << spaces <<
" nReplicas " << nReplicas << G4endl;
472 if (
pv->GetParameterisation() !=
nullptr)
473 out << spaces <<
" It is parameterisation " << G4endl;
475 out << spaces <<
" width " <<
width << G4endl << spaces <<
" offset " <<
offset << G4endl << spaces
476 <<
" consuming" << consuming << G4endl;
477 if (
pv->GetParameterisation() !=
nullptr)
478 out << spaces <<
" It is parameterisation " << G4endl;
485 out << spaces << *(
sol) << G4endl;
495 G4ThreeVector globalpoint =
fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
496 G4LogicalVolume *lv =
pv->GetLogicalVolume();
499 if (
pv->GetMotherLogical())
500 mother =
pv->GetMotherLogical()->GetName();
502 lvname.assign(lvname, 0,
nchar_);
504 out << leafDepth << spaces <<
"### VOLUME = " << lv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
505 <<
" global position of centre " << globalpoint <<
" (r = " << globalpoint.perp()
508 int NoDaughters = lv->GetNoDaughters();
509 while ((NoDaughters--) > 0) {
510 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
511 if (!pvD->IsReplicated())
523 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
525 for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++) {
527 fout << (*matite)->GetName() << G4endl;
529 fout << (*matite)->GetName() <<
" " << (*matite)->GetRadlen() <<
" " << (*matite)->GetNuclearInterLength()
534 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
537 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
539 fout << (*lvcite)->GetSolid()->GetName() << G4endl;
541 fout << (*lvcite)->GetSolid()->GetName() <<
" " << (*lvcite)->GetSolid()->GetCubicVolume() << G4endl;
546 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
548 fout << (*lvcite)->GetName() << G4endl;
550 fout << (*lvcite)->GetName() <<
" " << (*lvcite)->GetMass(
false,
false) << G4endl;
554 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
556 for (std::vector<G4VPhysicalVolume *>::const_iterator pvcite =
pvs->begin(); pvcite !=
pvs->end(); pvcite++) {
559 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetTranslation().x() <<
" " 560 << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() << G4endl;
562 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetCopyNo() <<
" " << (*pvcite)->GetTranslation().x()
563 <<
" " << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() << G4endl;
566 fout << (*pvcite)->GetName() << G4endl;
568 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetCopyNo() << G4endl;
575 std::vector<std::string> touches;
577 std::sort(touches.begin(), touches.end());
578 for (
const auto &touch : touches)
579 fout << touch << G4endl;
583 const G4RegionStore *regs = G4RegionStore::GetInstance();
585 for (std::vector<G4Region *>::const_iterator regite = regs->begin(); regite != regs->end(); regite++) {
587 fout << (*regite)->GetName() << G4endl;
589 fout << (*regite)->GetName() <<
" " << (*regite)->GetNumberOfMaterials() <<
" " 590 << (*regite)->GetNumberOfRootVolumes() << G4endl;
598 unsigned int leafDepth,
600 std::vector<std::string> &touches) {
607 if (
pv->GetMotherLogical())
608 mother = static_cast<std::string>(dd4hep::dd::noNamespace(
pv->GetMotherLogical()->GetName()));
610 G4LogicalVolume *lv =
pv->GetLogicalVolume();
612 unsigned int copy =
static_cast<unsigned int>(
pv->GetCopyNo());
615 touches.emplace_back(
name);
617 int NoDaughters = lv->GetNoDaughters();
618 while ((NoDaughters--) > 0) {
619 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
620 if (!pvD->IsReplicated())
631 for (
ii = 0;
ii < leafDepth;
ii++) {
638 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)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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)
uint32_t cc[maxCellsPerHit]
constexpr NumType convertRadToDeg(NumType radians)
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
void dumpG4LVLeaf(G4LogicalVolume *lv, unsigned int leafDepth, unsigned int count, std::ostream &out=G4cout)
G4NavigationHistory fHistory_
Compact representation of the geometrical detector hierarchy.
static std::string to_string(const XMLCh *ch)
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
Abs< T >::type abs(const T &t)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
std::string spacesFromLeafDepth(unsigned int leafDepth)
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()
void dumpG4Region(std::ostream &out=G4cout)
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)
const std::vector< double > parameters() const
extract shape parameters
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
edm::ESGetToken< DDCompactView, IdealGeometryRecord > dddToken_
const Translation translation() const