Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:52:07

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework includes
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 // ROOT includes
0022 #include <TMap.h>
0023 #include <TROOT.h>
0024 #include <TColor.h>
0025 #include <TGeoMatrix.h>
0026 #include <TGeoManager.h>
0027 
0028 /// C/C++ include files
0029 #include <iostream>
0030 
0031 /// Namespace for the AIDA detector description toolkit
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 }