Skip to content
Snippets Groups Projects
Commit 68b793d4 authored by Rosen Matev's avatar Rosen Matev :sunny:
Browse files

Allow histograms to be saved in custom directories

Before this change, RootHistogramSink always puts a histogram
in a top level directory named according to the component name.
This change allows a histogram to be saved in a custom directory
by naming it with a leading slash. In that case, the component
name is ignored.
parent e9955164
No related branches found
No related tags found
1 merge request!1353Allow histograms to be saved in custom directories
......@@ -67,6 +67,11 @@ namespace {
auto totNBins = ( ( axis[index].nBins + 2 ) * ... );
assert( weights.size() == totNBins );
if ( name[0] == '/' ) {
dir = "";
name = name.substr( 1 );
}
// take into account the case where name contains '/'s (e.g. "Group/Name") by
// moving the prefix into dir
if ( auto pos = name.rfind( '/' ); pos != std::string::npos ) {
......
......@@ -90,6 +90,7 @@ namespace Gaudi {
// updating histograms
++m_gauss[gauss];
++m_gaussAbsName[gauss];
++m_gaussVflat[{ flat, gauss }];
++m_gaussVflatVgauss[{ flat, gauss, gauss2 }];
++m_gauss_noato[gauss];
......@@ -273,6 +274,10 @@ namespace Gaudi {
mutable Accumulators::LogHistogram<1> m_log_gauss{ this, "LogGauss", "Log, Gaussian", { 5, 0, 2 } };
mutable Accumulators::LogHistogram<2, Accumulators::atomicity::full, float> m_log_gaussVflat{
this, "LogGaussFlat", "LogLog, Gaussian V Flat", { { 5, 0, 2 }, { 5, 0, 2 } } };
// Histogram in an absolute location
mutable Gaudi::Accumulators::Histogram<1> m_gaussAbsName{
this, "/TopDir/SubDir/Gauss", "Gaussian mean=0, sigma=1, atomic", { 100, -5, 5, "X" } };
};
DECLARE_COMPONENT( GaudiHistoAlgorithm )
} // namespace Counter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment