Skip to content
Snippets Groups Projects
Commit e4437121 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'navthinning3.AthenaServices-20200420' into 'master'

AthenaServices: ThinningCache holds a pointer to a ITrigNavigationThinningSvc.

See merge request atlas/athena!32158
parents c0e46a55 8b046e2f
No related branches found
No related tags found
No related merge requests found
......@@ -15,3 +15,4 @@ HistogramPersis...WARNING Histograms saving not required.
ApplicationMgr INFO Application Manager Initialized successfully
ApplicationMgr Ready
test1
test2
// job opts for ThinningCacheTool test
ToolSvc.TestCacheTool.StreamName = "MyStream";
ToolSvc.TestCacheTool2.StreamName = "MyStream2";
ToolSvc.TestCacheTool2.TrigNavigationThinningSvc = "TestTNThinningSvc";
/*
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
* Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file AthenaServices/src/ThinningCacheTool.h
......@@ -20,6 +20,18 @@
namespace Athena {
/**
* @brief Gaudi initialize method.
*/
StatusCode ThinningCacheTool::initialize()
{
if (!m_trigNavigationThinningSvc.empty()) {
ATH_CHECK( m_trigNavigationThinningSvc.retrieve() );
}
return StatusCode::SUCCESS;
}
/**
* @brief Called at the end of initialize. A no-op here.
*/
......@@ -63,9 +75,14 @@ StatusCode ThinningCacheTool::preExecute()
}
}
// Set the TrigNavigation thinning tool if needed.
if (!m_trigNavigationThinningSvc.empty()) {
m_cache.setTrigNavigationThinningSvc (m_trigNavigationThinningSvc.get());
}
// If there was any thinning for this stream, then install the cache
// in the EventContext.
if (!m_cache.empty()) {
if (!m_cache.empty() || m_cache.trigNavigationThinningSvc()) {
m_cache.lockOwned();
EventContext ctx = Gaudi::Hive::currentContext();
Atlas::getExtendedEventContext (ctx).setThinningCache (&m_cache);
......@@ -82,7 +99,7 @@ StatusCode ThinningCacheTool::preExecute()
*/
StatusCode ThinningCacheTool::postExecute()
{
if (!m_cache.empty()) {
if (!m_cache.empty() || m_cache.trigNavigationThinningSvc()) {
EventContext ctx = Gaudi::Hive::currentContext();
Atlas::getExtendedEventContext (ctx).setThinningCache (nullptr);
Gaudi::Hive::setCurrentContext (ctx);
......
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
* Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file AthenaServices/src/ThinningCacheTool.h
......@@ -17,6 +17,8 @@
#include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaKernel/ThinningCache.h"
#include "AthenaKernel/IAthenaOutputTool.h"
#include "AthenaKernel/ITrigNavigationThinningSvc.h"
#include "GaudiKernel/ServiceHandle.h"
namespace Athena {
......@@ -37,6 +39,12 @@ public:
using base_class::base_class;
/**
* @brief Gaudi initialize method.
*/
virtual StatusCode initialize() override;
/**
* @brief Called at the end of initialize. A no-op here.
*/
......@@ -79,6 +87,11 @@ private:
StringProperty m_streamName
{ this, "StreamName", "", "Name of the stream being written." };
/// Optional TrigNavigation thinning service to use.
ServiceHandle<ITrigNavigationThinningSvc> m_trigNavigationThinningSvc
{ this, "TrigNavigationThinningSvc", "", "Service to use for TrigNavigation thinning (optional)." };
/// Thinning cache instance for this stream.
SG::ThinningCache m_cache;
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file AthenaServices/test/ThinningCacheTool_test.cxx
......@@ -11,11 +11,14 @@
#undef NDEBUG
#include "StoreGate/StoreGateSvc.h"
#include "AthenaBaseComps/AthService.h"
#include "AthContainers/DataVector.h"
#include "AthContainers/ThinningDecision.h"
#include "AthenaKernel/ExtendedEventContext.h"
#include "AthenaKernel/IAthenaOutputTool.h"
#include "AthenaKernel/ITrigNavigationThinningSvc.h"
#include "AthenaKernel/getThinningCache.h"
#include "AthenaKernel/ThinningCache.h"
#include "AthenaKernel/CLASS_DEF.h"
#include "TestTools/initGaudi.h"
#include "GaudiKernel/ToolHandle.h"
......@@ -29,6 +32,23 @@ class Test {};
CLASS_DEF (DataVector<Test>, 29384894, 0)
class TestTNThinningSvc
: public extends<AthService, ITrigNavigationThinningSvc>
{
public:
using base_class::base_class;
virtual
StatusCode doSlimming (const EventContext& /*ctx*/,
std::vector<uint32_t>& /*slimmed_and_serialized*/) const override
{
return StatusCode::SUCCESS;
}
};
DECLARE_COMPONENT (TestTNThinningSvc)
void thin (SG::ThinningDecisionBase& dec, unsigned int mask)
{
for (size_t i = 0; mask != 0; i++, mask>>=1) {
......@@ -100,11 +120,32 @@ void test1()
assert (SG::getThinningDecision ("v1")->index (7) == 3);
assert (SG::getThinningDecision ("v2")->index (7) == 6);
assert (SG::getThinningCache()->trigNavigationThinningSvc() == nullptr);
assert (tool->postExecute().isSuccess());
assert (SG::getThinningCache() == nullptr);
}
void test2()
{
std::cout << "test2\n";
ToolHandle<IAthenaOutputTool> tool ("Athena::ThinningCacheTool/TestCacheTool2");
assert (tool.retrieve().isSuccess());
ServiceHandle<ITrigNavigationThinningSvc> tsvc ("TestTNThinningSvc", "test");
assert (tsvc.retrieve().isSuccess());
assert (tool->preExecute().isSuccess());
assert (SG::getThinningCache() != nullptr);
assert (SG::getThinningCache()->trigNavigationThinningSvc() == tsvc.get());
assert (tool->postExecute().isSuccess());
assert (SG::getThinningCache() == nullptr);
}
int main()
{
std::cout << "AthenaServices/ThinningCacheTool_test\n";
......@@ -120,5 +161,6 @@ int main()
Gaudi::Hive::setCurrentContext (ctx);
test1();
test2();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment