diff --git a/GaudiCoreSvc/src/MessageSvc/JSONSink.cpp b/GaudiCoreSvc/src/MessageSvc/JSONSink.cpp index 4c9a2de9f944e5ddc4be7af7e7f22e5c71ce3488..5798912fc2c2de10543d1e7159a7402f717c75fc 100644 --- a/GaudiCoreSvc/src/MessageSvc/JSONSink.cpp +++ b/GaudiCoreSvc/src/MessageSvc/JSONSink.cpp @@ -73,12 +73,7 @@ namespace Gaudi::Monitoring { StatusCode stop() override; // Gaudi::Monitoring::Hub::Sink implementation - void registerEntity( Hub::Entity ent ) override { - if ( std::string_view( ent.type ).substr( 0, 8 ) == "counter:" || ent.type == "statentity" || - ent.type == "histogram" ) { - m_monitoringEntities.emplace_back( std::move( ent ) ); - } - } + void registerEntity( Hub::Entity ent ) override { m_monitoringEntities.emplace_back( std::move( ent ) ); } // Gaudi::Monitoring::Hub::Sink implementation void removeEntity( Hub::Entity const& ent ) override { diff --git a/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp b/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp index 714bf19ed63c87cdcae7958571cbbe358c92c590..0f2351bdfe178dd0f71f87f6bcac3c7cf97ca409 100644 --- a/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp +++ b/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp @@ -171,12 +171,7 @@ namespace Gaudi::Monitoring { StatusCode stop() override; // Gaudi::Monitoring::Hub::Sink implementation - void registerEntity( Hub::Entity ent ) override { - if ( std::string_view( ent.type ).substr( 0, 8 ) == "counter:" || ent.type == "statentity" || - ent.type == "histogram" ) { - m_monitoringEntities.emplace_back( std::move( ent ) ); - } - } + void registerEntity( Hub::Entity ent ) override { m_monitoringEntities.emplace_back( std::move( ent ) ); } // Gaudi::Monitoring::Hub::Sink implementation void removeEntity( Hub::Entity const& ent ) override { diff --git a/GaudiExamples/options/Histograms.py b/GaudiExamples/options/Histograms.py index 07efde9e20b95d5c21f43dee773b4a5b7fc5afc7..969ddf19270db16239c7427f6d0258743ae98cd5 100644 --- a/GaudiExamples/options/Histograms.py +++ b/GaudiExamples/options/Histograms.py @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ##################################################################################### +from Configurables import Gaudi__Monitoring__JSONSink as JSONSink from Configurables import Gaudi__Monitoring__MessageSvcSink as MessageSvcSink from Gaudi.Configuration import * @@ -36,5 +37,5 @@ app = ApplicationMgr( EvtSel="NONE", HistogramPersistency="ROOT", TopAlg=algs, - ExtSvc=[MessageSvcSink(), RootHistoSink()], + ExtSvc=[MessageSvcSink(), RootHistoSink(), JSONSink(DumpFullInfo=True)], ) diff --git a/GaudiExamples/src/Histograms/CounterHistos.cpp b/GaudiExamples/src/Histograms/CounterHistos.cpp index e8224c1e76c7263b357cdbe5eed33dbd3eb33a4a..321ed349c41ab67ad3c5fa28c5d10a67c3de33c4 100644 --- a/GaudiExamples/src/Histograms/CounterHistos.cpp +++ b/GaudiExamples/src/Histograms/CounterHistos.cpp @@ -73,6 +73,18 @@ namespace Gaudi { public: using Gaudi::Algorithm::Algorithm; + StatusCode initialize() override { + return Algorithm::initialize().andThen( [&] { + for ( int i : { 1, 2, 3 } ) { + using AxesSpecType = decltype( m_map_prof_gauss_init )::mapped_type::AxesSpecType; + m_map_prof_gauss_init.emplace( std::piecewise_construct, std::forward_as_tuple( i ), + std::forward_as_tuple( this, "MapGaussInit" + std::to_string( i ), + "Gaussian mean=0, sigma=1, atomic", + AxesSpecType( { 50, -5, 5 }, { 50, -5, 5 } ) ) ); + } + } ); + } + StatusCode execute( const EventContext& ) const override { // some random number generators, just to provide numbers static Rndm::Numbers Gauss( randSvc(), Rndm::Gauss( 0.0, 1.0 ) ); @@ -137,6 +149,12 @@ namespace Gaudi { prof_gaussVflatVgauss_buf[{ flat, gauss, gauss2 }] += gauss3; } + // maps of histograms + for ( int i : { 1, 2, 3 } ) { + ++m_map_gauss_construct.at( i )[gauss]; + m_map_prof_gauss_init.at( i )[gauss] += gauss3; + } + if ( m_nCalls.nEntries() == 0 ) always() << "Filling Histograms...... Please be patient !" << endmsg; ++m_nCalls; return StatusCode::SUCCESS; @@ -261,6 +279,21 @@ namespace Gaudi { "ProfGaussFlatGaussBuf", "Profile, Gaussian V Flat V Gaussian, buffered", { { 10, -5, 5 }, { 10, -5, 5 }, { 10, -5, 5 } } }; + + // map of histograms that is filled on construction + mutable std::map<int, Gaudi::Accumulators::Histogram<1>> m_map_gauss_construct = [this]() { + std::map<int, Gaudi::Accumulators::Histogram<1>> map; + for ( int i : { 1, 2, 3 } ) { + using AxesSpecType = decltype( map )::mapped_type::AxesSpecType; + map.emplace( std::piecewise_construct, std::forward_as_tuple( i ), + std::forward_as_tuple( this, "MapGaussConstruct" + std::to_string( i ), + "Gaussian mean=0, sigma=1, atomic", AxesSpecType( { 50, -5, 5 } ) ) ); + } + return map; + }(); + + // map of histograms that is filled at initialization (e.g. because it depends on properties) + mutable std::map<int, Gaudi::Accumulators::ProfileHistogram<2>> m_map_prof_gauss_init; }; DECLARE_COMPONENT( GaudiHistoAlgorithm ) } // namespace Counter diff --git a/GaudiExamples/tests/qmtest/refs/Histograms.ref b/GaudiExamples/tests/qmtest/refs/Histograms.ref index af1541cd5e2bdc4718f2f5654baf03d2d847b980..388fd735f34974085ee2dbfa140f62ba1e8a8373 100644 --- a/GaudiExamples/tests/qmtest/refs/Histograms.ref +++ b/GaudiExamples/tests/qmtest/refs/Histograms.ref @@ -1,10 +1,9 @@ -# setting LC_ALL to "C" -# --> Including file '/builds/gaudi/Gaudi/GaudiExamples/options/Histograms.py' -# <-- End of file '/builds/gaudi/Gaudi/GaudiExamples/options/Histograms.py' +# --> Including file '/home/rmatev/stack/Gaudi/GaudiExamples/options/Histograms.py' +# <-- End of file '/home/rmatev/stack/Gaudi/GaudiExamples/options/Histograms.py' ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v34r1) - running on runner-7f-zqs17-project-38-concurrent-0 on Mon Oct 19 16:16:56 2020 + Welcome to ApplicationMgr (GaudiCoreSvc v36r5) + running on n4050101 on Thu Jun 9 09:11:00 2022 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully SimpleHistos DEBUG Property update for OutputLevel : new value = 2 @@ -134,8 +133,45 @@ SimpleHistos DEBUG Monitoring histogram 'test1' desc = 'Forced Alpha ID t SimpleHistos DEBUG Booked 1D Histogram : ID='test1' Path=SimpleHistos Title='Forced Alpha ID time test' SimpleHistos INFO GaudiHistoAlgorithm:: Filling Histograms...... Please be patient ! SimpleCounterHi...SUCCESS Filling Histograms...... Please be patient ! -SimpleCounterHi... INFO Number of counters : 1 +Gaudi::Monitori... INFO Writing counters to JSON file counters.json +SimpleCounterHi... INFO Number of counters : 37 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | + | "Gauss" | 50000 | + | "GaussBuf" | 500000 | + | "GaussFlat" | 50000 | + | "GaussFlatBuf" | 500000 | + | "GaussFlatGauss" | 50000 | + | "GaussFlatGaussBuf" | 500000 | + | "GaussFlatGaussInt" | 50000 | + | "GaussFlatGaussNA" | 50000 | + | "GaussFlatGaussW" | 24836 | + | "GaussFlatInt" | 50000 | + | "GaussFlatNA" | 50000 | + | "GaussFlatW" | 24592 | + | "GaussInt" | 50000 | + | "GaussNA" | 50000 | + | "GaussW" | 24981 | + | "MapGaussConstruct1" | 50000 | + | "MapGaussConstruct2" | 50000 | + | "MapGaussConstruct3" | 50000 | + | "MapGaussInit1" | 50000 | + | "MapGaussInit2" | 50000 | + | "MapGaussInit3" | 50000 | + | "ProfGauss" | 50000 | + | "ProfGaussBuf" | 500000 | + | "ProfGaussFlat" | 50000 | + | "ProfGaussFlatBuf" | 500000 | + | "ProfGaussFlatGauss" | 50000 | + | "ProfGaussFlatGaussBuf" | 500000 | + | "ProfGaussFlatGaussInt" | 50000 | + | "ProfGaussFlatGaussNA" | 50000 | + | "ProfGaussFlatGaussW" | 24836 | + | "ProfGaussFlatInt" | 50000 | + | "ProfGaussFlatNA" | 50000 | + | "ProfGaussFlatW" | 24592 | + | "ProfGaussInt" | 50000 | + | "ProfGaussNA" | 50000 | + | "ProfGaussW" | 24981 | | "calls" | 50000 | ApplicationMgr INFO Application Manager Stopped successfully SimpleHistos SUCCESS Booked 30 Histogram(s) : 1D=10 2D=5 3D=3 1DProf=9 2DProf=3 @@ -183,11 +219,11 @@ EventLoopMgr INFO Histograms converted successfully according to request *****Chrono***** INFO **************************************************************************************************** *****Chrono***** INFO The Final CPU consumption ( Chrono ) Table (ordered) *****Chrono***** INFO **************************************************************************************************** -1DOldStyle INFO Time User : Tot= 30 [ms] Ave/Min/Max= 0.0006(+- 0.0775)/ 0/ 10 [ms] #=49999 -1DForcedAlphaID INFO Time User : Tot= 80 [ms] Ave/Min/Max= 0.0016(+- 0.126)/ 0/ 10 [ms] #=49999 -1DAutoID INFO Time User : Tot= 100 [ms] Ave/Min/Max= 0.002(+- 0.141)/ 0/ 10 [ms] #=49999 -1DForcedNumericID INFO Time User : Tot= 120 [ms] Ave/Min/Max= 0.0024(+- 0.155)/ 0/ 10 [ms] #=49999 -ChronoStatSvc INFO Time User : Tot= 3.34 [s] #= 1 +1DForcedAlphaID INFO Time User : Tot= 0 [us] Ave/Min/Max= 0(+- 0)/ 0/ 0 [us] #=49999 +1DOldStyle INFO Time User : Tot= 10 [ms] Ave/Min/Max= 0.0002(+- 0.0447)/ 0/ 10 [ms] #=49999 +1DForcedNumericID INFO Time User : Tot= 10 [ms] Ave/Min/Max= 0.0002(+- 0.0447)/ 0/ 10 [ms] #=49999 +1DAutoID INFO Time User : Tot= 40 [ms] Ave/Min/Max= 0.0008(+- 0.0894)/ 0/ 10 [ms] #=49999 +ChronoStatSvc INFO Time User : Tot= 3.14 [s] #= 1 *****Chrono***** INFO **************************************************************************************************** ChronoStatSvc.f... INFO Service finalized successfully ApplicationMgr INFO Application Manager Finalized successfully diff --git a/GaudiExamples/tests/qmtest/refs/config2/Histograms_wg.ref b/GaudiExamples/tests/qmtest/refs/config2/Histograms_wg.ref index 08be8f1522f870f0b00ae6f6af85741b153ae954..46d71e2418fd7bd786d1b53240e27d8875c0a3f0 100644 --- a/GaudiExamples/tests/qmtest/refs/config2/Histograms_wg.ref +++ b/GaudiExamples/tests/qmtest/refs/config2/Histograms_wg.ref @@ -1,10 +1,9 @@ -# setting LC_ALL to "C" -# --> Including file '/builds/gaudi/Gaudi/GaudiExamples/options/Histograms_with_global.py' -# <-- End of file '/builds/gaudi/Gaudi/GaudiExamples/options/Histograms_with_global.py' +# --> Including file '/home/rmatev/stack/Gaudi/GaudiExamples/options/Histograms_with_global.py' +# <-- End of file '/home/rmatev/stack/Gaudi/GaudiExamples/options/Histograms_with_global.py' ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v34r1) - running on runner-7f-zqs17-project-38-concurrent-0 on Mon Oct 19 16:16:46 2020 + Welcome to ApplicationMgr (GaudiCoreSvc v36r5) + running on n4050101 on Thu Jun 9 09:10:57 2022 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully SimpleHistos DEBUG Property update for OutputLevel : new value = 2 @@ -136,8 +135,44 @@ SimpleHistos DEBUG Monitoring histogram 'test1' desc = 'Forced Alpha ID t SimpleHistos DEBUG Booked 1D Histogram : ID='test1' Path=SimpleHistos Title='Forced Alpha ID time test' SimpleHistos INFO GaudiHistoAlgorithm:: Filling Histograms...... Please be patient ! SimpleCounterHi...SUCCESS Filling Histograms...... Please be patient ! -SimpleCounterHi... INFO Number of counters : 1 +SimpleCounterHi... INFO Number of counters : 37 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | + | "Gauss" | 50000 | + | "GaussBuf" | 500000 | + | "GaussFlat" | 50000 | + | "GaussFlatBuf" | 500000 | + | "GaussFlatGauss" | 50000 | + | "GaussFlatGaussBuf" | 500000 | + | "GaussFlatGaussInt" | 50000 | + | "GaussFlatGaussNA" | 50000 | + | "GaussFlatGaussW" | 24836 | + | "GaussFlatInt" | 50000 | + | "GaussFlatNA" | 50000 | + | "GaussFlatW" | 24592 | + | "GaussInt" | 50000 | + | "GaussNA" | 50000 | + | "GaussW" | 24981 | + | "MapGaussConstruct1" | 50000 | + | "MapGaussConstruct2" | 50000 | + | "MapGaussConstruct3" | 50000 | + | "MapGaussInit1" | 50000 | + | "MapGaussInit2" | 50000 | + | "MapGaussInit3" | 50000 | + | "ProfGauss" | 50000 | + | "ProfGaussBuf" | 500000 | + | "ProfGaussFlat" | 50000 | + | "ProfGaussFlatBuf" | 500000 | + | "ProfGaussFlatGauss" | 50000 | + | "ProfGaussFlatGaussBuf" | 500000 | + | "ProfGaussFlatGaussInt" | 50000 | + | "ProfGaussFlatGaussNA" | 50000 | + | "ProfGaussFlatGaussW" | 24836 | + | "ProfGaussFlatInt" | 50000 | + | "ProfGaussFlatNA" | 50000 | + | "ProfGaussFlatW" | 24592 | + | "ProfGaussInt" | 50000 | + | "ProfGaussNA" | 50000 | + | "ProfGaussW" | 24981 | | "calls" | 50000 | ApplicationMgr INFO Application Manager Stopped successfully SimpleHistos SUCCESS Booked 30 Histogram(s) : 1D=10 2D=5 3D=3 1DProf=9 2DProf=3 @@ -185,11 +220,11 @@ EventLoopMgr INFO Histograms converted successfully according to request *****Chrono***** INFO **************************************************************************************************** *****Chrono***** INFO The Final CPU consumption ( Chrono ) Table (ordered) *****Chrono***** INFO **************************************************************************************************** -1DAutoID INFO Time User : Tot= 80 [ms] Ave/Min/Max= 0.0016(+- 0.126)/ 0/ 10 [ms] #=49999 -1DForcedAlphaID INFO Time User : Tot= 120 [ms] Ave/Min/Max= 0.0024(+- 0.155)/ 0/ 10 [ms] #=49999 -1DForcedNumericID INFO Time User : Tot= 110 [ms] Ave/Min/Max= 0.0022(+- 0.148)/ 0/ 10 [ms] #=49999 -1DOldStyle INFO Time User : Tot= 130 [ms] Ave/Min/Max= 0.0026(+- 0.161)/ 0/ 10 [ms] #=49999 -ChronoStatSvc INFO Time User : Tot= 3.26 [s] #= 1 +1DOldStyle INFO Time User : Tot= 10 [ms] Ave/Min/Max= 0.0002(+- 0.0447)/ 0/ 10 [ms] #=49999 +1DForcedNumericID INFO Time User : Tot= 30 [ms] Ave/Min/Max= 0.0006(+- 0.0775)/ 0/ 10 [ms] #=49999 +1DForcedAlphaID INFO Time User : Tot= 30 [ms] Ave/Min/Max= 0.0006(+- 0.0775)/ 0/ 10 [ms] #=49999 +1DAutoID INFO Time User : Tot= 30 [ms] Ave/Min/Max= 0.0006(+- 0.0775)/ 0/ 10 [ms] #=49999 +ChronoStatSvc INFO Time User : Tot= 3.04 [s] #= 1 *****Chrono***** INFO **************************************************************************************************** ChronoStatSvc.f... INFO Service finalized successfully ApplicationMgr INFO Application Manager Finalized successfully diff --git a/GaudiKernel/include/Gaudi/Accumulators/Histogram.h b/GaudiKernel/include/Gaudi/Accumulators/Histogram.h index e33fff7a6366e4307312c9d7fc4f329812c017ce..032c34ef71f9e1325cc7e157e41bdb55630ce8e0 100644 --- a/GaudiKernel/include/Gaudi/Accumulators/Histogram.h +++ b/GaudiKernel/include/Gaudi/Accumulators/Histogram.h @@ -265,8 +265,9 @@ namespace Gaudi::Accumulators { public: using BaseAccumulator = BaseAccumulatorT<Atomicity, Arithmetic>; using AxisArithmeticType = typename InputType::AxisArithmeticType; + using AxesSpecType = GetTuple_t<Axis<AxisArithmeticType>, ND::value>; template <std::size_t... Is> - HistogramingAccumulatorInternal( GetTuple_t<Axis<AxisArithmeticType>, ND::value> axis, std::index_sequence<Is...> ) + HistogramingAccumulatorInternal( AxesSpecType axis, std::index_sequence<Is...> ) : m_axis{ std::get<Is>( axis )... } , m_totNBins{ computeTotNBins() } , m_value( new BaseAccumulator[m_totNBins] ) {