Skip to content
Snippets Groups Projects
Commit 0c57cf2c authored by Scott Snyder's avatar Scott Snyder Committed by scott snyder
Browse files

ViewAlgsTest: const fixes.

A long-standing bug in DataVector has allowed getting non-const pointers
from a const_iterator.  This package was relying on this to compile.
Fix by using ConstDataVector.  Also, one should generally not have an
aux store for a view container; fix that too.
parent 9a24e08c
No related branches found
No related tags found
No related merge requests found
......@@ -19,13 +19,11 @@ EventViewCreatorAlgorithm::EventViewCreatorAlgorithm( const std::string& name, I
m_inputKey( "InputCollection" ),
m_inputAuxKey( "InputCollectionAux" ),
m_outputKey( "OutputCollection" ),
m_outputAuxKey( "OutputCollectionAux" ),
m_viewAlgorithmPool( "ViewAlgPool" )
{
//VarHandleKeys
declareProperty( "OutputViewCollection", m_viewsKey, "Name of output event view collection" );
declareProperty( "WithinViewCollection", m_outputKey, "Name of the collection to make inside views" );
declareProperty( "WithinViewAuxCollection", m_outputAuxKey, "Name of the aux collection to make inside views" );
declareProperty( "InputCollection", m_inputKey, "Name of the collection to split into views" );
declareProperty( "InputAuxCollection", m_inputAuxKey, "Name of the aux collection to split into views" );
......@@ -39,7 +37,6 @@ StatusCode EventViewCreatorAlgorithm::initialize()
//Initialize VarHandleKeys
CHECK( m_viewsKey.initialize() );
CHECK( m_outputKey.initialize() );
CHECK( m_outputAuxKey.initialize() );
CHECK( m_inputKey.initialize() );
CHECK( m_inputAuxKey.initialize() );
......@@ -66,32 +63,22 @@ StatusCode EventViewCreatorAlgorithm::execute()
//Split into views
std::vector< SG::View* > viewVector;
std::vector< xAOD::TrigCompositeContainer > viewCollections;
std::vector< xAOD::TrigCompositeAuxContainer > viewAuxCollections;
std::vector< ConstDataVector<xAOD::TrigCompositeContainer> > viewCollections;
for ( const auto input: *inputHandle.cptr() )
{
xAOD::TrigCompositeContainer oneInput;
xAOD::TrigCompositeAuxContainer oneAuxInput;
oneInput.setStore( oneAuxInput );
ConstDataVector<xAOD::TrigCompositeContainer> oneInput;
oneInput.clear( SG::VIEW_ELEMENTS );
oneInput.push_back( input );
viewCollections.push_back( oneInput );
viewAuxCollections.push_back( oneAuxInput );
}
//Make the views
SG::WriteHandle< xAOD::TrigCompositeContainer > viewHandle( m_outputKey, ctx );
SG::WriteHandle< ConstDataVector<xAOD::TrigCompositeContainer> > viewHandle( m_outputKey, ctx );
CHECK( ViewHelper::MakeAndPopulate( name() + "_view", // Base name for all views to use
viewVector, // Vector to store views
viewHandle, // A writehandle to use to access the views (the handle itself, not the contents)
viewCollections ) ); // Data to initialise each view - one view will be made per entry
//Add the aux collections
SG::WriteHandle< xAOD::TrigCompositeAuxContainer > viewAuxHandle( m_outputAuxKey, ctx );
CHECK( ViewHelper::Populate( viewVector, // Vector containing views
viewAuxHandle, // A writehandle to use to access the views (the handle itself, not the contents)
viewAuxCollections ) ); // Data to add to each view - vector must be same length as view vector
// Run the views
CHECK( ViewHelper::RunViews( viewVector, // Vector containing views
m_viewAlgorithmNames, // Algorithms to run in each view
......
......@@ -16,6 +16,7 @@
#include "xAODTrigger/TrigCompositeContainer.h"
#include "xAODTrigger/TrigCompositeAuxContainer.h"
#include "AthViews/View.h"
#include "AthContainers/ConstDataVector.h"
class EventViewCreatorAlgorithm : public AthAlgorithm
{
......@@ -33,8 +34,7 @@ class EventViewCreatorAlgorithm : public AthAlgorithm
SG::ReadHandleKey< xAOD::TrigCompositeAuxContainer > m_inputAuxKey;
//Output the split composite collection into views
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_outputKey;
SG::WriteHandleKey< xAOD::TrigCompositeAuxContainer > m_outputAuxKey;
SG::WriteHandleKey< ConstDataVector<xAOD::TrigCompositeContainer> > m_outputKey;
//Algorithms to run in views
std::vector< std::string > m_viewAlgorithmNames;
......
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