diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/L1JetMonitoringConfig.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/L1JetMonitoringConfig.py index f45216061bd696fb4dfca5e1b4a7fa36db12c0fb..f03e5e66e634e5b88b945daf4bcc901ebf00db03 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/L1JetMonitoringConfig.py +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/L1JetMonitoringConfig.py @@ -38,14 +38,15 @@ class L1JetMonAlg(): def container2tool_class_name(): - c2t = { - 'L1_jFexSRJetRoI': '<DataVector<xAOD::jFexSRJetRoI_v1, DataModel_detail::NoBase> >', - 'L1_jFexLRJetRoI': '<DataVector<xAOD::jFexLRJetRoI_v1, DataModel_detail::NoBase> >', - 'L1_gFexSRJetRoI': '<DataVector<xAOD::gFexJetRoI_v1, DataModel_detail::NoBase> >', - 'L1_gFexLRJetRoI': '<DataVector<xAOD::gFexJetRoI_v1, DataModel_detail::NoBase> >', - } - - return 'TrigL1FexJetMonitorTool' + c2t[self.L1JetContainer] + # Note: there are two gFex names, both correspond to the same container type. + + return { + 'L1_jFexSRJetRoI': 'TrigL1FexJetMonitorTool_jFexSR', + 'L1_jFexLRJetRoI': 'TrigL1FexJetMonitorTool_jFexLR', + 'L1_gFexSRJetRoI': 'TrigL1FexJetMonitorTool_gFex', + 'L1_gFexLRJetRoI': 'TrigL1FexJetMonitorTool_gFex', + 'LVL1JetRoIs': 'TrigL1FexJetMonitorTool_jetRoI', + }[self.L1JetContainer] def container2tool_inst_name(): @@ -53,7 +54,9 @@ class L1JetMonAlg(): return {'L1_jFexSRJetRoI': 'jFexSRDataRetriever', 'L1_jFexLRJetRoI': 'jFexLRDataRetriever', 'L1_gFexSRJetRoI': 'gFexSRDataRetriever', - 'L1_gFexLRJetRoI': 'gFexLRDataRetriever',}[self.L1JetContainer] + 'L1_gFexLRJetRoI': 'gFexLRDataRetriever', + 'LVL1JetRoIs': 'JetRoIDataRetriever', + }[self.L1JetContainer] def container2_monitorgroup(): @@ -61,48 +64,29 @@ class L1JetMonAlg(): return {'L1_jFexSRJetRoI': 'TrigL1JFexSRJetMonitor', 'L1_jFexLRJetRoI': 'TrigL1JFexLRJetMonitor', 'L1_gFexSRJetRoI': 'TrigL1GFexSRJetMonitor', - 'L1_gFexLRJetRoI': 'TrigL1GFexLRJetMonitor',}[self.L1JetContainer] + 'L1_gFexLRJetRoI': 'TrigL1GFexLRJetMonitor', + 'LVL1JetRoIs': 'TrigL1JetMonitor'}[self.L1JetContainer] - if L1Fex: - alg = monhelper.addAlgorithm(CompFactory.TrigL1FexJetMonitorAlgorithm, + + alg = monhelper.addAlgorithm(CompFactory.TrigL1FexJetMonitorAlgorithm, self.name) - toolClass = getattr(CompFactory, container2tool_class_name()) - tool = toolClass(container2tool_inst_name()) - tool.do_matching = self.matched - tool.offlineJetsToMatch = self.matchedOJ - tool.HLTJetsToMatch = self.matchedHLTJ - tool.l1container = self.L1JetContainer - alg.group_name = container2_monitorgroup() - alg.filler = tool - alg.TriggerChain = self.triggerChain - - else: - alg = monhelper.addAlgorithm(CompFactory.TrigL1JetMonitorAlgorithm, self.name) - alg.IsMatched = self.matched - alg.L1JetContainer = self.L1JetContainer - alg.TriggerChain = self.triggerChain - if self.matched: - alg.MatchedOfflineJets = self.matchedOJ - alg.MatchedHLTJets = self.matchedHLTJ - + toolClass = getattr(CompFactory, container2tool_class_name()) + tool = toolClass(container2tool_inst_name()) + tool.do_matching = self.matched + tool.offlineJetsToMatch = self.matchedOJ + tool.HLTJetsToMatch = self.matchedHLTJ + tool.l1container = self.L1JetContainer + alg.group_name = container2_monitorgroup() + alg.filler = tool + alg.TriggerChain = self.triggerChain # Add a generic monitoring tool (a "group" in old language). The returned # object here is the standard GenericMonitoringTool Path = self.L1JetContainer+'/' Path += 'NoTriggerSelection/' if self.triggerChain == '' else self.triggerChain+'/' - if jFexSR: - myGroup = monhelper.addGroup(alg,'TrigL1JFexSRJetMonitor','HLT/JetMon/L1/') - elif jFexLR: - myGroup = monhelper.addGroup(alg,'TrigL1JFexLRJetMonitor','HLT/JetMon/L1/') - elif gFexSR: - myGroup = monhelper.addGroup(alg,'TrigL1GFexSRJetMonitor','HLT/JetMon/L1/') - elif gFexLR: - myGroup = monhelper.addGroup(alg,'TrigL1GFexLRJetMonitor','HLT/JetMon/L1/') - else: - myGroup = monhelper.addGroup(alg,'TrigL1JetMonitor','HLT/JetMon/L1/') - - + myGroup = monhelper.addGroup(alg, container2_monitorgroup(),'HLT/JetMon/L1/') + if L1Fex: myGroup.defineHistogram('et',title='et',path=Path,xbins=400,xmin=0.0,xmax=400.0) else: diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/DataStructs.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/DataStructs.h index 2718b6b28b08dd8d38622a496a24237d76eac850..a812b89cf0a9b8df57a85aa5016019cfefe89cf0 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/DataStructs.h +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/DataStructs.h @@ -5,12 +5,16 @@ #ifndef TRIGJETMONITORING_DATASTRUCTS_H #define TRIGJETMONITORING_DATASTRUCTS_H +#include <string> + struct JetData { -JetData(float et, float eta, float phi) : m_et{et}, m_eta{eta}, m_phi{phi}{} +JetData(float et, float eta, float phi, std::string et_label) : + m_et{et}, m_eta{eta}, m_phi{phi}, m_et_label{et_label}{} float m_et; float m_eta; float m_phi; + std::string m_et_label; //"et", "et8x8" ... }; struct JetMatchData { diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1FexGroupNameDispatcher.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1FexGroupNameDispatcher.cxx deleted file mode 100644 index 9a594ba38973412bf75435d06a9cc64e00d78e7a..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1FexGroupNameDispatcher.cxx +++ /dev/null @@ -1,22 +0,0 @@ - -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ - -#include "./L1FexGroupNameDispatcher.h" - -std::string -groupNameDispatcher(TrigL1FexJetMonitorTool<xAOD::jFexSRJetRoIContainer>*) { - return "TrigL1JFexSRJetMonitor"; -} - -std::string -groupNameDispatcher(TrigL1FexJetMonitorTool<xAOD::jFexLRJetRoIContainer>*) { - return "TrigL1JFexLRJetMonitor"; -} - - -std::string -groupNameDispatcher(TrigL1FexJetMonitorTool<xAOD::gFexJetRoIContainer>*) { - return "TrigL1GFexJetMonitor"; -} diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1FexGroupNameDispatcher.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1FexGroupNameDispatcher.h deleted file mode 100644 index d83c657c45cadd7499c6471e6a5cb0b4e52642ee..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1FexGroupNameDispatcher.h +++ /dev/null @@ -1,23 +0,0 @@ - -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ -#ifndef TRIGJETMONITORING_L1FEXGROUPNAMEDISPATCHER_H -#define TRIGJETMONITORING_L1FEXGROUPNAMEDISPATCHER_H - -#include "./TrigL1FexJetMonitorTool.h" -#include "xAODTrigger/jFexSRJetRoIContainer.h" -#include "xAODTrigger/jFexLRJetRoIContainer.h" -#include "xAODTrigger/gFexJetRoIContainer.h" - -std::string -groupNameDispatcher(TrigL1FexJetMonitorTool<xAOD::jFexSRJetRoIContainer>*); - -std::string -groupNameDispatcher(TrigL1FexJetMonitorTool<xAOD::jFexLRJetRoIContainer>*); - - -std::string -groupNameDispatcher(TrigL1FexJetMonitorTool<xAOD::gFexJetRoIContainer>*); - -#endif diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1MonitorAdaptors.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1MonitorAdaptors.h new file mode 100644 index 0000000000000000000000000000000000000000..811998ea7b97bd3eeb7a7eda9f9a133a2d3449c5 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/L1MonitorAdaptors.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGJETMONITOR_L1MONITORADAPTORS_H +#define TRIGJETMONITOR_L1MONITORADAPTORS_H + +#include "xAODTrigger/jFexSRJetRoI.h" +#include "xAODTrigger/jFexLRJetRoI.h" +#include "xAODTrigger/gFexJetRoI.h" +#include "xAODTrigger/JetRoI.h" + + +inline bool vetoJet(const xAOD::jFexSRJetRoI* j){ + return j->tobWord() == 0; +} +inline float et(const xAOD::jFexSRJetRoI* j){ + return j->et(); +} +inline std::string et_label(const xAOD::jFexSRJetRoI*){ + return "et"; +} + +inline bool vetoJet(const xAOD::jFexLRJetRoI*){ + return false; +} +inline float et(const xAOD::jFexLRJetRoI* j){ + return j->et(); +} +inline std::string et_label(const xAOD::jFexLRJetRoI*){ + return "et"; +} + + +inline bool vetoJet(const xAOD::gFexJetRoI*){ + return false; +} +inline float et(const xAOD::gFexJetRoI* j){ + return j->et(); +} +inline std::string et_label(const xAOD::gFexJetRoI*){ + return "et"; +} + + +inline bool vetoJet(const xAOD::JetRoI*){ + return false; +} +inline float et(const xAOD::JetRoI* j){ + return j->et8x8(); +} +inline std::string et_label(const xAOD::JetRoI*){ + return "et8x8"; +} + + +#endif diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.cxx index b5da7a171021393d9db0d81cb7e12db48432179a..b0899a8f8c45e287e3453894eac830406bec6ed7 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.cxx +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.cxx @@ -3,8 +3,6 @@ */ #include "TrigL1FexJetMonitorAlgorithm.h" -#include "TrigL1FexJetMonitorTool.h" - #include "AsgDataHandles/ReadDecorHandle.h" #include <vector> @@ -32,7 +30,7 @@ StatusCode TrigL1FexJetMonitorAlgorithm::fillHistograms(const EventContext& ctx) auto groupTool = getGroup(m_groupName); for (const auto& jd : jetData) { - Monitored::Scalar<float> et{"et", jd.m_et}; + Monitored::Scalar<float> et{jd.m_et_label, jd.m_et}; Monitored::Scalar<float> eta{"eta", jd.m_eta}; Monitored::Scalar<float> phi{"phi", jd.m_phi}; diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_gFex.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_gFex.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c943c42dc079f81b2c72fce523a54e84dc53066b --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_gFex.cxx @@ -0,0 +1,262 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigL1FexJetMonitorTool_gFex.h" +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "AsgDataHandles/ReadDecorHandle.h" + +#include "./L1MonitorAdaptors.h" +#include <memory> + + +///////////////////////////////////////////////////////////////////////////// + +TrigL1FexJetMonitorTool_gFex::TrigL1FexJetMonitorTool_gFex(const std::string& type, + const std::string& name, + const IInterface* parent) + : AthAlgTool( type, name, parent ) +{ + declareProperty("l1container", m_l1jetContainerkey); + +} + + + +StatusCode TrigL1FexJetMonitorTool_gFex::initialize() +{ + ATH_CHECK(m_l1jetContainerkey.initialize()); + + if (m_doMatching) { + m_offmatchedKey = + m_l1jetContainerkey.key() + ".matched_" + m_offlineJetContainerToMatch; + + m_offptdiffKey = + m_l1jetContainerkey.key() + ".ptdiff_" + m_offlineJetContainerToMatch; + + m_offenergydiffKey = + m_l1jetContainerkey.key() + ".energydiff_" + m_offlineJetContainerToMatch; + + m_offmassdiffKey = + m_l1jetContainerkey.key() + ".massdiff_" + m_offlineJetContainerToMatch; + + m_offptrespKey = + m_l1jetContainerkey.key() + ".ptresp_" + m_offlineJetContainerToMatch; + + m_offenergyrespKey = + m_l1jetContainerkey.key() + ".energyresp_" + m_offlineJetContainerToMatch; + + m_offmassrespKey = + m_l1jetContainerkey.key() + ".massresp_" + m_offlineJetContainerToMatch; + + m_offptrefKey = + m_l1jetContainerkey.key() + ".ptRef_" + m_offlineJetContainerToMatch; + + m_offetarefKey = + m_l1jetContainerkey.key() + ".etaRef_" + m_offlineJetContainerToMatch; + + ATH_CHECK(m_offmatchedKey.initialize() ); + ATH_CHECK(m_offptdiffKey.initialize() ); + ATH_CHECK(m_offenergydiffKey.initialize() ); + ATH_CHECK(m_offmassdiffKey.initialize() ); + ATH_CHECK(m_offptrespKey.initialize() ); + ATH_CHECK(m_offenergyrespKey.initialize() ); + ATH_CHECK(m_offmassrespKey.initialize() ); + ATH_CHECK(m_offptrefKey.initialize() ); + ATH_CHECK(m_offetarefKey.initialize() ); + + m_hltmatchedKey = + m_l1jetContainerkey.key() + ".matched_" + m_HLTJetContainerToMatch; + + m_hltptdiffKey = + m_l1jetContainerkey.key() + ".ptdiff_" + m_HLTJetContainerToMatch; + + m_hltenergydiffKey = + m_l1jetContainerkey.key() + ".energydiff_" + m_HLTJetContainerToMatch; + + m_hltmassdiffKey = + m_l1jetContainerkey.key() + ".massdiff_" + m_HLTJetContainerToMatch; + + m_hltptrespKey = + m_l1jetContainerkey.key() + ".ptresp_" + m_HLTJetContainerToMatch; + + m_hltenergyrespKey = + m_l1jetContainerkey.key() + ".energyresp_" + m_HLTJetContainerToMatch; + + m_hltmassrespKey = + m_l1jetContainerkey.key() + ".massresp_" + m_HLTJetContainerToMatch; + + m_hltptrefKey = + m_l1jetContainerkey.key() + ".ptRef_" + m_HLTJetContainerToMatch; + + m_hltetarefKey = + m_l1jetContainerkey.key() + ".etaRef_" + m_HLTJetContainerToMatch; + + ATH_CHECK(m_hltmatchedKey.initialize()); + ATH_CHECK(m_hltptdiffKey.initialize()); + ATH_CHECK(m_hltenergydiffKey.initialize()); + ATH_CHECK(m_hltmassdiffKey.initialize()); + ATH_CHECK(m_hltptrespKey.initialize()); + ATH_CHECK(m_hltenergyrespKey.initialize()); + ATH_CHECK(m_hltmassrespKey.initialize()); + ATH_CHECK(m_hltptrefKey.initialize()); + ATH_CHECK(m_hltetarefKey.initialize()); + + } else { + // declare the keys unused if no matching is configured + + // offline container matching + ATH_CHECK(m_offmatchedKey.initialize(false)); + ATH_CHECK(m_offptdiffKey.initialize(false)); + ATH_CHECK(m_offenergydiffKey.initialize(false)); + ATH_CHECK(m_offmassdiffKey.initialize(false)); + ATH_CHECK(m_offptrespKey.initialize(false)); + ATH_CHECK(m_offenergyrespKey.initialize(false)); + ATH_CHECK(m_offmassrespKey.initialize(false)); + ATH_CHECK(m_offptrefKey.initialize(false)); + ATH_CHECK(m_offetarefKey.initialize(false)); + + // trigger container matching + ATH_CHECK(m_hltmatchedKey.initialize(false)); + ATH_CHECK(m_hltptdiffKey.initialize(false)); + ATH_CHECK(m_hltenergydiffKey.initialize(false)); + ATH_CHECK(m_hltmassdiffKey.initialize(false)); + ATH_CHECK(m_hltptrespKey.initialize(false)); + ATH_CHECK(m_hltenergyrespKey.initialize(false)); + ATH_CHECK(m_hltmassrespKey.initialize(false)); + ATH_CHECK(m_hltptrefKey.initialize(false)); + ATH_CHECK(m_hltetarefKey.initialize(false)); + } + + return StatusCode::SUCCESS; +} + + + +StatusCode +TrigL1FexJetMonitorTool_gFex::getData(const EventContext& ctx, + std::vector<JetData>& jetData + ) const{ + + + // Retrieve the L1 jet container + SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); + if( !jets.isValid() ){ + // the L1 containers should _always_ be present, although may be empty. + ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " + << m_l1jetContainerkey); + return StatusCode::SUCCESS; + } + + // find variables associated with jets in the input container. + for(const auto& jet : *jets){ + /* + Ensure that the the et is above a hardware threshold: + From Sergi Rodriguez 23/02/2022 + in the bitwise simulation we also have an energy threshold, + which is taken from the trigger menu. + If the Et is below the threshold the TOB word is set to 0 + */ + + if (vetoJet(jet)) {continue;} // see L1MonitoredAdaptors + + jetData.emplace_back(et(jet)*0.001, // see L1MonitoredAdaptors + jet->eta(), + jet->phi(), + et_label(jet)); + + } + return StatusCode::SUCCESS; +} + + + +StatusCode +TrigL1FexJetMonitorTool_gFex::getMatchData(const EventContext& ctx, + MatchToEnum matchTo, + std::vector<JetMatchData>& jetMatchData + ) const { + if (!m_doMatching) { + // otherwise will attempt to use uniniatialied Keys + return StatusCode::SUCCESS; + } + + std::unique_ptr<SG::ReadDecorHandle<JetContainer, char>> matchedHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptdiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energydiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massdiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energyrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrefHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> etarefHandle; + + if (matchTo == MatchToEnum::hlt) { + + matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_hltmatchedKey, ctx)); + ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptdiffKey, ctx)); + energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergydiffKey, ctx)); + massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassdiffKey, ctx)); + ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrespKey, ctx)); + energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergyrespKey, ctx)); + massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassrespKey, ctx)); + ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrefKey, ctx)); + etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltetarefKey, ctx)); + } else if (matchTo == MatchToEnum::offline) { + matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_offmatchedKey, ctx)); + ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptdiffKey, ctx)); + energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergydiffKey, ctx)); + massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassdiffKey, ctx)); + ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrespKey, ctx)); + energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergyrespKey, ctx)); + massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassrespKey, ctx)); + ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrefKey, ctx)); + etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offetarefKey, ctx)); + } else { + ATH_MSG_ERROR ("unsupported MatchTo value"); + return StatusCode::FAILURE; + } + + ATH_CHECK((*matchedHandle).initialize()); + ATH_CHECK((*ptdiffHandle).initialize()); + ATH_CHECK((*energydiffHandle).initialize()); + ATH_CHECK((*massdiffHandle).initialize()); + ATH_CHECK((*ptrespHandle).initialize()); + ATH_CHECK((*energyrespHandle).initialize()); + ATH_CHECK((*massrespHandle).initialize()); + ATH_CHECK((*ptrefHandle).initialize()); + ATH_CHECK((*etarefHandle).initialize()); + + + // Loop over L1 jets and fill pt, energy, mass differences and responses + // between matched jets, plus reference pT and eta + + // Retrieve the L1 jet container + SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); + if(!jets.isValid()){ + // the L1 containers should _always_ be present, although may be empty. + ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " + << m_l1jetContainerkey); + return StatusCode::SUCCESS; + } + + for(const auto& jet : *jets){ + bool matched = (*matchedHandle)(*jet); + + if(matched){ + jetMatchData.emplace_back((*ptdiffHandle)(*jet), + (*energydiffHandle)(*jet), + (*massdiffHandle)(*jet), + (*ptrespHandle)(*jet), + (*energyrespHandle)(*jet), + (*massrespHandle)(*jet), + (*ptrefHandle)(*jet), + (*etarefHandle)(*jet)); + } + } + + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_gFex.h similarity index 82% rename from Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool.h rename to Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_gFex.h index be59b11375a0ab53af6ffcbc561f5cc9f62731c1..9fef98a3d252f12fdae075cb62e1bbdc2bc523c6 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool.h +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_gFex.h @@ -4,41 +4,30 @@ Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ -#ifndef TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_H -#define TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_H +#ifndef TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_GFEX_H +#define TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_GFEX_H #include "./ITrigJetMonitorTool.h" #include "AsgDataHandles/ReadDecorHandleKey.h" #include "AthenaBaseComps/AthAlgTool.h" +#include "xAODTrigger/gFexJetRoIContainer.h" #include <string> ///////////////////////////////////////////////////////////////////////////// -// Header file for this templated AlgTool follows -// Control/AthenaExamples/AthExJobOptions/src/TemplatedTool.h -// extracts data from l1 jet containers. No monitoring code -// specifics here. - - -template<typename JetContainer> -class TrigL1FexJetMonitorTool : virtual public AthAlgTool, +class TrigL1FexJetMonitorTool_gFex : virtual public AthAlgTool, virtual public ITrigJetMonitorTool { public: - TrigL1FexJetMonitorTool(const std::string&, + using JetContainer = xAOD::gFexJetRoIContainer; + + TrigL1FexJetMonitorTool_gFex(const std::string&, const std::string&, const IInterface*); - // to allow access to the ITrigJetMonitorTool interface - virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvIf ) override; - // to resolve possible conflicts with IProperty::interfaceID() - static const InterfaceID& interfaceID() { - return ITrigJetMonitorTool::interfaceID();} - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; virtual StatusCode getData(const EventContext& ctx, @@ -138,8 +127,7 @@ private: this, "hltetaref", "hltetaref", "SG key for input matched etaref decoration"}; - }; -#include "./TrigL1FexJetMonitorTool.icc" -#endif // !TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_H +#endif + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool.icc b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexLR.cxx similarity index 86% rename from Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool.icc rename to Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexLR.cxx index a8e4478a2818a936e241971c59dd1e7da54c96ee..36b6fd90122b29bebdc0c0d5a94e8ad60b7b3a13 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool.icc +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexLR.cxx @@ -4,18 +4,17 @@ Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ -// #include "TrigL1FexJetMonitorTool.h" +#include "TrigL1FexJetMonitorTool_jFexLR.h" #include "AthenaMonitoring/AthMonitorAlgorithm.h" #include "AsgDataHandles/ReadDecorHandle.h" -#include "./vetoL1Jet.h" +#include "./L1MonitorAdaptors.h" #include <memory> ///////////////////////////////////////////////////////////////////////////// -template<typename JetContainer> -TrigL1FexJetMonitorTool<JetContainer>::TrigL1FexJetMonitorTool(const std::string& type, +TrigL1FexJetMonitorTool_jFexLR::TrigL1FexJetMonitorTool_jFexLR(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool( type, name, parent ) @@ -24,22 +23,9 @@ TrigL1FexJetMonitorTool<JetContainer>::TrigL1FexJetMonitorTool(const std::string } -//___________________________________________________________________________ -template<typename JetContainer> -StatusCode TrigL1FexJetMonitorTool<JetContainer>::queryInterface(const InterfaceID& riid, void** ppvIf ) -{ - if ( riid == ITrigJetMonitorTool::interfaceID() ) { - *ppvIf = (ITrigJetMonitorTool*)this; - addRef(); - return StatusCode::SUCCESS; - } - - return AthAlgTool::queryInterface( riid, ppvIf ); -} -//___________________________________________________________________________ -template<typename JetContainer> -StatusCode TrigL1FexJetMonitorTool<JetContainer>::initialize() + +StatusCode TrigL1FexJetMonitorTool_jFexLR::initialize() { ATH_CHECK(m_l1jetContainerkey.initialize()); @@ -142,35 +128,28 @@ StatusCode TrigL1FexJetMonitorTool<JetContainer>::initialize() ATH_CHECK(m_hltmassrespKey.initialize(false)); ATH_CHECK(m_hltptrefKey.initialize(false)); ATH_CHECK(m_hltetarefKey.initialize(false)); - } return StatusCode::SUCCESS; } -//___________________________________________________________________________ -template<typename JetContainer> -StatusCode TrigL1FexJetMonitorTool<JetContainer>::finalize() -{ - return StatusCode::SUCCESS; -} -//___________________________________________________________________________ -template<typename JetContainer> + StatusCode -TrigL1FexJetMonitorTool<JetContainer>::getData(const EventContext& ctx, +TrigL1FexJetMonitorTool_jFexLR::getData(const EventContext& ctx, std::vector<JetData>& jetData ) const{ + // Retrieve the L1 jet container SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); if( !jets.isValid() ){ // the L1 containers should _always_ be present, although may be empty. ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " - << m_l1jetContainerkey); + << m_l1jetContainerkey); return StatusCode::SUCCESS; } - + // find variables associated with jets in the input container. for(const auto& jet : *jets){ /* @@ -180,25 +159,25 @@ TrigL1FexJetMonitorTool<JetContainer>::getData(const EventContext& ctx, which is taken from the trigger menu. If the Et is below the threshold the TOB word is set to 0 */ - - if (vetoJet(jet)) {continue;} - - jetData.emplace_back(jet->et()*0.001, + + if (vetoJet(jet)) {continue;} // see L1MonitoredAdaptors + + jetData.emplace_back(et(jet)*0.001, // see L1MonitoredAdaptors jet->eta(), - jet->phi()); - + jet->phi(), + et_label(jet)); + } return StatusCode::SUCCESS; } -template<typename JetContainer> + + StatusCode -TrigL1FexJetMonitorTool<JetContainer>::getMatchData(const EventContext& ctx, - MatchToEnum matchTo, - std::vector<JetMatchData>& jetMatchData - ) const - -{ +TrigL1FexJetMonitorTool_jFexLR::getMatchData(const EventContext& ctx, + MatchToEnum matchTo, + std::vector<JetMatchData>& jetMatchData + ) const { if (!m_doMatching) { // otherwise will attempt to use uniniatialied Keys return StatusCode::SUCCESS; @@ -239,7 +218,7 @@ TrigL1FexJetMonitorTool<JetContainer>::getMatchData(const EventContext& ctx, ATH_MSG_ERROR ("unsupported MatchTo value"); return StatusCode::FAILURE; } - + ATH_CHECK((*matchedHandle).initialize()); ATH_CHECK((*ptdiffHandle).initialize()); ATH_CHECK((*energydiffHandle).initialize()); @@ -280,4 +259,4 @@ TrigL1FexJetMonitorTool<JetContainer>::getMatchData(const EventContext& ctx, return StatusCode::SUCCESS; } - + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexLR.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexLR.h new file mode 100644 index 0000000000000000000000000000000000000000..4227507b9858ce40617ed2a44662ecbf61ff2e46 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexLR.h @@ -0,0 +1,133 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_JFEXLR_H +#define TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_JFEXLR_H + +#include "./ITrigJetMonitorTool.h" +#include "AsgDataHandles/ReadDecorHandleKey.h" + +#include "AthenaBaseComps/AthAlgTool.h" +#include "xAODTrigger/jFexLRJetRoIContainer.h" + +#include <string> + +///////////////////////////////////////////////////////////////////////////// + +class TrigL1FexJetMonitorTool_jFexLR : virtual public AthAlgTool, + virtual public ITrigJetMonitorTool { + +public: + using JetContainer = xAOD::jFexLRJetRoIContainer; + + TrigL1FexJetMonitorTool_jFexLR(const std::string&, + const std::string&, + const IInterface*); + + virtual StatusCode initialize() override; + + virtual StatusCode + getData(const EventContext& ctx, + std::vector<JetData>& jetData) const override; + + virtual StatusCode + getMatchData(const EventContext& ctx, + MatchToEnum, + std::vector<JetMatchData>& jetData) const override; + +private: + + // initialisation using an initialise list ie {...} + // does not work - sommrthing to do with the template. + // intstead use declareProperty in the constructor. + SG::ReadHandleKey<JetContainer> m_l1jetContainerkey; + + // Variables to add matched histograms + Gaudi::Property<bool> m_doMatching { + this, "do_matching", false, + "Plotting response histograms for L1 jets matched to online/offline jets"}; + + Gaudi::Property<std::string> m_offlineJetContainerToMatch { + this, "offlineJetsToMatch", "", + "Name of matched offline jet collection"}; + + Gaudi::Property<std::string> m_HLTJetContainerToMatch { + this, "HLTJetsToMatch", "", "Name of matched HLT jet collection"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmatchedKey{ + this, "offmatched", "offmatched", "SG key for input matched decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptdiffKey{ + this, "offptdiff", "offptdiff", + "SG key for input matched ptdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offenergydiffKey{ + this, "offenergydiff", "offenergydiff", + "SG key for input matched energydiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmassdiffKey{ + this, "offmassdiff", "offmassdiff", + "SG key for input matched massdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptrespKey{ + this, "offptresp", "offptresp", + "SG key for input matched ptresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offenergyrespKey{ + this, "offenergyresp", "offenergyresp", + "SG key for input matched energyresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmassrespKey{ + this, "offmassresp", "offmassresp", + "SG key for input matched massresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptrefKey{ + this, "offptref", "offptref", + "SG key for input matched ptref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offetarefKey{ + this, "offetaref", "offetaref", + "SG key for input matched etaref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmatchedKey{ + this, "hltmatched", "hltmatched", "SG key for input matched decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptdiffKey{ + this, "hltptdiff", "hltptdiff", + "SG key for input matched ptdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltenergydiffKey{ + this, "hltenergydiff", "hltenergydiff", + "SG key for input matched energydiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmassdiffKey{ + this, "hltmassdiff", "hltmassdiff", + "SG key for input matched massdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptrespKey{ + this, "hltptresp", "hltptresp", + "SG key for input matched ptresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltenergyrespKey{ + this, "hltenergyresp", "hltenergyresp", + "SG key for input matched energyresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmassrespKey{ + this, "hltmassresp", "hltmassresp", + "SG key for input matched massresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptrefKey{ + this, "hltptref", "hltptref", + "SG key for input matched ptref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltetarefKey{ + this, "hltetaref", "hltetaref", + "SG key for input matched etaref decoration"}; + +}; + +#endif + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexSR.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexSR.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ac29e18f6ad9f2e2d11ab61248ce727405f72d83 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexSR.cxx @@ -0,0 +1,262 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigL1FexJetMonitorTool_jFexSR.h" +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "AsgDataHandles/ReadDecorHandle.h" + +#include "./L1MonitorAdaptors.h" +#include <memory> + + +///////////////////////////////////////////////////////////////////////////// + +TrigL1FexJetMonitorTool_jFexSR::TrigL1FexJetMonitorTool_jFexSR(const std::string& type, + const std::string& name, + const IInterface* parent) + : AthAlgTool( type, name, parent ) +{ + declareProperty("l1container", m_l1jetContainerkey); + +} + + + +StatusCode TrigL1FexJetMonitorTool_jFexSR::initialize() +{ + ATH_CHECK(m_l1jetContainerkey.initialize()); + + if (m_doMatching) { + m_offmatchedKey = + m_l1jetContainerkey.key() + ".matched_" + m_offlineJetContainerToMatch; + + m_offptdiffKey = + m_l1jetContainerkey.key() + ".ptdiff_" + m_offlineJetContainerToMatch; + + m_offenergydiffKey = + m_l1jetContainerkey.key() + ".energydiff_" + m_offlineJetContainerToMatch; + + m_offmassdiffKey = + m_l1jetContainerkey.key() + ".massdiff_" + m_offlineJetContainerToMatch; + + m_offptrespKey = + m_l1jetContainerkey.key() + ".ptresp_" + m_offlineJetContainerToMatch; + + m_offenergyrespKey = + m_l1jetContainerkey.key() + ".energyresp_" + m_offlineJetContainerToMatch; + + m_offmassrespKey = + m_l1jetContainerkey.key() + ".massresp_" + m_offlineJetContainerToMatch; + + m_offptrefKey = + m_l1jetContainerkey.key() + ".ptRef_" + m_offlineJetContainerToMatch; + + m_offetarefKey = + m_l1jetContainerkey.key() + ".etaRef_" + m_offlineJetContainerToMatch; + + ATH_CHECK(m_offmatchedKey.initialize() ); + ATH_CHECK(m_offptdiffKey.initialize() ); + ATH_CHECK(m_offenergydiffKey.initialize() ); + ATH_CHECK(m_offmassdiffKey.initialize() ); + ATH_CHECK(m_offptrespKey.initialize() ); + ATH_CHECK(m_offenergyrespKey.initialize() ); + ATH_CHECK(m_offmassrespKey.initialize() ); + ATH_CHECK(m_offptrefKey.initialize() ); + ATH_CHECK(m_offetarefKey.initialize() ); + + m_hltmatchedKey = + m_l1jetContainerkey.key() + ".matched_" + m_HLTJetContainerToMatch; + + m_hltptdiffKey = + m_l1jetContainerkey.key() + ".ptdiff_" + m_HLTJetContainerToMatch; + + m_hltenergydiffKey = + m_l1jetContainerkey.key() + ".energydiff_" + m_HLTJetContainerToMatch; + + m_hltmassdiffKey = + m_l1jetContainerkey.key() + ".massdiff_" + m_HLTJetContainerToMatch; + + m_hltptrespKey = + m_l1jetContainerkey.key() + ".ptresp_" + m_HLTJetContainerToMatch; + + m_hltenergyrespKey = + m_l1jetContainerkey.key() + ".energyresp_" + m_HLTJetContainerToMatch; + + m_hltmassrespKey = + m_l1jetContainerkey.key() + ".massresp_" + m_HLTJetContainerToMatch; + + m_hltptrefKey = + m_l1jetContainerkey.key() + ".ptRef_" + m_HLTJetContainerToMatch; + + m_hltetarefKey = + m_l1jetContainerkey.key() + ".etaRef_" + m_HLTJetContainerToMatch; + + ATH_CHECK(m_hltmatchedKey.initialize()); + ATH_CHECK(m_hltptdiffKey.initialize()); + ATH_CHECK(m_hltenergydiffKey.initialize()); + ATH_CHECK(m_hltmassdiffKey.initialize()); + ATH_CHECK(m_hltptrespKey.initialize()); + ATH_CHECK(m_hltenergyrespKey.initialize()); + ATH_CHECK(m_hltmassrespKey.initialize()); + ATH_CHECK(m_hltptrefKey.initialize()); + ATH_CHECK(m_hltetarefKey.initialize()); + + } else { + // declare the keys unused if no matching is configured + + // offline container matching + ATH_CHECK(m_offmatchedKey.initialize(false)); + ATH_CHECK(m_offptdiffKey.initialize(false)); + ATH_CHECK(m_offenergydiffKey.initialize(false)); + ATH_CHECK(m_offmassdiffKey.initialize(false)); + ATH_CHECK(m_offptrespKey.initialize(false)); + ATH_CHECK(m_offenergyrespKey.initialize(false)); + ATH_CHECK(m_offmassrespKey.initialize(false)); + ATH_CHECK(m_offptrefKey.initialize(false)); + ATH_CHECK(m_offetarefKey.initialize(false)); + + // trigger container matching + ATH_CHECK(m_hltmatchedKey.initialize(false)); + ATH_CHECK(m_hltptdiffKey.initialize(false)); + ATH_CHECK(m_hltenergydiffKey.initialize(false)); + ATH_CHECK(m_hltmassdiffKey.initialize(false)); + ATH_CHECK(m_hltptrespKey.initialize(false)); + ATH_CHECK(m_hltenergyrespKey.initialize(false)); + ATH_CHECK(m_hltmassrespKey.initialize(false)); + ATH_CHECK(m_hltptrefKey.initialize(false)); + ATH_CHECK(m_hltetarefKey.initialize(false)); + } + + return StatusCode::SUCCESS; +} + + + +StatusCode +TrigL1FexJetMonitorTool_jFexSR::getData(const EventContext& ctx, + std::vector<JetData>& jetData + ) const{ + + + // Retrieve the L1 jet container + SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); + if( !jets.isValid() ){ + // the L1 containers should _always_ be present, although may be empty. + ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " + << m_l1jetContainerkey); + return StatusCode::SUCCESS; + } + + // find variables associated with jets in the input container. + for(const auto& jet : *jets){ + /* + Ensure that the the et is above a hardware threshold: + From Sergi Rodriguez 23/02/2022 + in the bitwise simulation we also have an energy threshold, + which is taken from the trigger menu. + If the Et is below the threshold the TOB word is set to 0 + */ + + if (vetoJet(jet)) {continue;} // see L1MonitoredAdaptors + + jetData.emplace_back(et(jet)*0.001, // see L1MonitoredAdaptors + jet->eta(), + jet->phi(), + et_label(jet)); + + } + return StatusCode::SUCCESS; +} + + + +StatusCode +TrigL1FexJetMonitorTool_jFexSR::getMatchData(const EventContext& ctx, + MatchToEnum matchTo, + std::vector<JetMatchData>& jetMatchData + ) const { + if (!m_doMatching) { + // otherwise will attempt to use uniniatialied Keys + return StatusCode::SUCCESS; + } + + std::unique_ptr<SG::ReadDecorHandle<JetContainer, char>> matchedHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptdiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energydiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massdiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energyrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrefHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> etarefHandle; + + if (matchTo == MatchToEnum::hlt) { + + matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_hltmatchedKey, ctx)); + ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptdiffKey, ctx)); + energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergydiffKey, ctx)); + massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassdiffKey, ctx)); + ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrespKey, ctx)); + energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergyrespKey, ctx)); + massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassrespKey, ctx)); + ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrefKey, ctx)); + etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltetarefKey, ctx)); + } else if (matchTo == MatchToEnum::offline) { + matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_offmatchedKey, ctx)); + ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptdiffKey, ctx)); + energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergydiffKey, ctx)); + massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassdiffKey, ctx)); + ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrespKey, ctx)); + energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergyrespKey, ctx)); + massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassrespKey, ctx)); + ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrefKey, ctx)); + etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offetarefKey, ctx)); + } else { + ATH_MSG_ERROR ("unsupported MatchTo value"); + return StatusCode::FAILURE; + } + + ATH_CHECK((*matchedHandle).initialize()); + ATH_CHECK((*ptdiffHandle).initialize()); + ATH_CHECK((*energydiffHandle).initialize()); + ATH_CHECK((*massdiffHandle).initialize()); + ATH_CHECK((*ptrespHandle).initialize()); + ATH_CHECK((*energyrespHandle).initialize()); + ATH_CHECK((*massrespHandle).initialize()); + ATH_CHECK((*ptrefHandle).initialize()); + ATH_CHECK((*etarefHandle).initialize()); + + + // Loop over L1 jets and fill pt, energy, mass differences and responses + // between matched jets, plus reference pT and eta + + // Retrieve the L1 jet container + SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); + if(!jets.isValid()){ + // the L1 containers should _always_ be present, although may be empty. + ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " + << m_l1jetContainerkey); + return StatusCode::SUCCESS; + } + + for(const auto& jet : *jets){ + bool matched = (*matchedHandle)(*jet); + + if(matched){ + jetMatchData.emplace_back((*ptdiffHandle)(*jet), + (*energydiffHandle)(*jet), + (*massdiffHandle)(*jet), + (*ptrespHandle)(*jet), + (*energyrespHandle)(*jet), + (*massrespHandle)(*jet), + (*ptrefHandle)(*jet), + (*etarefHandle)(*jet)); + } + } + + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexSR.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexSR.h new file mode 100644 index 0000000000000000000000000000000000000000..a6c9eedb2147e26396137d95d66eeca0bf3bb4ef --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jFexSR.h @@ -0,0 +1,133 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_JFEXSR_H +#define TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_JFEXSR_H + +#include "./ITrigJetMonitorTool.h" +#include "AsgDataHandles/ReadDecorHandleKey.h" + +#include "AthenaBaseComps/AthAlgTool.h" +#include "xAODTrigger/jFexSRJetRoIContainer.h" + +#include <string> + +///////////////////////////////////////////////////////////////////////////// + +class TrigL1FexJetMonitorTool_jFexSR : virtual public AthAlgTool, + virtual public ITrigJetMonitorTool { + +public: + using JetContainer = xAOD::jFexSRJetRoIContainer; + + TrigL1FexJetMonitorTool_jFexSR(const std::string&, + const std::string&, + const IInterface*); + + virtual StatusCode initialize() override; + + virtual StatusCode + getData(const EventContext& ctx, + std::vector<JetData>& jetData) const override; + + virtual StatusCode + getMatchData(const EventContext& ctx, + MatchToEnum, + std::vector<JetMatchData>& jetData) const override; + +private: + + // initialisation using an initialise list ie {...} + // does not work - sommrthing to do with the template. + // intstead use declareProperty in the constructor. + SG::ReadHandleKey<JetContainer> m_l1jetContainerkey; + + // Variables to add matched histograms + Gaudi::Property<bool> m_doMatching { + this, "do_matching", false, + "Plotting response histograms for L1 jets matched to online/offline jets"}; + + Gaudi::Property<std::string> m_offlineJetContainerToMatch { + this, "offlineJetsToMatch", "", + "Name of matched offline jet collection"}; + + Gaudi::Property<std::string> m_HLTJetContainerToMatch { + this, "HLTJetsToMatch", "", "Name of matched HLT jet collection"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmatchedKey{ + this, "offmatched", "offmatched", "SG key for input matched decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptdiffKey{ + this, "offptdiff", "offptdiff", + "SG key for input matched ptdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offenergydiffKey{ + this, "offenergydiff", "offenergydiff", + "SG key for input matched energydiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmassdiffKey{ + this, "offmassdiff", "offmassdiff", + "SG key for input matched massdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptrespKey{ + this, "offptresp", "offptresp", + "SG key for input matched ptresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offenergyrespKey{ + this, "offenergyresp", "offenergyresp", + "SG key for input matched energyresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmassrespKey{ + this, "offmassresp", "offmassresp", + "SG key for input matched massresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptrefKey{ + this, "offptref", "offptref", + "SG key for input matched ptref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offetarefKey{ + this, "offetaref", "offetaref", + "SG key for input matched etaref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmatchedKey{ + this, "hltmatched", "hltmatched", "SG key for input matched decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptdiffKey{ + this, "hltptdiff", "hltptdiff", + "SG key for input matched ptdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltenergydiffKey{ + this, "hltenergydiff", "hltenergydiff", + "SG key for input matched energydiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmassdiffKey{ + this, "hltmassdiff", "hltmassdiff", + "SG key for input matched massdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptrespKey{ + this, "hltptresp", "hltptresp", + "SG key for input matched ptresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltenergyrespKey{ + this, "hltenergyresp", "hltenergyresp", + "SG key for input matched energyresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmassrespKey{ + this, "hltmassresp", "hltmassresp", + "SG key for input matched massresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptrefKey{ + this, "hltptref", "hltptref", + "SG key for input matched ptref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltetarefKey{ + this, "hltetaref", "hltetaref", + "SG key for input matched etaref decoration"}; + +}; + +#endif + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jetRoI.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jetRoI.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a696a35e07d845fa1679c57764a539febd5d0eb4 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jetRoI.cxx @@ -0,0 +1,262 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigL1FexJetMonitorTool_jetRoI.h" +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "AsgDataHandles/ReadDecorHandle.h" + +#include "./L1MonitorAdaptors.h" +#include <memory> + + +///////////////////////////////////////////////////////////////////////////// + +TrigL1FexJetMonitorTool_jetRoI::TrigL1FexJetMonitorTool_jetRoI(const std::string& type, + const std::string& name, + const IInterface* parent) + : AthAlgTool( type, name, parent ) +{ + declareProperty("l1container", m_l1jetContainerkey); + +} + + + +StatusCode TrigL1FexJetMonitorTool_jetRoI::initialize() +{ + ATH_CHECK(m_l1jetContainerkey.initialize()); + + if (m_doMatching) { + m_offmatchedKey = + m_l1jetContainerkey.key() + ".matched_" + m_offlineJetContainerToMatch; + + m_offptdiffKey = + m_l1jetContainerkey.key() + ".ptdiff_" + m_offlineJetContainerToMatch; + + m_offenergydiffKey = + m_l1jetContainerkey.key() + ".energydiff_" + m_offlineJetContainerToMatch; + + m_offmassdiffKey = + m_l1jetContainerkey.key() + ".massdiff_" + m_offlineJetContainerToMatch; + + m_offptrespKey = + m_l1jetContainerkey.key() + ".ptresp_" + m_offlineJetContainerToMatch; + + m_offenergyrespKey = + m_l1jetContainerkey.key() + ".energyresp_" + m_offlineJetContainerToMatch; + + m_offmassrespKey = + m_l1jetContainerkey.key() + ".massresp_" + m_offlineJetContainerToMatch; + + m_offptrefKey = + m_l1jetContainerkey.key() + ".ptRef_" + m_offlineJetContainerToMatch; + + m_offetarefKey = + m_l1jetContainerkey.key() + ".etaRef_" + m_offlineJetContainerToMatch; + + ATH_CHECK(m_offmatchedKey.initialize() ); + ATH_CHECK(m_offptdiffKey.initialize() ); + ATH_CHECK(m_offenergydiffKey.initialize() ); + ATH_CHECK(m_offmassdiffKey.initialize() ); + ATH_CHECK(m_offptrespKey.initialize() ); + ATH_CHECK(m_offenergyrespKey.initialize() ); + ATH_CHECK(m_offmassrespKey.initialize() ); + ATH_CHECK(m_offptrefKey.initialize() ); + ATH_CHECK(m_offetarefKey.initialize() ); + + m_hltmatchedKey = + m_l1jetContainerkey.key() + ".matched_" + m_HLTJetContainerToMatch; + + m_hltptdiffKey = + m_l1jetContainerkey.key() + ".ptdiff_" + m_HLTJetContainerToMatch; + + m_hltenergydiffKey = + m_l1jetContainerkey.key() + ".energydiff_" + m_HLTJetContainerToMatch; + + m_hltmassdiffKey = + m_l1jetContainerkey.key() + ".massdiff_" + m_HLTJetContainerToMatch; + + m_hltptrespKey = + m_l1jetContainerkey.key() + ".ptresp_" + m_HLTJetContainerToMatch; + + m_hltenergyrespKey = + m_l1jetContainerkey.key() + ".energyresp_" + m_HLTJetContainerToMatch; + + m_hltmassrespKey = + m_l1jetContainerkey.key() + ".massresp_" + m_HLTJetContainerToMatch; + + m_hltptrefKey = + m_l1jetContainerkey.key() + ".ptRef_" + m_HLTJetContainerToMatch; + + m_hltetarefKey = + m_l1jetContainerkey.key() + ".etaRef_" + m_HLTJetContainerToMatch; + + ATH_CHECK(m_hltmatchedKey.initialize()); + ATH_CHECK(m_hltptdiffKey.initialize()); + ATH_CHECK(m_hltenergydiffKey.initialize()); + ATH_CHECK(m_hltmassdiffKey.initialize()); + ATH_CHECK(m_hltptrespKey.initialize()); + ATH_CHECK(m_hltenergyrespKey.initialize()); + ATH_CHECK(m_hltmassrespKey.initialize()); + ATH_CHECK(m_hltptrefKey.initialize()); + ATH_CHECK(m_hltetarefKey.initialize()); + + } else { + // declare the keys unused if no matching is configured + + // offline container matching + ATH_CHECK(m_offmatchedKey.initialize(false)); + ATH_CHECK(m_offptdiffKey.initialize(false)); + ATH_CHECK(m_offenergydiffKey.initialize(false)); + ATH_CHECK(m_offmassdiffKey.initialize(false)); + ATH_CHECK(m_offptrespKey.initialize(false)); + ATH_CHECK(m_offenergyrespKey.initialize(false)); + ATH_CHECK(m_offmassrespKey.initialize(false)); + ATH_CHECK(m_offptrefKey.initialize(false)); + ATH_CHECK(m_offetarefKey.initialize(false)); + + // trigger container matching + ATH_CHECK(m_hltmatchedKey.initialize(false)); + ATH_CHECK(m_hltptdiffKey.initialize(false)); + ATH_CHECK(m_hltenergydiffKey.initialize(false)); + ATH_CHECK(m_hltmassdiffKey.initialize(false)); + ATH_CHECK(m_hltptrespKey.initialize(false)); + ATH_CHECK(m_hltenergyrespKey.initialize(false)); + ATH_CHECK(m_hltmassrespKey.initialize(false)); + ATH_CHECK(m_hltptrefKey.initialize(false)); + ATH_CHECK(m_hltetarefKey.initialize(false)); + } + + return StatusCode::SUCCESS; +} + + + +StatusCode +TrigL1FexJetMonitorTool_jetRoI::getData(const EventContext& ctx, + std::vector<JetData>& jetData + ) const{ + + + // Retrieve the L1 jet container + SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); + if( !jets.isValid() ){ + // the L1 containers should _always_ be present, although may be empty. + ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " + << m_l1jetContainerkey); + return StatusCode::SUCCESS; + } + + // find variables associated with jets in the input container. + for(const auto& jet : *jets){ + /* + Ensure that the the et is above a hardware threshold: + From Sergi Rodriguez 23/02/2022 + in the bitwise simulation we also have an energy threshold, + which is taken from the trigger menu. + If the Et is below the threshold the TOB word is set to 0 + */ + + if (vetoJet(jet)) {continue;} // see L1MonitoredAdaptors + + jetData.emplace_back(et(jet)*0.001, // see L1MonitoredAdaptors + jet->eta(), + jet->phi(), + et_label(jet)); + + } + return StatusCode::SUCCESS; +} + + + +StatusCode +TrigL1FexJetMonitorTool_jetRoI::getMatchData(const EventContext& ctx, + MatchToEnum matchTo, + std::vector<JetMatchData>& jetMatchData + ) const { + if (!m_doMatching) { + // otherwise will attempt to use uniniatialied Keys + return StatusCode::SUCCESS; + } + + std::unique_ptr<SG::ReadDecorHandle<JetContainer, char>> matchedHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptdiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energydiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massdiffHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energyrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massrespHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrefHandle; + std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> etarefHandle; + + if (matchTo == MatchToEnum::hlt) { + + matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_hltmatchedKey, ctx)); + ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptdiffKey, ctx)); + energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergydiffKey, ctx)); + massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassdiffKey, ctx)); + ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrespKey, ctx)); + energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergyrespKey, ctx)); + massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassrespKey, ctx)); + ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrefKey, ctx)); + etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltetarefKey, ctx)); + } else if (matchTo == MatchToEnum::offline) { + matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_offmatchedKey, ctx)); + ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptdiffKey, ctx)); + energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergydiffKey, ctx)); + massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassdiffKey, ctx)); + ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrespKey, ctx)); + energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergyrespKey, ctx)); + massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassrespKey, ctx)); + ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrefKey, ctx)); + etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offetarefKey, ctx)); + } else { + ATH_MSG_ERROR ("unsupported MatchTo value"); + return StatusCode::FAILURE; + } + + ATH_CHECK((*matchedHandle).initialize()); + ATH_CHECK((*ptdiffHandle).initialize()); + ATH_CHECK((*energydiffHandle).initialize()); + ATH_CHECK((*massdiffHandle).initialize()); + ATH_CHECK((*ptrespHandle).initialize()); + ATH_CHECK((*energyrespHandle).initialize()); + ATH_CHECK((*massrespHandle).initialize()); + ATH_CHECK((*ptrefHandle).initialize()); + ATH_CHECK((*etarefHandle).initialize()); + + + // Loop over L1 jets and fill pt, energy, mass differences and responses + // between matched jets, plus reference pT and eta + + // Retrieve the L1 jet container + SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx); + if(!jets.isValid()){ + // the L1 containers should _always_ be present, although may be empty. + ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " + << m_l1jetContainerkey); + return StatusCode::SUCCESS; + } + + for(const auto& jet : *jets){ + bool matched = (*matchedHandle)(*jet); + + if(matched){ + jetMatchData.emplace_back((*ptdiffHandle)(*jet), + (*energydiffHandle)(*jet), + (*massdiffHandle)(*jet), + (*ptrespHandle)(*jet), + (*energyrespHandle)(*jet), + (*massrespHandle)(*jet), + (*ptrefHandle)(*jet), + (*etarefHandle)(*jet)); + } + } + + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jetRoI.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jetRoI.h new file mode 100644 index 0000000000000000000000000000000000000000..bce0d9a55ba59caf4bd8b65a28badbf65089ab57 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorTool_jetRoI.h @@ -0,0 +1,133 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_JETROI_H +#define TRIGJETMONITORING_TRIGL1JETFEXMONITORTOOL_JETROI_H + +#include "./ITrigJetMonitorTool.h" +#include "AsgDataHandles/ReadDecorHandleKey.h" + +#include "AthenaBaseComps/AthAlgTool.h" +#include "xAODTrigger/JetRoIContainer.h" + +#include <string> + +///////////////////////////////////////////////////////////////////////////// + +class TrigL1FexJetMonitorTool_jetRoI : virtual public AthAlgTool, + virtual public ITrigJetMonitorTool { + +public: + using JetContainer = xAOD::JetRoIContainer; + + TrigL1FexJetMonitorTool_jetRoI(const std::string&, + const std::string&, + const IInterface*); + + virtual StatusCode initialize() override; + + virtual StatusCode + getData(const EventContext& ctx, + std::vector<JetData>& jetData) const override; + + virtual StatusCode + getMatchData(const EventContext& ctx, + MatchToEnum, + std::vector<JetMatchData>& jetData) const override; + +private: + + // initialisation using an initialise list ie {...} + // does not work - sommrthing to do with the template. + // intstead use declareProperty in the constructor. + SG::ReadHandleKey<JetContainer> m_l1jetContainerkey; + + // Variables to add matched histograms + Gaudi::Property<bool> m_doMatching { + this, "do_matching", false, + "Plotting response histograms for L1 jets matched to online/offline jets"}; + + Gaudi::Property<std::string> m_offlineJetContainerToMatch { + this, "offlineJetsToMatch", "", + "Name of matched offline jet collection"}; + + Gaudi::Property<std::string> m_HLTJetContainerToMatch { + this, "HLTJetsToMatch", "", "Name of matched HLT jet collection"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmatchedKey{ + this, "offmatched", "offmatched", "SG key for input matched decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptdiffKey{ + this, "offptdiff", "offptdiff", + "SG key for input matched ptdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offenergydiffKey{ + this, "offenergydiff", "offenergydiff", + "SG key for input matched energydiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmassdiffKey{ + this, "offmassdiff", "offmassdiff", + "SG key for input matched massdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptrespKey{ + this, "offptresp", "offptresp", + "SG key for input matched ptresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offenergyrespKey{ + this, "offenergyresp", "offenergyresp", + "SG key for input matched energyresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offmassrespKey{ + this, "offmassresp", "offmassresp", + "SG key for input matched massresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offptrefKey{ + this, "offptref", "offptref", + "SG key for input matched ptref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_offetarefKey{ + this, "offetaref", "offetaref", + "SG key for input matched etaref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmatchedKey{ + this, "hltmatched", "hltmatched", "SG key for input matched decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptdiffKey{ + this, "hltptdiff", "hltptdiff", + "SG key for input matched ptdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltenergydiffKey{ + this, "hltenergydiff", "hltenergydiff", + "SG key for input matched energydiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmassdiffKey{ + this, "hltmassdiff", "hltmassdiff", + "SG key for input matched massdiff decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptrespKey{ + this, "hltptresp", "hltptresp", + "SG key for input matched ptresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltenergyrespKey{ + this, "hltenergyresp", "hltenergyresp", + "SG key for input matched energyresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltmassrespKey{ + this, "hltmassresp", "hltmassresp", + "SG key for input matched massresp decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltptrefKey{ + this, "hltptref", "hltptref", + "SG key for input matched ptref decoration"}; + + SG::ReadDecorHandleKey<JetContainer> m_hltetarefKey{ + this, "hltetaref", "hltetaref", + "SG key for input matched etaref decoration"}; + +}; + +#endif + diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JFexSRJetMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JFexSRJetMonitorAlgorithm.cxx deleted file mode 100644 index cfe5d8afe1b5f7d0680f3f47103483cd75d975f9..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JFexSRJetMonitorAlgorithm.cxx +++ /dev/null @@ -1,233 +0,0 @@ -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ - -#include "TrigL1JFexSRJetMonitorAlgorithm.h" -#include "AsgDataHandles/ReadDecorHandle.h" - -TrigL1JFexSRJetMonitorAlgorithm::TrigL1JFexSRJetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) - : AthMonitorAlgorithm(name,pSvcLocator) -{ - declareProperty("L1JetContainer", m_l1jetContainerkey = "L1_jFexSRJetRoI"); -} - -TrigL1JFexSRJetMonitorAlgorithm::~TrigL1JFexSRJetMonitorAlgorithm() {} - - - -StatusCode TrigL1JFexSRJetMonitorAlgorithm::initialize() { - - ATH_CHECK(m_l1jetContainerkey.initialize()); - - if (m_isMatched) { - m_offmatchedKey = m_l1jetContainerkey.key() + ".matched_" + m_matchedOfflineJetContainer; - m_offptdiffKey = m_l1jetContainerkey.key() + ".ptdiff_" + m_matchedOfflineJetContainer; - m_offenergydiffKey = m_l1jetContainerkey.key() + ".energydiff_" + m_matchedOfflineJetContainer; - m_offmassdiffKey = m_l1jetContainerkey.key() + ".massdiff_" + m_matchedOfflineJetContainer; - m_offptrespKey = m_l1jetContainerkey.key() + ".ptresp_" + m_matchedOfflineJetContainer; - m_offenergyrespKey = m_l1jetContainerkey.key() + ".energyresp_" + m_matchedOfflineJetContainer; - m_offmassrespKey = m_l1jetContainerkey.key() + ".massresp_" + m_matchedOfflineJetContainer; - m_offptrefKey = m_l1jetContainerkey.key() + ".ptRef_" + m_matchedOfflineJetContainer; - m_offetarefKey = m_l1jetContainerkey.key() + ".etaRef_" + m_matchedOfflineJetContainer; - - ATH_CHECK( m_offmatchedKey.initialize() ); - ATH_CHECK( m_offptdiffKey.initialize() ); - ATH_CHECK( m_offenergydiffKey.initialize() ); - ATH_CHECK( m_offmassdiffKey.initialize() ); - ATH_CHECK( m_offptrespKey.initialize() ); - ATH_CHECK( m_offenergyrespKey.initialize() ); - ATH_CHECK( m_offmassrespKey.initialize() ); - ATH_CHECK( m_offptrefKey.initialize() ); - ATH_CHECK( m_offetarefKey.initialize() ); - - m_hltmatchedKey = m_l1jetContainerkey.key() + ".matched_" + m_matchedHLTJetContainer; - m_hltptdiffKey = m_l1jetContainerkey.key() + ".ptdiff_" + m_matchedHLTJetContainer; - m_hltenergydiffKey = m_l1jetContainerkey.key() + ".energydiff_" + m_matchedHLTJetContainer; - m_hltmassdiffKey = m_l1jetContainerkey.key() + ".massdiff_" + m_matchedHLTJetContainer; - m_hltptrespKey = m_l1jetContainerkey.key() + ".ptresp_" + m_matchedHLTJetContainer; - m_hltenergyrespKey = m_l1jetContainerkey.key() + ".energyresp_" + m_matchedHLTJetContainer; - m_hltmassrespKey = m_l1jetContainerkey.key() + ".massresp_" + m_matchedHLTJetContainer; - m_hltptrefKey = m_l1jetContainerkey.key() + ".ptRef_" + m_matchedHLTJetContainer; - m_hltetarefKey = m_l1jetContainerkey.key() + ".etaRef_" + m_matchedHLTJetContainer; - - ATH_CHECK( m_hltmatchedKey.initialize()); - ATH_CHECK( m_hltptdiffKey.initialize()); - ATH_CHECK( m_hltenergydiffKey.initialize()); - ATH_CHECK( m_hltmassdiffKey.initialize()); - ATH_CHECK( m_hltptrespKey.initialize()); - ATH_CHECK( m_hltenergyrespKey.initialize()); - ATH_CHECK( m_hltmassrespKey.initialize()); - ATH_CHECK( m_hltptrefKey.initialize()); - ATH_CHECK( m_hltetarefKey.initialize()); - - - ATH_MSG_INFO("Match hists " << m_l1jetContainerkey.key() << " hlt: " << m_matchedHLTJetContainer - << " offline: " << m_matchedOfflineJetContainer); - - } else { - // declare the keys unused if no matching is configured - - // offline container matching - ATH_CHECK(m_offmatchedKey.initialize(false)); - ATH_CHECK( m_offptdiffKey.initialize(false)); - ATH_CHECK( m_offenergydiffKey.initialize(false)); - ATH_CHECK( m_offmassdiffKey.initialize(false)); - ATH_CHECK( m_offptrespKey.initialize(false)); - ATH_CHECK( m_offenergyrespKey.initialize(false)); - ATH_CHECK( m_offmassrespKey.initialize(false)); - ATH_CHECK( m_offptrefKey.initialize(false)); - ATH_CHECK( m_offetarefKey.initialize(false)); - - // trigger container matching - ATH_CHECK( m_hltmatchedKey.initialize(false)); - ATH_CHECK( m_hltptdiffKey.initialize(false)); - ATH_CHECK( m_hltenergydiffKey.initialize(false)); - ATH_CHECK( m_hltmassdiffKey.initialize(false)); - ATH_CHECK( m_hltptrespKey.initialize(false)); - ATH_CHECK( m_hltenergyrespKey.initialize(false)); - ATH_CHECK( m_hltmassrespKey.initialize(false)); - ATH_CHECK( m_hltptrefKey.initialize(false)); - ATH_CHECK( m_hltetarefKey.initialize(false)); - - ATH_MSG_INFO("No Match hists "); - - } - - - return AthMonitorAlgorithm::initialize(); -} - - -void TrigL1JFexSRJetMonitorAlgorithm::fillMatchedHistograms(const xAOD::jFexSRJetRoIContainer & jets, const EventContext& ctx) const { - - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, char> offmatchedHandle(m_offmatchedKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offptdiffHandle(m_offptdiffKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offenergydiffHandle(m_offenergydiffKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offmassdiffHandle(m_offmassdiffKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offptrespHandle(m_offptrespKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offenergyrespHandle(m_offenergyrespKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offmassrespHandle(m_offmassrespKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offptrefHandle(m_offptrefKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> offetarefHandle(m_offetarefKey, ctx); - - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, char> hltmatchedHandle(m_hltmatchedKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltptdiffHandle(m_hltptdiffKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltenergydiffHandle(m_hltenergydiffKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltmassdiffHandle(m_hltmassdiffKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltptrespHandle(m_hltptrespKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltenergyrespHandle(m_hltenergyrespKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltmassrespHandle(m_hltmassrespKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltptrefHandle(m_hltptrefKey, ctx); - SG::ReadDecorHandle<xAOD::jFexSRJetRoIContainer, double> hltetarefHandle(m_hltetarefKey, ctx); - - auto offmatched = Monitored::Collection("offmatched", jets, [offmatchedHandle](const xAOD::jFexSRJetRoI * jet) {return offmatchedHandle(*jet);}); - auto offdPt = Monitored::Scalar("offptdiff",0.0); - auto offdEnergy = Monitored::Scalar("offenergydiff",0.0); - auto offdMass = Monitored::Scalar("offmassdiff",0.0); - auto offrPt = Monitored::Scalar("offptresp",0.0); - auto offrEnergy = Monitored::Scalar("offenergyresp",0.0); - auto offrMass = Monitored::Scalar("offmassresp",0.0); - auto offptRef = Monitored::Scalar("offptref",0.0); - auto offetaRef = Monitored::Scalar("offetaref",0.0); - - auto hltmatched = Monitored::Collection("hltmatched", jets, [hltmatchedHandle](const xAOD::jFexSRJetRoI * jet) {return hltmatchedHandle(*jet);}); - auto hltdPt = Monitored::Scalar("hltptdiff",0.0); - auto hltdEnergy = Monitored::Scalar("hltenergydiff",0.0); - auto hltdMass = Monitored::Scalar("hltmassdiff",0.0); - auto hltrPt = Monitored::Scalar("hltptresp",0.0); - auto hltrEnergy = Monitored::Scalar("hltenergyresp",0.0); - auto hltrMass = Monitored::Scalar("hltmassresp",0.0); - auto hltptRef = Monitored::Scalar("hltptref",0.0); - auto hltetaRef = Monitored::Scalar("hltetaref",0.0); - - // Loop over L1 jets and fill pt, energy, mass differences and responses between matched jets, plus reference pT and eta - auto tool = getGroup("TrigL1JFexSRJetMonitor"); - for(const xAOD::jFexSRJetRoI* jet : jets){ - bool offmatched = offmatchedHandle(*jet); - bool hltmatched = hltmatchedHandle(*jet); - if(offmatched){ - - offdPt = offptdiffHandle(*jet); - offdEnergy = offenergydiffHandle(*jet); - offdMass = offmassdiffHandle(*jet); - offrPt = offptrespHandle(*jet); - offrEnergy = offenergyrespHandle(*jet); - offrMass = offmassrespHandle(*jet); - offptRef = offptrefHandle(*jet); - offetaRef = offetarefHandle(*jet); - fill(tool, offdPt, offdEnergy, offdMass, offrPt, offrEnergy, offrMass, offptRef, offetaRef); - } - if(hltmatched){ - hltdPt = hltptdiffHandle(*jet); - hltdEnergy = hltenergydiffHandle(*jet); - hltdMass = hltmassdiffHandle(*jet); - hltrPt = hltptrespHandle(*jet); - hltrEnergy = hltenergyrespHandle(*jet); - hltrMass = hltmassrespHandle(*jet); - hltptRef = hltptrefHandle(*jet); - hltetaRef = hltetarefHandle(*jet); - fill(tool, hltdPt, hltdEnergy, hltdMass, hltrPt, hltrEnergy, hltrMass, hltptRef, hltetaRef); - } - } - fill(tool,offmatched); - fill(tool,hltmatched); - - return; -} - -StatusCode TrigL1JFexSRJetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const { - - std::stringstream ss; - - using namespace Monitored; - - // Retrieve the L1 jet container - SG::ReadHandle<xAOD::jFexSRJetRoIContainer> jets(m_l1jetContainerkey, ctx); - if( !jets.isValid() ){ - ATH_MSG_INFO("evtStore() does not contain the L1 jet collection with name " << m_l1jetContainerkey); - return StatusCode::SUCCESS; - } - - - // Declare the quantities which should be monitored - auto et = Monitored::Scalar<float>("et"); - auto eta = Monitored::Scalar<float>("eta"); - auto phi = Monitored::Scalar<float>("phi"); - - - // Loop over jets - - for(const auto j : *jets){ - - //Set the values of the monitored variables for the event - - /* - Ensure that the the et is above a hardware threshold: - From Sergi Rodriguez 23/02/2022 - in the bitwise simulation we also have an energy threshold, which is taken from the trigger menu. - If the Et is below the threshold the TOB word is set to 0 - */ - - if (j->tobWord() == 0) {continue;} - - et = j->et()*0.001; - eta = j->eta(); - phi = j->phi(); - // Fill. First argument is the tool (GMT) name as defined in TrigJetMonitorAlgorithm.py, - // all others are the variables to be saved. - auto tool = getGroup("TrigL1JFexSRJetMonitor"); - fill(tool,et,eta,phi); - } - // Adding histograms for L1 jets matched to offline/online jets - - if (m_isMatched) { - // turn SG::ReadHandle<xAOD::jFexSRJetRoIContainer> into xAOD::jFexSRJetRoIContainer to be able to use Monitored::Collection on the L1 jet collection - ConstDataVector< xAOD::jFexSRJetRoIContainer > tmpCont(SG::VIEW_ELEMENTS); - for(const xAOD::jFexSRJetRoI* l1jet : *jets ) tmpCont.push_back(l1jet); - const xAOD::jFexSRJetRoIContainer *l1JetContainer = tmpCont.asDataVector(); - fillMatchedHistograms(*l1JetContainer, ctx); - } - - return StatusCode::SUCCESS; -} - diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JFexSRJetMonitorAlgorithm.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JFexSRJetMonitorAlgorithm.h deleted file mode 100644 index dd997998e2ef9050aff98abbe6c947a9f0cb590d..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JFexSRJetMonitorAlgorithm.h +++ /dev/null @@ -1,57 +0,0 @@ - -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGJETMONITORING_TRIGL1JFEXSRJETMONITORALGORITHM_H -#define TRIGJETMONITORING_TRIGL1JFEXSRJETMONITORALGORITHM_H - -#include "AthenaMonitoring/AthMonitorAlgorithm.h" -#include "AthenaMonitoringKernel/Monitored.h" -#include "xAODTrigger/jFexSRJetRoIContainer.h" -#include "AsgDataHandles/ReadDecorHandleKey.h" - -class TrigL1JFexSRJetMonitorAlgorithm : public AthMonitorAlgorithm { - public: - TrigL1JFexSRJetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~TrigL1JFexSRJetMonitorAlgorithm(); - virtual StatusCode initialize() override; - - virtual StatusCode fillHistograms( const EventContext& ctx ) const override; - - // private: - // Name of the L1 jet collection to be monitored - SG::ReadHandleKey<xAOD::jFexSRJetRoIContainer> m_l1jetContainerkey; - - // Variables to add matched histograms - Gaudi::Property<bool> m_isMatched {this, "IsMatched", true, "Plotting response histograms for L1 jets matched to online/offline jets"}; - - Gaudi::Property<std::string> m_matchedOfflineJetContainer {this, "MatchedOfflineJets", "", "Name of matched offline jet collection"}; - Gaudi::Property<std::string> m_matchedHLTJetContainer {this, "MatchedHLTJets", "", "Name of matched HLT jet collection"}; - - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offmatchedKey{this, "offmatched", "offmatched", "SG key for input matched decoration"}; - - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offptdiffKey{this, "offptdiff", "offptdiff", "SG key for input matched ptdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offenergydiffKey{this, "offenergydiff", "offenergydiff", "SG key for input matched energydiff decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offmassdiffKey{this, "offmassdiff", "offmassdiff", "SG key for input matched massdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offptrespKey{this, "offptresp", "offptresp", "SG key for input matched ptresp decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offenergyrespKey{this, "offenergyresp", "offenergyresp", "SG key for input matched energyresp decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offmassrespKey{this, "offmassresp", "offmassresp", "SG key for input matched massresp decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offptrefKey{this, "offptref", "offptref", "SG key for input matched ptref decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_offetarefKey{this, "offetaref", "offetaref", "SG key for input matched etaref decoration"}; - - - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltmatchedKey{this, "hltmatched", "hltmatched", "SG key for input matched decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltptdiffKey{this, "hltptdiff", "hltptdiff", "SG key for input matched ptdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltenergydiffKey{this, "hltenergydiff", "hltenergydiff", "SG key for input matched energydiff decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltmassdiffKey{this, "hltmassdiff", "hltmassdiff", "SG key for input matched massdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltptrespKey{this, "hltptresp", "hltptresp", "SG key for input matched ptresp decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltenergyrespKey{this, "hltenergyresp", "hltenergyresp", "SG key for input matched energyresp decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltmassrespKey{this, "hltmassresp", "hltmassresp", "SG key for input matched massresp decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltptrefKey{this, "hltptref", "hltptref", "SG key for input matched ptref decoration"}; - SG::ReadDecorHandleKey<xAOD::jFexSRJetRoIContainer> m_hltetarefKey{this, "hltetaref", "hltetaref", "SG key for input matched etaref decoration"}; - - void fillMatchedHistograms(const xAOD::jFexSRJetRoIContainer & jets, const EventContext& ctx) const ; - -}; -#endif diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JetMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JetMonitorAlgorithm.cxx deleted file mode 100644 index 783717088c76220f29f01d2ab97939ce63110645..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JetMonitorAlgorithm.cxx +++ /dev/null @@ -1,174 +0,0 @@ -/* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration -*/ - -#include "TrigL1JetMonitorAlgorithm.h" -#include "AsgDataHandles/ReadDecorHandle.h" - -TrigL1JetMonitorAlgorithm::TrigL1JetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) - : AthMonitorAlgorithm(name,pSvcLocator) -{ - declareProperty("L1JetContainer", m_l1jetContainerkey = "LVL1JetRoIs"); -} - -TrigL1JetMonitorAlgorithm::~TrigL1JetMonitorAlgorithm() {} - -StatusCode TrigL1JetMonitorAlgorithm::initialize() { - ATH_CHECK(m_l1jetContainerkey.initialize()); - if (m_isMatched) { - m_offmatchedKey = m_l1jetContainerkey.key() + ".matched_" + m_matchedOfflineJetContainer; - m_offptdiffKey = m_l1jetContainerkey.key() + ".ptdiff_" + m_matchedOfflineJetContainer; - m_offenergydiffKey = m_l1jetContainerkey.key() + ".energydiff_" + m_matchedOfflineJetContainer; - m_offmassdiffKey = m_l1jetContainerkey.key() + ".massdiff_" + m_matchedOfflineJetContainer; - m_offptrespKey = m_l1jetContainerkey.key() + ".ptresp_" + m_matchedOfflineJetContainer; - m_offenergyrespKey = m_l1jetContainerkey.key() + ".energyresp_" + m_matchedOfflineJetContainer; - m_offmassrespKey = m_l1jetContainerkey.key() + ".massresp_" + m_matchedOfflineJetContainer; - m_offptrefKey = m_l1jetContainerkey.key() + ".ptRef_" + m_matchedOfflineJetContainer; - m_offetarefKey = m_l1jetContainerkey.key() + ".etaRef_" + m_matchedOfflineJetContainer; - - m_hltmatchedKey = m_l1jetContainerkey.key() + ".matched_" + m_matchedHLTJetContainer; - m_hltptdiffKey = m_l1jetContainerkey.key() + ".ptdiff_" + m_matchedHLTJetContainer; - m_hltenergydiffKey = m_l1jetContainerkey.key() + ".energydiff_" + m_matchedHLTJetContainer; - m_hltmassdiffKey = m_l1jetContainerkey.key() + ".massdiff_" + m_matchedHLTJetContainer; - m_hltptrespKey = m_l1jetContainerkey.key() + ".ptresp_" + m_matchedHLTJetContainer; - m_hltenergyrespKey = m_l1jetContainerkey.key() + ".energyresp_" + m_matchedHLTJetContainer; - m_hltmassrespKey = m_l1jetContainerkey.key() + ".massresp_" + m_matchedHLTJetContainer; - m_hltptrefKey = m_l1jetContainerkey.key() + ".ptRef_" + m_matchedHLTJetContainer; - m_hltetarefKey = m_l1jetContainerkey.key() + ".etaRef_" + m_matchedHLTJetContainer; - } - ATH_CHECK( m_offmatchedKey.initialize(m_isMatched) ); - ATH_CHECK( m_offptdiffKey.initialize(m_isMatched) ); - ATH_CHECK( m_offenergydiffKey.initialize(m_isMatched) ); - ATH_CHECK( m_offmassdiffKey.initialize(m_isMatched) ); - ATH_CHECK( m_offptrespKey.initialize(m_isMatched) ); - ATH_CHECK( m_offenergyrespKey.initialize(m_isMatched) ); - ATH_CHECK( m_offmassrespKey.initialize(m_isMatched) ); - ATH_CHECK( m_offptrefKey.initialize(m_isMatched) ); - ATH_CHECK( m_offetarefKey.initialize(m_isMatched) ); - - ATH_CHECK( m_hltmatchedKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltptdiffKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltenergydiffKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltmassdiffKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltptrespKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltenergyrespKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltmassrespKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltptrefKey.initialize(m_isMatched) ); - ATH_CHECK( m_hltetarefKey.initialize(m_isMatched) ); - - return AthMonitorAlgorithm::initialize(); -} - -void TrigL1JetMonitorAlgorithm::fillMatchedHistograms(const xAOD::JetRoIContainer & jets, const EventContext& ctx) const { - - SG::ReadDecorHandle<xAOD::JetRoIContainer, char> offmatchedHandle(m_offmatchedKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offptdiffHandle(m_offptdiffKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offenergydiffHandle(m_offenergydiffKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offmassdiffHandle(m_offmassdiffKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offptrespHandle(m_offptrespKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offenergyrespHandle(m_offenergyrespKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offmassrespHandle(m_offmassrespKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offptrefHandle(m_offptrefKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> offetarefHandle(m_offetarefKey, ctx); - - SG::ReadDecorHandle<xAOD::JetRoIContainer, char> hltmatchedHandle(m_hltmatchedKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltptdiffHandle(m_hltptdiffKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltenergydiffHandle(m_hltenergydiffKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltmassdiffHandle(m_hltmassdiffKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltptrespHandle(m_hltptrespKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltenergyrespHandle(m_hltenergyrespKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltmassrespHandle(m_hltmassrespKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltptrefHandle(m_hltptrefKey, ctx); - SG::ReadDecorHandle<xAOD::JetRoIContainer, double> hltetarefHandle(m_hltetarefKey, ctx); - - auto offmatched = Monitored::Collection("offmatched", jets, [offmatchedHandle](const xAOD::JetRoI * jet) {return offmatchedHandle(*jet);}); - auto offdPt = Monitored::Scalar("offptdiff",0.0); - auto offdEnergy = Monitored::Scalar("offenergydiff",0.0); - auto offdMass = Monitored::Scalar("offmassdiff",0.0); - auto offrPt = Monitored::Scalar("offptresp",0.0); - auto offrEnergy = Monitored::Scalar("offenergyresp",0.0); - auto offrMass = Monitored::Scalar("offmassresp",0.0); - auto offptRef = Monitored::Scalar("offptref",0.0); - auto offetaRef = Monitored::Scalar("offetaref",0.0); - - auto hltmatched = Monitored::Collection("hltmatched", jets, [hltmatchedHandle](const xAOD::JetRoI * jet) {return hltmatchedHandle(*jet);}); - auto hltdPt = Monitored::Scalar("hltptdiff",0.0); - auto hltdEnergy = Monitored::Scalar("hltenergydiff",0.0); - auto hltdMass = Monitored::Scalar("hltmassdiff",0.0); - auto hltrPt = Monitored::Scalar("hltptresp",0.0); - auto hltrEnergy = Monitored::Scalar("hltenergyresp",0.0); - auto hltrMass = Monitored::Scalar("hltmassresp",0.0); - auto hltptRef = Monitored::Scalar("hltptref",0.0); - auto hltetaRef = Monitored::Scalar("hltetaref",0.0); - - // Loop over L1 jets and fill pt, energy, mass differences and responses between matched jets, plus reference pT and eta - auto tool = getGroup("TrigL1JetMonitor"); - for(const xAOD::JetRoI* jet : jets){ - bool offmatched = offmatchedHandle(*jet); - bool hltmatched = hltmatchedHandle(*jet); - if(offmatched){ - offdPt = offptdiffHandle(*jet); - offdEnergy = offenergydiffHandle(*jet); - offdMass = offmassdiffHandle(*jet); - offrPt = offptrespHandle(*jet); - offrEnergy = offenergyrespHandle(*jet); - offrMass = offmassrespHandle(*jet); - offptRef = offptrefHandle(*jet); - offetaRef = offetarefHandle(*jet); - fill(tool, offdPt, offdEnergy, offdMass, offrPt, offrEnergy, offrMass, offptRef, offetaRef); - } - if(hltmatched){ - hltdPt = hltptdiffHandle(*jet); - hltdEnergy = hltenergydiffHandle(*jet); - hltdMass = hltmassdiffHandle(*jet); - hltrPt = hltptrespHandle(*jet); - hltrEnergy = hltenergyrespHandle(*jet); - hltrMass = hltmassrespHandle(*jet); - hltptRef = hltptrefHandle(*jet); - hltetaRef = hltetarefHandle(*jet); - fill(tool, hltdPt, hltdEnergy, hltdMass, hltrPt, hltrEnergy, hltrMass, hltptRef, hltetaRef); - } - } - fill(tool,offmatched); - fill(tool,hltmatched); - - return; -} - -StatusCode TrigL1JetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const { - using namespace Monitored; - - // Retrieve the L1 jet container - SG::ReadHandle<xAOD::JetRoIContainer> jets(m_l1jetContainerkey, ctx); - if( !jets.isValid() ){ - ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name " << m_l1jetContainerkey); - return StatusCode::FAILURE; - } - - // Declare the quantities which should be monitored - auto et8x8 = Monitored::Scalar<float>("et8x8"); - auto eta = Monitored::Scalar<float>("eta"); - auto phi = Monitored::Scalar<float>("phi"); - - // Loop over jets - for(const auto j : *jets){ - // Set the values of the monitored variables for the event - et8x8 = j->et8x8()*0.001; - eta = j->eta(); - phi = j->phi(); - // Fill. First argument is the tool (GMT) name as defined in TrigJetMonitorAlgorithm.py, - // all others are the variables to be saved. - auto tool = getGroup("TrigL1JetMonitor"); - fill(tool,et8x8,eta,phi); - } - // Adding histograms for L1 jets matched to offline/online jets - if (m_isMatched) { - // turn SG::ReadHandle<xAOD::JetRoIContainer> into xAOD::JetRoIContainer to be able to use Monitored::Collection on the L1 jet collection - ConstDataVector< xAOD::JetRoIContainer > tmpCont(SG::VIEW_ELEMENTS); - for(const xAOD::JetRoI* l1jet : *jets ) tmpCont.push_back(l1jet); - const xAOD::JetRoIContainer *l1JetContainer = tmpCont.asDataVector(); - fillMatchedHistograms(*l1JetContainer, ctx); - } - - return StatusCode::SUCCESS; -} diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JetMonitorAlgorithm.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JetMonitorAlgorithm.h deleted file mode 100644 index b24c0ff6b8bc743a6bbd32754a625aa8a7417deb..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1JetMonitorAlgorithm.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGJETMONITORING_TRIGL1JETMONITORALGORITHM_H -#define TRIGJETMONITORING_TRIGL1JETMONITORALGORITHM_H - -#include "AthenaMonitoring/AthMonitorAlgorithm.h" -#include "AthenaMonitoringKernel/Monitored.h" -#include "xAODTrigger/JetRoIContainer.h" -#include "AsgDataHandles/ReadDecorHandleKey.h" - -class TrigL1JetMonitorAlgorithm : public AthMonitorAlgorithm { - public: - TrigL1JetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~TrigL1JetMonitorAlgorithm(); - virtual StatusCode initialize() override; - virtual StatusCode fillHistograms( const EventContext& ctx ) const override; - void fillMatchedHistograms(const xAOD::JetRoIContainer & jets, const EventContext& ctx) const ; - - // Name of the L1 jet collection to be monitored - SG::ReadHandleKey<xAOD::JetRoIContainer> m_l1jetContainerkey; - // Variables to add matched histograms - Gaudi::Property<bool> m_isMatched {this, "IsMatched", false, "Plotting response histograms for L1 jets matched to online/offline jets"}; - Gaudi::Property<std::string> m_matchedOfflineJetContainer {this, "MatchedOfflineJets", "", "Name of matched offline jet collection"}; - Gaudi::Property<std::string> m_matchedHLTJetContainer {this, "MatchedHLTJets", "", "Name of matched HLT jet collection"}; - - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offmatchedKey{this, "offmatched", "offmatched", "SG key for input matched decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offptdiffKey{this, "offptdiff", "offptdiff", "SG key for input matched ptdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offenergydiffKey{this, "offenergydiff", "offenergydiff", "SG key for input matched energydiff decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offmassdiffKey{this, "offmassdiff", "offmassdiff", "SG key for input matched massdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offptrespKey{this, "offptresp", "offptresp", "SG key for input matched ptresp decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offenergyrespKey{this, "offenergyresp", "offenergyresp", "SG key for input matched energyresp decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offmassrespKey{this, "offmassresp", "offmassresp", "SG key for input matched massresp decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offptrefKey{this, "offptref", "offptref", "SG key for input matched ptref decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_offetarefKey{this, "offetaref", "offetaref", "SG key for input matched etaref decoration"}; - - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltmatchedKey{this, "hltmatched", "hltmatched", "SG key for input matched decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltptdiffKey{this, "hltptdiff", "hltptdiff", "SG key for input matched ptdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltenergydiffKey{this, "hltenergydiff", "hltenergydiff", "SG key for input matched energydiff decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltmassdiffKey{this, "hltmassdiff", "hltmassdiff", "SG key for input matched massdiff decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltptrespKey{this, "hltptresp", "hltptresp", "SG key for input matched ptresp decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltenergyrespKey{this, "hltenergyresp", "hltenergyresp", "SG key for input matched energyresp decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltmassrespKey{this, "hltmassresp", "hltmassresp", "SG key for input matched massresp decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltptrefKey{this, "hltptref", "hltptref", "SG key for input matched ptref decoration"}; - SG::ReadDecorHandleKey<xAOD::JetRoIContainer> m_hltetarefKey{this, "hltetaref", "hltetaref", "SG key for input matched etaref decoration"}; - -}; -#endif diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx index 3ed6087e451318175fb1e2ab11e1b6637d78a36f..a271324bcf0ef3d4e25d8598139083d41893ff7d 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx @@ -2,29 +2,17 @@ Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ -#include "../TrigL1JetMonitorAlgorithm.h" -#include "../TrigL1JFexSRJetMonitorAlgorithm.h" -#include "../TrigL1FexJetMonitorTool.h" +#include "../TrigL1FexJetMonitorTool_jFexSR.h" +#include "../TrigL1FexJetMonitorTool_jFexLR.h" +#include "../TrigL1FexJetMonitorTool_gFex.h" +#include "../TrigL1FexJetMonitorTool_jetRoI.h" #include "../TrigL1FexJetMonitorAlgorithm.h" -#include "xAODTrigger/jFexSRJetRoIContainer.h" -#include "xAODTrigger/jFexLRJetRoIContainer.h" -#include "xAODTrigger/gFexJetRoIContainer.h" -typedef TrigL1FexJetMonitorTool<xAOD::jFexSRJetRoIContainer> -TrigjFexSRJetRoIMonitorTool; - -typedef TrigL1FexJetMonitorTool<xAOD::jFexLRJetRoIContainer> -TrigjFexLRJetRoIMonitorTool; - -typedef TrigL1FexJetMonitorTool<xAOD::gFexJetRoIContainer> -TriggFexJetRoIMonitorTool; - -DECLARE_COMPONENT(TrigL1JetMonitorAlgorithm) DECLARE_COMPONENT(TrigL1FexJetMonitorAlgorithm) -DECLARE_COMPONENT(TrigL1JFexSRJetMonitorAlgorithm) -DECLARE_COMPONENT(TrigjFexSRJetRoIMonitorTool) -DECLARE_COMPONENT(TrigjFexLRJetRoIMonitorTool) -DECLARE_COMPONENT(TriggFexJetRoIMonitorTool) +DECLARE_COMPONENT(TrigL1FexJetMonitorTool_jFexSR) +DECLARE_COMPONENT(TrigL1FexJetMonitorTool_jFexLR) +DECLARE_COMPONENT(TrigL1FexJetMonitorTool_gFex) +DECLARE_COMPONENT(TrigL1FexJetMonitorTool_jetRoI) diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/vetoL1Jet.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/vetoL1Jet.cxx deleted file mode 100644 index a06975c98c55fef130f2a6ac891ed295216e3c41..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/vetoL1Jet.cxx +++ /dev/null @@ -1,13 +0,0 @@ - -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ - -#include "./vetoL1Jet.h" - -bool vetoJet(const xAOD::jFexSRJetRoI* j){ - return j->tobWord() == 0; -} - -bool vetoJet(const xAOD::jFexLRJetRoI*) {return false;} -bool vetoJet(const xAOD::gFexJetRoI*) {return false;} diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/vetoL1Jet.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/vetoL1Jet.h deleted file mode 100644 index a04e183c4a2013c3f14d41c619b7240ebfadf2b6..0000000000000000000000000000000000000000 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/vetoL1Jet.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ - -#include "xAODTrigger/jFexSRJetRoI.h" -#include "xAODTrigger/jFexLRJetRoI.h" -#include "xAODTrigger/gFexJetRoI.h" - -#ifndef TRIGJETMONITORING_L1VETOJET_H -#define TRIGJETMONITORING_L1VETOJET_H -bool vetoJet(const xAOD::jFexSRJetRoI*); -bool vetoJet(const xAOD::jFexLRJetRoI*); -bool vetoJet(const xAOD::gFexJetRoI*); - -#endif