From def8078de9adcc890d51785867a4bd7ffc2cc10f Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Mon, 19 Nov 2018 20:59:17 +0100
Subject: [PATCH] attempt to get FS decision associated wiht FSRoI

---
 .../L1Decoder/src/JRoIsUnpackingTool.cxx      | 25 +++++++++++++------
 .../L1Decoder/src/JRoIsUnpackingTool.h        |  3 +++
 Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx | 17 ++++++-------
 .../TrigUpgradeTest/python/jetDefs.py         |  2 +-
 .../TrigUpgradeTest/python/jetMenuDefs.py     |  2 +-
 5 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.cxx
index 1747779987bc..57605bc4c0c2 100644
--- a/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.cxx
+++ b/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.cxx
@@ -50,7 +50,10 @@ StatusCode JRoIsUnpackingTool::unpack( const EventContext& ctx,
   auto trigRoIs = std::make_unique< TrigRoiDescriptorCollection >();
   auto recRoIs  = std::make_unique< DataVector<LVL1::RecJetRoI> >();
 
-
+ 
+  auto decision  = TrigCompositeUtils::newDecisionIn( decisionOutput.get() );  
+  decision->setObjectLink( "initialRoI", ElementLink<TrigRoiDescriptorCollection>( m_fsRoIKey, 0 ) );
+  
 
   // RoIBResult contains vector of TAU fragments
   for ( auto& jetFragment : roib.jetEnergyResult() ) {
@@ -63,15 +66,17 @@ StatusCode JRoIsUnpackingTool::unpack( const EventContext& ctx,
       
       auto recRoI = new LVL1::RecJetRoI( roIWord, &m_jetThresholds );
       recRoIs->push_back( recRoI );
-      
+
+      /* TDOD, decide if we need this collection at all here, now keep filling of it commented out
+      //decision->setObjectLink( "initialRecRoI", ElementLink<DataVector<LVL1::RecJetRoI>>( m_recRoIsKey.key(), recRoIs->size()-1 ) );
       auto trigRoI = new TrigRoiDescriptor( roIWord, 0u ,0u,
 					    recRoI->eta(), recRoI->eta()-m_roIWidth, recRoI->eta()+m_roIWidth,
 					    recRoI->phi(), recRoI->phi()-m_roIWidth, recRoI->phi()+m_roIWidth );
       trigRoIs->push_back( trigRoI );
-        
+      */
       ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw( 8 ) << roIWord << MSG::dec );      
 
-      auto decision  = TrigCompositeUtils::newDecisionIn( decisionOutput.get() );
+
       
       for ( auto th: m_jetThresholds ) {
 	ATH_MSG_VERBOSE( "Checking if the threshold " << th->name() << " passed" );
@@ -86,11 +91,17 @@ StatusCode JRoIsUnpackingTool::unpack( const EventContext& ctx,
       }
       
 
-      // TODO would be nice to have this. Requires modifying the TC class: decision->setDetail( "Thresholds", passedThresholds ); // record passing threshold names ( for easy debugging )            
-      decision->setObjectLink( "initialRoI", ElementLink<TrigRoiDescriptorCollection>( m_trigRoIsKey.key(), trigRoIs->size()-1 ) );
-      decision->setObjectLink( "initialRecRoI", ElementLink<DataVector<LVL1::RecJetRoI>>( m_recRoIsKey.key(), recRoIs->size()-1 ) );
     }     
   }
+  TrigCompositeUtils::DecisionIDContainer uniqueDecisions; // this is set
+  std::vector<int>& storedIDs = TrigCompositeUtils::decisionIDs( decision );
+  TrigCompositeUtils::decisionIDs( decision, uniqueDecisions ); // copy to set -> unique
+  storedIDs.clear();
+  storedIDs.insert( storedIDs.end(), uniqueDecisions.begin(), uniqueDecisions.end() );
+  //copy back
+  
+
+
   if ( msgLvl(MSG::DEBUG) ) {
     for ( auto roi: *trigRoIs ) {
       ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() );
diff --git a/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.h b/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.h
index 240499ce89ac..493f234a06e8 100644
--- a/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.h
+++ b/Trigger/TrigSteer/L1Decoder/src/JRoIsUnpackingTool.h
@@ -42,6 +42,9 @@ private:
   Gaudi::Property<float>            m_roIWidth{
     this, "RoIWidth", 0.4, "Size of RoI in eta/ phi"};
   
+  //SG::ReadHandleKey<TrigRoiDescriptorCollection> m_fsRoIKey{ this, "FSRoIKey", "FSRoI", "The key of FS RoI made earlier by the L1Decoder" };
+  Gaudi::Property<std::string> m_fsRoIKey{ this, "FSRoIKey", "FSRoI", "The key of FS RoI made earlier by the L1Decoder" };
+
   ServiceHandle<TrigConf::ILVL1ConfigSvc> m_configSvc;
   std::vector<TrigConf::TriggerThreshold*> m_jetThresholds;
 
diff --git a/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx b/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx
index 890a856c7e8e..2ff51b5f3609 100644
--- a/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx
+++ b/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx
@@ -75,7 +75,14 @@ StatusCode L1Decoder::execute_r (const EventContext& ctx) const {
   // this should really be: const ROIB::RoIBResult* roib = SG::INPUT_PTR (m_RoIBResultKey, ctx);
   // or const ROIB::RoIBResult& roib = SG::INPUT_REF (m_RoIBResultKey, ctx);
 
-
+  {
+    std::unique_ptr<TrigRoiDescriptorCollection> fsRoIsColl = std::make_unique<TrigRoiDescriptorCollection>();
+    TrigRoiDescriptor* fsRoI = new TrigRoiDescriptor( true ); // true == FS
+    fsRoIsColl->push_back( fsRoI );
+   
+    auto handle = SG::makeHandle( m_trigFSRoIKey, ctx );
+    ATH_CHECK( handle.record ( std::move( fsRoIsColl ) ) );
+  }
 
   auto chainsInfo = std::make_unique<DecisionContainer>();
   auto chainsAux = std::make_unique<DecisionAuxContainer>();
@@ -120,14 +127,6 @@ StatusCode L1Decoder::execute_r (const EventContext& ctx) const {
     ATH_CHECK( unpacker->unpack( ctx, *roib, rerunChainSet ) );
   }
 
-  {
-    std::unique_ptr<TrigRoiDescriptorCollection> fsRoIsColl = std::make_unique<TrigRoiDescriptorCollection>();
-    TrigRoiDescriptor* fsRoI = new TrigRoiDescriptor( true ); // true == FS
-    fsRoIsColl->push_back( fsRoI );
-   
-    auto handle = SG::makeHandle( m_trigFSRoIKey, ctx );
-    ATH_CHECK( handle.record ( std::move( fsRoIsColl ) ) );
-  }
 
 
   ATH_MSG_DEBUG("Recording chains");
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py
index 8b2388c11b34..82cca27cc39b 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py
@@ -54,7 +54,7 @@ def jetRecoSequence(inputMakerOut):
 
     from TrigCaloRec.TrigCaloRecConfig import TrigCaloClusterMakerMT_topo
     algo2 = TrigCaloClusterMakerMT_topo(doMoments=True, doLC=False)
-    algo2.Cells = "StoreGateSvc+FullScanCells"
+    algo2.Cells = "CellsClusters"
     algo2.OutputLevel = INFO
     jetRecoSequence += algo2
 
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py
index 5f3ed3b56b95..bd5e7a707be8 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py
@@ -16,7 +16,7 @@ def jetSequence():
 
     #reco sequence
     from TrigUpgradeTest.jetDefs import jetRecoSequence
-    (recoSequence, sequenceOut) = jetRecoSequence(InputMakerAlg.Output)
+    (recoSequence, sequenceOut) = jetRecoSequence("FSRoI")
 
     #hypo
     from TrigHLTJetHypo.TrigHLTJetHypoConf import TrigJetHypoAlgMT
-- 
GitLab