From 9bf3ba89b0e820ae288928f8111a2fe6285780ea Mon Sep 17 00:00:00 2001
From: rquaglia <rquaglia@cern.ch>
Date: Tue, 8 Oct 2024 23:18:04 +0200
Subject: [PATCH 1/8] add NtupleSvc basketsize property and forward in
 RCWNTupleCnv

---
 GaudiSvc/src/NTupleSvc/NTupleSvc.cpp | 3 +++
 GaudiSvc/src/NTupleSvc/NTupleSvc.h   | 6 ++++++
 RootHistCnv/src/RCWNTupleCnv.cpp     | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp
index 523152c023..cdc55e5e56 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp
@@ -90,6 +90,9 @@ bool NTupleSvc::isConnected( const std::string& identifier ) const {
   auto i = m_connections.find( identifier );
   return i != m_connections.end();
 }
+int NTupleSvc::basketSize() const{
+  return m_basketsize;
+}
 
 /// DataSvc override: Retrieve data loader
 IConversionSvc* NTupleSvc::getDataLoader( IRegistry* pRegistry ) {
diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.h b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
index 3d82e87b5d..be122bd45f 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.h
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
@@ -98,6 +98,10 @@ public:
 
   /// Check if a datasource is connected
   bool isConnected( const std::string& identifier ) const override;
+
+  /// Get the configured basketSize for Branches creation
+  int basketSize()const override;
+
   /// Add file to list I/O list
   StatusCode connect( const std::string& ident ) override;
   /// Add file to list I/O list
@@ -124,6 +128,8 @@ protected:
   Gaudi::Property<DBaseEntries> m_input{ this, "Input", {}, "input streams" };
   Gaudi::Property<DBaseEntries> m_output{ this, "Output", {}, "output streams" };
 
+  Gaudi::Property<int> m_basketsize{ this, "BasketSize", 32000, "BasketSize" }; //ROOT default
+
   /// Container of connection points
   std::map<std::string, Connection> m_connections;
 };
diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index 77e70dc2f0..2e997188a1 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -214,7 +214,7 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
 #else
     TBranch* br = new TBranch(
 #endif
-                           item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() );
+                           item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() , m_ntupleSvc->basketSize() );
 
     if ( itr->first != "AUTO_BLK" ) {
       std::string title = itr->first;
-- 
GitLab


From 54fdfb02618b6674440c0b9bcd5d48700ca69969 Mon Sep 17 00:00:00 2001
From: rquaglia <rquaglia@cern.ch>
Date: Wed, 9 Oct 2024 06:31:45 +0200
Subject: [PATCH 2/8] update

---
 GaudiKernel/include/GaudiKernel/INTupleSvc.h | 6 ++++++
 GaudiSvc/src/NTupleSvc/NTupleSvc.h           | 2 +-
 RootHistCnv/src/RCWNTupleCnv.cpp             | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/GaudiKernel/include/GaudiKernel/INTupleSvc.h b/GaudiKernel/include/GaudiKernel/INTupleSvc.h
index 5b05d77586..173b2abde6 100644
--- a/GaudiKernel/include/GaudiKernel/INTupleSvc.h
+++ b/GaudiKernel/include/GaudiKernel/INTupleSvc.h
@@ -209,6 +209,12 @@ public:
       @return               Status code indicating success or failure.
   */
   virtual StatusCode readRecord( DataObject* pParent, const std::string& relPath ) = 0;
+
+
+
+  /** Configure and set the basket size of an Ntuple (needed in RCWNTupleCnv)
+  */
+  virtual int basketSize() const = 0;
 };
 
 #endif // INTERFACES_INTUPLESVC_H
diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.h b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
index be122bd45f..b25563b5d1 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.h
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
@@ -100,7 +100,7 @@ public:
   bool isConnected( const std::string& identifier ) const override;
 
   /// Get the configured basketSize for Branches creation
-  int basketSize()const override;
+  int basketSize() const override;
 
   /// Add file to list I/O list
   StatusCode connect( const std::string& ident ) override;
diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index 2e997188a1..2cb4934937 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -215,7 +215,7 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
     TBranch* br = new TBranch(
 #endif
                            item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() , m_ntupleSvc->basketSize() );
-
+    log << MSG::WARNING << "adding TBranch with basked size" <<  m_ntupleSvc->basketSize() << endmsg;
     if ( itr->first != "AUTO_BLK" ) {
       std::string title = itr->first;
       title             = itr->first + "::" + br->GetTitle();
-- 
GitLab


From 2822fb52e4b81b7ba39b658eb90e0f824b67d6e2 Mon Sep 17 00:00:00 2001
From: rquaglia <rquaglia@cern.ch>
Date: Thu, 10 Oct 2024 16:59:02 +0200
Subject: [PATCH 3/8] clean up following Marco suggestions

---
 GaudiKernel/include/GaudiKernel/INTupleSvc.h |  6 ------
 GaudiSvc/src/NTupleSvc/NTupleSvc.cpp         |  3 ---
 GaudiSvc/src/NTupleSvc/NTupleSvc.h           |  3 ---
 RootHistCnv/src/RCWNTupleCnv.cpp             | 15 +++++++++++++--
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/GaudiKernel/include/GaudiKernel/INTupleSvc.h b/GaudiKernel/include/GaudiKernel/INTupleSvc.h
index 173b2abde6..5b05d77586 100644
--- a/GaudiKernel/include/GaudiKernel/INTupleSvc.h
+++ b/GaudiKernel/include/GaudiKernel/INTupleSvc.h
@@ -209,12 +209,6 @@ public:
       @return               Status code indicating success or failure.
   */
   virtual StatusCode readRecord( DataObject* pParent, const std::string& relPath ) = 0;
-
-
-
-  /** Configure and set the basket size of an Ntuple (needed in RCWNTupleCnv)
-  */
-  virtual int basketSize() const = 0;
 };
 
 #endif // INTERFACES_INTUPLESVC_H
diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp
index cdc55e5e56..523152c023 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp
@@ -90,9 +90,6 @@ bool NTupleSvc::isConnected( const std::string& identifier ) const {
   auto i = m_connections.find( identifier );
   return i != m_connections.end();
 }
-int NTupleSvc::basketSize() const{
-  return m_basketsize;
-}
 
 /// DataSvc override: Retrieve data loader
 IConversionSvc* NTupleSvc::getDataLoader( IRegistry* pRegistry ) {
diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.h b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
index b25563b5d1..2baab7e476 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.h
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
@@ -99,9 +99,6 @@ public:
   /// Check if a datasource is connected
   bool isConnected( const std::string& identifier ) const override;
 
-  /// Get the configured basketSize for Branches creation
-  int basketSize() const override;
-
   /// Add file to list I/O list
   StatusCode connect( const std::string& ident ) override;
   /// Add file to list I/O list
diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index 2cb4934937..1a34c211d5 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -198,6 +198,15 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
 
   // Loop over items, creating a new branch for each one;
   unsigned int i_item = 0;
+
+  int basket_size = 32000; //ROOT DEFAULT
+  try {
+    Gaudi::Property<int> tmp;
+    tmp.assign( m_ntupleSvc.as<IProperty>()->getProperty("BasketSize" ));
+    basket_size = tmp.value();
+  }catch (...) {}
+
+
   for ( auto itr = item_name.cbegin(); itr != end; ++itr, ++i_item ) {
 
     buf_pos = buff + item_buf_pos[i_item];
@@ -209,13 +218,15 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
     //  	<< (void*)item_buf_pos[i_item] << ")"
     //  	<< endmsg;
 
+
+
 #if ROOT_VERSION_CODE >= ROOT_VERSION( 5, 15, 0 )
     auto br = new TBranch( rtree,
 #else
     TBranch* br = new TBranch(
 #endif
-                           item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() , m_ntupleSvc->basketSize() );
-    log << MSG::WARNING << "adding TBranch with basked size" <<  m_ntupleSvc->basketSize() << endmsg;
+                           item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() , basket_size );
+    log << MSG::WARNING << "adding TBranch with basked size" <<  basket_size << endmsg;
     if ( itr->first != "AUTO_BLK" ) {
       std::string title = itr->first;
       title             = itr->first + "::" + br->GetTitle();
-- 
GitLab


From 70073796a7eca4f1253fdc831a0f3c87173b80d5 Mon Sep 17 00:00:00 2001
From: rquaglia <rquaglia@cern.ch>
Date: Thu, 10 Oct 2024 17:37:22 +0200
Subject: [PATCH 4/8] update

---
 GaudiSvc/src/NTupleSvc/NTupleSvc.h | 1 -
 RootHistCnv/src/RCWNTupleCnv.cpp   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.h b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
index 2baab7e476..0a76521d21 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.h
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
@@ -126,7 +126,6 @@ protected:
   Gaudi::Property<DBaseEntries> m_output{ this, "Output", {}, "output streams" };
 
   Gaudi::Property<int> m_basketsize{ this, "BasketSize", 32000, "BasketSize" }; //ROOT default
-
   /// Container of connection points
   std::map<std::string, Connection> m_connections;
 };
diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index 1a34c211d5..b718730dfe 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -206,7 +206,6 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
     basket_size = tmp.value();
   }catch (...) {}
 
-
   for ( auto itr = item_name.cbegin(); itr != end; ++itr, ++i_item ) {
 
     buf_pos = buff + item_buf_pos[i_item];
-- 
GitLab


From 301920b2c78e638873bf4d77bdc4aab0eed38db9 Mon Sep 17 00:00:00 2001
From: rquaglia <rquaglia@cern.ch>
Date: Thu, 10 Oct 2024 17:57:23 +0200
Subject: [PATCH 5/8] adapt to use a simpler wrapper

---
 RootHistCnv/src/RCWNTupleCnv.cpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index b718730dfe..cb0fa17f5b 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -199,12 +199,9 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
   // Loop over items, creating a new branch for each one;
   unsigned int i_item = 0;
 
-  int basket_size = 32000; //ROOT DEFAULT
-  try {
-    Gaudi::Property<int> tmp;
-    tmp.assign( m_ntupleSvc.as<IProperty>()->getProperty("BasketSize" ));
-    basket_size = tmp.value();
-  }catch (...) {}
+  Gaudi::Property<int> basket_size( "BasketSize", 32000);
+  m_ntupleSvc.as<IProperty>()->getProperty( &basket_size ).ignore();
+
 
   for ( auto itr = item_name.cbegin(); itr != end; ++itr, ++i_item ) {
 
-- 
GitLab


From 3c3e02eecc8de5953e923e18a0aa52d8b2fc07f7 Mon Sep 17 00:00:00 2001
From: Renato Quagliani <renato.quagliani@cern.ch>
Date: Thu, 10 Oct 2024 18:52:38 +0200
Subject: [PATCH 6/8] remove warning message, tested to load the option from
 lbexec

---
 RootHistCnv/src/RCWNTupleCnv.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index cb0fa17f5b..6d0930fa7d 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -222,7 +222,6 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
     TBranch* br = new TBranch(
 #endif
                            item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() , basket_size );
-    log << MSG::WARNING << "adding TBranch with basked size" <<  basket_size << endmsg;
     if ( itr->first != "AUTO_BLK" ) {
       std::string title = itr->first;
       title             = itr->first + "::" + br->GetTitle();
-- 
GitLab


From affa0961c16c4cb58515937f7ff7569a8dc89da7 Mon Sep 17 00:00:00 2001
From: Marco Clemencic <marco.clemencic@cern.ch>
Date: Mon, 14 Oct 2024 14:28:17 +0200
Subject: [PATCH 7/8] Update MetadataSvc test reference

---
 GaudiTestSuite/tests/qmtest/refs/MetaDataSvc.ref | 1 +
 1 file changed, 1 insertion(+)

diff --git a/GaudiTestSuite/tests/qmtest/refs/MetaDataSvc.ref b/GaudiTestSuite/tests/qmtest/refs/MetaDataSvc.ref
index bbaadadd59..080c63d007 100644
--- a/GaudiTestSuite/tests/qmtest/refs/MetaDataSvc.ref
+++ b/GaudiTestSuite/tests/qmtest/refs/MetaDataSvc.ref
@@ -289,6 +289,7 @@ NTupleSvc.AuditServices:False
 NTupleSvc.AuditStart:False
 NTupleSvc.AuditStop:False
 NTupleSvc.AutoRetrieveTools:True
+NTupleSvc.BasketSize:32000
 NTupleSvc.CheckToolDeps:True
 NTupleSvc.DataAccessName:'DataAccess'
 NTupleSvc.DataFaultName:'DataFault'
-- 
GitLab


From 57f93c3f2b3f404914ac951dad3337557db858e2 Mon Sep 17 00:00:00 2001
From: Marco Clemencic <marco.clemencic@cern.ch>
Date: Mon, 14 Oct 2024 14:30:10 +0200
Subject: [PATCH 8/8] Update copyright year and fix formatting

---
 GaudiSvc/src/NTupleSvc/NTupleSvc.h | 4 ++--
 RootHistCnv/src/RCWNTupleCnv.cpp   | 9 +++------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/GaudiSvc/src/NTupleSvc/NTupleSvc.h b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
index 0a76521d21..cc19b1ac45 100644
--- a/GaudiSvc/src/NTupleSvc/NTupleSvc.h
+++ b/GaudiSvc/src/NTupleSvc/NTupleSvc.h
@@ -1,5 +1,5 @@
 /***********************************************************************************\
-* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
+* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
 *                                                                                   *
 * This software is distributed under the terms of the Apache version 2 licence,     *
 * copied verbatim in the file "LICENSE".                                            *
@@ -125,7 +125,7 @@ protected:
   Gaudi::Property<DBaseEntries> m_input{ this, "Input", {}, "input streams" };
   Gaudi::Property<DBaseEntries> m_output{ this, "Output", {}, "output streams" };
 
-  Gaudi::Property<int> m_basketsize{ this, "BasketSize", 32000, "BasketSize" }; //ROOT default
+  Gaudi::Property<int> m_basketsize{ this, "BasketSize", 32000, "BasketSize" }; // ROOT default
   /// Container of connection points
   std::map<std::string, Connection> m_connections;
 };
diff --git a/RootHistCnv/src/RCWNTupleCnv.cpp b/RootHistCnv/src/RCWNTupleCnv.cpp
index 6d0930fa7d..b1a800461f 100644
--- a/RootHistCnv/src/RCWNTupleCnv.cpp
+++ b/RootHistCnv/src/RCWNTupleCnv.cpp
@@ -1,5 +1,5 @@
 /***********************************************************************************\
-* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
+* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
 *                                                                                   *
 * This software is distributed under the terms of the Apache version 2 licence,     *
 * copied verbatim in the file "LICENSE".                                            *
@@ -199,10 +199,9 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
   // Loop over items, creating a new branch for each one;
   unsigned int i_item = 0;
 
-  Gaudi::Property<int> basket_size( "BasketSize", 32000);
+  Gaudi::Property<int> basket_size( "BasketSize", 32000 );
   m_ntupleSvc.as<IProperty>()->getProperty( &basket_size ).ignore();
 
-
   for ( auto itr = item_name.cbegin(); itr != end; ++itr, ++i_item ) {
 
     buf_pos = buff + item_buf_pos[i_item];
@@ -214,14 +213,12 @@ StatusCode RootHistCnv::RCWNTupleCnv::book( const std::string& desc, INTuple* nt
     //  	<< (void*)item_buf_pos[i_item] << ")"
     //  	<< endmsg;
 
-
-
 #if ROOT_VERSION_CODE >= ROOT_VERSION( 5, 15, 0 )
     auto br = new TBranch( rtree,
 #else
     TBranch* br = new TBranch(
 #endif
-                           item_fullname[i_item].c_str(), buf_pos, itr->second.c_str() , basket_size );
+                           item_fullname[i_item].c_str(), buf_pos, itr->second.c_str(), basket_size );
     if ( itr->first != "AUTO_BLK" ) {
       std::string title = itr->first;
       title             = itr->first + "::" + br->GetTitle();
-- 
GitLab