diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index 72ae0497a043b..99e63bf33c4ae 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -271,7 +271,8 @@ struct OutputManager { static bool postRun(EndOfStreamContext& context, HistogramRegistry& what) { - context.outputs().snapshot(what.ref(), *(*what)); + context.outputs().snapshot(what.ref(), *(what.getListOfHistograms())); + what.clean(); return true; } }; diff --git a/Framework/Core/include/Framework/HistogramRegistry.h b/Framework/Core/include/Framework/HistogramRegistry.h index 97a65a5b29f7a..a255c157040fd 100644 --- a/Framework/Core/include/Framework/HistogramRegistry.h +++ b/Framework/Core/include/Framework/HistogramRegistry.h @@ -119,7 +119,11 @@ class HistogramRegistry void setHash(uint32_t hash); - TList* operator*(); + /// returns the list of histograms, properly sorted for writing. + TList* getListOfHistograms(); + + /// deletes all the histograms from the registry + void clean(); // fill hist with values template diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index d2bd45af9d8c2..90574532744a6 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -183,6 +183,13 @@ double HistogramRegistry::getSize(double fillFraction) return size; } +void HistogramRegistry::clean() +{ + for (auto& value : mRegistryValue) { + std::visit([](auto&& hist) { hist.reset(); }, value); + } +} + // print some useful meta-info about the stored histograms void HistogramRegistry::print(bool showAxisDetails) { @@ -272,7 +279,7 @@ void HistogramRegistry::print(bool showAxisDetails) } // create output structure will be propagated to file-sink -TList* HistogramRegistry::operator*() +TList* HistogramRegistry::getListOfHistograms() { TList* list = new TList(); list->SetName(mName.data());