From 0c57cf2cecb1aba9cd91bc7173f809622340d3a2 Mon Sep 17 00:00:00 2001
From: scott snyder <scott.snyder@cern.ch>
Date: Mon, 28 Aug 2017 22:46:57 +0200
Subject: [PATCH] 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.
---
 .../src/EventViewCreatorAlgorithm.cxx         | 19 +++----------------
 .../src/EventViewCreatorAlgorithm.h           |  4 ++--
 2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.cxx b/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.cxx
index 1b49500cd60..5ea15e158eb 100644
--- a/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.cxx
+++ b/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.cxx
@@ -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
diff --git a/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.h b/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.h
index 87720929ddf..243ee60d407 100644
--- a/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.h
+++ b/Trigger/TrigSteer/ViewAlgsTest/src/EventViewCreatorAlgorithm.h
@@ -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;
-- 
GitLab