DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
LCDD2Output.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework includes
15 #include <XML/Conversions.h>
16 #include <DD4hep/Detector.h>
17 #include <DD4hep/Objects.h>
18 #include <DD4hep/Printout.h>
19 #include <DD4hep/IDDescriptor.h>
20 
21 // ROOT includes
22 #include <TMap.h>
23 #include <TROOT.h>
24 #include <TColor.h>
25 #include <TGeoMatrix.h>
26 #include <TGeoManager.h>
27 
29 #include <iostream>
30 #include <iomanip>
31 
33 namespace dd4hep {
34 
35  void dumpNode(TGeoNode* n, int level) {
36  TGeoMatrix* mat = n->GetMatrix();
37  TGeoVolume* vol = n->GetVolume();
38  TGeoMedium* med = vol->GetMedium();
39  TGeoShape* shape = vol->GetShape();
40  TObjArray* nodes = vol->GetNodes();
41  for (int i = 0; i < level; ++i)
42  std::cout << " ";
43  std::cout << " ++Node:|" << n->GetName() << "| ";
44  std::cout << " Volume: " << vol->GetName() << " material:" << med->GetName()
45  << " shape:" << shape->GetName() << std::endl;
46  for (int i = 0; i < level; ++i)
47  std::cout << " ";
48  const Double_t* tr = mat->GetTranslation();
49  std::cout << " matrix:|" << mat->GetName()
50  << "|" << mat->IsTranslation() << mat->IsRotation() << mat->IsScale()
51  << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2];
52  if (mat->IsRotation()) {
53  Double_t theta, phi, psi;
54  TGeoRotation rot(*mat);
55  rot.GetAngles(phi, theta, psi);
56  std::cout << " rot: theta:" << theta << " phi:" << phi << " psi:" << psi;
57  }
58  std::cout << std::endl;
59  PlacedVolume plv(n);
60  for (int i = 0; i < level; ++i)
61  std::cout << " ";
62  std::cout << " volume:" << plv.toString();
63  std::cout << std::endl;
64  TIter next(nodes);
65  TGeoNode *geoNode;
66  while ((geoNode = (TGeoNode *) next())) {
67  dumpNode(geoNode, level + 1);
68  }
69  }
70 
71  void dumpVolume(TGeoVolume* vol, int level) {
72  TObjArray* nodes = vol->GetNodes();
73  TGeoMedium* med = vol->GetMedium();
74  TGeoShape* shape = vol->GetShape();
75 
76  for (int i = 0; i < level; ++i)
77  std::cout << " ";
78  std::cout << "++Volume: " << vol->GetName() << " material:" << med->GetName() << " shape:" << shape->GetName() << std::endl;
79  TIter next(nodes);
80  TGeoNode *geoNode;
81  while ((geoNode = (TGeoNode *) next())) {
82  dumpNode(geoNode, level + 1);
83  }
84  }
85 
86  void dumpTopVolume(const Detector& description) {
87  dumpVolume(description.manager().GetTopVolume(), 0);
88  }
89 }
dd4hep::Detector::manager
virtual TGeoManager & manager() const =0
Access the geometry manager of this instance.
Objects.h
Detector.h
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::dumpTopVolume
void dumpTopVolume(const Detector &description)
Definition: LCDD2Output.cpp:86
dd4hep::dumpNode
void dumpNode(TGeoNode *n, int level)
Definition: LCDD2Output.cpp:35
dd4hep::PlacedVolume::toString
std::string toString() const
String dump.
Definition: Volumes.cpp:524
IDDescriptor.h
Conversions.h
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::dumpVolume
void dumpVolume(TGeoVolume *vol, int level)
Definition: LCDD2Output.cpp:71
Printout.h