From 565db739a80f0ceea3a76d201985d2e26ba374a8 Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Wed, 30 Aug 2023 14:09:51 +0200
Subject: [PATCH 01/11] add alogrithm to monitor event variables based on
 functors

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 131 +++++++++++++++++++++++++
 1 file changed, 131 insertions(+)
 create mode 100644 Phys/SelAlgorithms/src/VoidMonitor.cpp

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
new file mode 100644
index 00000000000..1b29c97d3f2
--- /dev/null
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -0,0 +1,131 @@
+/*****************************************************************************\
+* (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration           *
+*                                                                             *
+* This software is distributed under the terms of the GNU General Public      *
+* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   *
+*                                                                             *
+* In applying this licence, CERN does not waive the privileges and immunities *
+* granted to it by virtue of its status as an Intergovernmental Organization  *
+* or submit itself to any jurisdiction.                                       *
+\*****************************************************************************/
+#include "Functors/with_functors.h"
+#include "Functors/with_output_tree.h"
+#include "Gaudi/Accumulators/Histogram.h"
+// #include "GaudiAlg/FilterPredicate.h"
+#include "LHCbAlgs/Producer.h"
+
+namespace {
+  struct VoidFunctor {
+    using Signature                    = std::any();
+    static constexpr auto PropertyName = "Variable";
+  };
+  struct VoidFunctorX {
+    using Signature                    = std::any();
+    static constexpr auto PropertyName = "VariableX";
+  };
+  struct VoidFunctorY {
+    using Signature                    = std::any();
+    static constexpr auto PropertyName = "VariableY";
+  };
+  using base_type = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctor>;
+  using base_type2 = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctorX, VoidFunctorY>;
+  using value_type = int;
+} // namespace
+
+
+
+/** @class EventVariableMonitor EventVariableMonitor.cpp
+ */
+struct EventVariableMonitor final : public base_type {
+  EventVariableMonitor( const std::string& name, ISvcLocator* pSvcLocator )
+      : base_type{name, pSvcLocator, { "Dummy", "" }} {}
+
+
+
+  int operator()() const override {
+    auto const& functor = getFunctor<VoidFunctor>();
+    Functors::detail::with_output_tree::numeric_value_wrapper w( functor.rtype() );
+    std::visit(
+              [&]( auto& x ) {
+                auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functor ) );
+                ++( *m_histogram )[LHCb::Utils::as_arithmetic( unwrapped )];
+              },
+              w.get() );
+    return 1;
+  }
+
+  StatusCode initialize() override {
+
+    auto sc = base_type::initialize();
+      if ( sc.isFailure() ) return sc;
+      if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
+      m_histogram.emplace(
+        this, m_histogram_name.value(), m_histogram_title.value(),
+        Gaudi::Accumulators::Axis<value_type>{m_bins.value(), m_range.value().first, m_range.value().second} );
+      return sc;
+  }
+
+private:
+  // Counter for recording cut retention statistics
+  mutable Gaudi::Accumulators::BinomialCounter<> m_cutEff{this, "Cut selection efficiency"};
+  private:
+  // properties
+  Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
+  Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
+                                                 "Histogram title (it defaults to the histogram name)"};
+  Gaudi::Property<unsigned int> m_bins{this, "Bins", 100};
+  Gaudi::Property<std::pair<value_type, value_type>> m_range{this, "Range", {0., 1.}};
+  mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, value_type>> m_histogram;
+};
+
+DECLARE_COMPONENT_WITH_ID( EventVariableMonitor, "EventVariableMonitor" )
+
+
+struct EventCorrelationsMonitor final : public base_type2 {
+  EventCorrelationsMonitor( const std::string& name, ISvcLocator* pSvcLocator )
+      : base_type2{name, pSvcLocator, { "Dummy", "" }} {}
+
+
+
+  int operator()() const override {
+    auto const& functorX = getFunctor<VoidFunctorX>();
+    auto const& functorY = getFunctor<VoidFunctorY>();
+    Functors::detail::with_output_tree::numeric_value_wrapper wX( functorX.rtype() );
+    Functors::detail::with_output_tree::numeric_value_wrapper wY( functorY.rtype() );
+    std::visit(
+              [&]( auto& x ) {
+                auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorX ) );
+                ++( *m_histogram )[{LHCb::Utils::as_arithmetic( unwrapped ),LHCb::Utils::as_arithmetic( unwrapped )}] ;
+              },
+              wX.get() );
+    return 1;
+  }
+
+  StatusCode initialize() override {
+
+    auto sc = base_type2::initialize();
+      if ( sc.isFailure() ) return sc;
+      if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
+      m_histogram.emplace(
+        this, m_histogram_name.value(), m_histogram_title.value(),
+        Gaudi::Accumulators::Axis<value_type>{m_binsX.value(), m_rangeX.value().first, m_rangeX.value().second},
+        Gaudi::Accumulators::Axis<value_type>{m_binsY.value(), m_rangeY.value().first, m_rangeY.value().second} );
+      return sc;
+  }
+
+private:
+  // Counter for recording cut retention statistics
+  mutable Gaudi::Accumulators::BinomialCounter<> m_cutEff{this, "Cut selection efficiency"};
+  private:
+  // properties
+  Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
+  Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
+                                                 "Histogram title (it defaults to the histogram name)"};
+  Gaudi::Property<unsigned int> m_binsX{this, "BinsX", 100};
+  Gaudi::Property<unsigned int> m_binsY{this, "BinsY", 100};
+  Gaudi::Property<std::pair<value_type, value_type>> m_rangeX{this, "RangeX", {0., 1.}};
+  Gaudi::Property<std::pair<value_type, value_type>> m_rangeY{this, "RangeY", {0., 1.}};
+  mutable std::optional<Gaudi::Accumulators::Histogram<2, Gaudi::Accumulators::atomicity::full, value_type>> m_histogram;
+};
+
+DECLARE_COMPONENT_WITH_ID( EventCorrelationsMonitor, "EventCorrelationsMonitor" )
-- 
GitLab


From 426f60d038b31cba6de65e07b38f7ac7565e5680 Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Wed, 30 Aug 2023 14:10:58 +0200
Subject: [PATCH 02/11] add alogrithm to monitor event variables based on
 functors

---
 Phys/SelAlgorithms/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Phys/SelAlgorithms/CMakeLists.txt b/Phys/SelAlgorithms/CMakeLists.txt
index 35024fbb206..623ceb85e53 100644
--- a/Phys/SelAlgorithms/CMakeLists.txt
+++ b/Phys/SelAlgorithms/CMakeLists.txt
@@ -36,6 +36,7 @@ gaudi_add_module(SelAlgorithms
         src/TestFunctors_PrTracks.cpp
         src/TestFunctors_void.cpp
         src/VoidFilter.cpp
+        src/VoidMonitor.cpp
     LINK
         SelAlgorithmsLib
         Gaudi::GaudiAlgLib
-- 
GitLab


From b24b363e6022d21823d6bfce9a5f066c1986042b Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Tue, 17 Oct 2023 11:36:14 +0200
Subject: [PATCH 03/11] Void monitpr

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 1b29c97d3f2..0792e4ad730 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -29,7 +29,7 @@ namespace {
   };
   using base_type = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctor>;
   using base_type2 = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctorX, VoidFunctorY>;
-  using value_type = int;
+  using value_type = float;
 } // namespace
 
 
@@ -45,6 +45,9 @@ struct EventVariableMonitor final : public base_type {
   int operator()() const override {
     auto const& functor = getFunctor<VoidFunctor>();
     Functors::detail::with_output_tree::numeric_value_wrapper w( functor.rtype() );
+
+    always()<<std::any_cast<value_type>( std::invoke( functor ) )<<endmsg;
+
     std::visit(
               [&]( auto& x ) {
                 auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functor ) );
@@ -78,7 +81,7 @@ private:
   mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, value_type>> m_histogram;
 };
 
-DECLARE_COMPONENT_WITH_ID( EventVariableMonitor, "EventVariableMonitor" )
+DECLARE_COMPONENT_WITH_ID( EventVariableMonitor, "Monitor__EventVariable" )
 
 
 struct EventCorrelationsMonitor final : public base_type2 {
@@ -92,12 +95,19 @@ struct EventCorrelationsMonitor final : public base_type2 {
     auto const& functorY = getFunctor<VoidFunctorY>();
     Functors::detail::with_output_tree::numeric_value_wrapper wX( functorX.rtype() );
     Functors::detail::with_output_tree::numeric_value_wrapper wY( functorY.rtype() );
+    Functors::detail::with_output_tree::numeric_value valueX;
+    auto fval = std::invoke( functorX );
+    std::visit( [&]( auto& x ) { valueX = std::any_cast<std::decay_t<decltype( x )>>( fval ); }, valueX );
+    // LHCb::Utils::as_arithmetic( valueX.get() );
     std::visit(
               [&]( auto& x ) {
-                auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorX ) );
-                ++( *m_histogram )[{LHCb::Utils::as_arithmetic( unwrapped ),LHCb::Utils::as_arithmetic( unwrapped )}] ;
+                auto unwrappedX = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorX ) );
+                auto unwrappedY = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorY ) );
+                ++( *m_histogram )[{LHCb::Utils::as_arithmetic( unwrappedX ),LHCb::Utils::as_arithmetic( unwrappedY )}] ;
+
               },
               wX.get() );
+
     return 1;
   }
 
-- 
GitLab


From 83c633f2d16e20245785c13a4b2904fdfbe62b8d Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Wed, 13 Dec 2023 12:59:07 +0100
Subject: [PATCH 04/11] remove test code

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 0792e4ad730..3e88a7e594d 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -46,8 +46,6 @@ struct EventVariableMonitor final : public base_type {
     auto const& functor = getFunctor<VoidFunctor>();
     Functors::detail::with_output_tree::numeric_value_wrapper w( functor.rtype() );
 
-    always()<<std::any_cast<value_type>( std::invoke( functor ) )<<endmsg;
-
     std::visit(
               [&]( auto& x ) {
                 auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functor ) );
-- 
GitLab


From 44b21ede13f6bc2c59c02923b51fa9d3603143c9 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Wed, 13 Dec 2023 11:59:47 +0000
Subject: [PATCH 05/11] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/34695717
---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 74 ++++++++++++--------------
 1 file changed, 35 insertions(+), 39 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 3e88a7e594d..d1791388d41 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -27,84 +27,78 @@ namespace {
     using Signature                    = std::any();
     static constexpr auto PropertyName = "VariableY";
   };
-  using base_type = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctor>;
+  using base_type  = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctor>;
   using base_type2 = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctorX, VoidFunctorY>;
   using value_type = float;
 } // namespace
 
-
-
 /** @class EventVariableMonitor EventVariableMonitor.cpp
  */
 struct EventVariableMonitor final : public base_type {
   EventVariableMonitor( const std::string& name, ISvcLocator* pSvcLocator )
-      : base_type{name, pSvcLocator, { "Dummy", "" }} {}
-
-
+      : base_type{name, pSvcLocator, {"Dummy", ""}} {}
 
   int operator()() const override {
-    auto const& functor = getFunctor<VoidFunctor>();
+    auto const&                                               functor = getFunctor<VoidFunctor>();
     Functors::detail::with_output_tree::numeric_value_wrapper w( functor.rtype() );
 
     std::visit(
-              [&]( auto& x ) {
-                auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functor ) );
-                ++( *m_histogram )[LHCb::Utils::as_arithmetic( unwrapped )];
-              },
-              w.get() );
+        [&]( auto& x ) {
+          auto unwrapped = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functor ) );
+          ++( *m_histogram )[LHCb::Utils::as_arithmetic( unwrapped )];
+        },
+        w.get() );
     return 1;
   }
 
   StatusCode initialize() override {
 
     auto sc = base_type::initialize();
-      if ( sc.isFailure() ) return sc;
-      if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
-      m_histogram.emplace(
+    if ( sc.isFailure() ) return sc;
+    if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
+    m_histogram.emplace(
         this, m_histogram_name.value(), m_histogram_title.value(),
         Gaudi::Accumulators::Axis<value_type>{m_bins.value(), m_range.value().first, m_range.value().second} );
-      return sc;
+    return sc;
   }
 
 private:
   // Counter for recording cut retention statistics
   mutable Gaudi::Accumulators::BinomialCounter<> m_cutEff{this, "Cut selection efficiency"};
-  private:
+
+private:
   // properties
   Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
   Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
                                                  "Histogram title (it defaults to the histogram name)"};
   Gaudi::Property<unsigned int> m_bins{this, "Bins", 100};
   Gaudi::Property<std::pair<value_type, value_type>> m_range{this, "Range", {0., 1.}};
-  mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, value_type>> m_histogram;
+  mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, value_type>>
+      m_histogram;
 };
 
 DECLARE_COMPONENT_WITH_ID( EventVariableMonitor, "Monitor__EventVariable" )
 
-
 struct EventCorrelationsMonitor final : public base_type2 {
   EventCorrelationsMonitor( const std::string& name, ISvcLocator* pSvcLocator )
-      : base_type2{name, pSvcLocator, { "Dummy", "" }} {}
-
-
+      : base_type2{name, pSvcLocator, {"Dummy", ""}} {}
 
   int operator()() const override {
-    auto const& functorX = getFunctor<VoidFunctorX>();
-    auto const& functorY = getFunctor<VoidFunctorY>();
+    auto const&                                               functorX = getFunctor<VoidFunctorX>();
+    auto const&                                               functorY = getFunctor<VoidFunctorY>();
     Functors::detail::with_output_tree::numeric_value_wrapper wX( functorX.rtype() );
     Functors::detail::with_output_tree::numeric_value_wrapper wY( functorY.rtype() );
-    Functors::detail::with_output_tree::numeric_value valueX;
-    auto fval = std::invoke( functorX );
+    Functors::detail::with_output_tree::numeric_value         valueX;
+    auto                                                      fval = std::invoke( functorX );
     std::visit( [&]( auto& x ) { valueX = std::any_cast<std::decay_t<decltype( x )>>( fval ); }, valueX );
     // LHCb::Utils::as_arithmetic( valueX.get() );
     std::visit(
-              [&]( auto& x ) {
-                auto unwrappedX = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorX ) );
-                auto unwrappedY = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorY ) );
-                ++( *m_histogram )[{LHCb::Utils::as_arithmetic( unwrappedX ),LHCb::Utils::as_arithmetic( unwrappedY )}] ;
-
-              },
-              wX.get() );
+        [&]( auto& x ) {
+          auto unwrappedX = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorX ) );
+          auto unwrappedY = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorY ) );
+          ++( *m_histogram )[{LHCb::Utils::as_arithmetic( unwrappedX ), LHCb::Utils::as_arithmetic( unwrappedY )}];
+        },
+        wX.get() );
 
     return 1;
   }
@@ -112,19 +106,20 @@ struct EventCorrelationsMonitor final : public base_type2 {
   StatusCode initialize() override {
 
     auto sc = base_type2::initialize();
-      if ( sc.isFailure() ) return sc;
-      if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
-      m_histogram.emplace(
+    if ( sc.isFailure() ) return sc;
+    if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
+    m_histogram.emplace(
         this, m_histogram_name.value(), m_histogram_title.value(),
         Gaudi::Accumulators::Axis<value_type>{m_binsX.value(), m_rangeX.value().first, m_rangeX.value().second},
         Gaudi::Accumulators::Axis<value_type>{m_binsY.value(), m_rangeY.value().first, m_rangeY.value().second} );
-      return sc;
+    return sc;
   }
 
 private:
   // Counter for recording cut retention statistics
   mutable Gaudi::Accumulators::BinomialCounter<> m_cutEff{this, "Cut selection efficiency"};
-  private:
+
+private:
   // properties
   Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
   Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
@@ -133,7 +128,8 @@ private:
   Gaudi::Property<unsigned int> m_binsY{this, "BinsY", 100};
   Gaudi::Property<std::pair<value_type, value_type>> m_rangeX{this, "RangeX", {0., 1.}};
   Gaudi::Property<std::pair<value_type, value_type>> m_rangeY{this, "RangeY", {0., 1.}};
-  mutable std::optional<Gaudi::Accumulators::Histogram<2, Gaudi::Accumulators::atomicity::full, value_type>> m_histogram;
+  mutable std::optional<Gaudi::Accumulators::Histogram<2, Gaudi::Accumulators::atomicity::full, value_type>>
+      m_histogram;
 };
 
 DECLARE_COMPONENT_WITH_ID( EventCorrelationsMonitor, "EventCorrelationsMonitor" )
-- 
GitLab


From 2c76fe2166b090eb2171166c7e456836f5aa2dad Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Wed, 13 Dec 2023 15:07:22 +0100
Subject: [PATCH 06/11] remove monitor for 2 variables

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 73 ++------------------------
 1 file changed, 5 insertions(+), 68 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index d1791388d41..6d66a494325 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -12,23 +12,15 @@
 #include "Functors/with_output_tree.h"
 #include "Gaudi/Accumulators/Histogram.h"
 // #include "GaudiAlg/FilterPredicate.h"
-#include "LHCbAlgs/Producer.h"
+// #include "LHCbAlgs/Producer.h"
+#include "LHCbAlgs/Consumer.h"
 
 namespace {
   struct VoidFunctor {
     using Signature                    = std::any();
     static constexpr auto PropertyName = "Variable";
   };
-  struct VoidFunctorX {
-    using Signature                    = std::any();
-    static constexpr auto PropertyName = "VariableX";
-  };
-  struct VoidFunctorY {
-    using Signature                    = std::any();
-    static constexpr auto PropertyName = "VariableY";
-  };
-  using base_type  = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctor>;
-  using base_type2 = with_functors<LHCb::Algorithm::Producer<int()>, VoidFunctorX, VoidFunctorY>;
+  using base_type  = with_functors<LHCb::Algorithm::Consumer<void()>, VoidFunctor>;
   using value_type = float;
 } // namespace
 
@@ -36,9 +28,9 @@ namespace {
  */
 struct EventVariableMonitor final : public base_type {
   EventVariableMonitor( const std::string& name, ISvcLocator* pSvcLocator )
-      : base_type{name, pSvcLocator, {"Dummy", ""}} {}
+      : base_type{name, pSvcLocator, {}} {}
 
-  int operator()() const override {
+  void operator()() const override {
     auto const&                                               functor = getFunctor<VoidFunctor>();
     Functors::detail::with_output_tree::numeric_value_wrapper w( functor.rtype() );
 
@@ -48,7 +40,6 @@ struct EventVariableMonitor final : public base_type {
           ++( *m_histogram )[LHCb::Utils::as_arithmetic( unwrapped )];
         },
         w.get() );
-    return 1;
   }
 
   StatusCode initialize() override {
@@ -79,57 +70,3 @@ private:
 
 DECLARE_COMPONENT_WITH_ID( EventVariableMonitor, "Monitor__EventVariable" )
 
-struct EventCorrelationsMonitor final : public base_type2 {
-  EventCorrelationsMonitor( const std::string& name, ISvcLocator* pSvcLocator )
-      : base_type2{name, pSvcLocator, {"Dummy", ""}} {}
-
-  int operator()() const override {
-    auto const&                                               functorX = getFunctor<VoidFunctorX>();
-    auto const&                                               functorY = getFunctor<VoidFunctorY>();
-    Functors::detail::with_output_tree::numeric_value_wrapper wX( functorX.rtype() );
-    Functors::detail::with_output_tree::numeric_value_wrapper wY( functorY.rtype() );
-    Functors::detail::with_output_tree::numeric_value         valueX;
-    auto                                                      fval = std::invoke( functorX );
-    std::visit( [&]( auto& x ) { valueX = std::any_cast<std::decay_t<decltype( x )>>( fval ); }, valueX );
-    // LHCb::Utils::as_arithmetic( valueX.get() );
-    std::visit(
-        [&]( auto& x ) {
-          auto unwrappedX = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorX ) );
-          auto unwrappedY = std::any_cast<std::decay_t<decltype( x )>>( std::invoke( functorY ) );
-          ++( *m_histogram )[{LHCb::Utils::as_arithmetic( unwrappedX ), LHCb::Utils::as_arithmetic( unwrappedY )}];
-        },
-        wX.get() );
-
-    return 1;
-  }
-
-  StatusCode initialize() override {
-
-    auto sc = base_type2::initialize();
-    if ( sc.isFailure() ) return sc;
-    if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
-    m_histogram.emplace(
-        this, m_histogram_name.value(), m_histogram_title.value(),
-        Gaudi::Accumulators::Axis<value_type>{m_binsX.value(), m_rangeX.value().first, m_rangeX.value().second},
-        Gaudi::Accumulators::Axis<value_type>{m_binsY.value(), m_rangeY.value().first, m_rangeY.value().second} );
-    return sc;
-  }
-
-private:
-  // Counter for recording cut retention statistics
-  mutable Gaudi::Accumulators::BinomialCounter<> m_cutEff{this, "Cut selection efficiency"};
-
-private:
-  // properties
-  Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
-  Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
-                                                 "Histogram title (it defaults to the histogram name)"};
-  Gaudi::Property<unsigned int> m_binsX{this, "BinsX", 100};
-  Gaudi::Property<unsigned int> m_binsY{this, "BinsY", 100};
-  Gaudi::Property<std::pair<value_type, value_type>> m_rangeX{this, "RangeX", {0., 1.}};
-  Gaudi::Property<std::pair<value_type, value_type>> m_rangeY{this, "RangeY", {0., 1.}};
-  mutable std::optional<Gaudi::Accumulators::Histogram<2, Gaudi::Accumulators::atomicity::full, value_type>>
-      m_histogram;
-};
-
-DECLARE_COMPONENT_WITH_ID( EventCorrelationsMonitor, "EventCorrelationsMonitor" )
-- 
GitLab


From 465179ff8aedd29119ece1a6b50b340370a3c1ee Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Wed, 13 Dec 2023 14:08:01 +0000
Subject: [PATCH 07/11] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/34699797
---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 6d66a494325..f523eb91aed 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -27,8 +27,7 @@ namespace {
 /** @class EventVariableMonitor EventVariableMonitor.cpp
  */
 struct EventVariableMonitor final : public base_type {
-  EventVariableMonitor( const std::string& name, ISvcLocator* pSvcLocator )
-      : base_type{name, pSvcLocator, {}} {}
+  EventVariableMonitor( const std::string& name, ISvcLocator* pSvcLocator ) : base_type{name, pSvcLocator, {}} {}
 
   void operator()() const override {
     auto const&                                               functor = getFunctor<VoidFunctor>();
@@ -69,4 +68,3 @@ private:
 };
 
 DECLARE_COMPONENT_WITH_ID( EventVariableMonitor, "Monitor__EventVariable" )
-
-- 
GitLab


From 2c2f1758f64bd117c5026b6221aef668904c693c Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Wed, 13 Dec 2023 16:57:08 +0100
Subject: [PATCH 08/11] remove commented lines

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index f523eb91aed..95af9863f56 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -11,8 +11,6 @@
 #include "Functors/with_functors.h"
 #include "Functors/with_output_tree.h"
 #include "Gaudi/Accumulators/Histogram.h"
-// #include "GaudiAlg/FilterPredicate.h"
-// #include "LHCbAlgs/Producer.h"
 #include "LHCbAlgs/Consumer.h"
 
 namespace {
-- 
GitLab


From 0fab44e315d5bbe14621b979e2b6387b76b886da Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Tue, 9 Jan 2024 17:22:23 +0100
Subject: [PATCH 09/11] use histodef

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 95af9863f56..7fe39f85d9f 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -19,7 +19,7 @@ namespace {
     static constexpr auto PropertyName = "Variable";
   };
   using base_type  = with_functors<LHCb::Algorithm::Consumer<void()>, VoidFunctor>;
-  using value_type = float;
+  using value_type = double;
 } // namespace
 
 /** @class EventVariableMonitor EventVariableMonitor.cpp
@@ -46,7 +46,7 @@ struct EventVariableMonitor final : public base_type {
     if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
     m_histogram.emplace(
         this, m_histogram_name.value(), m_histogram_title.value(),
-        Gaudi::Accumulators::Axis<value_type>{m_bins.value(), m_range.value().first, m_range.value().second} );
+        Gaudi::Accumulators::Axis<value_type>{static_cast<unsigned int>(m_histodef.value().bins()), m_histodef.value().lowEdge(), m_histodef.value().highEdge()} );
     return sc;
   }
 
@@ -56,6 +56,8 @@ private:
 
 private:
   // properties
+  Gaudi::Property<Gaudi::Histo1DDef> m_histodef{this,"HistogramDef",{"DefaultTitle",0.,1.,100},"Histogram definition"};
+
   Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
   Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
                                                  "Histogram title (it defaults to the histogram name)"};
-- 
GitLab


From 2abb07e1d4188cd03116d91ab227414475eab8b3 Mon Sep 17 00:00:00 2001
From: sstahl <sascha.stahl@cern.ch>
Date: Mon, 22 Jan 2024 16:12:40 +0100
Subject: [PATCH 10/11] Change to using HistoDef

---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 7fe39f85d9f..7cb3b453aca 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -43,9 +43,8 @@ struct EventVariableMonitor final : public base_type {
 
     auto sc = base_type::initialize();
     if ( sc.isFailure() ) return sc;
-    if ( m_histogram_title.value().empty() ) m_histogram_title = m_histogram_name.value();
     m_histogram.emplace(
-        this, m_histogram_name.value(), m_histogram_title.value(),
+        this, m_histogram_name.value(), m_histodef.value().title(),
         Gaudi::Accumulators::Axis<value_type>{static_cast<unsigned int>(m_histodef.value().bins()), m_histodef.value().lowEdge(), m_histodef.value().highEdge()} );
     return sc;
   }
@@ -59,10 +58,6 @@ private:
   Gaudi::Property<Gaudi::Histo1DDef> m_histodef{this,"HistogramDef",{"DefaultTitle",0.,1.,100},"Histogram definition"};
 
   Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
-  Gaudi::Property<std::string>  m_histogram_title{this, "HistogramTitle", "",
-                                                 "Histogram title (it defaults to the histogram name)"};
-  Gaudi::Property<unsigned int> m_bins{this, "Bins", 100};
-  Gaudi::Property<std::pair<value_type, value_type>> m_range{this, "Range", {0., 1.}};
   mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, value_type>>
       m_histogram;
 };
-- 
GitLab


From 418a5e720c9cd6a265d64ca73e9fc4a1d46074ff Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Mon, 22 Jan 2024 15:13:23 +0000
Subject: [PATCH 11/11] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/35441838
---
 Phys/SelAlgorithms/src/VoidMonitor.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Phys/SelAlgorithms/src/VoidMonitor.cpp b/Phys/SelAlgorithms/src/VoidMonitor.cpp
index 7cb3b453aca..50b83e619c4 100644
--- a/Phys/SelAlgorithms/src/VoidMonitor.cpp
+++ b/Phys/SelAlgorithms/src/VoidMonitor.cpp
@@ -43,9 +43,10 @@ struct EventVariableMonitor final : public base_type {
 
     auto sc = base_type::initialize();
     if ( sc.isFailure() ) return sc;
-    m_histogram.emplace(
-        this, m_histogram_name.value(), m_histodef.value().title(),
-        Gaudi::Accumulators::Axis<value_type>{static_cast<unsigned int>(m_histodef.value().bins()), m_histodef.value().lowEdge(), m_histodef.value().highEdge()} );
+    m_histogram.emplace( this, m_histogram_name.value(), m_histodef.value().title(),
+                         Gaudi::Accumulators::Axis<value_type>{static_cast<unsigned int>( m_histodef.value().bins() ),
+                                                               m_histodef.value().lowEdge(),
+                                                               m_histodef.value().highEdge()} );
     return sc;
   }
 
@@ -55,9 +56,10 @@ private:
 
 private:
   // properties
-  Gaudi::Property<Gaudi::Histo1DDef> m_histodef{this,"HistogramDef",{"DefaultTitle",0.,1.,100},"Histogram definition"};
+  Gaudi::Property<Gaudi::Histo1DDef> m_histodef{
+      this, "HistogramDef", {"DefaultTitle", 0., 1., 100}, "Histogram definition"};
 
-  Gaudi::Property<std::string>  m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
+  Gaudi::Property<std::string> m_histogram_name{this, "HistogramName", "Histogram", "Histogram name"};
   mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, value_type>>
       m_histogram;
 };
-- 
GitLab