From 1a12ee3a8d6d24cdc6630ce858304f9f34f84d93 Mon Sep 17 00:00:00 2001 From: Tomasz Bold <tomasz.bold@gmail.com> Date: Mon, 19 Jun 2017 23:26:04 +0200 Subject: [PATCH] Added RoIs monitoring --- .../L1Decoder/python/L1DecoderMonitoring.py | 29 ++++++++--- Trigger/TrigSteer/L1Decoder/share/decodeBS.py | 2 + .../L1Decoder/src/EMRoIsUnpackingTool.cxx | 49 ++++++++++++------- .../L1Decoder/src/EMRoIsUnpackingTool.h | 2 + .../L1Decoder/src/IRoIsUnpackingTool.cxx | 1 - .../L1Decoder/src/IRoIsUnpackingTool.h | 5 +- .../L1Decoder/src/MURoIsUnpackingTool.cxx | 38 +++++++++----- .../L1Decoder/src/MURoIsUnpackingTool.h | 3 +- 8 files changed, 87 insertions(+), 42 deletions(-) diff --git a/Trigger/TrigSteer/L1Decoder/python/L1DecoderMonitoring.py b/Trigger/TrigSteer/L1Decoder/python/L1DecoderMonitoring.py index b262ca91a19..48e5d23e4e4 100644 --- a/Trigger/TrigSteer/L1Decoder/python/L1DecoderMonitoring.py +++ b/Trigger/TrigSteer/L1Decoder/python/L1DecoderMonitoring.py @@ -1,12 +1,27 @@ from AthenaMonitoring.AthenaMonitoringConf import GenericMonitoringTool from AthenaMonitoring.DefineHistogram import defineHistogram +import math - -def CTPUnpackingMonitoring(maxItems, maxChains): - tool = GenericMonitoringTool('CTPUnpackingMonitoring') +def CTPUnpackingMonitoring( maxItems, maxChains ): + tool = GenericMonitoringTool( 'CTPUnpackingMonitoring' ) tool.HistogramsGroupName="L1Decoder"; - tool.Histograms = [defineHistogram('TAVItems', path='EXPERT', type='TH1F', title='Number of active L1 TAV items;N Items;N Events', - xbins=maxItems, xmin=0, xmax=maxItems), - defineHistogram('Chains', path='EXPERT', type='TH1F', title='Number of activated Chains;N Chains;N Events', - xbins=maxChains, xmin=0, xmax=maxChains) ] + tool.Histograms = [defineHistogram( 'TAVItems', path='EXPERT', type='TH1F', title='Number of active L1 TAV items;N Items;N Events', + xbins=maxItems, xmin=0, xmax=maxItems ), + defineHistogram( 'Chains', path='EXPERT', type='TH1F', title='Number of activated Chains;N Chains;N Events', + xbins=maxChains, xmin=0, xmax=maxChains ) ] + return tool + + +def RoIsUnpackingMonitoring( prefix, maxCount, maxEta=3. ): + tool = GenericMonitoringTool( prefix+'RoIsUnpackingMonitoring' ) + tool.HistogramsGroupName="L1Decoder/RoIs"+prefix; + tool.Histograms = [ defineHistogram( 'count', path='EXPERT', type='TH1F', title='Number of RoIs;N RoIs;N Events', + xbins=maxCount, xmin=0, xmax=maxCount ), + defineHistogram( 'eta', path='EXPERT', type='TH1F', title='Eta distribution;eta;N RoIs', + xbins=60, xmin=-maxEta, xmax=maxEta ), + defineHistogram( 'phi', path='EXPERT', type='TH1F', title='Phi distribution;phi;N RoIs', + xbins=64, xmin=-math.pi, xmax=math.pi ), + defineHistogram( 'eta, phi', path='EXPERT', type='TH2F', title='RoIs map;eta;phi', + xbins=30, xmin=-maxEta, xmax=maxEta, + ybins=32, ymin=-math.pi, ymax=math.pi ) ] return tool diff --git a/Trigger/TrigSteer/L1Decoder/share/decodeBS.py b/Trigger/TrigSteer/L1Decoder/share/decodeBS.py index 8ebd64b2d90..0c142ec77cd 100755 --- a/Trigger/TrigSteer/L1Decoder/share/decodeBS.py +++ b/Trigger/TrigSteer/L1Decoder/share/decodeBS.py @@ -101,9 +101,11 @@ l1Decoder.ctpUnpacker.CTPToChainMapping = ["0:HLT_e3", "0:HLT_g5", "1:HLT_e7", emUnpacker = EMRoIsUnpackingTool( OutputLevel=DEBUG ) emUnpacker.ThresholdToChainMapping = ["EM3 : HLT_e3", "EM3 : HLT_g5", "EM7 : HLT_e7", "EM15 : HLT_e15mu4" ] +emUnpacker.MonTool = RoIsUnpackingMonitoring( prefix="EM", maxCount=30 ) muUnpacker = MURoIsUnpackingTool( OutputLevel=DEBUG ) muUnpacker.ThresholdToChainMapping = ["MU6 : HLT_mu6", "MU6 : HLT_mu6idperf", "MU4 : HLT_e15mu4"] +muUnpacker.MonTool = RoIsUnpackingMonitoring( prefix="MU", maxCount=20 ) # do not know yet how to configure the services for it l1Decoder.roiUnpackers = [emUnpacker] diff --git a/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx index 0f2546bfebe..deda05bb9f3 100644 --- a/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.cxx @@ -17,13 +17,15 @@ EMRoIsUnpackingTool::EMRoIsUnpackingTool( const std::string& type, const std::string& name, const IInterface* parent ) : AthAlgTool ( type, name, parent ), - m_configSvc( "TrigConf::LVL1ConfigSvc/LVL1ConfigSvc", name ) { + m_configSvc( "TrigConf::LVL1ConfigSvc/LVL1ConfigSvc", name ), + m_monTool( "GenericMonitoringTool/MonTool", this ) { declareProperty( "Decisions", m_decisionsKey="EMRoIDecisions", "Decisions for each RoI" ); - declareProperty( "ThresholdToChainMapping", m_thresholdToChainProperty, "Mapping from the threshold name to chain in the form: 'EM3 : HLT_e5', 'EM3 : HLT_e5tight', ..., (note spaces)" ); + declareProperty( "ThresholdToChainMapping", m_thresholdToChainProperty, "Mapping from the threshold name to chain in the form: 'EM3 : HLT_e5', 'EM3 : HLT_e5tight', ..., ( note spaces )" ); declareProperty( "OutputTrigRoIs", m_trigRoIsKey="EMRoIs", "Name of the RoIs object produced by the unpacker" ); declareProperty( "OutputRecRoIs", m_recRoIsKey="RecEMRoIs", "Name of the RoIs object produced by the unpacker" ); declareProperty( "RoIWidth", m_roIWidth = 0.1, "Size of RoI in eta/ phi" ); + declareProperty( "MonTool", m_monTool=ToolHandle<GenericMonitoringTool>( "", this ), "Monitoring tool" ); } @@ -36,8 +38,10 @@ StatusCode EMRoIsUnpackingTool::initialize() { CHECK( m_decisionsKey.initialize() ); CHECK( m_trigRoIsKey.initialize() ); CHECK( m_recRoIsKey.initialize() ); + if ( not m_monTool.name().empty() ) + CHECK( m_monTool.retrieve() ); - if (decodeMapping().isFailure() ) { + if ( decodeMapping().isFailure() ) { ATH_MSG_ERROR( "Failed to decode threshold to chains mapping, is the format th : chain?" ); return StatusCode::FAILURE; } @@ -50,10 +54,10 @@ StatusCode EMRoIsUnpackingTool::updateConfiguration() { const ThresholdConfig* thresholdConfig = m_configSvc->thresholdConfig(); auto filteredThresholds= thresholdConfig->getThresholdVector( L1DataDef::EM ); ATH_MSG_DEBUG( "Number of filtered thresholds " << filteredThresholds.size() ); - for (auto th : filteredThresholds ) { + for ( auto th : filteredThresholds ) { if ( th != nullptr ) { - ATH_MSG_DEBUG( "Found threshold in the configuration: " << th->name() << " of ID: " << HLT::Identifier(th->name()).numeric() ); - m_emThresholds.push_back(th); + ATH_MSG_DEBUG( "Found threshold in the configuration: " << th->name() << " of ID: " << HLT::Identifier( th->name() ).numeric() ); + m_emThresholds.push_back( th ); } else { ATH_MSG_DEBUG( "Nullptr to the threshold" ); } @@ -74,10 +78,11 @@ StatusCode EMRoIsUnpackingTool::unpack( const EventContext& ctx, using namespace TrigCompositeUtils; auto decisionOutput = std::make_unique<DecisionContainer>(); auto decisionAux = std::make_unique<DecisionAuxContainer>(); - decisionOutput->setStore(decisionAux.get()); + decisionOutput->setStore( decisionAux.get() ); auto trigRoIs = std::make_unique< TrigRoiDescriptorCollection >(); auto recRoIs = std::make_unique< DataVector<LVL1::RecEmTauRoI> >(); + // RoIBResult contains vector of EM fragments for ( auto& emTauFragment : roib.eMTauResult() ) { for ( auto& roi : emTauFragment.roIVec() ) { @@ -95,38 +100,46 @@ StatusCode EMRoIsUnpackingTool::unpack( const EventContext& ctx, 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 ); + ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw( 8 ) << roIWord << MSG::dec ); auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.get() ); for ( auto th: m_emThresholds ) { ATH_MSG_VERBOSE( "Checking if the threshold " << th->name() << " passed" ); if ( recRoI->passedThreshold( th->thresholdNumber() ) ) { - ATH_MSG_DEBUG("Passed Threshold name " << th->name()); + ATH_MSG_DEBUG( "Passed Threshold name " << th->name() ); addChainsToDecision( HLT::Identifier( th->name() ), decision, activeChains ); } } - // 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::RecEmTauRoI>>(m_recRoIsKey.key(), recRoIs->size()-1) ); + // 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::RecEmTauRoI>>( m_recRoIsKey.key(), recRoIs->size()-1 ) ); } } for ( auto roi: *trigRoIs ) { - ATH_MSG_DEBUG("RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord()); + ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() ); + } + // monitoring + { + using namespace Monitored; + auto RoIsCount = MonitoredScalar::declare( "count", trigRoIs->size() ); + auto RoIsPhi = MonitoredCollection::declare( "phi", *trigRoIs.get(), &TrigRoiDescriptor::phi ); + auto RoIsEta = MonitoredCollection::declare( "eta", *trigRoIs.get(), &TrigRoiDescriptor::eta ); + auto monitorit = MonitoredScope::declare( m_monTool, RoIsCount, RoIsEta, RoIsPhi ); } // recording { - SG::WriteHandle<TrigRoiDescriptorCollection> handle(m_trigRoIsKey, ctx); - CHECK( handle.record (std::move(trigRoIs)) ); + SG::WriteHandle<TrigRoiDescriptorCollection> handle( m_trigRoIsKey, ctx ); + CHECK( handle.record ( std::move( trigRoIs ) ) ); } { - SG::WriteHandle<DataVector<LVL1::RecEmTauRoI>> handle(m_recRoIsKey, ctx); - CHECK( handle.record( std::move(recRoIs)) ); + SG::WriteHandle<DataVector<LVL1::RecEmTauRoI>> handle( m_recRoIsKey, ctx ); + CHECK( handle.record( std::move( recRoIs ) ) ); } { - auto handle = SG::makeHandle(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/EMRoIsUnpackingTool.h b/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.h index cfd48eff417..e07af275f1a 100644 --- a/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.h +++ b/Trigger/TrigSteer/L1Decoder/src/EMRoIsUnpackingTool.h @@ -12,6 +12,7 @@ #include "TrigConfL1Data/TriggerThreshold.h" #include "TrigT1Interfaces/RecEmTauRoI.h" #include "TrigSteeringEvent/TrigRoiDescriptorCollection.h" +#include "AthenaMonitoring/GenericMonitoringTool.h" // FrameWork includes #include "AthenaBaseComps/AthAlgTool.h" @@ -47,6 +48,7 @@ class EMRoIsUnpackingTool : virtual public AthAlgTool, virtual public IRoIsUnpac SG::WriteHandleKey< DataVector<LVL1::RecEmTauRoI> > m_recRoIsKey; ServiceHandle<TrigConf::ILVL1ConfigSvc> m_configSvc; float m_roIWidth; + ToolHandle<GenericMonitoringTool> m_monTool; }; #endif //> !L1DECODER_EMROISUNPACKINGTOOL_H diff --git a/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.cxx index 5b4749c3100..14a38c9e913 100644 --- a/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.cxx @@ -7,7 +7,6 @@ #include "IRoIsUnpackingTool.h" - IRoIsUnpackingTool::~IRoIsUnpackingTool() {} diff --git a/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.h b/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.h index c561ac43e9e..c15a9dc9b51 100644 --- a/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.h +++ b/Trigger/TrigSteer/L1Decoder/src/IRoIsUnpackingTool.h @@ -9,11 +9,11 @@ #include "DecisionHandling/TrigCompositeUtils.h" #include "DecisionHandling/HLTIdentifier.h" + namespace ROIB { class RoIBResult; } - static const InterfaceID IID_IRoIsUnpackingTool("IRoIsUnpackingTool", 1, 0); class IRoIsUnpackingTool @@ -21,6 +21,8 @@ class IRoIsUnpackingTool { public: + + /** Destructor: */ virtual ~IRoIsUnpackingTool(); @@ -52,7 +54,6 @@ protected: std::vector<std::string> m_thresholdToChainProperty; std::map<HLT::Identifier, HLT::IDVec> m_thresholdToChainMapping; - // ToolHandle<GenericMonitoringTool> m_monTool; StatusCode decodeMapping(); void addChainsToDecision( HLT::Identifier thresholdId, diff --git a/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx index 70b364b1094..75b16098f6a 100644 --- a/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.cxx @@ -19,13 +19,15 @@ MURoIsUnpackingTool::MURoIsUnpackingTool( const std::string& type, : AthAlgTool ( type, name, parent ), m_configSvc( "TrigConf::LVL1ConfigSvc/LVL1ConfigSvc", name ), m_recRpcRoISvc( "LVL1RPC::RPCRecRoiSvc/RPCRecRoiSvc", name ), - m_recTgcRoISvc( "LVL1TGC::TGCRecRoiSvc/TGCRecRoiSvc", name ) { + m_recTgcRoISvc( "LVL1TGC::TGCRecRoiSvc/TGCRecRoiSvc", name ), + m_monTool( "GenericMonitoringTool/MonTool", this ) { declareProperty( "Decisions", m_decisionsKey="MURoIDecisions", "Decisions for each RoI" ); declareProperty( "ThresholdToChainMapping", m_thresholdToChainProperty, "Mapping from the threshold name to chain in the form: 'EM3:HLT_e5', 'EM3:HLT_e5tight', ..." ); declareProperty( "OutputTrigRoIs", m_trigRoIsKey="MURoIs", "Name of the RoIs object produced by the unpacker" ); declareProperty( "OutputRecRoIs", m_recRoIsKey ="RecMURoIs", "Name of the RoIs object produced by the unpacker" ); declareProperty( "RoIWidth", m_roIWidth = 0.1, "Size of RoI in eta/ phi" ); + declareProperty( "MonTool", m_monTool=ToolHandle<GenericMonitoringTool>( "", this ), "Monitoring tool" ); } // Destructor @@ -41,7 +43,10 @@ StatusCode MURoIsUnpackingTool::initialize() { CHECK( m_recRoIsKey.initialize() ); CHECK( m_recRpcRoISvc.retrieve() ); CHECK( m_recTgcRoISvc.retrieve() ); - if (decodeMapping().isFailure() ) { + if ( not m_monTool.name().empty() ) + CHECK( m_monTool.retrieve() ); + + if ( decodeMapping().isFailure() ) { ATH_MSG_ERROR( "Failed to decode threshold to chains mapping, is the format th : chain?" ); return StatusCode::FAILURE; } @@ -51,10 +56,10 @@ StatusCode MURoIsUnpackingTool::initialize() { StatusCode MURoIsUnpackingTool::updateConfiguration() { using namespace TrigConf; const ThresholdConfig* thresholdConfig = m_configSvc->thresholdConfig(); - for (TriggerThreshold * th : thresholdConfig->getThresholdVector( L1DataDef::MUON ) ) { + for ( TriggerThreshold * th : thresholdConfig->getThresholdVector( L1DataDef::MUON ) ) { if ( th != nullptr ) { - ATH_MSG_DEBUG( "Found threshold in the configuration: " << th->name() << " of ID: " << HLT::Identifier(th->name()).numeric() ); - m_muonThresholds.push_back(th); + ATH_MSG_DEBUG( "Found threshold in the configuration: " << th->name() << " of ID: " << HLT::Identifier( th->name() ).numeric() ); + m_muonThresholds.push_back( th ); } } return StatusCode::SUCCESS; @@ -70,7 +75,7 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx, using namespace TrigCompositeUtils; auto decisionOutput = std::make_unique<DecisionContainer>(); auto decisionAux = std::make_unique<DecisionAuxContainer>(); - decisionOutput->setStore(decisionAux.get()); + decisionOutput->setStore( decisionAux.get() ); auto trigRoIs = std::make_unique< TrigRoiDescriptorCollection >(); auto recRoIs = std::make_unique< DataVector<LVL1::RecMuonRoI> >(); @@ -83,14 +88,14 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx, << thresholdNumber << ", force setting it to 1" ); thresholdNumber = 1; } - LVL1::RecMuonRoI* recRoI = new LVL1::RecMuonRoI(roIWord, m_recRpcRoISvc.get(), m_recTgcRoISvc.get(), &m_muonThresholds); - recRoIs->push_back(recRoI); + LVL1::RecMuonRoI* recRoI = new LVL1::RecMuonRoI( roIWord, m_recRpcRoISvc.get(), m_recTgcRoISvc.get(), &m_muonThresholds ); + recRoIs->push_back( recRoI ); 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 << ", threshold pattern "); + ATH_MSG_DEBUG( "RoI word: 0x" << MSG::hex << std::setw( 8 ) << roIWord << ", threshold pattern " ); auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.get() ); @@ -101,19 +106,26 @@ StatusCode MURoIsUnpackingTool::unpack( const EventContext& ctx, } } } - + // monitoring + { + using namespace Monitored; + auto RoIsCount = MonitoredScalar::declare( "count", trigRoIs->size() ); + auto RoIsPhi = MonitoredCollection::declare( "phi", *trigRoIs.get(), &TrigRoiDescriptor::phi ); + auto RoIsEta = MonitoredCollection::declare( "eta", *trigRoIs.get(), &TrigRoiDescriptor::eta ); + auto monitorit = MonitoredScope::declare( m_monTool, RoIsCount, RoIsEta, RoIsPhi ); + } // recording { auto handle = SG::makeHandle( m_trigRoIsKey, ctx ); - CHECK( handle.record( std::move(trigRoIs) ) ); + CHECK( handle.record( std::move( trigRoIs ) ) ); } { auto handle = SG::makeHandle( m_recRoIsKey, ctx ); - CHECK( handle.record( std::move(recRoIs) ) ); + CHECK( handle.record( std::move( recRoIs ) ) ); } { auto handle = SG::makeHandle( m_decisionsKey, ctx ); - CHECK( handle.record( std::move(decisionOutput) ) ); + CHECK( handle.record( std::move( decisionOutput ) ) ); } return StatusCode::SUCCESS; } diff --git a/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.h b/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.h index 7ee84dbdf37..c7c18fa0db5 100644 --- a/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.h +++ b/Trigger/TrigSteer/L1Decoder/src/MURoIsUnpackingTool.h @@ -18,7 +18,7 @@ #include "GaudiKernel/ServiceHandle.h" #include "TrigT1Interfaces/RecMuonRoI.h" #include "TrigT1Interfaces/RecMuonRoiSvc.h" - +#include "AthenaMonitoring/GenericMonitoringTool.h" #include "IRoIsUnpackingTool.h" @@ -62,6 +62,7 @@ private: ServiceHandle<LVL1::RecMuonRoiSvc> m_recRpcRoISvc; ServiceHandle<LVL1::RecMuonRoiSvc> m_recTgcRoISvc; float m_roIWidth; + ToolHandle<GenericMonitoringTool> m_monTool; }; // I/O operators -- GitLab