diff --git a/Kernel/SelectionLine/Kernel/SelectionLine.h b/Kernel/SelectionLine/Kernel/SelectionLine.h index 63ef5d7c0e2183d5d3a774c591c76f06238a6d73..0b8fe77de8ee93bb8321dacaba3fd4d550c4f9fb 100644 --- a/Kernel/SelectionLine/Kernel/SelectionLine.h +++ b/Kernel/SelectionLine/Kernel/SelectionLine.h @@ -1,5 +1,5 @@ /*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * +* (c) Copyright 2000-2020 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". * @@ -8,8 +8,7 @@ * granted to it by virtue of its status as an Intergovernmental Organization * * or submit itself to any jurisdiction. * \*****************************************************************************/ -#ifndef SELECTION_LINE_H -#define SELECTION_LINE_H 1 +#pragma once #include #include @@ -23,7 +22,6 @@ class StatEntity; class ISequencerTimerTool; class Algorithm; -class IJobOptionsSvc; class IAlgManager; /** @class Line Line.h @@ -158,7 +156,6 @@ namespace Selection { std::array, nStages> m_stages; ///< List of algorithms to process. SubAlgos m_subAlgo; ///< list of subalgorithms and their sub-count ISequencerTimerTool* m_timerTool; ///< Pointer to the timer tool - IJobOptionsSvc* m_jos; ///< Pointer to job options service IAlgManager* m_algMgr; ///< Pointer to algorithm manager AIDA::IHistogram1D* m_errorHisto; AIDA::IHistogram1D* m_timeHisto; @@ -189,4 +186,3 @@ namespace Selection { mutable Gaudi::Accumulators::BinomialCounter<> m_slowCounter{this, "#slow events"}; }; } // namespace Selection -#endif // Line_H diff --git a/Kernel/SelectionLine/src/SelectionLine.cpp b/Kernel/SelectionLine/src/SelectionLine.cpp index 9c6137911bcad0db97e47ab4f538532294ed2954..42a5a37373effba65c6c92791e8963b8569c60e2 100644 --- a/Kernel/SelectionLine/src/SelectionLine.cpp +++ b/Kernel/SelectionLine/src/SelectionLine.cpp @@ -1,5 +1,5 @@ /*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * +* (c) Copyright 2000-2020 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". * @@ -8,9 +8,22 @@ * granted to it by virtue of its status as an Intergovernmental Organization * * or submit itself to any jurisdiction. * \*****************************************************************************/ -// ============================================================================ -// Include files -// ============================================================================ +#include "HistogramUtilities.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -20,101 +33,11 @@ #include #include #include -// ============================================================================ -// Boost -// ============================================================================ -// ============================================================================ -// AIDA -// ============================================================================ -#include "AIDA/IAxis.h" -#include "AIDA/IHistogram.h" -#include "AIDA/IHistogram1D.h" -#include "AIDA/IProfile1D.h" -// ============================================================================ -// GaudiKernel -// ============================================================================ -#include "GaudiKernel/IAlgContextSvc.h" -#include "GaudiKernel/IAlgManager.h" -#include "GaudiKernel/IIncidentSvc.h" -#include "GaudiKernel/IJobOptionsSvc.h" -#include "GaudiKernel/StatusCode.h" -#include "GaudiKernel/StringKey.h" -#include "GaudiKernel/TypeNameString.h" - -// ============================================================================ -// GaudiAlg -// ============================================================================ -#include "GaudiAlg/GaudiHistos.icpp" -#include "GaudiAlg/ISequencerTimerTool.h" -// ============================================================================ -// HLT -// ============================================================================ -#include "HistogramUtilities.h" + using namespace HistogramUtilities; -// ============================================================================ -// HltEvent -// ============================================================================ -#include "Event/HltDecReports.h" -// ============================================================================ -// Local -// ============================================================================ -#include "Kernel/SelectionLine.h" -// ============================================================================ - -#include "GaudiKernel/ThreadLocalContext.h" namespace { static const double timeHistoLowBound = -3; - - bool isDefault( const std::string& s ) { return s.empty(); } // empty is not constexpr??? - - class populate_JobOptionsSvc_t { - std::vector> m_props; - IJobOptionsSvc* m_jos; - std::string m_name; - - template - void process( T&& t ) { - static_assert( std::tuple_size::value == 2, "Expecting an std::tuple key-value pair" ); - using type = typename std::decay::type>::type; - // static_assert( std::is_same::value || - // std::is_same::value , - // "Expecting either double (GlobalTimeOffSet) or string (Context,RootInTES) as value type" ); - using prop_t = SimpleProperty; - if ( !isDefault( std::get<1>( t ) ) ) - m_props.push_back( std::make_unique( std::get<0>( t ), std::get<1>( t ) ) ); - } - template - void process( T&& t, Args&&... args ) { - process( std::forward( t ) ); - process( std::forward( args )... ); - } - void check_veto() { // avoid changing properties expliclty present in the JOS... - const auto* props = m_jos->getProperties( m_name ); - if ( !props ) return; - for ( const auto& i : *props ) { - auto j = std::find_if( std::begin( m_props ), std::end( m_props ), - [&i]( const auto& prop ) { return prop->name() == i->name(); } ); - if ( j == std::end( m_props ) ) continue; - m_props.erase( j ); - if ( m_props.empty() ) return; // done! - } - } - - public: - template - populate_JobOptionsSvc_t( std::string name, IJobOptionsSvc* jos, Args&&... args ) - : m_jos{jos}, m_name{std::move( name )} { - process( std::forward( args )... ); - if ( !m_props.empty() ) check_veto(); - std::for_each( std::begin( m_props ), std::end( m_props ), - [&]( const auto& i ) { m_jos->addPropertyToCatalogue( m_name, *i ).ignore(); } ); - } - ~populate_JobOptionsSvc_t() { - std::for_each( std::begin( m_props ), std::end( m_props ), - [&]( const auto& i ) { m_jos->removePropertyFromCatalogue( m_name, i->name() ).ignore(); } ); - } - }; } // namespace //----------------------------------------------------------------------------- @@ -205,7 +128,6 @@ IANNSvc& Selection::Line::annSvc() const { Selection::Line::Line( const std::string& name, ISvcLocator* pSvcLocator ) : base_class( name, pSvcLocator ) , m_timerTool{nullptr} - , m_jos{nullptr} , m_algMgr{nullptr} , m_errorHisto{nullptr} , m_timeHisto{nullptr} @@ -247,7 +169,6 @@ StatusCode Selection::Line::initialize() { Gaudi::Utils::AlgContext lock1( this, contextSvc() ); if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg; - m_jos = svc( "JobOptionsSvc" ); m_algMgr = svc( "ApplicationMgr" ); // register for incidents... @@ -472,9 +393,12 @@ Gaudi::Algorithm* Selection::Line::getSubAlgorithm( const std::string& algname ) subAlgorithms()->push_back( myAlg ); return myAlg; } + + auto& optsSvc = serviceLocator()->getOptsSvc(); // It doesn't. Create it, and while doing so, ensure some magic properties are propagated... - populate_JobOptionsSvc_t populate{name.name(), m_jos, std::forward_as_tuple( "Context", context() ), - std::forward_as_tuple( "RootInTES", rootInTES() )}; + if ( !optsSvc.isSet( name.name() + ".Context" ) ) optsSvc.set( name.name() + ".Context", context() ); + if ( !optsSvc.isSet( name.name() + ".RootInTES" ) ) optsSvc.set( name.name() + ".RootInTES", rootInTES() ); + return createSubAlgorithm( name.type(), name.name(), myAlg ).isSuccess() ? myAlg : nullptr; }