00001 //$id$ 00002 /* 00003 * 2004/12/9 Zhengyun You Peking University 00004 * ROOT Geometry for Bes sub-detector in event display and reconstruction. 00005 * 00006 */ 00007 00008 using namespace std; 00009 00010 #include <string> 00011 #include <iostream> 00012 00013 #include "TGeoVolume.h" 00014 #include "TGeoNode.h" 00015 00016 #include "ROOTGeo/SubDetectorROOTGeo.h" 00017 00018 SubDetectorROOTGeo::SubDetectorROOTGeo() 00019 : m_ROOTGeoInit(0) 00020 { 00021 // Default constructor. 00022 //m_sxp.Initialize(); 00023 } 00024 00025 SubDetectorROOTGeo::~SubDetectorROOTGeo() 00026 { 00027 m_sxp.Finalize(); 00028 } 00029 00030 void 00031 SubDetectorROOTGeo::ReadGdml( const char *gdmlFile, const char *setupName ) 00032 { 00033 m_config.SetURI( gdmlFile ); 00034 m_config.SetSetupName( setupName ); 00035 m_config.SetType ( "ROOT" ); 00036 00037 m_sxp.Configure( &m_config ); 00038 m_sxp.Initialize(); 00039 m_sxp.Run(); 00040 00041 m_TopVolume = (TGeoVolume*)TGDMLProcessor::GetInstance()->GetWorldVolume(); 00042 if (!m_TopVolume) std::cout << "Top Volume not found " << std::endl; 00043 } 00044 00045 TGeoVolume* SubDetectorROOTGeo::GetLogicalVolume( const std::string& vn ) 00046 { 00047 TGeoVolume *lv = (TGeoVolume*)TGDMLProcessor::GetInstance()->GetLogicalVolume(vn); 00048 if (!lv) std::cout << "Logical Volume " << vn << " not found " << std::endl; 00049 return lv; 00050 } 00051 00052 TGeoVolumeAssembly* SubDetectorROOTGeo::GetAssemblyVolume( const std::string& an ) 00053 { 00054 TGeoVolumeAssembly *av = (TGeoVolumeAssembly*)TGDMLProcessor::GetInstance()->GetAssemblyVolume(an); 00055 if (!av) std::cout << "Assembly Volume " << an << " not found " << std::endl; 00056 return av; 00057 } 00058 00059 TGeoNode* SubDetectorROOTGeo::GetNode( const std::string& nn ) 00060 { 00061 TGeoNode *node = (TGeoNode*)TGDMLProcessor::GetInstance()->GetPhysicalVolume(nn); 00062 if (!node) std::cout << "Physical Volume " << nn << " not found " << std::endl; 00063 return node; 00064 } 00065