diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp index a34d6bf4fe7abe348fe07bf29e7e15eb54fc211c..b632d27ae3777cae048250616ce6bd0644131134 100644 --- a/DDCore/src/GeoHandler.cpp +++ b/DDCore/src/GeoHandler.cpp @@ -77,11 +77,6 @@ GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { if ( v ) { TGeoMedium* m = v->GetMedium(); Volume vol = Ref_t(v); - VisAttr vis = vol.visAttributes(); - //Region reg = vol.region(); - //LimitSet lim = vol.limitSet(); - //SensitiveDetector det = vol.sensitiveDetector(); - // Note : assemblies and the world do not have a real volume nor a material if ( info.volumeSet.find(v) == info.volumeSet.end() ) { info.volumeSet.insert(v); @@ -89,12 +84,16 @@ GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { } if ( m ) info.materials.insert(m); if ( dynamic_cast<Volume::Object*>(v) ) { + VisAttr vis = vol.visAttributes(); + //Region reg = vol.region(); + //LimitSet lim = vol.limitSet(); + //SensitiveDetector det = vol.sensitiveDetector(); + if ( vis.isValid() ) info.vis.insert(vis.ptr()); + //if ( lim.isValid() ) info.limits[lim.ptr()].insert(v); + //if ( reg.isValid() ) info.regions[reg.ptr()].insert(v); + //if ( det.isValid() ) info.sensitives[det.ptr()].insert(v); } - //if ( lim.isValid() ) info.limits[lim.ptr()].insert(v); - //if ( reg.isValid() ) info.regions[reg.ptr()].insert(v); - //if ( det.isValid() ) info.sensitives[det.ptr()].insert(v); - collectSolid(info,v->GetName(),n->GetName(),v->GetShape(),n->GetMatrix()); } } diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index e588752ad34073d39d9c2fb9a664e8a0dbb2a1be..056867ccb23a23f8c9a6abe59e95262339d7b32a 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -263,7 +263,9 @@ PlacedVolume::VolIDs::insert(const string& name, int value) { } static PlacedVolume::Object* _data(const PlacedVolume& v) { - return dynamic_cast<PlacedVolume::Object*>(v.ptr()); + PlacedVolume::Object* o = dynamic_cast<PlacedVolume::Object*>(v.ptr()); + if ( o ) return o; + throw runtime_error("Attempt to access invalid handle of type: PlacedVolume"); } /// Add identifier @@ -316,9 +318,12 @@ Volume::Object::~Object() { } /// Accessor to the data part of the Volume -Volume::Object* _data(const Volume& v) { +Volume::Object* _data(const Volume& v, bool throw_exception = true) { //if ( v.ptr() && v.ptr()->IsA() == TGeoVolume::Class() ) return v.data<Volume::Object>(); - return dynamic_cast<Volume::Object*>(v.ptr()); + Volume::Object* o = dynamic_cast<Volume::Object*>(v.ptr()); + if ( o ) return o; + else if ( !throw_exception ) return 0; + throw runtime_error("Attempt to access invalid handle of type: PlacedVolume"); } /// Constructor to be used when creating a new geometry tree. @@ -535,12 +540,16 @@ Material Volume::material() const { return Ref_t(m_element->GetMedium()); } /// Access the visualisation attributes -VisAttr Volume::visAttributes() const -{ return _data(*this)->vis; } +VisAttr Volume::visAttributes() const { + Object* o = _data(*this,false); + if ( o ) return o->vis; + return VisAttr(); +} /// Access to the handle to the region structure -Region Volume::region() const -{ return _data(*this)->region; } +Region Volume::region() const { + return _data(*this)->region; +} /// Access to the limit set LimitSet Volume::limitSet() const diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index 358123f0a1d2fa7fcadee06ccb2b31fb5a31036e..a121fd6e3e7c88a84049e4c9da57001ff9106ccf 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -72,7 +72,6 @@ void LCDDConverter::GeometryInfo::check(const string& name, const TNamed* n,map< /// Initializing Constructor LCDDConverter::LCDDConverter( LCDD& lcdd ) : m_lcdd(lcdd), m_dataPtr(0) { - m_checkOverlaps = true; } LCDDConverter::~LCDDConverter() { @@ -952,10 +951,9 @@ xml_doc_t LCDDConverter::createGDML(DetElement top) { } GeometryInfo& geo = *(m_dataPtr=new GeometryInfo); m_data->clear(); - collect(top,geo); - m_checkOverlaps = false; + cout << "++ ==> Converting in memory detector description to GDML format..." << endl; const char* comment = "\n" " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" " ++++ Linear collider detector description GDML in C++ ++++\n" @@ -1020,8 +1018,7 @@ xml_doc_t LCDDConverter::createVis(DetElement top) { GeometryInfo& geo = *(m_dataPtr=new GeometryInfo); m_data->clear(); collect(top,geo); - m_checkOverlaps = false; - + cout << "++ ==> Dump visualisation attributes from in memory detector description..." << endl; const char comment[] = "\n" " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" " ++++ Linear collider detector description LCDD in C++ ++++\n" @@ -1054,8 +1051,6 @@ xml_doc_t LCDDConverter::createLCDD(DetElement top) { GeometryInfo& geo = *(m_dataPtr=new GeometryInfo); m_data->clear(); collect(top,geo); - m_checkOverlaps = false; - const char comment[] = "\n" " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" " ++++ Linear collider detector description LCDD in C++ ++++\n" @@ -1098,6 +1093,7 @@ xml_doc_t LCDDConverter::createLCDD(DetElement top) { for(LCDD::HandleMap::const_iterator i=fld.begin(); i!=fld.end(); ++i) geo.fields.insert((*i).second.ptr()); + cout << "++ ==> Converting in memory detector description to LCDD format..." << endl; handleHeader(); // Start creating the objects for materials, solids and log volumes. handle(this, geo.materials, &LCDDConverter::handleMaterial); diff --git a/DDCore/src/plugins/LCDDConverter.h b/DDCore/src/plugins/LCDDConverter.h index 1ae298d669ed229d7b24e5e57e5259620229d9e1..ac1065b8a0906ee3df9224b89739e07bab377d54 100644 --- a/DDCore/src/plugins/LCDDConverter.h +++ b/DDCore/src/plugins/LCDDConverter.h @@ -94,20 +94,17 @@ namespace DD4hep { doc_display, doc_gdml, doc_fields, doc_define, doc_materials, doc_solids, doc_structure, doc_setup; GeometryInfo(); }; + typedef std::set<std::string> NameSet; + /// Reference to detector description LCDD& m_lcdd; - /// Processing flag - bool m_checkOverlaps; - - typedef std::set<std::string> NameSet; mutable NameSet m_checkNames; + GeometryInfo* m_dataPtr; - GeometryInfo* m_dataPtr; GeometryInfo& data() const { return *m_dataPtr; } /// Data integrity checker void checkVolumes(const std::string& name, const TGeoVolume* volume) const; - /// Initializing Constructor LCDDConverter( LCDD& lcdd ); diff --git a/DDExamples/CLICSiD/compact/compact_polycones.xml b/DDExamples/CLICSiD/compact/compact_polycones.xml index 2ee0b5fa6fa1d9a3bf9e66dd7266d78460aef036..94aa2bde2bf3adc61ab2dac5627849accc747f97 100644 --- a/DDExamples/CLICSiD/compact/compact_polycones.xml +++ b/DDExamples/CLICSiD/compact/compact_polycones.xml @@ -835,7 +835,7 @@ </readout> </readouts> <fields> - <field name="GlobalSolenoid" type="SolenoidMagnet" + <field name="GlobalSolenoid" type="solenoid" inner_field="5.0*tesla" outer_field="-1.5*tesla" zmax="SolenoidCoilOuterZ" diff --git a/DDExamples/ILDExDet/compact/CLIC_ILD_CDR.xml b/DDExamples/ILDExDet/compact/CLIC_ILD_CDR.xml index 73bc17df121d9258d7c70e09e94822e7ac5f111e..d7e39eda8ce7d32c4d5d9a72bae8cb2767cc3fb5 100644 --- a/DDExamples/ILDExDet/compact/CLIC_ILD_CDR.xml +++ b/DDExamples/ILDExDet/compact/CLIC_ILD_CDR.xml @@ -963,7 +963,7 @@ </readouts> <fields> - <field type="SolenoidMagnet" name="GlobalSolenoid" inner_field="5.0*tesla" + <field type="solenoid" name="GlobalSolenoid" inner_field="5.0*tesla" outer_field="-1.5*tesla" zmax="SolenoidCoilOuterZ" outer_radius="SolenoidalFieldRadius" /> </fields> diff --git a/DDExamples/UtilityApps/src/converter.cpp b/DDExamples/UtilityApps/src/converter.cpp index 66ee4b9944b3d3e142af565ff81fc659fd6981b1..84ab53f25ba1cd0f6c8f4cbdd5d57fcb0f9d009d 100644 --- a/DDExamples/UtilityApps/src/converter.cpp +++ b/DDExamples/UtilityApps/src/converter.cpp @@ -79,6 +79,9 @@ int main(int argc,char** argv) { LCDD& lcdd = dd4hep_instance(); // Load compact files run_plugin(lcdd,"DD4hepCompactLoader",int(geo_files.size()),&geo_files[0]); + // Create volume manager and populate it required + if ( volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0); + // Execute data converter. if ( compact2lcdd ) run_plugin(lcdd,"DD4hepGeometry2LCDD",output,&argv[output]); else if ( compact2gdml ) @@ -89,7 +92,6 @@ int main(int argc,char** argv) { run_plugin(lcdd,"DD4hepGeometry2VISASCII",output,&argv[output]); else if ( compact2vis ) run_plugin(lcdd,"DD4hepGeometry2VIS",output,&argv[output]); - if ( volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0); if ( destroy ) delete &lcdd; return 0; } diff --git a/DDExamples/UtilityApps/src/plugin_runner.cpp b/DDExamples/UtilityApps/src/plugin_runner.cpp index 5c98e619c391334b3f65596132ff6f3886e9caf9..b6eb0bd1de80c31aa4ec9e75c9d86e221b3f9a0f 100644 --- a/DDExamples/UtilityApps/src/plugin_runner.cpp +++ b/DDExamples/UtilityApps/src/plugin_runner.cpp @@ -54,9 +54,10 @@ int main(int argc,char** argv) { LCDD& lcdd = dd4hep_instance(); // Load compact files run_plugin(lcdd,"DD4hepCompactLoader",int(geo_files.size()),&geo_files[0]); + // Create volume manager and populate it required + if ( volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0); // Execute plugin run_plugin(lcdd,plugin.c_str(),0,0); - if ( volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0); if ( destroy ) delete &lcdd; return 0; }