DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4HierarchyDump.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/LCDD.h"
17 #include "DD4hep/Plugins.h"
18 #include "DD4hep/Volumes.h"
19 #include "DD4hep/Printout.h"
21 
22 // Geant4 include files
23 #include "G4Version.hh"
24 #include "G4VisAttributes.hh"
25 #include "G4ProductionCuts.hh"
26 #include "G4VUserRegionInformation.hh"
27 #include "G4Element.hh"
28 #include "G4SDManager.hh"
29 
30 #include "G4AssemblyVolume.hh"
31 #include "G4Box.hh"
32 #include "G4Trd.hh"
33 #include "G4Tubs.hh"
34 #include "G4Cons.hh"
35 #include "G4Torus.hh"
36 #include "G4Sphere.hh"
37 #include "G4Polycone.hh"
38 #include "G4Polyhedra.hh"
39 #include "G4UnionSolid.hh"
40 #include "G4Paraboloid.hh"
41 #include "G4SubtractionSolid.hh"
42 #include "G4IntersectionSolid.hh"
43 
44 #include "G4Region.hh"
45 #include "G4UserLimits.hh"
46 #include "G4VSensitiveDetector.hh"
47 
48 #include "G4LogicalVolume.hh"
49 #include "G4Material.hh"
50 #include "G4Element.hh"
51 #include "G4Isotope.hh"
52 #include "G4Transform3D.hh"
53 #include "G4ThreeVector.hh"
54 #include "G4PVPlacement.hh"
55 #include "G4ElectroMagneticField.hh"
56 #include "G4FieldManager.hh"
57 
58 // C/C++ include files
59 #include <iostream>
60 #include <iomanip>
61 #include <sstream>
62 
63 using namespace DD4hep::Simulation;
64 using namespace DD4hep::Geometry;
65 using namespace DD4hep;
66 using namespace std;
67 
68 static const char* _T(const std::string& s) {
69  return s.c_str();
70 }
71 //static const char* _T(const char* s) { return s; }
72 
73 enum {
74  G4DUMP_ALL = 0xFFFFFFFF,
75  G4DUMP_LOGVOL = 1 << 0,
76  G4DUMP_SOLID = 1 << 1,
77  G4DUMP_SENSDET = 1 << 2,
78  G4DUMP_LIMITS = 1 << 3,
79  G4DUMP_REGION = 1 << 4,
81 };
82 static unsigned long m_flags = ~0x0UL;
83 
86 : m_lcdd(lcdd) {
87 }
88 
91 }
92 
93 void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) const {
94  G4LogicalVolume* lv = v->GetLogicalVolume();
95  G4VSensitiveDetector* sd = lv->GetSensitiveDetector();
96  G4Material* mat = lv->GetMaterial();
97  G4VSolid* sol = lv->GetSolid();
98  G4Region* rg = lv->GetRegion();
99  G4UserLimits* ul = lv->GetUserLimits();
100  G4int ndau = lv->GetNoDaughters();
101  char text[32];
102  stringstream str;
103 
104  m_flags &= ~G4DUMP_SOLID;
105  printout(INFO, "Geant4Hierarchy", "%s -> Placement:%s LV:%s Material:%s Solid:%s # of Daughters:%d", indent.c_str(),
106  _T(v->GetName()), _T(lv->GetName()), _T(mat->GetName()), _T(sol->GetName()), ndau);
107 
108  if (sd && (m_flags & G4DUMP_SOLID)) {
109  str.str("");
110  sol->StreamInfo(str);
111  printout(INFO, "Geant4Hierarchy", "%s Solid:%s", indent.c_str(), str.str().c_str());
112  }
113  if (rg && (m_flags & G4DUMP_LIMITS)) {
114  G4UserLimits* rg_limits = rg->GetUserLimits();
115  str.str("");
116  str << indent << " Region:" << rg->GetName() << " #Materials:" << rg->GetNumberOfMaterials() << " #Volumes:"
117  << rg->GetNumberOfRootVolumes();
118  if (rg_limits)
119  str << " Limits:" << rg_limits->GetType();
120  printout(INFO, "Geant4Hierarchy", str.str().c_str());
121  }
122  if (sd && (m_flags & G4DUMP_SENSDET)) {
123  printout(INFO, "Geant4Hierarchy", "%s Sens.det:%p %s path:%s Active:%-3s #Coll:%d", indent.c_str(), sd,
124  _T(sd->GetName()), _T(sd->GetFullPathName()), yes_no(sd->isActive()), sd->GetNumberOfCollections());
125  }
126  if (ul && (m_flags & G4DUMP_LIMITS)) {
127  printout(INFO, "Geant4Hierarchy", "%s Limits:%s ", indent.c_str(), _T(ul->GetType()));
128  }
129  for (G4int idau = 0; idau < ndau; ++idau) {
130  ::snprintf(text, sizeof(text), " %-3d", idau);
131  dump(indent + text, lv->GetDaughter(idau));
132  }
133 }
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:48
const char * yes_no(bool value)
Helper function to print booleans in format YES/NO.
Definition: Printout.h:295
TGeoShape * s
Definition: Volumes.cpp:294
virtual ~Geant4HierarchyDump()
Standard destructor.
virtual void dump(const std::string &indent, const G4VPhysicalVolume *vol) const
Dump the volume hierarchy as it is known to geant 4.
View * v
Definition: MultiView.cpp:30
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
static const char * _T(const std::string &s)
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Definition: Printout.cpp:111
Geant4HierarchyDump(LCDD &lcdd)
Initializing Constructor.
static unsigned long m_flags