Skip to content
Snippets Groups Projects
Commit efbb9aab authored by Adam Edward Barton's avatar Adam Edward Barton :speech_balloon:
Browse files

Merge branch 'RemoveObsoleteViewAlgs' into 'master'

Remove obsolete view algorithms

See merge request atlas/athena!35006
parents 5bd2587f ea213da3
No related branches found
No related tags found
No related merge requests found
#
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#
###############################################################
#
# Job options file to demonstrate encapsulating algorithms
# within a single view, and retrieving data from that view
#
# Potentially useful for conflicting HLT sequences
#
#==============================================================
# Configure the scheduler
from AthenaCommon.AlgScheduler import AlgScheduler
AlgScheduler.ShowControlFlow( True )
AlgScheduler.ShowDataDependencies( True )
# Show the contents of StoreGate
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
svcMgr.StoreGateSvc.Dump = True
# Control flow
from AthenaCommon.AlgSequence import AthSequencer
allViewAlgorithms = AthSequencer( "allViewAlgorithms" )
allViewAlgorithms.ModeOR = False
allViewAlgorithms.Sequential = False
allViewAlgorithms.StopOverride = False
makeViewSequence = AthSequencer( "makeViewSequence" )
makeViewSequence.ModeOR = False
makeViewSequence.Sequential = True
makeViewSequence.StopOverride = False
# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
# Make views
makeViewAlg = CfgMgr.AthViews__MinimalViewAlg( "makeViewAlg" )
makeViewAlg.ViewNodeName = allViewAlgorithms.name()
makeViewAlg.Scheduler = AlgScheduler.getScheduler()
makeViewSequence += makeViewAlg
# View algorithm
viewTestAlg = CfgMgr.AthViews__ViewTestAlg( "viewTestAlg" )
viewTestAlg.Output = "TestOutput"
allViewAlgorithms += viewTestAlg
# Add the view algorithms to the job
makeViewSequence += allViewAlgorithms
# Retrieve data from the view
viewOutputAlg = CfgMgr.AthViews__AliasOutOfView( "viewOutputAlg" )
viewOutputAlg.ViewName = allViewAlgorithms.name()
viewOutputAlg.OutputLevel = DEBUG
viewOutputAlg.DataObjects = [ ( "int", "TestOutput" ) ]
makeViewSequence += viewOutputAlg
job += makeViewSequence
theApp.EvtMax = 10
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
// AliasOutOfView.cxx
// Implementation file for class AliasOutOfView
// Author: B. Wynne <bwynne@cern.ch>
///////////////////////////////////////////////////////////////////
#include "AliasOutOfView.h"
#include "AthenaKernel/ExtendedEventContext.h"
#include "AthViews/View.h"
namespace AthViews {
AliasOutOfView::AliasOutOfView( const std::string& name, ISvcLocator* pSvcLocator ) :
AthAlgorithm( name, pSvcLocator )
{
}
AliasOutOfView::~AliasOutOfView()
{
}
StatusCode AliasOutOfView::initialize()
{
for ( auto& obj : m_dataObjects.value() ) {
// Check for misconfiguration
if ( obj.key() == "" ) {
ATH_MSG_ERROR( "Empty key " << obj << " not permitted" );
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG( "Will alias " << m_viewName.value() << "_" << obj.key() << " to " << obj.key() );
}
// Inform the scheduler that these containers will be available
if ( !setProperty( "ExtraOutputs", m_dataObjects.toString() ).isSuccess() ) {
ATH_MSG_ERROR( "Failed setting property ExtraOutputs" );
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
StatusCode AliasOutOfView::execute()
{
// Retrieve the current view from the EventContext
auto viewProxy = Atlas::getExtendedEventContext( getContext() ).proxy();
ATH_MSG_DEBUG( "Executing " << name() << " with store " << viewProxy->name() );
// Test each container
for ( auto& obj : m_dataObjects.value() ) {
// Create a VarHandleKey for the object inside the view
SG::VarHandleKey vhk( obj.clid(), m_viewName + "_" + obj.key(), Gaudi::DataHandle::Reader );
// Create a test proxy
SG::DataProxy* dp = viewProxy->proxy( obj.clid(), vhk.key() );
// Test if the proxy is valid
if ( dp ) {
ATH_MSG_DEBUG( "Found " << vhk.key() << " in " << viewProxy->name() );
CHECK( evtStore()->setAlias( dp, obj.key() ) );
} else {
ATH_MSG_ERROR( "Did not find " << vhk.key() << " in " << viewProxy->name() );
return StatusCode::FAILURE;
}
}
return StatusCode::SUCCESS;
}
} //> end namespace AthViews
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
// AliasOutOfView.h
// Header file for class AliasOutOfView
// Author: B. Wynne <bwynne@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef ATHVIEWS_COPYOUTOFVIEW_H
#define ATHVIEWS_COPYOUTOFVIEW_H 1
#include <string>
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/DataObjID.h"
namespace AthViews {
class AliasOutOfView : public AthAlgorithm
{
public:
// Constructor with parameters
AliasOutOfView( const std::string& name, ISvcLocator* pSvcLocator );
// Destructor
virtual ~AliasOutOfView();
// Athena algorithm hooks
virtual StatusCode initialize() override;
virtual StatusCode execute() override;
private:
// Default constructor
AliasOutOfView();
// Configurable properties
Gaudi::Property< std::string > m_viewName{ this, "ViewName", "", "Name of view containing objects" };
Gaudi::Property< DataObjIDColl > m_dataObjects{ this, "DataObjects", DataObjIDColl(), "Objects to alias out of this view" };
};
} //> end namespace AthViews
#endif //> !ATHVIEWS_ALIASOUTOFVIEW_H
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "MinimalViewAlg.h"
#include "AthViews/ViewHelper.h"
#include "StoreGate/WriteHandle.h"
namespace AthViews {
// Constructor
MinimalViewAlg::MinimalViewAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator )
{
}
// Destructor
MinimalViewAlg::~MinimalViewAlg()
{
}
// Athena Algorithm hooks
StatusCode MinimalViewAlg::initialize()
{
ATH_MSG_DEBUG( "Initializing " << name() << "..." );
CHECK( m_scheduler.retrieve() );
return StatusCode::SUCCESS;
}
StatusCode MinimalViewAlg::finalize()
{
ATH_MSG_DEBUG( "Finalizing " << name() << "..." );
return StatusCode::SUCCESS;
}
StatusCode MinimalViewAlg::execute()
{
ATH_MSG_DEBUG( "Executing " << name() << "..." );
// Create the view
auto theView = ViewHelper::makeView( m_viewNodeName, -1, true );
// Schedule the algorithms in the view
const EventContext& ctx = getContext();
return ViewHelper::scheduleSingleView( theView,
m_viewNodeName, //Name of node to attach views to
ctx, //Context to attach the views to
Atlas::getExtendedEventContext( ctx ).conditionsRun(),
m_scheduler.get() ); //ServiceHandle for the scheduler
}
} //> end namespace AthViews
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ATHVIEWS_ATHVIEWS_MINIMALVIEWALG_H
#define ATHVIEWS_ATHVIEWS_MINIMALVIEWALG_H 1
#include <string>
#include "AthenaBaseComps/AthAlgorithm.h"
#include "AthViews/View.h"
#include "GaudiKernel/IScheduler.h"
namespace AthViews {
class MinimalViewAlg : public AthAlgorithm
{
public:
// Constructor with parameters
MinimalViewAlg( const std::string& name, ISvcLocator* pSvcLocator );
// Destructor
virtual ~MinimalViewAlg();
// Athena algorithm hooks
virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
private:
// Default constructor
MinimalViewAlg();
// Configurables
ServiceHandle< IScheduler > m_scheduler{ this, "Scheduler", "AvalancheSchedulerSvc", "The Athena scheduler" };
Gaudi::Property< std::string > m_viewNodeName{ this, "ViewNodeName", "", "Name of CF node to attach views to" };
};
} //> end namespace AthViews
#endif //> !ATHVIEWS_ATHVIEWS_MINIMALVIEWALG_H
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "RoiCollectionToViews.h"
#include "AthViews/ViewHelper.h"
#include "AthContainers/ConstDataVector.h"
namespace AthViews {
RoiCollectionToViews::RoiCollectionToViews( const std::string& name, ISvcLocator* pSvcLocator ) :
AthAlgorithm( name, pSvcLocator )
{
}
RoiCollectionToViews::~RoiCollectionToViews()
{
}
StatusCode RoiCollectionToViews::initialize()
{
ATH_MSG_DEBUG ("Initializing " << name() << "...");
CHECK( m_trigRoIs.initialize() );
CHECK( m_viewRoIs.initialize() );
CHECK( m_w_views.initialize() );
return StatusCode::SUCCESS;
}
StatusCode RoiCollectionToViews::execute()
{
ATH_MSG_DEBUG ("Executing " << name() << "...");
const EventContext& ctx = getContext();
//Load the collection of RoI descriptors
SG::ReadHandle< TrigRoiDescriptorCollection > inputRoIs( m_trigRoIs, ctx );
ATH_CHECK( inputRoIs.isValid() );
std::vector< ConstDataVector< TrigRoiDescriptorCollection> > outputRoICollectionVector;
for ( auto roi: *inputRoIs )
{
ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() );
ConstDataVector<TrigRoiDescriptorCollection> oneRoIColl (SG::VIEW_ELEMENTS);
oneRoIColl.push_back( roi );
outputRoICollectionVector.push_back( std::move(oneRoIColl) );
}
//Create the views and populate them
auto viewVector = std::make_unique<ViewContainer>();
CHECK( ViewHelper::makeAndPopulate( m_viewBaseName, //Base name for all views to use
viewVector.get(), //Vector to store views
m_viewRoIs, //A writehandlekey to use to access the views
ctx, //The context of this algorithm
outputRoICollectionVector, //Data to initialise each view - one view will be made per entry
m_viewFallThrough ) ); //Allow fall through from view to storegate
//Run the algorithms in views
CHECK( ViewHelper::scheduleViews( viewVector.get(), //View vector
m_viewNodeName, //CF node to attach views to
ctx, //Context to attach the views to
svcLoc()->service<IScheduler>(m_schedulerName,false) ) ); //Scheduler
//Store the collection of views
SG::WriteHandle< ViewContainer > outputViewHandle( m_w_views, ctx );
CHECK( outputViewHandle.record( std::move( viewVector ) ) );
return StatusCode::SUCCESS;
}
} //> end namespace AthViews
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ATHVIEWS_ATHVIEWS_ROICOLLECTIONTOVIEWS_H
#define ATHVIEWS_ATHVIEWS_ROICOLLECTIONTOVIEWS_H
// STL includes
#include <string>
#include <vector>
// FrameWork includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "AthViews/View.h"
#include "StoreGate/WriteHandleKey.h"
#include "StoreGate/ReadHandleKey.h"
#include "TrigSteeringEvent/TrigRoiDescriptorCollection.h"
#include "AthContainers/ConstDataVector.h"
#include "GaudiKernel/IScheduler.h"
namespace AthViews {
class RoiCollectionToViews
: public ::AthAlgorithm
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
// Copy constructor:
/// Constructor with parameters:
RoiCollectionToViews( const std::string& name, ISvcLocator* pSvcLocator );
/// Destructor:
virtual ~RoiCollectionToViews();
// Athena algorithm's Hooks
virtual StatusCode initialize() override;
virtual StatusCode execute() override;
private:
/// Default constructor:
RoiCollectionToViews();
/// Containers
// vars
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_trigRoIs { this, "InputRoICollection", "input_rois", "Collection of RoIs to split into views" };
SG::WriteHandleKey< ViewContainer > m_w_views { this, "AllViews", "all_views", "Output view collection" };
SG::WriteHandleKey< ConstDataVector<TrigRoiDescriptorCollection> > m_viewRoIs { this, "OutputRoICollection", "output_rois", "RoI collection to use inside views" };
Gaudi::Property< std::string > m_schedulerName { this, "SchedulerName", "AvalancheSchedulerSvc", "Name of the scheduler" };
Gaudi::Property< std::string > m_viewBaseName { this, "ViewBaseName", "", "Name to use for all views - number will be appended" };
Gaudi::Property< std::string > m_viewNodeName { this, "ViewNodeName", "", "Name of the CF node to attach views to" };
Gaudi::Property< bool > m_viewFallThrough { this, "ViewFallThrough", true, "Set whether views may access StoreGate directly to retrieve data" };
};
} //> end namespace AthViews
#endif //> !ATHVIEWS_ATHVIEWS_ROICOLLECTIONTOVIEWS_H
#include "../ViewDataVerifier.h"
#include "../ViewTestAlg.h"
#include "../MinimalViewAlg.h"
#include "../AliasOutOfView.h"
#include "../RoiCollectionToViews.h"
DECLARE_COMPONENT( AthViews::ViewDataVerifier )
DECLARE_COMPONENT( AthViews::ViewTestAlg )
DECLARE_COMPONENT( AthViews::MinimalViewAlg )
DECLARE_COMPONENT( AthViews::AliasOutOfView )
DECLARE_COMPONENT( AthViews::RoiCollectionToViews )
#!/bin/sh
# art-type: build
# art-include: master/Athena
# art-ci: master
athena.py --threads=1 AthViews/SingleViewSequence.py
......@@ -16,19 +16,24 @@ from AthenaCommon.AlgSequence import AthSequencer
viewSeq = AthSequencer("AthViewSeq", Sequential=True, ModeOR=False, StopOverride=False)
topSequence += viewSeq
from L1Decoder.L1DecoderConfig import mapThresholdToL1RoICollection
from L1Decoder.L1DecoderConfig import mapThresholdToL1RoICollection, mapThresholdToL1DecisionCollection
roiCollectionName = mapThresholdToL1RoICollection("EM")
# View maker alg
from AthenaCommon import CfgMgr
viewNodeName = "allViewAlgorithms"
viewMaker = CfgMgr.AthViews__RoiCollectionToViews("viewMaker")
viewMaker.ViewBaseName = "testView"
viewMaker.InputRoICollection = roiCollectionName
viewMaker.ViewNodeName = viewNodeName
viewMaker.OutputRoICollection = "EMViewRoIs"
viewMaker.ViewFallThrough = True
viewSeq += viewMaker
from ViewAlgs.ViewAlgsConf import EventViewCreatorAlgorithm
from DecisionHandling.DecisionHandlingConf import ViewCreatorInitialROITool
inputMakerAlg = EventViewCreatorAlgorithm("viewMaker")
inputMakerAlg.ViewFallThrough = True
inputMakerAlg.RoIsLink = roiCollectionName
inputMakerAlg.InViewRoIs = "EMViewRoIs"
inputMakerAlg.Views = "testView"
inputMakerAlg.RoITool = ViewCreatorInitialROITool()
inputMakerAlg.InputMakerInputDecisions = [ mapThresholdToL1DecisionCollection("EM") ]
inputMakerAlg.ViewNodeName = viewNodeName
inputMakerAlg.InputMakerOutputDecisions = 'DUMMYOUTDEC'
viewSeq += inputMakerAlg
# Set of view algs
allViewAlgorithms = AthSequencer(viewNodeName, Sequential=False, ModeOR=False, StopOverride=False)
......
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