File indexing completed on 2025-01-30 09:16:47
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 #include <iomanip>
0031
0032
0033 namespace dd4hep {
0034
0035 void dumpNode(TGeoNode* n, int level) {
0036 TGeoMatrix* mat = n->GetMatrix();
0037 TGeoVolume* vol = n->GetVolume();
0038 TGeoMedium* med = vol->GetMedium();
0039 TGeoShape* shape = vol->GetShape();
0040 TObjArray* nodes = vol->GetNodes();
0041 for (int i = 0; i < level; ++i)
0042 std::cout << " ";
0043 std::cout << " ++Node:|" << n->GetName() << "| ";
0044 std::cout << " Volume: " << vol->GetName() << " material:" << med->GetName()
0045 << " shape:" << shape->GetName() << std::endl;
0046 for (int i = 0; i < level; ++i)
0047 std::cout << " ";
0048 const Double_t* tr = mat->GetTranslation();
0049 std::cout << " matrix:|" << mat->GetName()
0050 << "|" << mat->IsTranslation() << mat->IsRotation() << mat->IsScale()
0051 << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2];
0052 if (mat->IsRotation()) {
0053 Double_t theta, phi, psi;
0054 TGeoRotation rot(*mat);
0055 rot.GetAngles(phi, theta, psi);
0056 std::cout << " rot: theta:" << theta << " phi:" << phi << " psi:" << psi;
0057 }
0058 std::cout << std::endl;
0059 PlacedVolume plv(n);
0060 for (int i = 0; i < level; ++i)
0061 std::cout << " ";
0062 std::cout << " volume:" << plv.toString();
0063 std::cout << std::endl;
0064 TIter next(nodes);
0065 TGeoNode *geoNode;
0066 while ((geoNode = (TGeoNode *) next())) {
0067 dumpNode(geoNode, level + 1);
0068 }
0069 }
0070
0071 void dumpVolume(TGeoVolume* vol, int level) {
0072 TObjArray* nodes = vol->GetNodes();
0073 TGeoMedium* med = vol->GetMedium();
0074 TGeoShape* shape = vol->GetShape();
0075
0076 for (int i = 0; i < level; ++i)
0077 std::cout << " ";
0078 std::cout << "++Volume: " << vol->GetName() << " material:" << med->GetName() << " shape:" << shape->GetName() << std::endl;
0079 TIter next(nodes);
0080 TGeoNode *geoNode;
0081 while ((geoNode = (TGeoNode *) next())) {
0082 dumpNode(geoNode, level + 1);
0083 }
0084 }
0085
0086 void dumpTopVolume(const Detector& description) {
0087 dumpVolume(description.manager().GetTopVolume(), 0);
0088 }
0089 }