From 45f06b8917426c02ee31ad68be8f0953dfd81c7a Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Tue, 26 Jul 2022 16:18:02 +0200 Subject: [PATCH] Issue 875 (plugin return codes). Incuding fixes to examples and plugins. --- DDCore/include/DD4hep/Factories.h | 10 +++++----- DDCore/include/DD4hep/Plugins.h | 7 ------- DDG4/include/DDG4/Factories.h | 3 ++- examples/CLICSiD/scripts/CLICSiDAClick.C | 1 + examples/CLICSiD/scripts/CLICSiDXML.C | 1 + 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/DDCore/include/DD4hep/Factories.h b/DDCore/include/DD4hep/Factories.h index e70b9aff4..7be5a22c5 100644 --- a/DDCore/include/DD4hep/Factories.h +++ b/DDCore/include/DD4hep/Factories.h @@ -220,9 +220,9 @@ namespace { DD4HEP_PLUGIN_FACTORY_ARGS_3(long,dd4hep::Detector*,int,char**) { static long ret; - ret = dd4hep::ApplyFactory<P>::create(*a0,a1,a2); - //return dd4hep::PluginFactoryBase::make_return<long>(ret); - return (long)&ret; + long result = dd4hep::ApplyFactory<P>::create(*a0,a1,a2); + ret = result; + return long(&ret); } DD4HEP_PLUGIN_FACTORY_ARGS_2(ns::Named*,dd4hep::Detector*,ns::xml_h*) @@ -233,8 +233,8 @@ namespace { DD4HEP_PLUGIN_FACTORY_ARGS_2(long,dd4hep::Detector*,ns::xml_h*) { static long ret; - ret = dd4hep::XMLDocumentReaderFactory<P>::create(*a0,*a1); - //return dd4hep::PluginFactoryBase::make_return<long>(ret); + long result = dd4hep::XMLDocumentReaderFactory<P>::create(*a0,*a1); + ret = result; return long(&ret); } diff --git a/DDCore/include/DD4hep/Plugins.h b/DDCore/include/DD4hep/Plugins.h index e071c75d5..e29df7410 100644 --- a/DDCore/include/DD4hep/Plugins.h +++ b/DDCore/include/DD4hep/Plugins.h @@ -55,7 +55,6 @@ namespace dd4hep { template <typename T> static T val(const T* _p) { return T(*_p); } template <typename T> static T value(const void* _p) { return (T)_p; } static const char* value(const void* _p) { return (const char*)(_p); } - //template <typename T> static T make_return(const T& _p);// { return _p; } }; template <> inline int PluginFactoryBase::value<int>(const void* _p) { return *(int*)(_p); } template <> inline long PluginFactoryBase::value<long>(const void* _p) { return *(long*)(_p); } @@ -142,12 +141,6 @@ namespace { /// Base factory template template <typename P, typename S> class Factory {}; } -#if 0 -namespace dd4hep { - template <> inline long PluginFactoryBase::make_return(const long& value) - { static long stored=value; return (long)&stored; } -} -#endif #define DD4HEP_FACTORY_CALL(type,name,signature) dd4hep::PluginRegistry<signature>::add(name,Factory<type,signature>::call) #define DD4HEP_IMPLEMENT_PLUGIN_REGISTRY(X,Y) diff --git a/DDG4/include/DDG4/Factories.h b/DDG4/include/DDG4/Factories.h index 681e2ad42..3e87259e1 100644 --- a/DDG4/include/DDG4/Factories.h +++ b/DDG4/include/DDG4/Factories.h @@ -85,7 +85,8 @@ namespace { DD4HEP_PLUGIN_FACTORY_ARGS_3(long, dd4hep::Detector*, const _ns::GH*, const _ns::STRM*) { static long ret; - ret = dd4hep::Geant4SetupAction<P>::create(*a0, *a1, *a2); + long result = dd4hep::Geant4SetupAction<P>::create(*a0, *a1, *a2); + ret = result; return long(&ret); } /// Factory to create Geant4 sensitive detectors diff --git a/examples/CLICSiD/scripts/CLICSiDAClick.C b/examples/CLICSiD/scripts/CLICSiDAClick.C index 9cc3ff7db..d1a522409 100644 --- a/examples/CLICSiD/scripts/CLICSiDAClick.C +++ b/examples/CLICSiD/scripts/CLICSiDAClick.C @@ -56,6 +56,7 @@ int setupG4_CINT(bool interactive) { kernel.loadGeometry(("file:"+det_dir+"/DDDetectors/compact/SiD.xml").c_str()); kernel.loadXML(("file:"+install_dir+"/examples/CLICSiD/sim/field.xml").c_str()); + kernel.property("NumEvents") = 10; if ( interactive ) { kernel.property("UI") = "UI"; setPrintLevel(DEBUG); diff --git a/examples/CLICSiD/scripts/CLICSiDXML.C b/examples/CLICSiD/scripts/CLICSiDXML.C index 39522c946..d61d5b4ff 100644 --- a/examples/CLICSiD/scripts/CLICSiDXML.C +++ b/examples/CLICSiD/scripts/CLICSiDXML.C @@ -40,6 +40,7 @@ int setupG4_XML(bool interactive) { kernel.loadXML((prefix+"CLICSiD/sim/field.xml").c_str()); kernel.loadXML((prefix+"CLICSiD/sim/sequences.xml").c_str()); kernel.loadXML((prefix+"CLICSiD/sim/physics.xml").c_str()); + kernel.property("NumEvents") = 10; if ( interactive ) { kernel.property("UI") = "UI"; } -- GitLab