diff --git a/DDCore/include/DD4hep/Factories.h b/DDCore/include/DD4hep/Factories.h index 069fd2c0363d401587425a0904abefef723524a0..19bc62adbfe35e0547b21dd140bb9305b62ba74a 100644 --- a/DDCore/include/DD4hep/Factories.h +++ b/DDCore/include/DD4hep/Factories.h @@ -317,6 +317,11 @@ namespace { template <> long XMLDocumentReaderFactory<xml_document_##name>::create(dd4hep::Detector& l,ns::xml_h e) {return func(l,e);} \ DD4HEP_PLUGINSVC_FACTORY(xml_document_##name,name##_XML_reader,long(dd4hep::Detector*,ns::xml_h*),__LINE__) } +// Call function of the type [long (*func)(dd4hep::Detector& description, xml_h handle)] +#define DECLARE_XML_PLUGIN(name,func) DD4HEP_OPEN_PLUGIN(dd4hep,xml_document_##name) { \ + template <> long XMLDocumentReaderFactory<xml_document_##name>::create(dd4hep::Detector& l,ns::xml_h e) {return func(l,e);} \ + DD4HEP_PLUGINSVC_FACTORY(xml_document_##name,name,long(dd4hep::Detector*,ns::xml_h*),__LINE__) } + // Call function of the type [NamedObject* (*func)(dd4hep::Detector& description, xml_h handle, ref_t reference)] #define DECLARE_XML_PROCESSOR_BASIC(name,func,deprecated) DD4HEP_OPEN_PLUGIN(dd4hep,det_element_##name) {\ template <> Ref_t XmlDetElementFactory< det_element_##name >::create(dd4hep::Detector& l,ns::xml_h e,ns::ref_t h) \ diff --git a/DDCore/include/DD4hep/GeoHandler.h b/DDCore/include/DD4hep/GeoHandler.h index 976ecbd9690a77873267ff9a899849b73d3636a4..61d9c04c15f1f852e5bd513cc0f7138c0c1e4f20 100644 --- a/DDCore/include/DD4hep/GeoHandler.h +++ b/DDCore/include/DD4hep/GeoHandler.h @@ -48,17 +48,6 @@ namespace dd4hep { */ class GeoHandlerTypes { public: -#if 0 - typedef std::set<const TGeoVolume*> ConstVolumeSet; - typedef std::map<SensitiveDetector, ConstVolumeSet> SensitiveVolumes; - typedef std::map<Region, ConstVolumeSet> RegionVolumes; - typedef std::map<LimitSet, ConstVolumeSet> LimitVolumes; - typedef std::map<int, std::set<const TGeoNode*> > Data; - typedef std::set<SensitiveDetector> SensitiveDetectorSet; - typedef std::set<Region> RegionSet; - typedef std::set<LimitSet> LimitSetSet; - typedef std::set<TNamed*> ObjectSet; -#endif /// Data container to store information obtained during the geometry scan /** * \author M.Frank @@ -101,6 +90,8 @@ namespace dd4hep { GeoHandler& i_collect(const TGeoNode* parent, const TGeoNode* node, int level, Region rg, LimitSet ls); + /// Assemble summary of the current node + void i_collect_node(const TGeoNode* node, GeometryInfo& info); private: /// Never call Copy constructor diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp index 61a7b746afae180bef1d2d84ca5f32079ec84703..3133eadbe53e338396558dcc34be41878e63de88 100644 --- a/DDCore/src/GeoHandler.cpp +++ b/DDCore/src/GeoHandler.cpp @@ -87,39 +87,48 @@ GeoHandler& GeoHandler::collect(DetElement element) { return i_collect(par_node, element.placement().ptr(), 0, Region(), LimitSet()); } +/// Assemble summary of the current node +void GeoHandler::i_collect_node(const TGeoNode* n, GeometryInfo& info) { + TGeoVolume* v = n->GetVolume(); + if (v) { + Material mat(v->GetMedium()); + Volume vol(v); + // Note : assemblies and the world do not have a real volume nor a material + if (info.volumeSet.find(vol) == info.volumeSet.end()) { + info.volumeSet.emplace(vol); + info.volumes.emplace_back(vol); + } + if ( mat.isValid() ) + info.materials.emplace(mat); + 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.emplace(vis); + //if ( lim.isValid() ) info.limits[lim.ptr()].emplace(v); + //if ( reg.isValid() ) info.regions[reg.ptr()].emplace(v); + //if ( det.isValid() ) info.sensitives[det.ptr()].emplace(v); + } + collectSolid(info, v->GetName(), n->GetName(), v->GetShape(), n->GetMatrix()); + } +} + GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { - DetElement par = element.parent(); + + DetElement par = element.parent(); + TGeoNode* place = element.placement().ptr(); TGeoNode* par_node = par.isValid() ? par.placement().ptr() : nullptr; + m_data->clear(); - i_collect(par_node, element.placement().ptr(), 0, Region(), LimitSet()); + i_collect_node(place, info); + i_collect(par_node, place, 0, Region(), LimitSet()); for (auto i = m_data->rbegin(); i != m_data->rend(); ++i) { const auto& mapped = (*i).second; for (const TGeoNode* n : mapped ) { - TGeoVolume* v = n->GetVolume(); - if (v) { - Material mat(v->GetMedium()); - Volume vol(v); - // Note : assemblies and the world do not have a real volume nor a material - if (info.volumeSet.find(vol) == info.volumeSet.end()) { - info.volumeSet.emplace(vol); - info.volumes.emplace_back(vol); - } - if ( mat.isValid() ) - info.materials.emplace(mat); - 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.emplace(vis); - //if ( lim.isValid() ) info.limits[lim.ptr()].emplace(v); - //if ( reg.isValid() ) info.regions[reg.ptr()].emplace(v); - //if ( det.isValid() ) info.sensitives[det.ptr()].emplace(v); - } - collectSolid(info, v->GetName(), n->GetName(), v->GetShape(), n->GetMatrix()); - } + i_collect_node(n, info); } } return *this; diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h index 894a044fe73979413df72724e958bb3fdecef185..d3b4d0c8d7e7e5aa05eafe0dc75dc06ce91ae307 100644 --- a/UtilityApps/src/run_plugin.h +++ b/UtilityApps/src/run_plugin.h @@ -223,7 +223,7 @@ namespace { result = run_plugin(description, name, a.first, a.second); return result; } - std::cout << "WARNING: No plugin name supplied. " + std::cout << "WARNING: run_plugin: No plugin name supplied. " << "Implicitly assuming execution steered by XML." << std::endl; return ENOENT; }