/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 00002 #include "XddDumpAlg.h" 00003 00004 #include "DetDesc/LVolume.h" 00005 #include "DetDesc/LAssembly.h" 00006 #include "DetDesc/DetectorElement.h" 00007 #include "DetDesc/Material.h" 00008 #include "DetDesc/IGeometryInfo.h" 00009 00010 #include "GaudiKernel/LinkManager.h" 00011 #include "GaudiKernel/IRegistry.h" 00012 #include "GaudiKernel/RegistryEntry.h" 00013 00014 #include <iostream> 00015 #include <string> 00016 using namespace std; 00017 00018 XddDumpAlg::XddDumpAlg(const std::string& name, ISvcLocator* pSvcLocator) 00019 : GaudiAlgorithm(name,pSvcLocator) 00020 , m_depth(0) 00021 { 00022 declareProperty("Paths",m_paths,"TDS paths to dump"); 00023 } 00024 00025 XddDumpAlg::~XddDumpAlg() 00026 { 00027 } 00028 00029 StatusCode XddDumpAlg::initialize() 00030 { 00031 this->GaudiAlgorithm::initialize(); 00032 00033 //msgSvc()->setOutputLevel("GeometryInfoPlus",1); 00034 00035 return StatusCode::SUCCESS; 00036 } 00037 00038 StatusCode XddDumpAlg::execute() 00039 { 00040 //detSvc()->addPreLoadItem("/dd/Structure"); 00041 //detSvc()->preLoad(); 00042 00043 if (!m_paths.size()) { 00044 warning() << "No TDS paths given, defaulting to /dd" << endreq; 00045 m_paths.push_back("/dd"); 00046 } 00047 00048 for (size_t ind=0; ind<m_paths.size(); ++ind) { 00049 const char* path = m_paths[ind].c_str(); 00050 cout << "Dumping " << path << endl; 00051 DataObject *d = getDet<DataObject>(path); 00052 this->dump(d); 00053 } 00054 00055 return StatusCode::SUCCESS; 00056 } 00057 00058 void XddDumpAlg::dump_children(DataObject* d) 00059 { 00060 IRegistry* dr = d->registry(); 00061 using namespace DataSvcHelpers; 00062 RegistryEntry* dre = dynamic_cast<RegistryEntry*>(dr); 00063 if (!dre) { 00064 cerr << "Failed to get RegistryEntry\n"; 00065 return; 00066 } 00067 00068 RegistryEntry::Iterator it = dre->begin(), done = dre->end(); 00069 size_t siz = done-it; 00070 cout << string(m_depth,' ') << siz << " sub-directories:" << endl; 00071 ++m_depth; 00072 for (; it != done; ++it) { 00073 string id = (*it)->identifier(); 00074 00075 cout << string(m_depth,' ') 00076 << "Registry: name=" << (*it)->name() 00077 << ", identifier=" << id << endl; 00078 00079 DataObject* child = getDet<DataObject>(id); 00080 if (!child) { 00081 cout << string(m_depth,' ') << " failed to retrieve " << id << endl; 00082 break; 00083 } 00084 ++m_depth; 00085 this->dump(child); 00086 --m_depth; 00087 } 00088 --m_depth; 00089 return; 00090 } 00091 void XddDumpAlg::dump(DataObject* d) 00092 { 00093 cout << string(m_depth,' ') << d->name() << ": " << *d << endl; 00094 00095 LVolume* lv = dynamic_cast<LVolume*>(d); 00096 if (lv) this->dump(lv); 00097 00098 LAssembly* la = dynamic_cast<LAssembly*>(d); 00099 if (la) this->dump(la); 00100 00101 DetectorElement* de = dynamic_cast<DetectorElement*>(d); 00102 if (de) this->dump(de); 00103 00104 Material* me = dynamic_cast<Material*>(d); 00105 if (me) this->dump(me); 00106 00107 this->dump_children(d); 00108 } 00109 00110 void XddDumpAlg::dump(LVolume* lv) 00111 { 00112 cout << string(m_depth,' '); 00113 lv->printOut(cout) << endl; 00114 } 00115 void XddDumpAlg::dump(LAssembly* la) 00116 { 00117 cout << string(m_depth,' '); 00118 la->printOut(cout) << endl; 00119 } 00120 void XddDumpAlg::dump(DetectorElement* de) 00121 { 00122 cout << string(m_depth,' '); 00123 de->printOut(cout) << endl; 00124 IGeometryInfo* gi = de->geometry(); 00125 Gaudi::XYZPoint zero(0,0,0); 00126 Gaudi::XYZPoint whereami = gi->toGlobal(zero); 00127 cout << "\t" << string(m_depth,' ') 00128 << "GeometryInfo @ " << (void*)gi << "\n" 00129 << "\t" << string(m_depth,' ') 00130 << "globally @ " << whereami << " mm" 00131 << endl; 00132 00133 IDetectorElement::IDEContainer& dechild = de->childIDetectorElements(); 00134 size_t nchildren = dechild.size(); 00135 cout << "\t" << string(m_depth,' ') << nchildren << " children:" << endl; 00136 for (size_t ind=0; ind<nchildren; ++ind) { 00137 cout << "\t" << string(m_depth,' ') << dechild[ind]->name() << endl; 00138 } 00139 } 00140 void XddDumpAlg::dump(Material* me) 00141 { 00142 cout << string(m_depth,' ') << *me << endl; 00143 } 00144 00145 StatusCode XddDumpAlg::finalize() 00146 { 00147 00148 return this->GaudiAlgorithm::finalize(); 00149 } 00150