7 #include "G4GDMLParser.hh"
8 #include "G4VPhysicalVolume.hh"
9 #include "G4LogicalVolume.hh"
10 #include "G4LogicalVolumeStore.hh"
11 #include "G4TransportationManager.hh"
12 #include "G4Navigator.hh"
13 #include "G4NistManager.hh"
14 #include "G4PVPlacement.hh"
19 #include "GaudiKernel/Bootstrap.h"
20 #include "GaudiKernel/ISvcLocator.h"
21 #include "GaudiKernel/IMessageSvc.h"
28 std::once_flag VolumeDebugger_DumpGeometryOnce;
44 std::vector<G4VPhysicalVolume*> pv_to_remove;
45 for (
unsigned int i=0;
i<
v->GetNoDaughters();++
i){
46 G4VPhysicalVolume * n_v =
v->GetDaughter(
i);
47 if ( n_v->GetName() ==
"LArMgr::LAr::EMEC::Pos::InnerWheel" ||
48 n_v->GetName() ==
"LArMgr::LAr::EMEC::Neg::InnerWheel" ||
49 n_v->GetName() ==
"LArMgr::LAr::EMEC::Pos::OuterWheel" ||
50 n_v->GetName() ==
"LArMgr::LAr::EMEC::Neg::OuterWheel" ){
52 pv_to_remove.push_back(n_v);
58 for (
unsigned int j=0;j<pv_to_remove.size();++j){
59 v->RemoveDaughter( pv_to_remove[j] );
65 G4VPhysicalVolume*
W =
66 G4TransportationManager::GetTransportationManager()->
67 GetNavigatorForTracking()->GetWorldVolume();
74 G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
75 for (
unsigned int i=0;
i<lvs->size();++
i){
76 for (
unsigned int j=0;j<(*lvs)[
i]->GetNoDaughters();++j){
81 G4NistManager* nist = G4NistManager::Instance();
82 G4Material* world_mat = nist->FindOrBuildMaterial(
"G4_AIR");
83 G4VSolid* vBox =
W->GetLogicalVolume()->GetSolid();
84 G4LogicalVolume* logicWorld =
new G4LogicalVolume(vBox,world_mat,
"World");
85 W =
new G4PVPlacement(0,G4ThreeVector(),logicWorld,
"World",0,
false,0,
false);
86 new G4PVPlacement(0,G4ThreeVector(),(*lvs)[
i]->GetDaughter(j)->GetLogicalVolume(),
m_config.
targetVolume,logicWorld,
false,0,
false);
96 for (
unsigned int i = 0;
i < lvs->size(); ++
i) {
97 for (
unsigned int j = 0; j < (*lvs)[
i]->GetNoDaughters(); ++j) {
101 ATH_MSG_FATAL(
"\n\n ================= E N D O F L I S T ========================\n\n");
123 ATH_MSG_INFO(
"Overlap check: there were problems with the geometry.");
134 std::call_once(VolumeDebugger_DumpGeometryOnce,
140 bool somethingOverlapped =
false;
143 somethingOverlapped |= hasOverlaps;
147 std::multimap<G4LogicalVolume *, G4VPhysicalVolume *> lv2pvMap;
148 G4LogicalVolume *lv = topPV->GetLogicalVolume();
149 unsigned int nDaughters = lv->GetNoDaughters();
150 for (
unsigned int i = 0;
i < nDaughters; ++
i) {
151 G4VPhysicalVolume *daughterPV = lv->GetDaughter(
i);
152 G4LogicalVolume *daughterLV = daughterPV->GetLogicalVolume();
153 lv2pvMap.insert(std::pair<G4LogicalVolume *, G4VPhysicalVolume *>(daughterLV, daughterPV));
160 G4VPhysicalVolume *daughterPV = mapEl->second;
162 somethingOverlapped |= hasOverlaps;
177 if (checkEveryNth <= 0) checkEveryNth = 1;
178 for (
int i = 1;
i <
n; ++
i) {
179 if (
i % checkEveryNth == 0) {
181 somethingOverlapped |= hasOverlaps;
187 return somethingOverlapped;
191 std::stringstream sstr{};
192 const G4ThreeVector trans =
pv->GetFrameTranslation();
193 const G4RotationMatrix* rot =
pv->GetFrameRotation();
195 sstr<<
"Volume: "<<
pv->GetName()<<
", location: "<<
Amg::toString(trans, 2)<<
", ";
202 G4LogicalVolume*
log =
pv->GetLogicalVolume();
203 for (
size_t d= 0;
d <
log->GetNoDaughters(); ++
d){