Skip to content
Snippets Groups Projects
Commit 0ed28076 authored by Tomasz Bold's avatar Tomasz Bold
Browse files

Handles wired properly now

Former-commit-id: ea7e732f
parent 863e6062
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
......@@ -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 ) {
......
......@@ -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 );
......
......@@ -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
......
......@@ -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
......
......@@ -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 {
......
......@@ -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;
}
......
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