From ea505c562d38ffb5eca244537e35654f8f6d4a3c Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Tue, 4 Jul 2017 15:35:21 +0200 Subject: [PATCH] DetectorData: Warn if a second object (e.g., constant) is created, as insert will not overwrite the existing one --- DDCore/include/DD4hep/DetectorData.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DDCore/include/DD4hep/DetectorData.h b/DDCore/include/DD4hep/DetectorData.h index 9ab7233de..4caddffaa 100644 --- a/DDCore/include/DD4hep/DetectorData.h +++ b/DDCore/include/DD4hep/DetectorData.h @@ -15,6 +15,7 @@ #define DD4HEP_DDCORE_DETECTORDATA_H // Framework includes +#include "DD4hep/Printout.h" #include "DD4hep/Detector.h" #include "DD4hep/ObjectExtensions.h" #include "DD4hep/detail/VolumeManagerInterna.h" @@ -64,8 +65,12 @@ namespace dd4hep { if (e.isValid()) { std::string n = e.name(); std::pair<iterator, bool> r = this->insert(std::make_pair(n, e.ptr())); - if (!throw_on_doubles || r.second) + if (!throw_on_doubles || r.second) { + if (not r.second) { + printout(WARNING,"Detector","+++ Object '%s' is already defined and new one will be ignored", n.c_str()); + } return; + } throw InvalidObjectError("Attempt to add an already existing object:" + std::string(e.name()) + "."); } throw InvalidObjectError("Attempt to add an invalid object."); -- GitLab