diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/TrigMissingETHypo/ITrigMissingETHypoToolMT.h b/Trigger/TrigHypothesis/TrigMissingETHypo/TrigMissingETHypo/ITrigMissingETHypoToolMT.h new file mode 100644 index 0000000000000000000000000000000000000000..7e3b013e84c1c171cb90b36f790644811983b329 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/TrigMissingETHypo/ITrigMissingETHypoToolMT.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGMISSINGET_ITRIGMISSINGETHYPOTOOLMT_H +#define TRIGMISSINGET_ITRIGMISSINGETHYPOTOOLMT_H + +#include "AsgTools/IAsgTool.h" +#include "xAODTrigMissingET/TrigMissingETContainer.h" +#include "DecisionHandling/TrigCompositeUtils.h" +#include "DecisionHandling/HLTIdentifier.h" + + +using TrigCompositeUtils::DecisionID; + + +class ITrigMissingETHypoToolMT : virtual public::IAlgTool { + +public: + DeclareInterfaceID(ITrigMissingETHypoToolMT, 1, 0); + + + virtual ~ITrigMissingETHypoToolMT(){}; + virtual StatusCode decide(const xAOD::TrigMissingETContainer*, bool&) const = 0; + virtual const HLT::Identifier& getId() const = 0; + + +}; +#endif diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py b/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py new file mode 100644 index 0000000000000000000000000000000000000000..33e571e014873f329c6c9b4062d328309071d87c --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py @@ -0,0 +1,59 @@ +# Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration + +from TrigMissingETHypo.TrigMissingETHypoConf import TrigMissingETHypoAlgMT, TrigMissingETHypoToolMT + +from AthenaCommon.SystemOfUnits import GeV + + +class MissingETHypoAlgMT(TrigMissingETHypoAlgMT): + __slots__ = [] + def __init__(self, name, hTools=[], metKey=""): + super( MissingETHypoAlgMT, self ).__init__( name ) + + if len(hTools)!=0: + self.HypoTools = hTools + if metKey!="": + self.METContainerKey = metKey + + # Monitoring code copied from old hypo config file. + # Kept here in case it may be useful during development + # Will be removed/re-implemented soon. + ''' + from TrigMissingETHypo.TrigMissingETHypoMonitoring import TrigEFMissingETHypoValidationMonitoring, TrigEFMissingETHypoCosmicMonitoring + validation = TrigEFMissingETHypoValidationMonitoring() + cosmic = TrigEFMissingETHypoCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("METHypo_Time") + time.TimerHistLimits = [0, 5] + + self.AthenaMonTools = [ time, validation, cosmic ] + ''' + + def onlineMonitoring(self): + from TrigMissingETHypo.TrigMissingETHypoMonitoringTool import TrigMissingETHypoMonitoringTool + self.MonTool = TrigMissingETHypoMonitoringTool() + +class MissingETHypoToolMT(TrigMissingETHypoToolMT): + __slots__ = [] + def __init__(self, name, **kwargs): + super( MissingETHypoToolMT, self ).__init__( name ) + + # Configure threshold from trigger name + if 'alg' in kwargs: + trigParts = name.split('_') + alg = kwargs['alg'] + if alg=='cell': + alg = trigParts[-1] + idx = trigParts.index(alg) + self.metThreshold = int(filter(str.isdigit, trigParts[idx-1])) + + +def TrigMETCellHypoToolFromName(name, conf): + return MissingETHypoToolMT(name, alg='cell') + +def TrigMETPufitHypoToolFromName(name, conf): + return MissingETHypoToolMT(name, alg='pufit') + +def TrigMETMhtHypoToolFromName(name, conf): + return MissingETHypoToolMT(name, alg='mht') diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoMonitoringTool.py b/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoMonitoringTool.py new file mode 100644 index 0000000000000000000000000000000000000000..3eaa9a96534b458b334a8e13640807d08f79e19b --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoMonitoringTool.py @@ -0,0 +1,37 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram + + +class TrigMissingETHypoMonitoringToolBase(GenericMonitoringTool): + def __init__ (self, name="TrigMissingETHypoMonitoringToolBase"): + super(TrigMissingETHypoMonitoringToolBase, self).__init__(name) + + self.Histograms = [] + + hEx_log = defineHistogram('Hypo_MEx_log', type='TH1F', title="Missing E_{x};sgn(ME_{x}) log_{10}(ME_{x}/GeV)", xbins=41, xmin=-5.075, xmax=5.075) + hEy_log = defineHistogram('Hypo_MEy_log', type='TH1F', title="Missing E_{y};sgn(ME_{y}) log_{10}(ME_{y}/GeV)", xbins=41, xmin=-5.075, xmax=5.075) + hEz_log = defineHistogram('Hypo_MEz_log', type='TH1F', title="Missing E_{z};sgn(ME_{z}) log_{10}(ME_{z}/GeV)", xbins=41, xmin=-5.075, xmax=5.075) + hMET_log = defineHistogram('Hypo_MET_log', type='TH1F', title="|Missing E_{T}|;log_{10}(ME_{T}/GeV)", xbins=35, xmin=-1.875, xmax=5.375) + hSumEt_log = defineHistogram('Hypo_SumEt_log', type='TH1F', title="Sum |E_{T}|;log_{10}(SumE_{T}/GeV)", xbins=35, xmin=-1.875, xmax=5.125) + + hEx_lin = defineHistogram('Hypo_MEx_lin', type='TH1F', title="Missing E_{x};ME_{x} (GeV)", xbins=199, xmin=-298.5, xmax=298.5) + hEy_lin = defineHistogram('Hypo_MEy_lin', type='TH1F', title="Missing E_{y};ME_{y} (GeV)", xbins=199, xmin=-298.5, xmax=298.5) + hEz_lin = defineHistogram('Hypo_MEz_lin', type='TH1F', title="Missing E_{z};ME_{z} (GeV)", xbins=199, xmin=-298.5, xmax=298.5) + hMET_lin = defineHistogram('Hypo_MET_lin', type='TH1F', title="|Missing E_{T}|;ME_{T} (GeV)", xbins=105, xmin=-13.5, xmax=301.5) + hSumEt_lin = defineHistogram('Hypo_SumEt_lin', type='TH1F', title="Sum |E_{T}|;SumE_{T} (GeV)", xbins=155, xmin=-27., xmax=2000.) + + hMETPhi = defineHistogram('Hypo_MET_phi', type='TH1F', title="MET #phi;#phi (rad)", xbins=32, xmin=-3.1416, xmax=3.1416) + hXS = defineHistogram('Hypo_XS', type='TH1F', title="EF Significance; (XS/GeV^{1/2})", xbins=40, xmin=-0.025, xmax=20.025) + hXS2 = defineHistogram('Hypo_XS2', type='TH1F', title="EF Significance 2; (XS2/GeV^{1/2})", xbins=40, xmin=-0.025, xmax=20.025) + + +class TrigMissingETHypoMonitoringTool(TrigMissingETHypoMonitoringToolBase): + def __init__ (self, name="TrigMissingETHypoMonitoringTool"): + super(TrigMissingETHypoMonitoringTool, self).__init__(name) + self.defineTarget("Validation") + + # self.Histograms = [ hCuts ] + self.Histograms += [ hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log ] + self.Histograms += [ hEx_lin, hEy_lin, hEz_lin, hMET_lin, hSumEt_lin, hMETPhi, hXS, hXS2 ] + diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoAlgMT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a55046ab9138bcd5973541281c9835149446bcfa --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoAlgMT.cxx @@ -0,0 +1,174 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ +#include "TrigMissingETHypoAlgMT.h" + +#include "GaudiKernel/Property.h" +#include "DecisionHandling/HLTIdentifier.h" +#include "DecisionHandling/TrigCompositeUtils.h" +#include "AthenaMonitoring/MonitoredScope.h" + + +using namespace TrigCompositeUtils; + +using xAOD::TrigMissingETContainer; + +//!< Converts from MeV to GeV and them log10, preserving the sign, the minimum dictated by monitoring histograms +float TrigMissingETHypoAlgMT::toLogGeV( const float& x, const float& fallback = 0, const float& epsilon = 1.189 ) { + const float absXGeV = std::fabs( x * 1.e-3 ); + if ( absXGeV < epsilon ) + return fallback; + return std::copysign( std::log10( absXGeV ), x ); +} + +//!< converts to from MeV to GeV if above threshold, else falback value +float TrigMissingETHypoAlgMT::toLinGeV( const float& x, const float& fallback = 0, const float& epsilon = 1e-6 ) { + const float xGeV = x * 1.e-3; + if ( xGeV < epsilon ) + return fallback; + return xGeV; +} + + +TrigMissingETHypoAlgMT::TrigMissingETHypoAlgMT( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::HypoBase( name, pSvcLocator ) {} + +TrigMissingETHypoAlgMT::~TrigMissingETHypoAlgMT() {} + +StatusCode TrigMissingETHypoAlgMT::finalize() { + return StatusCode::SUCCESS; +} + + +StatusCode TrigMissingETHypoAlgMT::initialize() { + ATH_MSG_INFO ( "Initializing " << name() << "..." ); + + CHECK( m_hypoTools.retrieve() ); + CHECK( m_metKey.initialize() ); + return StatusCode::SUCCESS; +} + +StatusCode TrigMissingETHypoAlgMT::execute( const EventContext& context ) const { + ATH_MSG_DEBUG ( "Executing " << name() << "..." ); + + // read in the met container + auto h_met = SG::makeHandle(m_metKey, context ); + ATH_MSG_DEBUG("Retrieving MET from: " << h_met.key()); + ATH_CHECK(h_met.isValid()); + const TrigMissingETContainer* metContainer = h_met.get(); + + ATH_MSG_DEBUG("The MET value is " << round(std::hypot((*metContainer)[0]->ex(), (*metContainer)[0]->ey())/1000.0 )); + + // read in the previous Decisions made before running this hypo Alg. + auto h_prevDecisions = SG::makeHandle(decisionInput(), context ); + if( not h_prevDecisions.isValid() ) {//implicit + ATH_MSG_DEBUG( "No implicit RH for previous decisions "<< decisionInput().key()<<": is this expected?" ); + return StatusCode::SUCCESS; + } + ATH_MSG_DEBUG( "Running with "<< h_prevDecisions->size() <<" implicit ReadHandles for previous decisions"); + ATH_CHECK(h_prevDecisions.isValid()); + auto prevDecisions = h_prevDecisions.get(); + + // Make a new Decisions container which will contain the previous + // decisions, and the one for this hypo. + auto newDecisions = std::make_unique<DecisionContainer>(); + auto aux = std::make_unique<DecisionAuxContainer>(); + newDecisions->setStore(aux.get()); + + + // Make trigger decisions and save to "newDecisions" + CHECK(decide(metContainer, newDecisions, prevDecisions)); + fillMonitoringHistograms(metContainer); + + // Write out decisions + auto outputHandle = SG::makeHandle(decisionOutput(), context); + CHECK( outputHandle.record( std::move( newDecisions ), std::move( aux ) ) ); + ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions"); + + + // debug.... + if ( msgLvl(MSG::DEBUG)) { + TrigCompositeUtils::DecisionIDContainer allPassingIDs; + for ( auto decisionObject: *outputHandle ) { + TrigCompositeUtils::decisionIDs( decisionObject, allPassingIDs ); + } + + for ( TrigCompositeUtils::DecisionID id : allPassingIDs ) { + ATH_MSG_DEBUG( " +++ " << HLT::Identifier( id ) ); + } + } + + return StatusCode::SUCCESS; +} + + + +StatusCode TrigMissingETHypoAlgMT::decide(const xAOD::TrigMissingETContainer* metContainer, + std::unique_ptr<DecisionContainer>& nDecisions, + const DecisionContainer* oDecisions) const{ + + ATH_MSG_DEBUG("Deciding" << name() ); + auto previousDecision = (*oDecisions)[0]; + auto newdecision = TrigCompositeUtils::newDecisionIn(nDecisions.get()); + + + const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{ + TrigCompositeUtils::decisionIDs(previousDecision).begin(), + TrigCompositeUtils::decisionIDs( previousDecision ).end() + }; + + //bool allPassed = true; + for (const auto& tool: m_hypoTools) { + auto decisionId = tool->getId(); + if (TrigCompositeUtils::passed(decisionId.numeric(), previousDecisionIDs)){ + ATH_MSG_DEBUG("Passed previous trigger"); + bool pass; + CHECK(tool->decide(metContainer, pass)); + if (pass) { + ATH_MSG_DEBUG("Passed HypoTools"); + TrigCompositeUtils::addDecisionID(decisionId, newdecision); + } else ATH_MSG_DEBUG("Didn't pass HypoTools"); + } ATH_MSG_DEBUG("Didn't pass previous trigger"); + } + + // if (allPassed) fillMonitoringHistograms(metContainer); + + return StatusCode::SUCCESS; +} + + +StatusCode TrigMissingETHypoAlgMT::fillMonitoringHistograms(const xAOD::TrigMissingETContainer* metContainer) const +{ + if (metContainer->size()!=1) return StatusCode::FAILURE; + auto met = (*metContainer)[0]; + + using namespace Monitored; + auto EF_MEx_log = MonitoredScalar::declare( "EF_MEx_log", toLogGeV( met->ex() ) ); + auto EF_MEy_log = MonitoredScalar::declare( "EF_MEy_log", toLogGeV( met->ey() ) ); + auto EF_MEz_log = MonitoredScalar::declare( "EF_MEz_log", toLogGeV( met->ez() ) ); + auto EF_MET_log = MonitoredScalar::declare( "EF_MET_log", toLogGeV( std::hypot( met->ex(), met->ey() ) ) ); + auto EF_ME_log = MonitoredScalar::declare( "EF_ME_log", toLogGeV( std::hypot( std::hypot(met->ex(), met->ey()), met->ez() ) ) ); + auto EF_SumEt_log = MonitoredScalar::declare( "EF_SumEt_log", toLogGeV( met->sumEt() ) ); + auto EF_SumE_log = MonitoredScalar::declare( "EF_SumE_log", toLogGeV( met->sumE(), -9e9 ) ); + + auto EF_MEx_lin = MonitoredScalar::declare( "EF_MEx_lin", toLinGeV( met->ex() ) ); + auto EF_MEy_lin = MonitoredScalar::declare( "EF_MEy_lin", toLinGeV( met->ey() ) ); + auto EF_MEz_lin = MonitoredScalar::declare( "EF_MEz_lin", toLinGeV( met->ez() ) ); + auto EF_MET_lin = MonitoredScalar::declare( "EF_MET_lin", toLinGeV( std::hypot( met->ex(), met->ey() ) ) ); + auto EF_ME_lin = MonitoredScalar::declare( "EF_ME_lin", toLinGeV( std::hypot( std::hypot(met->ex(), met->ey()), met->ez() ) ) ); + auto EF_SumEt_lin = MonitoredScalar::declare( "EF_SumEt_lin", toLinGeV( met->sumEt() ) ); + auto EF_SumE_lin = MonitoredScalar::declare( "EF_SumE_lin", toLinGeV( met->sumE(), -9e9 ) ); + auto EF_XS = MonitoredScalar::declare( "EF_XS", toLinGeV( std::hypot( met->ex(), met->ey() ) ) / toLinGeV( met->sumEt() ) ); + auto EF_MET_phi = MonitoredScalar::declare( "EF_MET_phi", std::atan2( met->ey(), met->ex() ) ); + + auto monitorIt = MonitoredScope::declare( m_monTool, + EF_MEx_log, EF_MEy_log, EF_MEz_log, EF_MET_log, EF_ME_log, EF_ME_log, EF_SumE_log, + EF_MEx_lin, EF_MEy_lin, EF_MEz_lin, EF_MET_lin, EF_ME_lin, EF_SumEt_lin, EF_SumE_lin, + EF_XS, EF_MET_phi); + + return StatusCode::SUCCESS; + +} + + diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoAlgMT.h b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoAlgMT.h new file mode 100644 index 0000000000000000000000000000000000000000..ea9066bcb24e2cb3120929993babcacaae345eaa --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoAlgMT.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef TRIGMISSINGETHYPO_TRIGMISSINGETHYPOALGMT_H +#define TRIGMISSINGETHYPO_TRIGMISSINGETHYPOALGMT_H + +#include <string> + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "DecisionHandling/HypoBase.h" +#include "AthenaMonitoring/GenericMonitoringTool.h" + + +#include "TrigMissingETHypo/ITrigMissingETHypoToolMT.h" +#include "xAODTrigMissingET/TrigMissingETContainer.h" + +using TrigCompositeUtils::DecisionContainer; + +/** + * @class TrigMissingETHypoAlgMT + * @brief Implements MET selection for the HLT framework + **/ +class TrigMissingETHypoAlgMT : public ::HypoBase { + public: + + TrigMissingETHypoAlgMT( const std::string& name, ISvcLocator* pSvcLocator ); + + virtual ~TrigMissingETHypoAlgMT(); + + virtual StatusCode initialize() override; + virtual StatusCode execute( const EventContext& context ) const override; + virtual StatusCode finalize() override; + + private: + + // TODO: Consider taking muonContainer etc in case they are needed in future. + StatusCode decide(const xAOD::TrigMissingETContainer*, + std::unique_ptr<DecisionContainer>& newDecisions, + const DecisionContainer* previousDecisions + ) const; + StatusCode fillMonitoringHistograms(const xAOD::TrigMissingETContainer*) const; + + ToolHandleArray<ITrigMissingETHypoToolMT> m_hypoTools { + this, "HypoTools", {}, "Hypo tools"}; + + SG::ReadHandleKey< xAOD::TrigMissingETContainer > m_metKey { + this, "METContainerKey", "HLT_MET", "MET Container name"}; + + ToolHandle<GenericMonitoringTool> m_monTool{ this, "MonTool", "", "Monitoring tool" }; + + static float toLogGeV(const float& x, const float& fallback, const float& epsilon ); + static float toLinGeV(const float& x, const float& fallback, const float& epsilon ); + + +}; + +#endif + diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoToolMT.cxx b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoToolMT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4cc562611e992cb65e0d22d119bf37f311a623a9 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoToolMT.cxx @@ -0,0 +1,68 @@ +/* + Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: TrigMissingETHypoToolMT.cxx +// PACKAGE: Trigger/TrigHypothesis/TrigMissingET +// +// +// ******************************************************************** + +#include "TrigMissingETHypoToolMT.h" + + +TrigMissingETHypoToolMT::TrigMissingETHypoToolMT(const std::string& type, + const std::string& name, + const IInterface* parent): + base_class(type, name, parent), + m_decisionId(HLT::Identifier::fromToolName(name)) {} + + +TrigMissingETHypoToolMT::~TrigMissingETHypoToolMT() {} + + +StatusCode TrigMissingETHypoToolMT::initialize() { + ATH_MSG_DEBUG("Initializing TrigMissingETHypoToolMT"); + ATH_MSG_DEBUG("MET threshold set to " << m_metThreshold ); + return StatusCode::SUCCESS; +} + +StatusCode TrigMissingETHypoToolMT::finalize() { + return StatusCode::SUCCESS; +} + +StatusCode TrigMissingETHypoToolMT::decide(const xAOD::TrigMissingETContainer* metContainer, bool& pass) const +{ + ATH_MSG_DEBUG("Executing decide() of " << name()); + switch(metContainer->size()){ + case 0: + pass = false; + break; + case 1: + { + float ex = (*metContainer)[0]->ex(); + float ey = (*metContainer)[0]->ey(); + float met = std::hypot(ex,ey)/1000.; + pass = met > m_metThreshold; + + ATH_MSG_VERBOSE("in " << name() << ": MET = " << met); + if (pass) + ATH_MSG_VERBOSE("Event passes the " << m_metThreshold << " GeV cut"); + else + ATH_MSG_VERBOSE("Event fails the " << m_metThreshold << " GeV cut"); + break; + } + default: + ATH_MSG_WARNING("There is more than one TrigEFMissingET object in the MET container. "); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; + +} + +const HLT::Identifier& TrigMissingETHypoToolMT::getId() const{ + return m_decisionId; +} + diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoToolMT.h b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoToolMT.h new file mode 100644 index 0000000000000000000000000000000000000000..a249ee225592f02312f451732124018b6be39c46 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/src/TrigMissingETHypoToolMT.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrigMissingETHypoToolMTMT_H +#define TrigMissingETHypoToolMTMT_H +/******************************************************************** + * + * NAME: TrigMissingETHypoToolMTMT.h + * PACKAGE: Trigger/TrigHypothesis/TrigMissingETHypo + * + * + *********************************************************************/ + + +#include "DecisionHandling/HLTIdentifier.h" +#include "AthenaBaseComps/AthAlgTool.h" +#include "DecisionHandling/TrigCompositeUtils.h" +#include "AthenaMonitoring/GenericMonitoringTool.h" + +#include "xAODTrigMissingET/TrigMissingETContainer.h" +#include "TrigMissingETHypo/ITrigMissingETHypoToolMT.h" + +class TrigMissingETHypoToolMT: public extends<AthAlgTool, ITrigMissingETHypoToolMT> { + + public: + + TrigMissingETHypoToolMT(const std::string& type, + const std::string& name, + const IInterface* parent); + virtual ~TrigMissingETHypoToolMT(); + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; + + virtual StatusCode + decide(const xAOD::TrigMissingETContainer*, bool& pass) const override; + virtual const HLT::Identifier& getId() const override; + private: + + // Identifier is used to keep track of which tool made which decision. + // The information is stored in the event store. + HLT::Identifier m_decisionId; + + private: + + Gaudi::Property<float> + m_metThreshold{this, "metThreshold", 50, "MET threshold" }; + + // Monitored variables... + /* + declareMonitoredVariable("Et", m_et); + declareMonitoredVariable("Eta", m_eta); + declareMonitoredVariable("Phi", m_phi); +*/ + + +}; +#endif + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py new file mode 100644 index 0000000000000000000000000000000000000000..917a18fc0ff45ca222000b495a590e51f9ed8b2b --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py @@ -0,0 +1,95 @@ +# +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# + +def metCellRecoSequence(RoIs): + ################################################# + # Useful imports + ################################################# + from AthenaCommon.Constants import VERBOSE,DEBUG,INFO,WARNING + + from math import pi + from TrigT2CaloCommon.TrigT2CaloCommonConf import TrigCaloDataAccessSvc#, TestCaloDataAccess + from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram + + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + from AthenaCommon.AppMgr import ToolSvc + from AthenaCommon.Constants import VERBOSE,DEBUG,INFO + + from AthenaCommon.CFElements import parOR, seqAND, seqOR, stepSeq + + ################################################# + # Declare reco sequence. This will be returned at the end of the function + ################################################# + metCellRecoSequence = seqAND("metCellRecoSequence") + + + ################################################# + # Set up monitoring for CaloDataAccess + ################################################# + mon = GenericMonitoringTool("CaloDataAccessSvcMon") + mon.Histograms += [defineHistogram( "TIME_locking_LAr_RoI", title="Time spent in unlocking the LAr collection", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "roiROBs_LAr", title="Number of ROBs unpacked in RoI requests", xbins=20, xmin=0, xmax=20 ), + defineHistogram( "TIME_locking_LAr_FullDet", title="Time spent in unlocking the LAr collection", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "roiEta_LAr,roiPhi_LAr", type="TH2F", title="Geometric usage", xbins=50, xmin=-5, xmax=5, ybins=64, ymin=-pi, ymax=pi )] + + svcMgr += TrigCaloDataAccessSvc() + svcMgr.TrigCaloDataAccessSvc.MonTool = mon + svcMgr.TrigCaloDataAccessSvc.OutputLevel=WARNING + + ################################################# + # Get cells + ################################################# + + from TrigCaloRec.TrigCaloRecConfig import HLTCaloCellMaker + cellMakerAlgo = HLTCaloCellMaker("CellMakerMT") + cellMakerAlgo.roiMode=True + cellMakerAlgo.RoIs=RoIs + cellMakerAlgo.OutputLevel=WARNING + cellMakerAlgo.CellsName="CaloCells" + metCellRecoSequence += cellMakerAlgo + + + ################################################# + # Add EFMissingETAlg and associated tools + ################################################# + from TrigEFMissingET.TrigEFMissingETConf import EFMissingETAlgMT, EFMissingETFromCellsMT, EFMissingETFromHelper + metAlg = EFMissingETAlgMT( name="EFMET" ) + metAlg.OutputLevel=WARNING + helperTool = EFMissingETFromHelper("theHelperTool") + metAlg.HelperTool= helperTool + metAlg.METContainerKey = "HLT_MET" + + #/////////////////////////////////////////// + # Setup monitoring for EFMissingETAlg + #/////////////////////////////////////////// + metMon = GenericMonitoringTool("METMonTool") + metMon.Histograms = [ defineHistogram( "TIME_Total", title="Time spent Alg", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "TIME_Loop", title="Time spent in Tools loop", xbins=100, xmin=0, xmax=100 )] + from TrigEFMissingET.TrigEFMissingETMonitoring import ( hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log, + hMET_lin, hSumEt_lin, + hXS, hMETPhi, hMETStatus, + hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE, + hCompEt_lin, hCompSumEt_lin ) + + metMon.Histograms = [ hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log ] + metMon.Histograms += [ hMET_lin, hSumEt_lin ] + metMon.Histograms += [ hXS, hMETPhi, hMETStatus] + metMon.Histograms += [ hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE ] + metMon.Histograms += [ hCompEt_lin, hCompSumEt_lin ] + metAlg.MonTool = metMon + + #/////////////////////////////////////////// + # Add EFMissingETFromCells tool + #/////////////////////////////////////////// + from TrigEFMissingET.TrigEFMissingETConf import EFMissingETFromCellsMT + cellTool = EFMissingETFromCellsMT( name="METFromCellsTool" ) + cellTool.CellsCollection = cellMakerAlgo.CellsName + + metAlg.METTools.append(cellTool) + + metCellRecoSequence += metAlg + + seqOut = metAlg.METContainerKey + return (metCellRecoSequence, seqOut) + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py new file mode 100644 index 0000000000000000000000000000000000000000..630a88a378775c716cff909e053a44a8876969f8 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py @@ -0,0 +1,64 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# + +from AthenaCommon.Constants import VERBOSE,DEBUG,INFO,WARNING +from TrigEFMissingET.TrigEFMissingETMonitoring import * +from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence +from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep + +# from TrigUpgradeTest import TrigMissingETStepFromName + +def metCellSequence(): + # menu components + from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence + from AthenaCommon.CFElements import parOR, seqAND, seqOR, stepSeq + + #input maker + from DecisionHandling.DecisionHandlingConf import InputMakerForRoI + InputMakerAlg = InputMakerForRoI("MetCellInputMaker", OutputLevel = DEBUG, LinkName="initialRoI") + InputMakerAlg.RoIs='METCellRoI' + + #reco sequence + from TrigUpgradeTest.metDefs import metCellRecoSequence + recoSequence, sequenceOut = metCellRecoSequence(InputMakerAlg.RoIs) + + #hypo + from TrigMissingETHypo.TrigMissingETHypoConfigMT import MissingETHypoAlgMT, TrigMETCellHypoToolFromName, MissingETHypoToolMT + + metHypoAlg = MissingETHypoAlgMT("METHypoAlg") + metHypoAlg.METContainerKey=sequenceOut + metHypoAlg.OutputLevel=DEBUG + + # sequence + metCellSequence = seqAND("metCellSequence",[InputMakerAlg, recoSequence]) + + return MenuSequence( Sequence = metCellSequence, + Maker = InputMakerAlg, + Hypo = metHypoAlg, + HypoToolGen = TrigMETCellHypoToolFromName ) + + +def TrigMissingETChainFromName(name): + parts = name.split('_') + # L1Seed = "L1_XE"+parts[-1][4:] + L1Seed = "L1_XE50" + parts=parts[1:-1] + + chainSteps = [] + + # Implement this function + def parseStepNames(name): + return ["cell"] + + stepNames = parseStepNames(name) + + for n_metStep, s in enumerate(stepNames, start=1): + stepName = "Step%d_%s" % (n_metStep, s) + seq = [] + if s == "cell": + seq.append(metCellSequence()) + + chainSteps.append(ChainStep(stepName, seq)) + + return Chain(name=name, Seed=L1Seed, ChainSteps=chainSteps) + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py b/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py new file mode 100644 index 0000000000000000000000000000000000000000..016a1d0b305d54607ca384ea1bb39ed6aafe0f80 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py @@ -0,0 +1,66 @@ +# +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# + +# import flags +include("TrigUpgradeTest/testHLT_MT.py") + +########################################## +# menu +########################################## +from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep + + +from TrigUpgradeTest.metMenuDefs import metCellSequence + +metCellSeq = metCellSequence() +metCellStep = ChainStep("Step1_met_cell", [metCellSeq]) +testChains = [ + Chain(name="HLT_xe65_L1XE50", Seed="L1_XE50", ChainSteps=[metCellStep]), + Chain(name="HLT_xe30_L1XE10", Seed="L1_XE10", ChainSteps=[metCellStep]) +] + +''' ## Will eventually automate the creation of MET trigger chains +from TrigUpgradeTest.metMenuDefs import TrigMissingETChainFromName +testChains = [ TrigMissingETChainFromName(chain) for chain in ["HLT_xe65_L1XE50"] ] +''' +################################# +# Configure L1Decoder +################################# + +# provide a minimal menu information +if globalflags.InputFormat.is_bytestream(): + topSequence.L1DecoderTest.ctpUnpacker.OutputLevel=DEBUG + topSequence.L1DecoderTest.roiUnpackers[0].OutputLevel=DEBUG + +# Hacking the chains name. Otherwise doesn't work. +topSequence.L1DecoderTest.Chains="HLTChains" +topSequence.L1DecoderTest.roiUnpackers["METRoIsUnpackingTool"].Decisions="L1XE" + + + +# this is a temporary hack to include new test chains +EnabledChainNamesToCTP = dict([ (c.name, c.seed) for c in testChains]) +topSequence.L1DecoderTest.ChainToCTPMapping = EnabledChainNamesToCTP + + + +########################################## +# CF construction +########################################## + +##### Make all HLT ####### +from TriggerMenuMT.HLTMenuConfig.Menu.HLTCFConfig import makeHLTTree +makeHLTTree(testChains) + + + +########################################## +# Some debug +########################################## +from AthenaCommon.AlgSequence import dumpSequence +dumpSequence(topSequence) + + + + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met.seq.test.py b/Trigger/TrigValidation/TrigUpgradeTest/share/met.seq.test.py new file mode 100644 index 0000000000000000000000000000000000000000..6d63777ed5d55eb65b8ad0a13920d1b63375c03a --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met.seq.test.py @@ -0,0 +1,35 @@ +# +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# + +include("TrigUpgradeTest/testHLT_MT.py") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +import math +from TrigT2CaloCommon.TrigT2CaloCommonConf import TrigCaloDataAccessSvc#, TestCaloDataAccess +from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram + + +from L1Decoder.L1DecoderConf import CreateFullScanRoI +topSequence += CreateFullScanRoI() + +from TrigUpgradeTest.metDefs import metCellRecoSequence +cellRecoSeq, METkey = metCellRecoSequence("FullScanRoIs") +topSequence += cellRecoSeq + +from TrigMissingETHypo.TrigMissingETHypoConfigMT import MissingETHypoAlgMT, TrigMETHypoToolFromName, MissingETHypoToolMT + +metHypoTool = MissingETHypoToolMT("METHypoTool") +metHypoTool.metThreshold=50 + +metHypoAlg = MissingETHypoAlgMT("METHypoAlg") +metHypoAlg.HypoTools = [metHypoTool] +metHypoAlg.METContainerKey="HLT_MET" +metHypoAlg.OutputLevel=DEBUG +metHypoAlg.HypoInputDecisions = "L1MET" +metHypoAlg.HypoOutputDecisions = "EFMETDecisions" + +topSequence += metHypoAlg + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met_standalone.ref b/Trigger/TrigValidation/TrigUpgradeTest/share/met_standalone.ref new file mode 100644 index 0000000000000000000000000000000000000000..0fd92ec58434e564311a669c5d747b1f1f10bb46 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met_standalone.ref @@ -0,0 +1,10 @@ +METHypoAlg 0 0 DEBUG The MET value is 82 +METHypoAlg 1 0 DEBUG The MET value is 31 +METHypoAlg 2 0 DEBUG The MET value is 39 +METHypoAlg 3 0 DEBUG The MET value is 67 +METHypoAlg 4 0 DEBUG The MET value is 40 +METHypoAlg 5 0 DEBUG The MET value is 29 +METHypoAlg 6 0 DEBUG The MET value is 73 +METHypoAlg 7 0 DEBUG The MET value is 11 +METHypoAlg 8 0 DEBUG The MET value is 65 +METHypoAlg 9 0 DEBUG The MET value is 19 diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_standalone.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_standalone.sh new file mode 100755 index 0000000000000000000000000000000000000000..a72ce3984e0d4b7cd52686e5979482b35e9fe72b --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_standalone.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# art-type: build +# art-ci: master + +athena --threads=1 --evtMax=10 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/metTest.py +