Skip to content
Snippets Groups Projects
Commit 57b1fac6 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'l1decoder-phase1-muon' into 'master'

L1Decoder: Seed HLT from Run-3 L1Muon simulation output (xAOD::MuonRoI)

See merge request atlas/athena!40463
parents c00a1552 567bfc99
No related branches found
No related tags found
No related merge requests found
Showing
with 169 additions and 46 deletions
......@@ -357,7 +357,7 @@ def generateL1Decoder():
muUnpacker = RoIsUnpackingEmulationTool("MURoIsUnpackingTool", InputFilename="l1muroi.dat", OutputTrigRoIs=mapThresholdToL1RoICollection("MU"), Decisions=mapThresholdToL1DecisionCollection("MU"), ThresholdPrefix="MU" )
l1Decoder.roiUnpackers = [emUnpacker, muUnpacker]
l1Decoder.RoIBRoIUnpackers = [emUnpacker, muUnpacker]
L1UnpackingSeq += l1Decoder
log.debug(L1UnpackingSeq)
......
......@@ -55,7 +55,7 @@ class L1EmulationTest(L1Decoder):
Decisions = "EMRoIDecisions",
OutputTrigRoIs = mapThresholdToL1RoICollection("EM"),
OutputLevel = self.getDefaultProperty("OutputLevel"))
self.roiUnpackers += [emUnpacker]
self.RoIBRoIUnpackers += [emUnpacker]
print (emUnpacker)
......@@ -65,7 +65,7 @@ class L1EmulationTest(L1Decoder):
Decisions = "MURoIDecisions",
OutputTrigRoIs = mapThresholdToL1RoICollection("MU"),
OutputLevel=self.getDefaultProperty("OutputLevel"))
self.roiUnpackers += [muUnpacker]
self.RoIBRoIUnpackers += [muUnpacker]
self.L1DecoderSummaryKey = "L1DecoderSummary"
......
......@@ -36,6 +36,9 @@ public:
virtual StatusCode passBeforePrescaleSelection(const ROIB::RoIBResult* /*roib*/,
const std::vector<std::string>& /*l1ItemNames*/, bool& /*pass*/) const override;
// Derived class may override this to return true if its decode() method doesn't depend on RoIBResult
virtual bool isEmulated() const override {return false;}
protected:
static constexpr int s_CTPIDForUndeededChains = -1;
......
......@@ -36,6 +36,10 @@ public:
*/
virtual StatusCode passBeforePrescaleSelection(const ROIB::RoIBResult* roib, const std::vector<std::string>& l1ItemNames, bool& pass) const = 0;
/**
* Should return true if the implementation of decode() doesn't depend on RoIBResult
*/
virtual bool isEmulated() const = 0;
};
......
......@@ -75,14 +75,17 @@ def createCaloRoIUnpackers():
return [emUnpacker, metUnpacker, tauUnpacker, jUnpacker ]
def createMuonRoIUnpackers():
def createMuonRoIUnpackers(flags):
#from L1Decoder.L1DecoderConf import MURoIsUnpackingTool
from L1Decoder.L1DecoderMonitoring import RoIsUnpackingMonitoring
from TrigEDMConfig.TriggerEDMRun3 import recordable
muUnpacker = CompFactory.MURoIsUnpackingTool(Decisions = mapThresholdToL1DecisionCollection("MU"),
OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("MU")))
muUnpacker = CompFactory.MURoIsUnpackingTool(
Decisions = mapThresholdToL1DecisionCollection("MU"),
OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("MU")))
muUnpacker.OutputRecRoIs = "" if flags.Trigger.enableL1Phase1 else "HLT_RecMURoIs"
muUnpacker.MuRoILinkName = "LVL1MuonRoIs" if flags.Trigger.enableL1Phase1 else ""
muUnpacker.MonTool = RoIsUnpackingMonitoring( prefix="MU", maxCount=20 )
return [muUnpacker]
......@@ -104,7 +107,6 @@ def getL1TriggerResultMaker():
# Muon RoIs
l1trMaker.MuRoIKey = "LVL1MuonRoIs"
l1trMaker.MuRoILinkName = "mu_roi"
# Placeholder for other L1 xAOD outputs:
# - CTP result
......@@ -120,29 +122,33 @@ class L1Decoder(CompFactory.L1Decoder) :
super(L1Decoder, self).__init__(name, *args, **kwargs)
from TriggerJobOpts.TriggerFlags import TriggerFlags
from AthenaConfiguration.AllConfigFlags import ConfigFlags as flags
# CTP unpacker
ctpUnpacker = CompFactory.CTPUnpackingTool()
self.ctpUnpacker = ctpUnpacker
from TrigEDMConfig.TriggerEDMRun3 import recordable
self.roiUnpackers += [ CompFactory.FSRoIsUnpackingTool("FSRoIsUnpackingTool",
Decisions=mapThresholdToL1DecisionCollection("FSNOSEED"),
OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("FSNOSEED") )) ]
self.RoIBRoIUnpackers += [
CompFactory.FSRoIsUnpackingTool("FSRoIsUnpackingTool",
Decisions=mapThresholdToL1DecisionCollection("FSNOSEED"),
OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("FSNOSEED") )) ]
# EM unpacker
if TriggerFlags.doID() or TriggerFlags.doCalo():
unpackers = createCaloRoIUnpackers()
self.roiUnpackers += unpackers
self.RoIBRoIUnpackers += unpackers
# MU unpacker
if TriggerFlags.doMuon():
unpackers = createMuonRoIUnpackers()
self.roiUnpackers += unpackers
unpackers = createMuonRoIUnpackers(flags)
if flags.Trigger.enableL1Phase1:
self.xAODRoIUnpackers += unpackers
else:
self.RoIBRoIUnpackers += unpackers
self.prescaler = createPrescalingTool()
self.KeyWriterTool = createKeyWriterTool()
from AthenaConfiguration.AllConfigFlags import ConfigFlags as flags
self.DoCostMonitoring = flags.Trigger.CostMonitoring.doCostMonitoring
self.CostMonitoringChain = flags.Trigger.CostMonitoring.chain
......@@ -174,16 +180,20 @@ def L1DecoderCfg(flags, seqName = None):
from TrigEDMConfig.TriggerEDMRun3 import recordable
decoderAlg.roiUnpackers += [ CompFactory.FSRoIsUnpackingTool("FSRoIsUnpackingTool", Decisions=mapThresholdToL1DecisionCollection("FSNOSEED"),
OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("FSNOSEED")) ) ]
decoderAlg.RoIBRoIUnpackers += [
CompFactory.FSRoIsUnpackingTool("FSRoIsUnpackingTool", Decisions=mapThresholdToL1DecisionCollection("FSNOSEED"),
OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("FSNOSEED")) ) ]
if flags.Trigger.doCalo:
unpackers = createCaloRoIUnpackers()
decoderAlg.roiUnpackers += unpackers
decoderAlg.RoIBRoIUnpackers += unpackers
if flags.Trigger.doMuon:
unpackers = createMuonRoIUnpackers()
decoderAlg.roiUnpackers += unpackers
unpackers = createMuonRoIUnpackers(flags)
if flags.Trigger.enableL1Phase1:
decoderAlg.xAODRoIUnpackers += unpackers
else:
decoderAlg.RoIBRoIUnpackers += unpackers
from MuonConfig.MuonCablingConfig import RPCCablingConfigCfg, TGCCablingConfigCfg
acc.merge( TGCCablingConfigCfg( flags ) )
acc.merge( RPCCablingConfigCfg( flags ) )
......
......@@ -21,6 +21,8 @@ public:
virtual StatusCode initialize() override;
virtual bool isEmulated() const override {return true;}
private:
///@{ @name Properties
......
......@@ -29,6 +29,7 @@ public:
const std::string& name,
const IInterface* parent);
using RoIsUnpackingToolBase::unpack;
StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const override;
......
......@@ -24,6 +24,7 @@ public:
virtual StatusCode initialize() override;
using RoIsUnpackingToolBase::unpack;
StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const override;
......
......@@ -30,13 +30,21 @@ public:
/**
* Unpack RoIB result depending on implementaton (e.g. EM, Jet, ...)
*
* In addition to the implementation specific collection, a collection of decision objects
* is created with each decision tagged by the chain ID it relates to. The mapping of threshold IDs
* and the chains is provided externally at each call (may be refactored later as this is pure config information).
* A collection of decision objects is created in event store with each decision tagged by the chain ID it relates to.
* In addition, an implementation specific "RecRoI" collection is produced.
*/
virtual StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const = 0;
/**
* Unpack specific sub-system RoIs (Muon, eFexEM, gFexJet, ...) linked to L1TriggerResult depending on implementation
*
* A collection of decision objects is created in event store with each decision tagged by the chain ID it relates to.
*/
virtual StatusCode unpack(const EventContext& /*ctx*/,
const xAOD::TrigComposite& /*l1TriggerResult*/,
const HLT::IDSet& /*activeChains*/) const = 0;
};
#endif
......@@ -23,6 +23,7 @@ public:
const std::string& name,
const IInterface* parent );
using RoIsUnpackingToolBase::unpack;
StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const override;
......
......@@ -29,7 +29,8 @@ StatusCode L1Decoder::initialize() {
ATH_CHECK( m_startStampKey.initialize() );
ATH_CHECK( m_ctpUnpacker.retrieve() );
ATH_CHECK( m_roiUnpackers.retrieve() );
ATH_CHECK( m_roiUnpackers_roib.retrieve() );
ATH_CHECK( m_roiUnpackers_xaod.retrieve() );
ATH_CHECK( m_prescaler.retrieve() );
if ( !m_keyWriterTool.empty() ) {
......@@ -53,10 +54,17 @@ void L1Decoder::handle(const Incident& incident) {
if (incident.type()!="BeginRun") return;
ATH_MSG_DEBUG( "In L1Decoder BeginRun incident" );
for ( auto t: m_roiUnpackers )
for ( auto t: m_roiUnpackers_roib ) {
if ( t->updateConfiguration().isFailure() ) {
ATH_MSG_ERROR( "Problem in configuring " << t->name() );
}
}
for ( auto t: m_roiUnpackers_xaod ) {
if ( t->updateConfiguration( ).isFailure() ) {
ATH_MSG_ERROR( "Problem in configuring " << t->name() );
}
}
}
......@@ -71,18 +79,18 @@ StatusCode L1Decoder::execute (const EventContext& ctx) const {
ATH_CHECK( timeStampHandle.record( std::make_unique<TrigTimeStamp>() ) );
}
using namespace TrigCompositeUtils;
const ROIB::RoIBResult dummyResult;
const ROIB::RoIBResult* roib = &dummyResult;
if ( !m_RoIBResultKey.empty() ) {
const bool decodeRoIB = !m_RoIBResultKey.empty();
const bool decodexAOD = !m_l1TriggerResultKey.empty();
const ROIB::RoIBResult* roib = nullptr;
if (decodeRoIB) {
SG::ReadHandle<ROIB::RoIBResult> roibH( m_RoIBResultKey, ctx );
roib = roibH.cptr();
ATH_MSG_DEBUG( "Obtained ROIB result" );
}
// 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);
const xAOD::TrigComposite* l1TriggerResult = nullptr;
if ( !m_l1TriggerResultKey.empty() ) {
if (decodexAOD) {
auto l1TriggerResultCont = SG::makeHandle(m_l1TriggerResultKey, ctx);
if (!l1TriggerResultCont.isValid()) {
ATH_MSG_ERROR("Failed to retrieve L1TriggerResult with key " << m_l1TriggerResultKey.key());
......@@ -94,10 +102,12 @@ StatusCode L1Decoder::execute (const EventContext& ctx) const {
}
l1TriggerResult = l1TriggerResultCont->at(0);
if (msgLvl(MSG::DEBUG)) {
const std::vector<std::string>& links = l1TriggerResult->linkColNames();
ATH_MSG_DEBUG("L1TriggerResult has " << links.size() << " links:");
for (std::string_view linkName : links)
ATH_MSG_DEBUG("--> " << linkName);
const std::vector<std::string>& linkNames = l1TriggerResult->linkColNames();
const std::vector<uint32_t>& linkClids = l1TriggerResult->linkColClids();
ATH_MSG_DEBUG("L1TriggerResult has " << linkNames.size() << " links:");
for (size_t i=0; i<linkNames.size(); ++i) {
ATH_MSG_DEBUG("--> " << linkNames.at(i) << " CLID: " << linkClids.at(i));
}
}
}
......@@ -114,7 +124,11 @@ StatusCode L1Decoder::execute (const EventContext& ctx) const {
*/
HLT::IDVec l1SeededChains;
ATH_CHECK( m_ctpUnpacker->decode( *roib, l1SeededChains ) );
if (decodeRoIB) {
ATH_CHECK( m_ctpUnpacker->decode( *roib, l1SeededChains ) );
} else if (m_ctpUnpacker->isEmulated()) {
ATH_CHECK( m_ctpUnpacker->decode( ROIB::RoIBResult{}, l1SeededChains ) );
}
sort( l1SeededChains.begin(), l1SeededChains.end() ); // do so that following scaling is reproducible
HLT::IDVec activeChains; // Chains which are activated to run in the first pass (seeded and pass prescale)
......@@ -140,8 +154,20 @@ StatusCode L1Decoder::execute (const EventContext& ctx) const {
ATH_MSG_DEBUG( "Unpacking RoIs" );
HLT::IDSet activeChainSet( activeChains.begin(), activeChains.end() );
for ( auto unpacker: m_roiUnpackers ) {
ATH_CHECK( unpacker->unpack( ctx, *roib, activeChainSet ) );
if (decodeRoIB) {
for ( auto unpacker: m_roiUnpackers_roib ) {
ATH_CHECK( unpacker->unpack( ctx, *roib, activeChainSet ) );
}
} else if (m_ctpUnpacker->isEmulated()) {
ROIB::RoIBResult roib{};
for ( auto unpacker: m_roiUnpackers_roib ) {
ATH_CHECK( unpacker->unpack( ctx, roib, activeChainSet ) );
}
}
if (decodexAOD) {
for ( auto unpacker: m_roiUnpackers_xaod ) {
ATH_CHECK( unpacker->unpack( ctx, *l1TriggerResult, activeChainSet ) );
}
}
if ( !m_keyWriterTool.empty() ) {
......
......@@ -80,9 +80,13 @@ private:
this, "ctpUnpacker", "CTPUnpackingTool/CTPUnpackingTool",
"Tool used to unpack the CTP info"};
ToolHandleArray<IRoIsUnpackingTool> m_roiUnpackers{
this, "roiUnpackers", {},
"Tools unpacking RoIs"};
ToolHandleArray<IRoIsUnpackingTool> m_roiUnpackers_roib{
this, "RoIBRoIUnpackers", {},
"Tools unpacking Run-2 RoIs from RoIBResult"};
ToolHandleArray<IRoIsUnpackingTool> m_roiUnpackers_xaod{
this, "xAODRoIUnpackers", {},
"Tools unpacking xAOD RoIs from L1TriggerResult"};
ToolHandle<IPrescalingTool> m_prescaler{
this, "prescaler", "PrescalingTool/PrescalingTool",
......
......@@ -56,7 +56,10 @@ StatusCode L1TriggerResultMaker::execute(const EventContext& eventContext) const
ATH_CHECK(muRoIHandle.isValid());
// Link the L1 xAOD containers (actually their first elements) to L1TriggerResult
makeLink(m_muRoIKey, *(l1trHandle->back()), m_muRoILinkName.value(), eventContext);
ATH_MSG_DEBUG(m_muRoIKey.key() << " size: " << muRoIHandle->size());
if (not muRoIHandle->empty()) {
makeLink(m_muRoIKey, *(l1trHandle->back()), m_muRoIKey.key(), eventContext);
}
return StatusCode::SUCCESS;
}
......@@ -37,10 +37,6 @@ private:
this, "MuRoIKey", "LVL1MuonRoIs",
"Key of the muon RoI container to be linked to L1 Trigger Result"};
Gaudi::Property<std::string> m_muRoILinkName {
this, "MuRoILinkName", "mu_roi",
"Name of the link to be created from L1 Trigger Result to muon RoI container"};
// Placeholder for other L1 xAOD outputs:
// - CTP result
// - L1Topo result
......
......@@ -24,6 +24,7 @@ public:
virtual StatusCode initialize() override;
using RoIsUnpackingToolBase::unpack;
StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const override;
......
......@@ -3,8 +3,10 @@
*/
#include "MURoIsUnpackingTool.h"
#include "TrigT1Result/RoIBResult.h"
#include "xAODTrigger/MuonRoIContainer.h"
#include "AthenaMonitoringKernel/Monitored.h"
#include "TrigConfL1Data/CTPConfig.h"
#include "TrigCompositeUtils/TrigCompositeUtils.h"
///////////////////////////////////////////////////////////////////
// Public methods:
......@@ -26,7 +28,7 @@ StatusCode MURoIsUnpackingTool::initialize() {
CHECK( RoIsUnpackingToolBase::initialize() );
CHECK( m_configSvc.retrieve() );
CHECK( m_trigRoIsKey.initialize() );
CHECK( m_recRoIsKey.initialize() );
CHECK( m_recRoIsKey.initialize(SG::AllowEmpty) );
CHECK( m_recRpcRoITool.retrieve() );
CHECK( m_recTgcRoITool.retrieve() );
......@@ -111,4 +113,51 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx,
}
StatusCode MURoIsUnpackingTool::unpack(const EventContext& ctx,
const xAOD::TrigComposite& l1TriggerResult,
const HLT::IDSet& activeChains) const {
// Retrieve the xAOD RoI container from L1TriggerResult
if (!l1TriggerResult.hasObjectLink(m_muRoILinkName, ClassID_traits<xAOD::MuonRoIContainer>::ID())) {
ATH_MSG_DEBUG("No muon RoIs in this event");
return StatusCode::SUCCESS;
}
ElementLink<xAOD::MuonRoIContainer> roisLink = l1TriggerResult.objectLink<xAOD::MuonRoIContainer>(m_muRoILinkName);
ATH_CHECK(roisLink.isValid());
const xAOD::MuonRoIContainer& rois = roisLink.getStorableObjectRef();
// Create and record RoI descriptor and decision containers
using namespace TrigCompositeUtils;
SG::WriteHandle<TrigRoiDescriptorCollection> roiDescriptors = createAndStoreNoAux(m_trigRoIsKey, ctx);
SG::WriteHandle<DecisionContainer> decisions = createAndStore(m_decisionsKey, ctx);
size_t linkIndex{0};
for (const xAOD::MuonRoI* roi : rois) {
// Create new RoI descriptor
roiDescriptors->push_back(std::make_unique<TrigRoiDescriptor>(
roi->eta(), roi->eta()-m_roIWidth, roi->eta()+m_roIWidth,
roi->phi(), roi->phi()-m_roIWidth, roi->phi()+m_roIWidth
));
// Create new decision and link the RoI objects
Decision* decision = TrigCompositeUtils::newDecisionIn(decisions.ptr(), l1DecoderNodeName());
decision->setObjectLink(initialRoIString(),
ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), linkIndex, ctx));
decision->setObjectLink(initialRecRoIString(),
ElementLink<xAOD::MuonRoIContainer>(m_muRoILinkName, linkIndex, ctx));
++linkIndex;
// Add positive decisions for chains above the threshold
for (const TrigConf::TriggerThreshold* thr : m_muonThresholds) {
if (thr->thresholdNumber() < roi->getThrNumber()) {
ATH_MSG_DEBUG("Threshold passed: " << thr->name());
addChainsToDecision(HLT::Identifier(thr->name()), decision, activeChains);
if (msgLvl(MSG::DEBUG)) {
DecisionIDContainer ids;
decisionIDs(decision, ids);
ATH_MSG_DEBUG("Activated chains: " << std::vector<DecisionID>(ids.begin(), ids.end()));
}
}
}
}
return StatusCode::SUCCESS;
}
......@@ -37,6 +37,9 @@ class MURoIsUnpackingTool : public RoIsUnpackingToolBase
virtual StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const override;
virtual StatusCode unpack(const EventContext& ctx,
const xAOD::TrigComposite& l1TriggerResult,
const HLT::IDSet& activeChains) const override;
virtual StatusCode start() override;
private:
......@@ -49,6 +52,10 @@ private:
this, "OutputRecRoIs", "HLT_RecMURoIs",
"Name of the RoIs object produced by the unpacker"};
Gaudi::Property<std::string> m_muRoILinkName {
this, "MuRoILinkName", "LVL1MuonRoIs",
"Name of the link to read from L1TriggerResult for muon RoI container"};
Gaudi::Property<float> m_roIWidth{
this, "RoIWidth", 0.1, "Size of RoI in eta/ phi"};
///@}
......
......@@ -35,6 +35,7 @@ class RerunRoIsUnpackingTool : public RoIsUnpackingToolBase
virtual StatusCode finalize() override;
virtual StatusCode updateConfiguration() override;
using RoIsUnpackingToolBase::unpack;
StatusCode unpack( const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains ) const override;
......
......@@ -24,6 +24,7 @@ class RoIsUnpackingEmulationTool : public RoIsUnpackingToolBase {
const std::string& name,
const IInterface* parent );
using RoIsUnpackingToolBase::unpack;
virtual StatusCode unpack(const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains) const override;
......
......@@ -13,6 +13,7 @@
#include "TrigConfL1Data/TriggerThreshold.h"
#include "TrigConfL1Data/Menu.h"
#include "TrigConfData/HLTMenu.h"
#include "xAODTrigger/TrigComposite.h"
namespace ROIB {
class RoIBResult;
......@@ -42,6 +43,10 @@ public:
const ROIB::RoIBResult& /*roib*/,
const HLT::IDSet& /*activeChains*/) const override { return StatusCode::SUCCESS; }
virtual StatusCode unpack(const EventContext& /*ctx*/,
const xAOD::TrigComposite& /*l1TriggerResult*/,
const HLT::IDSet& /*activeChains*/) const override { return StatusCode::SUCCESS; }
protected:
......
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