File indexing completed on 2025-07-11 07:52:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <XML/Conversions.h>
0016 #include <DD4hep/Detector.h>
0017 #include <DD4hep/Objects.h>
0018 #include <DD4hep/Printout.h>
0019 #include <DD4hep/IDDescriptor.h>
0020
0021
0022 #include <TMap.h>
0023 #include <TROOT.h>
0024 #include <TColor.h>
0025 #include <TGeoMatrix.h>
0026 #include <TGeoManager.h>
0027
0028
0029 #include <iostream>
0030
0031
0032 namespace dd4hep {
0033
0034 void dumpNode(TGeoNode* n, int level) {
0035 TGeoMatrix* mat = n->GetMatrix();
0036 TGeoVolume* vol = n->GetVolume();
0037 TGeoMedium* med = vol->GetMedium();
0038 TGeoShape* shape = vol->GetShape();
0039 TObjArray* nodes = vol->GetNodes();
0040 for (int i = 0; i < level; ++i)
0041 std::cout << " ";
0042 std::cout << " ++Node:|" << n->GetName() << "| ";
0043 std::cout << " Volume: " << vol->GetName() << " material:" << med->GetName()
0044 << " shape:" << shape->GetName() << std::endl;
0045 for (int i = 0; i < level; ++i)
0046 std::cout << " ";
0047 const Double_t* tr = mat->GetTranslation();
0048 std::cout << " matrix:|" << mat->GetName()
0049 << "|" << mat->IsTranslation() << mat->IsRotation() << mat->IsScale()
0050 << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2];
0051 if (mat->IsRotation()) {
0052 Double_t theta, phi, psi;
0053 TGeoRotation rot(*mat);
0054 rot.GetAngles(phi, theta, psi);
0055 std::cout << " rot: theta:" << theta << " phi:" << phi << " psi:" << psi;
0056 }
0057 std::cout << std::endl;
0058 PlacedVolume plv(n);
0059 for (int i = 0; i < level; ++i)
0060 std::cout << " ";
0061 std::cout << " volume:" << plv.toString();
0062 std::cout << std::endl;
0063 TIter next(nodes);
0064 TGeoNode *geoNode;
0065 while ((geoNode = (TGeoNode *) next())) {
0066 dumpNode(geoNode, level + 1);
0067 }
0068 }
0069
0070 void dumpVolume(TGeoVolume* vol, int level) {
0071 TObjArray* nodes = vol->GetNodes();
0072 TGeoMedium* med = vol->GetMedium();
0073 TGeoShape* shape = vol->GetShape();
0074
0075 for (int i = 0; i < level; ++i)
0076 std::cout << " ";
0077 std::cout << "++Volume: " << vol->GetName() << " material:" << med->GetName() << " shape:" << shape->GetName() << std::endl;
0078 TIter next(nodes);
0079 TGeoNode *geoNode;
0080 while ((geoNode = (TGeoNode *) next())) {
0081 dumpNode(geoNode, level + 1);
0082 }
0083 }
0084
0085 void dumpTopVolume(const Detector& description) {
0086 dumpVolume(description.manager().GetTopVolume(), 0);
0087 }
0088 }