From f7ad2d06f7958ef84555dc2f3261e8492ffd6787 Mon Sep 17 00:00:00 2001
From: Roel Aaij <raaij@nikhef.nl>
Date: Tue, 22 Mar 2022 16:07:26 +0100
Subject: [PATCH 1/3] Build EventBuilding

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 118eb4d99..d23f50ea2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,7 +64,7 @@ lhcb_add_subdirectories(
     Online/DataflowExample
     Online/Gaucho
     Online/DefHLTUtils
-#    Online/EventBuilding
+    Online/EventBuilding
     Online/EventData
     Online/FarmConfig
     Online/GaudiOnline
-- 
GitLab


From e2aa2bbca4684e2eaf9364c092a22ed7ffce2f50 Mon Sep 17 00:00:00 2001
From: Roel Aaij <raaij@nikhef.nl>
Date: Mon, 28 Mar 2022 16:55:13 +0200
Subject: [PATCH 2/3] Add missing PCIE40 lib

---
 cmake/PCIE40.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/PCIE40.cmake b/cmake/PCIE40.cmake
index 567f32715..8eeb63922 100644
--- a/cmake/PCIE40.cmake
+++ b/cmake/PCIE40.cmake
@@ -3,7 +3,7 @@ if (NOT DEFINED PCIE40_ROOT)
 endif()
 
 set(PCIE_40_LIBRARIES)
-foreach(lib IN ITEMS daq40 pcie40_daq pcie40_id pcie40)
+foreach(lib IN ITEMS daq40 pcie40_daq pcie40_id pcie40 pcie40_ecs)
   find_library(${lib}_path ${lib}
     HINTS
       ${PCIE40_ROOT}/lib64
-- 
GitLab


From 89625f1bce8bc9894db322f80722530190493086 Mon Sep 17 00:00:00 2001
From: Roel Aaij <raaij@nikhef.nl>
Date: Mon, 28 Mar 2022 17:10:01 +0200
Subject: [PATCH 3/3] Fixes for monitoring of MsgCounter and other Gaudi
 Accumulators

---
 .../components/MonCounterAccumulators.tcc.h   |  13 +-
 Online/Gaucho/src/components/MonitorSvc.cpp   |   3 +-
 .../Gaucho/src/components/OnlMonitorSink.cpp  | 357 +-----------------
 3 files changed, 23 insertions(+), 350 deletions(-)

diff --git a/Online/Gaucho/src/components/MonCounterAccumulators.tcc.h b/Online/Gaucho/src/components/MonCounterAccumulators.tcc.h
index 224c505c6..211b1861c 100644
--- a/Online/Gaucho/src/components/MonCounterAccumulators.tcc.h
+++ b/Online/Gaucho/src/components/MonCounterAccumulators.tcc.h
@@ -26,6 +26,7 @@ static std::map<std::pair<std::string,char>,MONTYPE> TypeTranslator=
     {std::pair{"Counter",'l'},C_GAUDIACCLONG},
     {std::pair{"Counter",'i'},C_GAUDIACCINT},
     {std::pair{"Counter",'m'},C_GAUDIACCuLONG},
+    {std::pair{"MsgCounter",'m'},C_GAUDIACCuLONG},
     {std::pair{"Counter",'j'},C_GAUDIACCuINT},
     {std::pair{"Counter",'f'},C_GAUDIACCFLOAT},
     {std::pair{"Counter",'d'},C_GAUDIACCDOUBLE},
@@ -45,13 +46,17 @@ namespace Online   {
     : MonCounterBase {H_ILLEGAL, name, title, 0, 0, 0 }
     {
       m_ent = std::make_unique<Entity>(ent);
-      auto j = m_ent->toJSON();
-      std::string typ = j.at("type").get<std::string>();
-      auto splt = RTL::str_split(typ.c_str(),":");
+      auto splt = RTL::str_split(ent.type.c_str(),":");
       if (splt.at(0) != "counter")  {
 	throw std::runtime_error("Bad Entity Type: "+splt.at(0));
       }
-      auto CType = TypeTranslator.find(std::make_pair(splt.at(1),*splt.at(2).c_str()));
+      auto CType = TypeTranslator.end();
+      if (splt.at(1) == "MsgCounter") {
+        CType = TypeTranslator.find(std::make_pair(splt.at(1),'m'));
+      }
+      else {
+        CType = TypeTranslator.find(std::make_pair(splt.at(1),*splt.at(2).c_str()));
+      }
       if (CType == TypeTranslator.end())  {
 	throw std::runtime_error("Unrecognized Accumulator/Precision combination: "+splt.at(2)+" "+splt.at(2));
       }
diff --git a/Online/Gaucho/src/components/MonitorSvc.cpp b/Online/Gaucho/src/components/MonitorSvc.cpp
index c74ceda83..526eaecae 100644
--- a/Online/Gaucho/src/components/MonitorSvc.cpp
+++ b/Online/Gaucho/src/components/MonitorSvc.cpp
@@ -276,8 +276,7 @@ void MonitorSvc::declareInfo(const string& name, const Entity &var,
   if (m_disableMonObjectsForHistos == 0)  {
     string oname = infoOwnerName(owner);
     string hname = (name.find(oname) == string::npos) ? oname+"/"+name : name;
-    auto json = var.toJSON();
-    string typ = json.at("type").get<string>();
+    string typ = var.type;
     if (typ.find("histogram:") != typ.npos)  {
       m_MonIntf->declareHistogram(hname, var, desc);
     }
diff --git a/Online/Gaucho/src/components/OnlMonitorSink.cpp b/Online/Gaucho/src/components/OnlMonitorSink.cpp
index 5ee782f3d..3fb631724 100644
--- a/Online/Gaucho/src/components/OnlMonitorSink.cpp
+++ b/Online/Gaucho/src/components/OnlMonitorSink.cpp
@@ -35,361 +35,34 @@ using namespace Gaudi::Accumulators;
 using namespace std;
 class OnlMonitorSink: public Service, public Gaudi::Monitoring::Hub::Sink
 {
-  public:
-    using Service::Service;
-    IGauchoMonitorSvc *m_mons = 0;
-    bool m_delayedProcessing = false;
-    void declareEnt(const Gaudi::Monitoring::Hub::Entity &e, const string &n, const std::string &comp)
-    {
-      //    T* var = static_cast<T*>(v);
-      nlohmann::json j = e.toJSON();
-      string tit;
-      try
-      {
-        tit = j.at("title").get<string>();
-        m_mons->declareInfo(comp + "/" + n, e, tit, 0);
-      }
-      catch (...)
-      {
-        tit = "";
-        m_mons->declareInfo(comp + "/" + n, e, tit, 0);
-      }
-    }
-#if 0
-    template<typename T> void declareHist(const void *v, const string &n, const std::string &comp)
-    {
-      //    T* var = static_cast<T*>(v);
-      const T* var = (const T*) v;
-      nlohmann::json j = var->toJSON();
-      string tit;
-      try
-      {
-        tit = j.at("title").get<string>();
-        m_mons->declareInfo(comp + "/" + n, var, tit, 0);
-      }
-      catch (...)
-      {
-        tit = "";
-        m_mons->declareInfo(comp + "/" + n, var, tit, 0);
-      }
-    }
-    template<typename T> void declareCnt(const void *v, const string &n, const std::string &comp)
-    {
-      //    T* var = static_cast<T*>(v);
-      const T var = *(const T*)v;
-      m_mons->declareInfo(comp + "/" + n, *(const T*)v, "", 0);
-    }
-#endif
-    StatusCode initialize() override
+public:
+  using Service::Service;
+  IGauchoMonitorSvc *m_mons = 0;
+  bool m_delayedProcessing = false;
+
+  void declareEnt(const Gaudi::Monitoring::Hub::Entity &e, const string &n, const std::string &comp)
+  {
+    m_mons->declareInfo(comp + "/" + n, e, "", 0);
+  }
+
+  StatusCode initialize() override
     {
       StatusCode sc;
       sc = Service::initialize();
       sc = serviceLocator()->service("MonitorSvc", m_mons, false);
       serviceLocator()->monitoringHub().addSink(this);
       m_delayedProcessing = true;
-//      for (auto i = m_monitoringEntities.begin();i!= m_monitoringEntities.end();i++)
-//      {
-//        registerEntity(**i);
-//      }
-//      m_monitoringEntities.clear();
       return sc;
     }
 
     StatusCode start() override
     {
-      auto ok = Service::start();
-      if (!ok)
-        return ok;
-//      std::sort(begin(m_monitoringEntities), end(m_monitoringEntities),
-//          []( const auto& a, const auto& b )
-//          {
-//            return std::tie( a.name, a.component ) > std::tie( b.name, b.component );
-//          });
-      return ok;
+      return Service::start();
     }
+
     void registerEntity(Gaudi::Monitoring::Hub::Entity ent) override
     {
-      printf("Monitoring Entity %s of Type %s\n", ent.name.c_str(), ent.type.c_str());
-//      auto j = ent.toJSON();
-//      string dmp = j.dump(0);
-//      printf ("%s\n",dmp.c_str());
-//      if (m_mons == 0)
-//      {
-//        m_monitoringEntities.push_back( &ent  );
-//        return;
-//      }
-//      else
-//      {
-//        if (!m_delayedProcessing)
-//        {
-//          m_delayedProcessing = true;
-//          for (auto i = m_monitoringEntities.begin();i!= m_monitoringEntities.end();i++)
-//          {
-//            registerEntity(**i);
-//          }
-//          m_monitoringEntities.clear();
-//        }
-//      }
-////      auto j = ent.toJSON();
-////      auto type = j.at("type").template get<std::string>();
-////      dyn_string *splt = Strsplit(ent.type.c_str(), ":");
-////      if (splt->size() <3)
-////      {
-////        ::lib_rtl_output(LIB_RTL_ERROR, "Badly formed Monitoring Hub Entity Type %s\n",ent.type.c_str());
-////        delete splt;
-////        return;
-////      }
       declareEnt(ent,ent.name,ent.component);
-#if 0
-      if (splt->at(0).find("histogram") != string::npos)
-      {
-        auto jj = j.at("bins");
-        auto iii=jj.begin();
-        auto tnam=typeid(iii.value()).name();
-        printf("%s\n",jj.dump().c_str());
-        auto valt =j.at("bins").type();
-        auto elt = j.at("bins")[0].type();
-        auto dim = j.at("dimension").template get<unsigned int>();
-        if (splt->at(1) == "Histogram")
-        {
-          switch (dim)
-          {
-            case 1:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<Histogram<1u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<Histogram<1u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 2:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<Histogram<2u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<Histogram<2u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 3:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<Histogram<3u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<Histogram<3u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-          }
-        }
-        else if (splt->at(1) == "WeightedHistogram")
-        {
-          switch (dim)
-          {
-            case 1:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<WeightedHistogram<1u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<WeightedHistogram<1u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 2:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<WeightedHistogram<2u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<WeightedHistogram<2u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 3:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<WeightedHistogram<3u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<WeightedHistogram<3u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-          }
-        }
-        else if (splt->at(1) == "ProfileHistogram")
-        {
-          switch (dim)
-          {
-            case 1:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<ProfileHistogram<1u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<ProfileHistogram<1u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 2:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<ProfileHistogram<2u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<ProfileHistogram<2u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-                break;
-              }
-              case 3:
-              {
-                if (splt->size() == 3)
-                {
-                  if (splt->at(2) == "d")
-                  {
-                    declareHist<ProfileHistogram<3u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                  }
-                  else if (splt->at(2) == "f")
-                  {
-                    declareHist<ProfileHistogram<3u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                  }
-                }
-                break;
-              }
-            }
-          }
-        }
-        else if (splt->at(1) == "WeightedProfileHistogram")
-        {
-          switch (dim)
-          {
-            case 1:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<WeightedProfileHistogram<1u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<WeightedProfileHistogram<1u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 2:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<WeightedProfileHistogram<2u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<WeightedProfileHistogram<2u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-            case 3:
-            {
-              if (splt->size() == 3)
-              {
-                if (splt->at(2) == "d")
-                {
-                  declareHist<WeightedProfileHistogram<3u, atomicity::full, double>>(ent.ptr, ent.name, ent.component);
-                }
-                else if (splt->at(2) == "f")
-                {
-                  declareHist<WeightedProfileHistogram<3u, atomicity::full, float>>(ent.ptr, ent.name, ent.component);
-                }
-              }
-              break;
-            }
-          }
-        }
-      }
-      else if (splt->at(0) == "counter")
-      {
-        if (splt->at(1) == "AveragingCounter")
-        {
-          if (splt->at(2) == "l")
-          {
-            declareCnt<Gaudi::Accumulators::AveragingCounter<long>>(ent.ptr, ent.name, ent.component);
-          }
-//          else if (splt->at(2) == "i")
-//          {
-//            declareCnt<Gaudi::Accumulators::AveragingCounter<int>>(ent.ptr, ent.name, ent.component);
-//          }
-          else if (splt->at(2) == "d")
-          {
-            declareCnt<Gaudi::Accumulators::AveragingCounter<double>>(ent.ptr, ent.name, ent.component);
-          }
-//          else if (splt->at(2) == "f")
-//          {
-//            declareCnt<Gaudi::Accumulators::AveragingCounter<float>>(ent.ptr, ent.name, ent.component);
-//          }
-        }
-        else if (splt->at(1) == "BinomialCounter")
-        {
-          if (splt->at(2) == "b")
-          {
-            declareCnt<Gaudi::Accumulators::BinomialCounter<bool>>(ent.ptr, ent.name, ent.component);
-          }
-        }
-      }
-      else
-      {
-        ::lib_rtl_output(LIB_RTL_ERROR,"Illegal Monitoring Hub Type %s\n",ent.type.c_str());
-      }
-      delete splt;
-#endif
     }
 
   void removeEntity( Gaudi::Monitoring::Hub::Entity const& ) override {
@@ -399,10 +72,6 @@ class OnlMonitorSink: public Service, public Gaudi::Monitoring::Hub::Sink
 
   private:
     std::list<Gaudi::Monitoring::Hub::Entity*> m_monitoringEntities;
-
-//    Gaudi::Property<std::string> m_fileName{this, "FileName", "testHisto.root",
-//                                            "Name of file where to save histograms"};
 };
 
 DECLARE_COMPONENT(OnlMonitorSink)
-
-- 
GitLab