diff --git a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.h b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.h index 4f1b75a3a8d41ef48c6cf5347966e30efce8a1c2..8355cdf99a4a7ba659e38df1470f47e42ab3345d 100644 --- a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.h +++ b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.h @@ -10,6 +10,8 @@ #include "GaudiKernel/EventContext.h" #include "StoreGate/WriteHandleKey.h" #include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandle.h" +#include "StoreGate/ReadHandle.h" #include "xAODTrigger/TrigCompositeContainer.h" #include "xAODTrigger/TrigCompositeAuxContainer.h" @@ -21,33 +23,12 @@ namespace TrigCompositeUtils { typedef xAOD::TrigCompositeContainer DecisionContainer; typedef xAOD::TrigCompositeAuxContainer DecisionAuxContainer; + typedef SG::WriteHandle<DecisionContainer> DecisionWriteHandle; /* - @brief Helper struct for output decision handling - usage: - DecisionOutput o; - fill(o.decisions); // - CEHCK(o.record(ctx, key)); - */ - struct DecisionOutput { - DecisionOutput(); - // TODO reading DecisionStorage(const SG::ReadHandleKey<DecisionContainer>& key); - StatusCode record(const SG::WriteHandleKey<DecisionContainer>& key, const EventContext& ctx ); - std::unique_ptr<DecisionContainer> decisions; - std::unique_ptr<DecisionAuxContainer> aux; - }; + creates and right away stores the DecisionContainer under the key + */ + DecisionWriteHandle createAndStore(const SG::WriteHandleKey<DecisionContainer>& key, const EventContext& ctx); - /* - @brief Helper struct for retrieveing (and holding) decision container - usage: - DecisionInput i; - CHECK(i.retrieve(ctx, key)); - i.decisions->size(); - */ - - struct DecisionInput { - StatusCode retrieve(const SG::ReadHandleKey<DecisionContainer>& key, const EventContext& ctx ); - const DecisionContainer* decisions = nullptr; - }; /* @brief helper method to that created the Decision objects, places it in the container and returns diff --git a/Trigger/TrigSteer/DecisionHandling/src/DumpDecisions.cxx b/Trigger/TrigSteer/DecisionHandling/src/DumpDecisions.cxx index 67e2b199199d35bce244ed24fe23170493c975a6..fd607142853220d42ef386f934bac1d81c163101 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/DumpDecisions.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/DumpDecisions.cxx @@ -47,20 +47,20 @@ StatusCode DumpDecisions::finalize() { StatusCode DumpDecisions:: execute_r( const EventContext& ctx ) const { using namespace TrigCompositeUtils; - DecisionInput decisionInput; - CHECK ( decisionInput.retrieve( m_decisionKey, ctx) ); - - for ( auto d: *decisionInput.decisions ) { - + // DecisionInput decisionInput; + auto decisionInput = SG::makeHandle(m_decisionKey, ctx); + // CHECK( decisionInput.retrieve() ); + // CHECK ( decisionInput.retrieve( m_decisionKey, ctx) ); + ATH_MSG_DEBUG( "Retrieved decision with the key " << m_decisionKey.key() ); + ATH_MSG_DEBUG( "Pointer value " << decisionInput.cptr() ); + for ( auto d: *decisionInput ) { DecisionIDContainer ids; TrigCompositeUtils::decisionIDs( d, ids ); - if ( not ids.empty() ) { - ATH_MSG_DEBUG( "Decision object" ); - if ( m_verbosityLevel >= 2 ) { - for ( auto id: ids ) { - ATH_MSG_DEBUG( "Passing decision " << HLT::Identifier(id) ); - } - } + ATH_MSG_DEBUG( "Decision object with " << ids.size() << " decisions" ); + if ( m_verbosityLevel >= 2 ) { + for ( auto id: ids ) { + ATH_MSG_DEBUG( "Passing decision " << HLT::Identifier(id) ); + } } } return StatusCode::SUCCESS; diff --git a/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx b/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx index 0bb20d67810c476a39744df16f60e384b5432b65..c1b938ef52df1c8e54ba8905d90b8cd960166c3c 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx @@ -9,42 +9,29 @@ -static SG::AuxElement::Accessor< std::vector< int > > readWriteAccessor( "decisions" ); +static SG::AuxElement::Accessor< std::vector< int > > readWriteAccessor( "decisions" ); static SG::AuxElement::ConstAccessor< std::vector<int> > readOnlyAccessor( "decisions" ); namespace TrigCompositeUtils { - DecisionOutput::DecisionOutput() { - decisions = std::make_unique<DecisionContainer>(); - aux = std::make_unique<DecisionAuxContainer>(); - decisions->setStore( aux.release() ); - } - - StatusCode DecisionOutput::record( const SG::WriteHandleKey<DecisionContainer>& key, const EventContext& ctx ) { + DecisionWriteHandle createAndStore(const SG::WriteHandleKey<DecisionContainer>& key, const EventContext& ctx) { SG::WriteHandle<DecisionContainer> handle(key, ctx); - // CHECK ( handle.record( std::move( decisions ) ) ); - // SG::WriteHandle<DecisionAuxContainer> auxHandle(key.key()+"Aux.", ctx); - // CHECK( auxHandle.record( std::move (aux) ) ); - // return StatusCode::SUCCESS; - return handle.record( std::move(decisions), std::move(aux) ); - } - - StatusCode DecisionInput::retrieve( const SG::ReadHandleKey<DecisionContainer>& key, const EventContext& ctx ) { - SG::ReadHandle<DecisionContainer> handle( key, ctx ); - decisions = handle.get(); - return StatusCode::SUCCESS; + auto data = std::make_unique<DecisionContainer>() ; + auto aux = std::make_unique<DecisionAuxContainer>() ; + data->setStore(aux.get()); + handle.record( std::move( data ), std::move( aux ) ).ignore(); + return handle; } - Decision* newDecisionIn (DecisionContainer* dc) { Decision * x = new Decision; dc->push_back( x ); + readWriteAccessor( *x ).size(); // fake operation just to make the decsions decoration return x; } void addDecisionID( DecisionID id, Decision* d) { readWriteAccessor( *d ).push_back( id ); - } void decisionIDs( const Decision* d, DecisionIDContainer& destination ) { diff --git a/Trigger/TrigSteer/DecisionHandling/test/TrigCompositeUtils_test.cxx b/Trigger/TrigSteer/DecisionHandling/test/TrigCompositeUtils_test.cxx index 35cdc9a68bc69cae8e48f73f817311fd82cf967f..4e6f28e74e05e817cca9a5ccf78d868588d501a8 100644 --- a/Trigger/TrigSteer/DecisionHandling/test/TrigCompositeUtils_test.cxx +++ b/Trigger/TrigSteer/DecisionHandling/test/TrigCompositeUtils_test.cxx @@ -11,14 +11,17 @@ int main() { using namespace TrigCompositeUtils; - auto dc = DecisionOutput(); + auto dc = std::make_unique<DecisionContainer>(); + auto decisionAux = std::make_unique<DecisionAuxContainer>(); + dc->setStore(decisionAux.get()); + // try insertions - auto d1 = newDecisionIn(dc.decisions.get()); + auto d1 = newDecisionIn(dc.get()); addDecisionID( 1, d1 ); addDecisionID( 2, d1 ); - auto d2 = newDecisionIn(dc.decisions.get()); + auto d2 = newDecisionIn(dc.get()); addDecisionID( 1, d2 ); addDecisionID( 3, d2 ); diff --git a/Trigger/TrigSteer/L1Decoder/share/decodeBS.py b/Trigger/TrigSteer/L1Decoder/share/decodeBS.py index 06ea9d57a43b0c00a1685c5d4c48e75c941f9b4f..11091652257b7e6819e508fc6afc9267f1c1105a 100755 --- a/Trigger/TrigSteer/L1Decoder/share/decodeBS.py +++ b/Trigger/TrigSteer/L1Decoder/share/decodeBS.py @@ -97,13 +97,20 @@ muUnpacker.ThresholdToChainMapping = ["MU6 : HLT_mu6", "MU6 : HLT_mu6idperf", "M # do not know yet how to configure the services for it l1Decoder.roiUnpackers = [emUnpacker] +l1Decoder.Chains="HLTChainsResult" topSequence += l1Decoder #Run calo decoder from DecisionHandling.DecisionHandlingConf import * -emDecisionsDumper = DumpDecisions("EML1RoIs") +emDecisionsDumper = DumpDecisions("DumpEML1RoIs", OutputLevel=DEBUG) emDecisionsDumper.Decisions = "EMRoIDecisions" -#topSequence += emDecisionsDumper +topSequence += emDecisionsDumper + +chainSeedingDumper = DumpDecisions("ChainSeedingDumper", OutputLevel=DEBUG) +chainSeedingDumper.Decisions = "HLTChainsResult" +topSequence += chainSeedingDumper + + # caloDecoder = L1CaloDecoder() # by default it is steered towards the RoIBResult of the name above # caloDecoder.OutputLevel=VERBOSE diff --git a/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx index d0d534a9c4edba79be7ffab20162962c776f6a63..e058d090cc844bbdcaf77cbf1ef3a04129209100 100644 --- a/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx @@ -36,7 +36,7 @@ StatusCode EMRoIsUnpackingTool::initialize() { CHECK( m_decisionsKey.initialize() ); CHECK( m_trigRoIsKey.initialize() ); CHECK( m_recRoIsKey.initialize() ); - //TODO add mapping retrieval + if (decodeMapping().isFailure() ) { ATH_MSG_ERROR( "Failed to decode threshold to chains mapping, is the format th : chain?" ); return StatusCode::FAILURE; @@ -69,8 +69,10 @@ StatusCode EMRoIsUnpackingTool::finalize() StatusCode EMRoIsUnpackingTool::unpack( const EventContext& ctx, const ROIB::RoIBResult& roib, const HLT::IDSet& activeChains ) const { - - TrigCompositeUtils::DecisionOutput decisionOutput; + using namespace TrigCompositeUtils; + auto decisionOutput = std::make_unique<DecisionContainer>(); + auto decisionAux = std::make_unique<DecisionAuxContainer>(); + decisionOutput->setStore(decisionAux.get()); auto trigRoIs = CxxUtils::make_unique< TrigRoiDescriptorCollection >(); auto recRoIs = CxxUtils::make_unique< DataVector<LVL1::RecEmTauRoI> >(); @@ -93,9 +95,10 @@ StatusCode EMRoIsUnpackingTool::unpack( const EventContext& ctx, ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw(8) << roIWord << ", threshold pattern " << MSG::dec ); - auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.decisions.get() ); + auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.get() ); for ( auto th: m_emThresholds ) { if ( recRoI->passedThreshold( th->thresholdNumber() ) ) { + ATH_MSG_DEBUG("Passed Threshold name " << th->name()); addChainsToDecision( HLT::Identifier( th->name() ), decision, activeChains ); } } @@ -118,7 +121,10 @@ StatusCode EMRoIsUnpackingTool::unpack( const EventContext& ctx, SG::WriteHandle<DataVector<LVL1::RecEmTauRoI>> handle(m_recRoIsKey, ctx); CHECK( handle.record( std::move(recRoIs)) ); } - CHECK( decisionOutput.record( m_decisionsKey, ctx) ); + { + auto handle = SG::makeHandle(m_decisionsKey, ctx); + CHECK ( handle.record( std::move( decisionOutput ), std::move( decisionAux ) ) ); + } return StatusCode::SUCCESS; // what else diff --git a/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx b/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx index acc35c236f34e987ea2ec92bb7a5f7c2814536a6..1b933d51160ab2370d56f2dc1a128eda7e8423d5 100644 --- a/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/L1Decoder.cxx @@ -46,8 +46,12 @@ StatusCode L1Decoder::execute_r (const EventContext& ctx) const { // this should realy be: const ROIB::RoIBResult* roib = SG::INPUT_PTR (m_RoIBResultKey, ctx); // or const ROIB::RoIBResult& roib = SG::INPUT_REF (m_RoIBResultKey, ctx); - DecisionOutput chainsInfo; - + + + auto chainsInfo = std::make_unique<DecisionContainer>(); + auto chainsAux = std::make_unique<DecisionAuxContainer>(); + chainsInfo->setStore(chainsAux.get()); + HLT::IDVec l1SeededChains; CHECK( m_ctpUnpacker->decode( *roibH, l1SeededChains ) ); sort( l1SeededChains.begin(), l1SeededChains.end() ); // do so that following scaling is reproducable @@ -56,23 +60,25 @@ StatusCode L1Decoder::execute_r (const EventContext& ctx) const { activeChains.reserve( l1SeededChains.size() ); // an optimisation, max we get as many active chains as were seeded by L1, rarely the condition, but allows to avoid couple of reallocations CHECK( prescaleChains( l1SeededChains, activeChains) ); - CHECK( saveChainsInfo( l1SeededChains, chainsInfo.decisions.get(), "l1seeded" ) ); - CHECK( saveChainsInfo( activeChains, chainsInfo.decisions.get(), "unprescaled" ) ); + CHECK( saveChainsInfo( l1SeededChains, chainsInfo.get(), "l1seeded" ) ); + CHECK( saveChainsInfo( activeChains, chainsInfo.get(), "unprescaled" ) ); HLT::IDSet activeChainSet( activeChains.begin(), activeChains.end() ); for ( auto unpacker: m_roiUnpackers ) { CHECK( unpacker->unpack( ctx, *roibH, activeChainSet ) ); } ATH_MSG_DEBUG("Recording chains"); - CHECK( chainsInfo.record( m_chainsKey, ctx ) ); + + auto handle = SG::makeHandle( m_chainsKey, ctx ); + CHECK( handle.record( std::move( chainsInfo ), std::move( chainsAux ) ) ); return StatusCode::SUCCESS; } + StatusCode L1Decoder::finalize() { return StatusCode::SUCCESS; } - StatusCode L1Decoder::prescaleChains( const HLT::IDVec& active, HLT::IDVec& notPrescaled ) const { diff --git a/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx index 33137f974fbc5faf47da849ecdb293953ddd8030..59313ec22317266771821eb116d1d0f8fb596172 100644 --- a/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx @@ -68,7 +68,10 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx, const ROIB::RoIBResult& roib, const HLT::IDSet& activeChains ) const { using namespace TrigCompositeUtils; - DecisionOutput decisionOutput; + auto decisionOutput = std::make_unique<DecisionContainer>(); + auto decisionAux = std::make_unique<DecisionAuxContainer>(); + decisionOutput->setStore(decisionAux.get()); + auto trigRoIs = CxxUtils::make_unique< TrigRoiDescriptorCollection >(); auto recRoIs = CxxUtils::make_unique< DataVector<LVL1::RecMuonRoI> >(); @@ -89,10 +92,10 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx, ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw(8) << roIWord << ", threshold pattern "); - auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.decisions.get() ); + auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.get() ); for ( auto th: m_muonThresholds ) { - if ( th->thresholdNumber() <= thresholdNumber ) { // TODO vrify if here should be <= or < + if ( th->thresholdNumber() <= thresholdNumber ) { // TODO verify if here should be <= or < // this code suggests <= https://gitlab.cern.ch/atlas/athena/blob/master/Trigger/TrigSteer/TrigSteering/src/Lvl1ResultAccessTool.cxx#L654 addChainsToDecision( HLT::Identifier( th->name() ), decision, activeChains ); } @@ -101,14 +104,17 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx, // recording { - SG::WriteHandle<TrigRoiDescriptorCollection> handle(m_trigRoIsKey, ctx); + auto handle = SG::makeHandle( m_trigRoIsKey, ctx ); CHECK( handle.record( std::move(trigRoIs) ) ); } { - SG::WriteHandle<DataVector<LVL1::RecMuonRoI>> handle(m_recRoIsKey, ctx); + auto handle = SG::makeHandle( m_recRoIsKey, ctx ); CHECK( handle.record( std::move(recRoIs) ) ); } - CHECK( decisionOutput.record(m_decisionsKey, ctx) ); + { + auto handle = SG::makeHandle( m_decisionsKey, ctx ); + CHECK( handle.record( std::move(decisionOutput) ) ); + } return StatusCode::SUCCESS; }