19 #include "DD4hep/DD4hepUnits.h" 20 #include "DD4hep/Filter.h" 22 #include "G4LogicalVolumeStore.hh" 23 #include "G4LogicalVolume.hh" 24 #include "G4VSolid.hh" 25 #include "G4Material.hh" 26 #include "G4NavigationHistory.hh" 27 #include "G4PhysicalVolumeStore.hh" 28 #include "G4Region.hh" 29 #include "G4RegionStore.hh" 32 #include "G4TransportationManager.hh" 33 #include "G4UserLimits.hh" 34 #include "G4VisAttributes.hh" 35 #include "G4VPhysicalVolume.hh" 46 typedef std::multimap<G4LogicalVolume *, G4VPhysicalVolume *, std::less<G4LogicalVolume *> >
mmlvpv;
68 void dumpLV(G4LogicalVolume *lv,
unsigned int leafDepth, std::ostream &
out =
G4cout);
69 void dumpPV(G4VPhysicalVolume *
pv,
unsigned int leafDepth, std::ostream &
out =
G4cout);
73 void getTouch(G4VPhysicalVolume *
pv,
unsigned int leafDepth,
unsigned int copym, std::vector<std::string> &touches);
96 dumpSummary_ =
p.getUntrackedParameter<
bool>(
"DumpSummary",
true);
97 dumpLVTree_ =
p.getUntrackedParameter<
bool>(
"DumpLVTree",
true);
98 dumpLVList_ =
p.getUntrackedParameter<
bool>(
"DumpLVList",
false);
99 dumpMaterial_ =
p.getUntrackedParameter<
bool>(
"DumpMaterial",
false);
100 dumpLV_ =
p.getUntrackedParameter<
bool>(
"DumpLV",
false);
101 dumpSolid_ =
p.getUntrackedParameter<
bool>(
"DumpSolid",
false);
102 dumpAtts_ =
p.getUntrackedParameter<
bool>(
"DumpAttributes",
false);
103 dumpPV_ =
p.getUntrackedParameter<
bool>(
"DumpPV",
false);
104 dumpRotation_ =
p.getUntrackedParameter<
bool>(
"DumpRotation",
false);
105 dumpReplica_ =
p.getUntrackedParameter<
bool>(
"DumpReplica",
false);
106 dumpTouch_ =
p.getUntrackedParameter<
bool>(
"DumpTouch",
false);
107 dumpSense_ =
p.getUntrackedParameter<
bool>(
"DumpSense",
false);
108 dumpParams_ =
p.getUntrackedParameter<
bool>(
"DumpParams",
false);
109 dumpRegion_ =
p.getUntrackedParameter<
bool>(
"DumpRegion",
false);
110 dd4hep_ =
p.getUntrackedParameter<
bool>(
"DD4hep",
false);
112 names_ =
p.getUntrackedParameter<std::vector<std::string> >(
"Names");
119 fileDetail_ =
p.getUntrackedParameter<
bool>(
"FileDetail",
false);
122 G4cout <<
"PrintGeomInfoAction:: initialised for dd4hep " <<
dd4hep_ <<
" with verbosity levels:" 133 <<
" for " <<
names_.size() <<
" names:";
134 for (
unsigned int i = 0;
i <
names_.size();
i++)
142 G4cout <<
"PrintGeomInfoAction::Initialize ESGetToken for cms::DDCompactView" << G4endl;
145 G4cout <<
"PrintGeomInfoAction::Initialize ESGetToken for DDCompactView" << G4endl;
154 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes " 155 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
156 for (
unsigned int i = 0;
i <
names_.size();
i++) {
160 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for ReadOutName = " << sd << G4endl;
161 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
168 auto lvname = fv.
name();
169 unsigned int leafDepth =
copy.size();
170 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
171 for (
unsigned int k = 0;
k < leafDepth; ++
k)
177 G4cout << std::setprecision(5);
179 G4cout << std::setprecision(6);
184 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi())
192 G4cout <<
"PrintGeomInfoAction::Get Printout of Sensitive Volumes " 193 <<
"for " <<
names_.size() <<
" Readout Units" << G4endl;
194 for (
unsigned int i = 0;
i <
names_.size();
i++) {
199 G4cout <<
"PrintGeomInfoAction:: Get Filtered view for " << attribute <<
" = " << sd << G4endl;
200 G4cout <<
"Lengths are in mm, angles in degrees" << G4endl;
211 unsigned int leafDepth =
copy.size();
212 G4cout << leafDepth << spaces <<
"### VOLUME = " << lvname <<
" Copy No";
213 for (
int k = leafDepth - 1;
k >= 0;
k--)
215 G4cout <<
" Centre at " << tran <<
" (r = " << tran.Rho() <<
", phi = " <<
convertRadToDeg(tran.phi()) <<
")" 252 out <<
" @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
254 out <<
" No volume created " << G4endl;
257 out <<
" @@@ Geometry built inside world volume: " <<
theTopPV_->GetName() << G4endl;
259 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
260 std::vector<G4LogicalVolume *>::const_iterator lvcite;
261 std::set<G4VSolid *> theSolids;
262 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
263 theSolids.insert((*lvcite)->GetSolid());
264 out <<
" Number of G4VSolid's: " << theSolids.size() << G4endl;
265 out <<
" Number of G4LogicalVolume's: " << lvs->size() << G4endl;
266 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
267 out <<
" Number of G4VPhysicalVolume's: " <<
pvs->size() << G4endl;
269 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
270 out <<
" Number of G4Material's: " << matTab->size() << G4endl;
271 const G4RegionStore *regs = G4RegionStore::GetInstance();
272 out <<
" Number of G4Region's: " << regs->size() << G4endl;
276 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List " << G4endl;
277 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
278 std::vector<G4LogicalVolume *>::const_iterator lvcite;
279 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
280 out <<
"LV:" << (*lvcite)->GetName() <<
"\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << G4endl;
284 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << G4endl;
290 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Region Tree " << G4endl;
291 const G4RegionStore *regs = G4RegionStore::GetInstance();
292 std::vector<G4Region *>::const_iterator regite;
293 for (regite = regs->begin(); regite != regs->end(); regite++)
294 out <<
"Region: " << (*regite)->GetName() <<
" with " << (*regite)->GetNumberOfMaterials() <<
" materials and " 295 << (*regite)->GetNumberOfRootVolumes() <<
" root volumes" << G4endl;
299 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
300 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
301 out <<
" with " << matTab->size() <<
" materials " << G4endl;
302 std::vector<G4Material *>::const_iterator matite;
303 for (matite = matTab->begin(); matite != matTab->end(); matite++)
304 out <<
"Material: " << (*matite) << G4endl;
308 unsigned int leafDepth,
311 for (
unsigned int ii = 0;
ii < leafDepth;
ii++)
313 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" <<
count <<
")" << G4endl;
315 std::map<G4LogicalVolume *, unsigned int> lvCount;
316 std::map<G4LogicalVolume *, unsigned int>::const_iterator cite;
317 int siz = lv->GetNoDaughters();
318 for (
int ii = 0;
ii < siz;
ii++) {
319 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
320 if (cite != lvCount.end())
321 lvCount[cite->first] = (cite->second) + 1;
323 lvCount.insert(std::pair<G4LogicalVolume *, unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(), 1));
325 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
337 int siz = lv->GetNoDaughters();
338 for (
int ii = 0;
ii < siz;
ii++)
349 G4LogicalVolume *topLV =
getTopLV();
366 std::set<G4LogicalVolume *> lvDaughters;
367 int NoDaughters = lv->GetNoDaughters();
368 while ((NoDaughters--) > 0) {
369 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
371 lvDaughters.insert(pvD->GetLogicalVolume());
374 std::set<G4LogicalVolume *>::const_iterator scite;
375 mmlvpv::const_iterator mmcite;
378 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
379 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
381 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
382 dumpPV((*mmcite).second, leafDepth + 1,
out);
393 out << leafDepth << spaces <<
"$$$ VOLUME = " << lv->GetName() <<
" Solid: " << lv->GetSolid()->GetName()
394 <<
" MATERIAL: " << lv->GetMaterial()->GetName() << G4endl;
402 const G4VisAttributes *fVA = lv->GetVisAttributes();
403 if (fVA !=
nullptr) {
404 out << spaces <<
" VISUALISATION ATTRIBUTES: " << G4endl;
405 out << spaces <<
" IsVisible " << fVA->IsVisible() << G4endl;
406 out << spaces <<
" IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << G4endl;
407 out << spaces <<
" Colour " << fVA->GetColour() << G4endl;
408 out << spaces <<
" LineStyle " << fVA->GetLineStyle() << G4endl;
409 out << spaces <<
" LineWidth " << fVA->GetLineWidth() << G4endl;
410 out << spaces <<
" IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << G4endl;
411 out << spaces <<
" ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << G4endl;
415 G4UserLimits *fUL = lv->GetUserLimits();
417 if (fUL !=
nullptr) {
418 out << spaces <<
" MaxAllowedStep " << fUL->GetMaxAllowedStep(
dummy) << G4endl;
419 out << spaces <<
" UserMaxTrackLength " << fUL->GetUserMaxTrackLength(
dummy) << G4endl;
420 out << spaces <<
" UserMaxTime " << fUL->GetUserMaxTime(
dummy) << G4endl;
421 out << spaces <<
" UserMinEkine " << fUL->GetUserMinEkine(
dummy) << G4endl;
422 out << spaces <<
" UserMinRange " << fUL->GetUserMinRange(
dummy) << G4endl;
426 if (lv->GetSensitiveDetector())
427 out << spaces <<
" IS SENSITIVE DETECTOR " << G4endl;
428 if (lv->GetFieldManager())
429 out << spaces <<
" FIELD ON " << G4endl;
432 out << spaces <<
" Quality for optimisation, average number of voxels to be spent per content " 433 << lv->GetSmartless() << G4endl;
436 if (lv->GetFastSimulationManager())
437 out << spaces <<
" Logical Volume is an envelope for a FastSimulationManager " << G4endl;
438 out << spaces <<
" Weight used in the event biasing technique = " << lv->GetBiasWeight() << G4endl;
449 if (
pv->GetMotherLogical())
450 mother =
pv->GetMotherLogical()->GetName();
451 out << leafDepth << spaces <<
"### VOLUME = " <<
pv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
452 <<
" at " <<
pv->GetTranslation();
454 if (!
pv->IsReplicated()) {
456 if (
pv->GetRotation() ==
nullptr)
457 out <<
" with no rotation" << G4endl;
459 out <<
" with rotation" << G4endl;
461 out <<
" with rotation " << *(
pv->GetRotation()) << G4endl;
465 out << spaces <<
" It is replica: " << G4endl;
471 pv->GetReplicationData(axis, nReplicas,
width,
offset, consuming);
472 out << spaces <<
" axis " << axis << G4endl << spaces <<
" nReplicas " << nReplicas << G4endl;
473 if (
pv->GetParameterisation() !=
nullptr)
474 out << spaces <<
" It is parameterisation " << G4endl;
476 out << spaces <<
" width " <<
width << G4endl << spaces <<
" offset " <<
offset << G4endl << spaces
477 <<
" consuming" << consuming << G4endl;
478 if (
pv->GetParameterisation() !=
nullptr)
479 out << spaces <<
" It is parameterisation " << G4endl;
486 out << spaces << *(
sol) << G4endl;
496 G4ThreeVector globalpoint =
fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
497 G4LogicalVolume *lv =
pv->GetLogicalVolume();
500 if (
pv->GetMotherLogical())
501 mother =
pv->GetMotherLogical()->GetName();
503 lvname.assign(lvname, 0,
nchar_);
505 out << leafDepth << spaces <<
"### VOLUME = " << lv->GetName() <<
" Copy No " <<
pv->GetCopyNo() <<
" in " << mother
506 <<
" global position of centre " << globalpoint <<
" (r = " << globalpoint.perp()
509 int NoDaughters = lv->GetNoDaughters();
510 while ((NoDaughters--) > 0) {
511 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
512 if (!pvD->IsReplicated())
524 const G4MaterialTable *matTab = G4Material::GetMaterialTable();
526 for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++) {
528 fout << (*matite)->GetName() << G4endl;
530 fout << (*matite)->GetName() <<
" " << (*matite)->GetRadlen() <<
" " << (*matite)->GetNuclearInterLength()
535 const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
538 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
540 fout << (*lvcite)->GetSolid()->GetName() << G4endl;
542 fout << (*lvcite)->GetSolid()->GetName() <<
" " << (*lvcite)->GetSolid()->GetCubicVolume() << G4endl;
547 for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
549 fout << (*lvcite)->GetName() << G4endl;
551 fout << (*lvcite)->GetName() <<
" " << (*lvcite)->GetMass(
false,
false) << G4endl;
555 const G4PhysicalVolumeStore *
pvs = G4PhysicalVolumeStore::GetInstance();
557 for (std::vector<G4VPhysicalVolume *>::const_iterator pvcite =
pvs->begin(); pvcite !=
pvs->end(); pvcite++) {
560 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetTranslation().x() <<
" " 561 << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() << G4endl;
563 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetCopyNo() <<
" " << (*pvcite)->GetTranslation().x()
564 <<
" " << (*pvcite)->GetTranslation().y() <<
" " << (*pvcite)->GetTranslation().z() << G4endl;
567 fout << (*pvcite)->GetName() << G4endl;
569 fout << (*pvcite)->GetName() <<
" " << (*pvcite)->GetCopyNo() << G4endl;
576 std::vector<std::string> touches;
578 std::sort(touches.begin(), touches.end());
579 for (
const auto &touch : touches)
580 fout << touch << G4endl;
584 const G4RegionStore *regs = G4RegionStore::GetInstance();
586 for (std::vector<G4Region *>::const_iterator regite = regs->begin(); regite != regs->end(); regite++) {
588 fout << (*regite)->GetName() << G4endl;
590 fout << (*regite)->GetName() <<
" " << (*regite)->GetNumberOfMaterials() <<
" " 591 << (*regite)->GetNumberOfRootVolumes() << G4endl;
599 unsigned int leafDepth,
601 std::vector<std::string> &touches) {
608 if (
pv->GetMotherLogical())
611 G4LogicalVolume *lv =
pv->GetLogicalVolume();
613 unsigned int copy =
static_cast<unsigned int>(
pv->GetCopyNo());
616 touches.emplace_back(
name);
618 int NoDaughters = lv->GetNoDaughters();
619 while ((NoDaughters--) > 0) {
620 G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
621 if (!pvD->IsReplicated())
632 for (
ii = 0;
ii < leafDepth;
ii++) {
639 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
std::string noNameSpace(const std::string &name)
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