From c337ea939da51f39a98d701c8e6d80e758954fb8 Mon Sep 17 00:00:00 2001
From: Tim Martin <Tim.Martin@cern.ch>
Date: Tue, 19 Feb 2019 17:35:49 +0100
Subject: [PATCH] Update tests to V2 of TrigComposite

---
 .../test/void_record_test.cxx                 | 45 ++++++++++++++++---
 .../TrigUpgradeTest/share/egamma.withViews.py |  2 +-
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/Trigger/TrigSteer/TrigOutputHandling/test/void_record_test.cxx b/Trigger/TrigSteer/TrigOutputHandling/test/void_record_test.cxx
index 8f78b891fda..592bbc9e5e4 100644
--- a/Trigger/TrigSteer/TrigOutputHandling/test/void_record_test.cxx
+++ b/Trigger/TrigSteer/TrigOutputHandling/test/void_record_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 #include <iostream>
 #include "TestTools/expect.h"
@@ -15,6 +15,8 @@
 
 int main() {
   using namespace std;
+  using TrigCompositeUtils::DecisionID;
+
   ISvcLocator* pSvcLoc;
   if (!Athena_test::initGaudi("test.txt",  pSvcLoc)) {
     cerr << "ERROR This test can not be run" << endl;
@@ -31,14 +33,27 @@ int main() {
     return -1;
   }
 
+  std::vector<DecisionID> decisions = {2, 4, 6};
+
   xAOD::TrigCompositeContainer* testContainer = new xAOD::TrigCompositeContainer();
   xAOD::TrigCompositeAuxContainer* aux = new xAOD::TrigCompositeAuxContainer();
   testContainer->setStore( aux );
   
+  // Note: idetail and fdetail are dynamic decorations.
+  // The decoration must be set on all objects within the container
+
   testContainer->push_back( new xAOD::TrigComposite() );
+  testContainer->back()->setDetail( "idetail", 7 );
+  testContainer->back()->setDetail( "fdetail", 2.5f );
+  testContainer->back()->setDetail( "decisions", decisions );
+
   testContainer->push_back( new xAOD::TrigComposite() );
-  testContainer->at(0)->setDetail( "idetail", 7 );
-  testContainer->at(1)->setDetail( "fdetail", 2.5f );
+  testContainer->back()->setDetail( "idetail", 8 );
+  testContainer->back()->setDetail( "fdetail", 3.5f );
+  testContainer->back()->setDetail( "decisions", decisions );
+  testContainer->back()->setObjectLink( "link", ElementLink<xAOD::TrigCompositeContainer>( 123, 456, testContainer->at(0) ) );
+  // Note the SG part of this link is junk data, but the third parameter is real. Meaning it will pass a isValid sanity check
+
   void * rawContainerPtr = static_cast<void*>( testContainer );
   void * rawStorePtr = static_cast<void*>( aux );
 
@@ -48,28 +63,44 @@ int main() {
   log << MSG::INFO << containerRT.Name() << endmsg;
   BareDataBucket containerDataBucket( rawContainerPtr, ClassID_traits<xAOD::TrigCompositeContainer>::ID(), containerRT ); 
   
-  RootType storeRT = RootType::ByName( "xAOD::TrigCompositeAuxContainer_v1" );
+  RootType storeRT = RootType::ByName( "xAOD::TrigCompositeAuxContainer_v2" );
   log << MSG::INFO << storeRT.Name() << endmsg;
   BareDataBucket storeDataBucket( rawStorePtr, ClassID_traits<xAOD::TrigCompositeAuxContainer>::ID(), storeRT ); 
+  log << MSG::INFO << "recordObject done" << endmsg;
 
   pStore->recordObject( SG::DataObjectSharedPtr<BareDataBucket>( &containerDataBucket ), "test", false, false );
   pStore->recordObject( SG::DataObjectSharedPtr<BareDataBucket>( &storeDataBucket ), "testAux.", false, false );
 
   log << MSG::INFO << "recordObject done" << endmsg;
 
-
   VALUE( pStore->accessData( ClassID_traits<xAOD::TrigCompositeContainer>::ID(),  "test" ) ) NOT_EXPECTED ( nullptr );
   VALUE( pStore->accessData( ClassID_traits<xAOD::TrigCompositeAuxContainer>::ID(),  "testAux." ) ) NOT_EXPECTED ( nullptr );
 
-  log << MSG::INFO << "objects in store, trying to read them back via rertieve" << endmsg;
+  log << MSG::INFO << "objects in store, trying to read them back via retrieve" << endmsg;
 
   const xAOD::TrigCompositeContainer* containerBack = 0;
   pStore->retrieve( containerBack, "test" );
   
+  log << MSG::INFO << "Check retrieve" << endmsg;
   VALUE ( containerBack ) NOT_EXPECTED ( nullptr );
+  log << MSG::INFO << "Check size" << endmsg;
   VALUE( containerBack->size() ) EXPECTED ( 2 );
+  log << MSG::INFO << "Check [0] int32_t" << endmsg;
   VALUE( containerBack->at(0)->getDetail<int32_t>( "idetail" ) ) EXPECTED ( 7 );
-  VALUE( containerBack->at(1)->getDetail<float>( "fdetail" ) ) EXPECTED ( 2.5f );
+  log << MSG::INFO << "Check [0] float" << endmsg;
+  VALUE( containerBack->at(0)->getDetail<float>( "fdetail" ) ) EXPECTED ( 2.5f );
+  log << MSG::INFO << "Check [0] std::vector<DecisionID>" << endmsg;
+  VALUE( containerBack->at(0)->getDetail<std::vector<DecisionID>>( "decisions" )[0] ) EXPECTED ( decisions[0] );
+  VALUE( containerBack->at(0)->getDetail<std::vector<DecisionID>>( "decisions" )[1] ) EXPECTED ( decisions[1] );
+  VALUE( containerBack->at(0)->getDetail<std::vector<DecisionID>>( "decisions" )[2] ) EXPECTED ( decisions[2] );
+  log << MSG::INFO << "Check [1] int32_t" << endmsg;
+  VALUE( containerBack->at(1)->getDetail<int32_t>( "idetail" ) ) EXPECTED ( 8 );
+  log << MSG::INFO << "Check [1] float" << endmsg;
+  VALUE( containerBack->at(1)->getDetail<float>( "fdetail" ) ) EXPECTED ( 3.5f );
+  log << MSG::INFO << "Check [1] link" << endmsg;
+  ElementLink<xAOD::TrigCompositeContainer> link = containerBack->at(1)->objectLink<xAOD::TrigCompositeContainer>("link");
+  VALUE( link.key() ) EXPECTED ( 123 );
+  VALUE( link.index() ) EXPECTED ( 456 );
 
   log << MSG::INFO << "Container read back is identical" << endmsg;
   return 0;
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py
index 3a05564a52c..d73e04d5431 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py
@@ -346,7 +346,7 @@ print summMaker
 serialiser = TriggerEDMSerialiserTool(name="Serialiser", OutputLevel=VERBOSE)
 
 serialiser.CollectionsToSerialize = [ "xAOD::TrigCompositeContainer_v1#remap_EgammaCaloDecisions",
-                                      "xAOD::TrigCompositeAuxContainer_v1#remap_EgammaCaloDecisionsAux.",
+                                      "xAOD::TrigCompositeAuxContainer_v2#remap_EgammaCaloDecisionsAux.",
                                       "xAOD::TrigEMClusterContainer_v1#HLT_xAOD__TrigEMClusterContainer_L2CaloClusters",
                                       "xAOD::TrigEMClusterAuxContainer_v2#HLT_xAOD__TrigEMClusterContainer_L2CaloClustersAux.RoIword.clusterQuality.e233.e237.e277.e2tsts1.ehad1.emaxs1.energy.energySample.et.eta.eta1.fracs1.nCells.phi.rawEnergy.rawEnergySample.rawEt.rawEta.rawPhi.viewIndex.weta2.wstot",
                                       "xAOD::TrigElectronContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFex",
-- 
GitLab