Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// $Id: Geant4Converter.cpp 602 2013-06-11 14:50:57Z markus.frank $
//====================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------
//
// Author : M.Frank
//
//====================================================================
#include "DD4hep/LCDD.h"
#include "DD4hep/Volumes.h"
#include "DD4hep/Printout.h"
#include "DDG4/Geant4HierarchyDump.h"
#include "Reflex/PluginService.h"
#include "G4VisAttributes.hh"
#include "G4ProductionCuts.hh"
#include "G4VUserRegionInformation.hh"
// Geant4 include files
#include "G4Element.hh"
#include "G4SDManager.hh"
#include "G4Assembly.hh"
#include "G4AssemblyVolume.hh"
#include "G4Box.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4Torus.hh"
#include "G4Sphere.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
#include "G4UnionSolid.hh"
#include "G4Paraboloid.hh"
#include "G4SubtractionSolid.hh"
#include "G4IntersectionSolid.hh"
#include "G4Region.hh"
#include "G4UserLimits.hh"
#include "G4VSensitiveDetector.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4Element.hh"
#include "G4Isotope.hh"
#include "G4Transform3D.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4ElectroMagneticField.hh"
#include "G4FieldManager.hh"
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace DD4hep::Simulation;
using namespace DD4hep::Geometry;
using namespace DD4hep;
using namespace std;
static const char* _T(const std::string& s) { return s.c_str(); }
//static const char* _T(const char* s) { return s; }
enum { G4DUMP_ALL = 0xFFFFFFFF,
G4DUMP_LOGVOL = 1<<0,
G4DUMP_SOLID = 1<<1,
G4DUMP_SENSDET = 1<<2,
G4DUMP_LIMITS = 1<<3,
G4DUMP_REGION = 1<<4,
G4DUMP_LAST
};
static unsigned long m_flags = ~0x0UL;
/// Initializing Constructor
Geant4HierarchyDump::Geant4HierarchyDump( LCDD& lcdd)
: m_lcdd(lcdd)
{
}
/// Standard destructor
Geant4HierarchyDump::~Geant4HierarchyDump() {
}
void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) const {
G4LogicalVolume* lv = v->GetLogicalVolume();
G4VSensitiveDetector* sd = lv->GetSensitiveDetector();
G4Material* mat = lv->GetMaterial();
G4VSolid* sol = lv->GetSolid();
G4Region* rg = lv->GetRegion();
G4UserLimits* ul = lv->GetUserLimits();
G4int ndau = lv->GetNoDaughters();
char text[32];
stringstream str;
m_flags &= ~G4DUMP_SOLID;
printout(INFO,"Geant4Hierarchy","%s -> Placement:%s LV:%s Material:%s Solid:%s # of Daughters:%d",indent.c_str(),
_T(v->GetName()), _T(lv->GetName()), _T(mat->GetName()), _T(sol->GetName()),ndau);
if ( sd && (m_flags&G4DUMP_SOLID) ) {
str.str("");
sol->StreamInfo(str);
printout(INFO,"Geant4Hierarchy","%s Solid:%s",indent.c_str(),str.str().c_str());
}
if ( rg && (m_flags&G4DUMP_LIMITS) ) {
G4UserLimits* rg_limits = rg->GetUserLimits();
str.str("");
str << indent << " Region:" << rg->GetName() << " #Materials:" << rg->GetNumberOfMaterials()
<< " #Volumes:" << rg->GetNumberOfRootVolumes();
if ( rg_limits ) str << " Limits:" << rg_limits->GetType();
printout(INFO,"Geant4Hierarchy",str.str().c_str());
}
if ( sd && (m_flags&G4DUMP_SENSDET) ) {
printout(INFO,"Geant4Hierarchy","%s Sens.det:%p %s path:%s Active:%-3s #Coll:%d",indent.c_str(),
sd, _T(sd->GetName()), _T(sd->GetFullPathName()), sd->isActive() ? "YES" : "NO",
sd->GetNumberOfCollections());
}
if ( ul && (m_flags&G4DUMP_LIMITS) ) {
printout(INFO,"Geant4Hierarchy","%s Limits:%s ",indent.c_str(),_T(ul->GetType()));
}
for(G4int idau = 0; idau < ndau; ++idau) {
::sprintf(text," %-3d",idau);
dump(indent+text,lv->GetDaughter(idau));
}
}