From fa385b9261a496304d0dcfb2b458c6b839295c4a Mon Sep 17 00:00:00 2001
From: Marco Clemencic <marco.clemencic@cern.ch>
Date: Wed, 8 Feb 2017 16:57:53 +0100
Subject: [PATCH 1/2] added backward compatibility hack for gaudi/Gaudi!273

---
 Kernel/SelectionLine/src/SelectionLine.cpp   | 11 ++++--
 Phys/DaVinciKernel/Kernel/DVCommonBase.h     | 15 +++++++-
 Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp | 36 ++++++++++++--------
 3 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/Kernel/SelectionLine/src/SelectionLine.cpp b/Kernel/SelectionLine/src/SelectionLine.cpp
index 3c4c18dbb..98738f6ad 100644
--- a/Kernel/SelectionLine/src/SelectionLine.cpp
+++ b/Kernel/SelectionLine/src/SelectionLine.cpp
@@ -1,4 +1,3 @@
-// $Id: SelectionLine.cpp,v 1.3 2010-02-27 09:08:24 graven Exp $
 // ============================================================================
 // Include files
 // ============================================================================
@@ -51,6 +50,14 @@ using namespace HistogramUtilities;
 #include "Kernel/SelectionLine.h"
 // ============================================================================
 
+#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+/// \fixme backward compatibility with Gaudi <= v28r1
+#include "GaudiKernel/ThreadLocalContext.h"
+#define SYSEX_ARGUMENT Gaudi::Hive::currentContext()
+#else
+#define SYSEX_ARGUMENT
+#endif
+
 namespace
 {
 
@@ -160,7 +167,7 @@ Selection::Line::Stage::execute(ISequencerTimerTool* timertool)
   if (  algorithm()->isExecuted() ) return StatusCode::SUCCESS;
   // TODO: bind timer at init time
   if ( timertool ) timertool->start( timer() );
-  StatusCode result = algorithm()->sysExecute();
+  StatusCode result = algorithm()->sysExecute(SYSEX_ARGUMENT);
   algorithm()->setExecuted( true );
   if ( timertool ) timertool->stop( timer() );
   return result;
diff --git a/Phys/DaVinciKernel/Kernel/DVCommonBase.h b/Phys/DaVinciKernel/Kernel/DVCommonBase.h
index ae0e365e3..710bb02e3 100644
--- a/Phys/DaVinciKernel/Kernel/DVCommonBase.h
+++ b/Phys/DaVinciKernel/Kernel/DVCommonBase.h
@@ -47,6 +47,14 @@
 // from DaVinciUtils
 // ============================================================================
 #include "DaVinciUtils/Guards.h"
+
+
+#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+/// \fixme backward compatibility with Gaudi <= v28r1
+#include "GaudiKernel/EventContext.h"
+#endif
+
+
 // ============================================================================
 
 /** @class DVCommonBase DVCommonBase.h Kernel/DVCommonBase.h
@@ -327,7 +335,12 @@ public:
   void setFilterPassed( bool state ) override;
 
   /// Overridden from Gaudi Algorithm
-  StatusCode sysExecute () override;
+  /// \fixme backward compatibility with Gaudi <= v28r1
+  #ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+  StatusCode sysExecute(const EventContext&) override;
+  #else
+  StatusCode sysExecute() override;
+  #endif
 
   // Overridden from Gaudi Algorithm
   StatusCode initialize () override;
diff --git a/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp b/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp
index 4907e7a13..f6a1b1029 100644
--- a/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp
+++ b/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp
@@ -84,14 +84,14 @@ DVCommonBase<PBASE>::DVCommonBase( const std::string& name,
                          "Output Location of Particles" );
 
   m_inputLocations.clear() ;
-  
+
   //
   this->declareProperty( "Inputs",
                          m_inputLocations,
-                         "Input Locations forwarded of Particles" ) 
+                         "Input Locations forwarded of Particles" )
     // use update handler
     -> declareUpdateHandler ( &DVCommonBase<PBASE>::handleInputsUpdate , this ) ;
-  
+
 
   m_p2PVInputLocations.clear() ;
   this->declareProperty( "P2PVInputLocations",
@@ -103,7 +103,7 @@ DVCommonBase<PBASE>::DVCommonBase( const std::string& name,
 
   this->declareProperty( "UseP2PVRelations", m_useP2PV,
                          "Use P->PV relations internally. Forced to true if re-fitting PVs. Otherwise disabled for single PV events. Default: true.");
-  
+
   this->declareProperty( "WriteP2PVRelations", m_writeP2PV,
                          "Write out P->PV relations table to TES. Default: true");
 
@@ -396,17 +396,17 @@ void DVCommonBase<PBASE>::initializeInputLocations()
     this->debug() << ">>> Initialising input locations : " << m_inputLocations
                   << endmsg;
   }
-  
+
   // Clean up the paths
   for ( auto& loc : m_inputLocations )
   {
-    
-    // remove RootInTES prefix, if any 
-    if ( !this->rootInTES().empty()    
-         && "/Event/" !=            this->rootInTES() 
-         &&        0  == loc.find ( this->rootInTES() ) ) 
+
+    // remove RootInTES prefix, if any
+    if ( !this->rootInTES().empty()
+         && "/Event/" !=            this->rootInTES()
+         &&        0  == loc.find ( this->rootInTES() ) )
     {  loc = std::string( loc , this->rootInTES().size() ) ; }
-    
+
     // Strip any ending "/Particles"
     DaVinci::StringUtils::removeEnding(loc,"/Particles");
     // Strip any starting "/Event/"
@@ -473,9 +473,9 @@ template <class PBASE>
 void DVCommonBase<PBASE>::handleInputsUpdate ( Property& /* p */ )
 {
   // no action if not yet initialized
-  // initialize will perform the needed actiom anyway 
+  // initialize will perform the needed actiom anyway
   if ( Gaudi::StateMachine::INITIALIZED > this->FSMState() ) { return ; }
-  // 
+  //
   this->initializeInputLocations() ;
   //
 }
@@ -499,7 +499,11 @@ StatusCode DVCommonBase<PBASE>::loadTools()
 // Execute
 // ============================================================================
 template <class PBASE>
-StatusCode DVCommonBase<PBASE>::sysExecute ()
+#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+StatusCode DVCommonBase<PBASE>::sysExecute(const EventContext& ctx)
+#else
+StatusCode DVCommonBase<PBASE>::sysExecute()
+#endif
 {
   // register for the algorithm context service
   IAlgContextSvc* ctx = NULL;
@@ -519,7 +523,11 @@ StatusCode DVCommonBase<PBASE>::sysExecute ()
   if ( sc.isFailure() ) return this->Error ( "Not able to load event input" , sc ) ;
 
   // execute the algorithm
+#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+  sc = this->Algorithm::sysExecute(ctx);
+#else
   sc = this->Algorithm::sysExecute();
+#endif
   if ( sc.isFailure() ) return sc;
 
   if ( !m_setFilterCalled )
-- 
GitLab


From 0025133fcffe0d07af098a490bba6f3aaf4f3ef0 Mon Sep 17 00:00:00 2001
From: Marco Clemencic <marco.clemencic@cern.ch>
Date: Thu, 9 Feb 2017 09:36:06 +0100
Subject: [PATCH 2/2] fixed name clash for EventContext variable

---
 Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp b/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp
index f6a1b1029..79048ab73 100644
--- a/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp
+++ b/Phys/DaVinciKernel/src/Lib/DVCommonBase.icpp
@@ -500,7 +500,7 @@ StatusCode DVCommonBase<PBASE>::loadTools()
 // ============================================================================
 template <class PBASE>
 #ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
-StatusCode DVCommonBase<PBASE>::sysExecute(const EventContext& ctx)
+StatusCode DVCommonBase<PBASE>::sysExecute(const EventContext& ectx)
 #else
 StatusCode DVCommonBase<PBASE>::sysExecute()
 #endif
@@ -524,7 +524,7 @@ StatusCode DVCommonBase<PBASE>::sysExecute()
 
   // execute the algorithm
 #ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
-  sc = this->Algorithm::sysExecute(ctx);
+  sc = this->Algorithm::sysExecute(ectx);
 #else
   sc = this->Algorithm::sysExecute();
 #endif
-- 
GitLab