From 34e0e0a51c5529cea4f754e0b1bbb5ebaae61cb6 Mon Sep 17 00:00:00 2001 From: Gabriel Gallardo <gabriel.gallardo@cern.ch> Date: Tue, 26 Mar 2019 08:53:16 +0000 Subject: [PATCH] MET Trigger: AthenaMT algorithms for clusters and jets --- .../TrigEFMissingET/IMissingETTool.h | 29 ++- .../TrigEFMissingET/src/EFMissingETAlgMT.cxx | 19 +- .../src/EFMissingETFromCellsMT.cxx | 8 +- .../EFMissingETFromCellsMT.h | 3 +- .../src/EFMissingETFromClustersMT.cxx | 179 +++++++++++++++++ .../src/EFMissingETFromClustersMT.h | 70 +++++++ .../src/EFMissingETFromHelper.cxx | 18 +- .../src/EFMissingETFromJetsMT.cxx | 185 ++++++++++++++++++ .../src/EFMissingETFromJetsMT.h | 72 +++++++ .../components/TrigEFMissingET_entries.cxx | 6 +- .../TrigEFMissingET/test/test_met_fexes.sh | 36 +++- .../test/test_met_fexes_cluster.sh | 89 +++++++++ .../python/TrigMissingETHypoConfigMT.py | 4 +- .../TrigUpgradeTest/CMakeLists.txt | 24 ++- .../TrigUpgradeTest/python/metDefs.py | 125 +++++++++++- .../TrigUpgradeTest/python/metMenuDefs.py | 37 +++- .../share/{metTest.py => met.fromCells.py} | 0 .../TrigUpgradeTest/share/met.fromClusters.py | 101 ++++++++++ .../TrigUpgradeTest/share/met.fromJets.py | 92 +++++++++ .../TrigUpgradeTest/share/met.menu.py | 7 +- .../{met_standalone.ref => met_fromCells.ref} | 0 .../share/met_fromClusters.ref | 10 + .../TrigUpgradeTest/share/met_fromJets.ref | 10 + .../test/test_met_fromCells.sh | 6 + .../test/test_met_fromClusters.sh | 6 + ...met_standalone.sh => test_met_fromJets.sh} | 2 +- 26 files changed, 1100 insertions(+), 38 deletions(-) rename Trigger/TrigAlgorithms/TrigEFMissingET/{TrigEFMissingET => src}/EFMissingETFromCellsMT.h (96%) create mode 100644 Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.cxx create mode 100644 Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.h create mode 100644 Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.cxx create mode 100644 Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.h create mode 100755 Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes_cluster.sh rename Trigger/TrigValidation/TrigUpgradeTest/share/{metTest.py => met.fromCells.py} (100%) create mode 100644 Trigger/TrigValidation/TrigUpgradeTest/share/met.fromClusters.py create mode 100644 Trigger/TrigValidation/TrigUpgradeTest/share/met.fromJets.py rename Trigger/TrigValidation/TrigUpgradeTest/share/{met_standalone.ref => met_fromCells.ref} (100%) create mode 100644 Trigger/TrigValidation/TrigUpgradeTest/share/met_fromClusters.ref create mode 100644 Trigger/TrigValidation/TrigUpgradeTest/share/met_fromJets.ref create mode 100755 Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromCells.sh create mode 100755 Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromClusters.sh rename Trigger/TrigValidation/TrigUpgradeTest/test/{test_met_standalone.sh => test_met_fromJets.sh} (90%) diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/IMissingETTool.h b/Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/IMissingETTool.h index 255eb17150f..cd6a3d55396 100644 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/IMissingETTool.h +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/IMissingETTool.h @@ -1,10 +1,23 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGEFMISSINGET_IMISSINGETTOOL_H #define TRIGEFMISSINGET_IMISSINGETTOOL_H 1 +/******************************************************************** + +NAME: IMissingETTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigEFMissingET +AUTHOR: Gabriel Gallardo +CREATED: September 2018 + +PURPOSE: Interface for MET trigger tools in AthenaMT + + ********************************************************************/ + + #include "GaudiKernel/IAlgTool.h" +#include "TrigTimeAlgs/ITrigTimerSvc.h" #include "TrigEFMissingET/EFMissingETHelper.h" #include "xAODTrigMissingET/TrigMissingET.h" @@ -22,13 +35,21 @@ public: /** * a method to update the met object (and met helper object) - * The API deliberately does not include EventContext as it is only needed - * in one implementation when input is not taken from the regular store. **/ virtual StatusCode update( xAOD::TrigMissingET *met, - TrigEFMissingEtHelper *metHelper ) const = 0; + TrigEFMissingEtHelper *metHelper, + const EventContext& ctx ) const = 0; protected: + + int m_fextype; //!< Fex type + + ITrigTimerSvc* m_timersvc; //!< Timer service + TrigTimer* m_timer[4][3]; //!< (EM, HEC, Tile, FCAL) x (RegionSelector, LoadCollections, loop) + TrigTimer* m_glob_timer; //!< total time + std::string m_FexName; //!< name of the parent Fex + + /** definition of the meaning for the component flag bits **/ static const unsigned short m_maskProcessing = 0x0001 ; // bit 0 Component is being processed diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETAlgMT.cxx b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETAlgMT.cxx index 145c9ab7e76..6b68dfa2cb2 100644 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETAlgMT.cxx +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETAlgMT.cxx @@ -1,6 +1,21 @@ /* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ + +/******************************************************************** + +NAME: EFMissingETFromJetsMT.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigEFMissingET +AUTHOR: Gabriel Gallardo +CREATED: Feb 19, 2018 + +BASED ON: EFMissingETFromJets.cxx +AUTHORS: Florian U. Bernlochner, Doug Schaefer, Justin Chiu + + +PURPOSE: Updates TrigMissingETHelper using info from jets + ********************************************************************/ + #include <cmath> #include "xAODTrigMissingET/TrigMissingETAuxContainer.h" #include "TrigEFMissingET/EFMissingETHelper.h" @@ -57,8 +72,8 @@ StatusCode EFMissingETAlgMT::execute( const EventContext& context ) const { loopTimer.start(); for ( auto& t: m_metTools ) { - ATH_MSG_DEBUG( "Invoking tool " << t->name() << " to update the MET obejct" ); - t->update( met, &metHelper ); + ATH_MSG_DEBUG( "Invoking tool " << t->name() << " to update the MET object" ); + t->update( met, &metHelper, context ); } loopTimer.stop(); diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.cxx b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.cxx index 62838f17ef8..8e747a82f7a 100644 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.cxx +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.cxx @@ -7,7 +7,7 @@ // TrigEFMissingET includes #include "TrigEFMissingET/IMissingETTool.h" -#include "TrigEFMissingET/EFMissingETFromCellsMT.h" +#include "EFMissingETFromCellsMT.h" EFMissingETFromCellsMT::EFMissingETFromCellsMT( const std::string& type, @@ -32,11 +32,11 @@ StatusCode EFMissingETFromCellsMT::initialize() } StatusCode EFMissingETFromCellsMT::update( xAOD::TrigMissingET */*met*/, - TrigEFMissingEtHelper *metHelper ) const { + TrigEFMissingEtHelper *metHelper, + const EventContext& ctx ) const { auto totalTimer = Monitored::Timer( "TIME_Total" ); - const EventContext context{ Gaudi::Hive::currentContext() }; - auto caloCellsHandle = SG::makeHandle( m_cellsKey ); + auto caloCellsHandle = SG::makeHandle( m_cellsKey, ctx ); auto loopTimer = Monitored::Timer( "TIME_Loop" ); auto countUsedCells = Monitored::Scalar<unsigned>( "UsedCells", 0 ); diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/EFMissingETFromCellsMT.h b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.h similarity index 96% rename from Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/EFMissingETFromCellsMT.h rename to Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.h index 92d975b2d66..263aa84939a 100644 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/TrigEFMissingET/EFMissingETFromCellsMT.h +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromCellsMT.h @@ -34,7 +34,8 @@ class EFMissingETFromCellsMT: public extends<AthAlgTool, IMissingETTool> { virtual StatusCode initialize() override; virtual StatusCode update( xAOD::TrigMissingET *met, - TrigEFMissingEtHelper *metHelper ) const override; + TrigEFMissingEtHelper *metHelper, + const EventContext& ctx ) const override; private: EFMissingETFromCellsMT(); diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.cxx b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.cxx new file mode 100644 index 00000000000..3707413a312 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.cxx @@ -0,0 +1,179 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: EFMissingETFromClustersMT.h +PACKAGE: Trigger/TrigAlgorithms/TrigEFMissingET + +AUTHORS: Kenji Hamano +CREATED: Feb 8, 2019 + +PURPOSE: athenaMT migration + + ********************************************************************/ +// Framework includes +#include "AthenaMonitoring/Monitored.h" +#include "GaudiKernel/IToolSvc.h" + +#include "CxxUtils/sincosf.h" + +#include "EventKernel/ISignalState.h" +#include "EventKernel/SignalStateHelper.h" + +// TrigEFMissingET includes +#include "EFMissingETFromClustersMT.h" + + +#include <cmath> +#include <string> +using namespace std; + +EFMissingETFromClustersMT::EFMissingETFromClustersMT(const std::string& type, + const std::string& name, + const IInterface* parent) : + base_class(type, name, parent) +{ + m_clusterstate = xAOD::CaloCluster_v1::UNCALIBRATED; +} + + +EFMissingETFromClustersMT::~EFMissingETFromClustersMT() +{ +} + + +StatusCode EFMissingETFromClustersMT::initialize() +{ + + ATH_MSG_DEBUG( "called EFMissingETFromClustersMT::initialize()" ); + + if(m_saveuncalibrated) + { + m_metHelperComp = TrigEFMissingEtComponent::TCEM; + m_clusterstate = xAOD::CaloCluster_v1::UNCALIBRATED; + } + else + { + m_metHelperComp = TrigEFMissingEtComponent::TCLCW; + m_clusterstate = xAOD::CaloCluster_v1::CALIBRATED; + } + + CHECK( m_clustersKey.initialize() ); + + return StatusCode::SUCCESS; +} + + +StatusCode EFMissingETFromClustersMT::update(xAOD::TrigMissingET *met , + TrigEFMissingEtHelper *metHelper, const EventContext& ctx ) const +{ + + ATH_MSG_DEBUG( "called EFMissingETFromClustersMT::execute()" ); + + /* This is a bit opaque but necessary to cooperate with how the MET helper + and MissingETFromHelper classes work. This will be cleaned up (ATR-19488). + - @ggallard + */ + const std::vector<std::string> vComp = {"TCLCWB1", "TCLCWB2", + "TCLCWE1", "TCLCWE2", + "TCEMB1", "TCEMB2", + "TCEME1", "TCEME2", + "Muons" }; + met->defineComponents(vComp); + + auto totalTimer = Monitored::Timer( "TIME_Total" ); + auto caloClustersHandle = SG::makeHandle( m_clustersKey, ctx ); + + auto loopTimer = Monitored::Timer( "TIME_Loop" ); + + TrigEFMissingEtComponent* metComp = nullptr; + metComp = metHelper->GetComponent(m_saveuncalibrated? TrigEFMissingEtComponent::TCEM : TrigEFMissingEtComponent::TCLCW); // fetch Cluster component + if (metComp==0) { + ATH_MSG_ERROR( "cannot fetch Topo. cluster component!" ); + return StatusCode::FAILURE; + } + + ATH_MSG_DEBUG( "fetched metHelper component \"" << metComp->m_name << "\"" ); + + if ( (metComp->m_status & m_maskProcessed)==0 ){ // not yet processed + metComp->Reset(); // reset component... + } else { // skip if processed + return StatusCode::SUCCESS; + } + + // set status to Processing + metComp->m_status |= m_maskProcessing; + + //--- fetching the topocluster components + const std::map<TrigEFMissingEtComponent::Component, std::pair<float, float> > tcComponents = { + {m_saveuncalibrated ? TrigEFMissingEtComponent::TCEM : TrigEFMissingEtComponent::TCLCW , { 20, -20 }}, + {m_saveuncalibrated ? TrigEFMissingEtComponent::TCEMB1 : TrigEFMissingEtComponent::TCLCWB1, { 1.5, 0 }}, + {m_saveuncalibrated ? TrigEFMissingEtComponent::TCEMB2 : TrigEFMissingEtComponent::TCLCWB2, { 0, -1.5 }}, + {m_saveuncalibrated ? TrigEFMissingEtComponent::TCEME1 : TrigEFMissingEtComponent::TCLCWE1, { 5, 1.5 }}, + {m_saveuncalibrated ? TrigEFMissingEtComponent::TCEME2 : TrigEFMissingEtComponent::TCLCWE2, {-1.5, -5 }} }; + + + for(auto const& [tcComp, etaLimits] : tcComponents){ + + switch(tcComp) + { + case TrigEFMissingEtComponent::TCEM : + case TrigEFMissingEtComponent::TCEMB1 : case TrigEFMissingEtComponent::TCEMB2 : + case TrigEFMissingEtComponent::TCEME1 : case TrigEFMissingEtComponent::TCEME2 : + case TrigEFMissingEtComponent::TCLCW : + case TrigEFMissingEtComponent::TCLCWB1 : case TrigEFMissingEtComponent::TCLCWB2 : + case TrigEFMissingEtComponent::TCLCWE1 : case TrigEFMissingEtComponent::TCLCWE2 : + break; + + default: + ATH_MSG_ERROR("You are somehow iterating over this non-tc component: " + << TrigEFMissingEtComponent::ComponentToName(tcComp) + << ". This is not okay, because this is supposed to be MET from clusters!"); + return StatusCode::FAILURE; + } + + metComp = metHelper->GetComponent(tcComp); // fetch Cluster component + + if (metComp==0) { + ATH_MSG_ERROR( "Cannot fetch topocluster component " + << TrigEFMissingEtComponent::ComponentToName(tcComp) << "!" ); + return StatusCode::FAILURE; + } + + for (const auto& clus : *caloClustersHandle) + { + + float phi = clus->phi(); + float eta = clus->eta(); + float Et = clus->pt(); + float cosPhi, sinPhi; + sincosf(phi, &sinPhi, &cosPhi); + float Ex = Et*cosPhi; + float Ey = Et*sinPhi; + float Ez = Et*sinhf(eta); + float E = sqrtf(Et*Et + Ez*Ez); + + if (eta < etaLimits.first && eta > etaLimits.second) + { + metComp->m_ex -= Ex; + metComp->m_ey -= Ey; + metComp->m_ez -= Ez; + metComp->m_sumEt += Et; + metComp->m_sumE += E; + metComp->m_usedChannels += 1; + metComp->m_sumOfSigns += static_cast<short int>(floor(copysign(1.0,Et)+0.5)); + } + + } // end for (cluster : topoclusters) + + // move from "processing" to "processed" state + metComp->m_status ^= m_maskProcessing; // switch off bit + metComp->m_status |= m_maskProcessed; // switch on bit + + } // end for (tcComp : tcComponents) + + return StatusCode::SUCCESS; + +} diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.h b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.h new file mode 100644 index 00000000000..c0ea240254c --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromClustersMT.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGEFMISSINGET_EFMISSINGETFROMCLUSTERSMT_H +#define TRIGEFMISSINGET_EFMISSINGETFROMCLUSTERSMT_H + +/******************************************************************** + +NAME: EFMissingETFromClustersMT.h +PACKAGE: Trigger/TrigAlgorithms/TrigEFMissingET + +AUTHORS: Kenji Hamano +CREATED: Feb 8, 2019 + +PURPOSE: athenaMT migration + + ********************************************************************/ + +// Framework includes +#include "AthenaBaseComps/AthAlgTool.h" +#include "GaudiKernel/ServiceHandle.h" + +// TrigEFMissingET included +#include "xAODCaloEvent/CaloClusterContainer.h" +#include "TrigMissingEtEvent/TrigMissingET.h" +#include "TrigEFMissingET/IMissingETTool.h" +#include "TrigEFMissingET/EFMissingETHelper.h" + +/** + @class EFMissingETFromClustersMT + \brief Updates metHelper object with topoclusters + \author Kenji Hamano + \author Gabriel Gallardo + \date Feb 8, 2019 + **/ +class EFMissingETFromClustersMT : public extends<AthAlgTool, IMissingETTool> +{ + public: + + EFMissingETFromClustersMT(const std::string& type, + const std::string& name, + const IInterface* parent); + + virtual ~EFMissingETFromClustersMT(); + + virtual StatusCode initialize() override; + + /** + This function does two things: + 1. It initializes the `met` object so that `EFMissingETFromHelper` knows that it will receive input from MetFromClusters + 2. It fills in the topocluster components of the `metHelper` object + It is meant to be called by the `EFMissingETAlgMT` class + + If `m_saveuncalibrated==true`, then EM calibrated TC are saved, else the LCW calibrated TC are saved. + **/ + virtual StatusCode update(xAOD::TrigMissingET *met, + TrigEFMissingEtHelper *metHelper, + const EventContext& ctx) const override; + + private: + Gaudi::Property<bool> m_saveuncalibrated {this, "SaveUncalibrated", false ,"save uncalibrated topo. clusters"}; + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_clustersKey { this, "ClustersCollection", "CaloClusters", "Collection containg all clusters" }; + + xAOD::CaloCluster_v1::State m_clusterstate; + TrigEFMissingEtComponent::Component m_metHelperComp; + +}; + +#endif // TRIGEFMISSINGET_EFMISSINGETFROMCLUSTERSMT_H diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromHelper.cxx b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromHelper.cxx index 7e7735cdf84..7688d7773ee 100644 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromHelper.cxx +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromHelper.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /******************************************************************** @@ -174,7 +174,7 @@ StatusCode EFMissingETFromHelper::execute(xAOD::TrigMissingET *met , met->setFlag( metHelper->GetStatus() ); - uint comp = met->getNumberOfComponents(); // final no. of aux. compon. + uint nMetComp = met->getNumberOfComponents(); // final no. of aux. compon. uint nHelperComp = metHelper->GetElements(); // no. of transient aux. compon. if (nHelperComp != static_cast<unsigned char>(TrigEFMissingEtComponent::ComponentSize)) { ATH_MSG_WARNING( "Found " << nHelperComp << " aux components in the transient helper class. Not supported!" ); @@ -187,7 +187,7 @@ StatusCode EFMissingETFromHelper::execute(xAOD::TrigMissingET *met , bool save3comp=false; bool save2comp=false; bool save1comp=false; - switch (comp) { + switch (nMetComp) { case 25: // default: do nothing break; case 9: @@ -209,10 +209,10 @@ StatusCode EFMissingETFromHelper::execute(xAOD::TrigMissingET *met , save1comp=true; break; default: - ATH_MSG_WARNING( "Found " << comp << " aux components in TrigMissingET. Not supported. NOT SAVING AUX INFO" ); + ATH_MSG_WARNING( "Found " << nMetComp << " aux components in TrigMissingET. Not supported. NOT SAVING AUX INFO" ); skipAuxInfo=true; } - ATH_MSG_DEBUG( "Found " << comp << " aux components in TrigMissingET." ); + ATH_MSG_DEBUG( "Found " << nMetComp << " aux components in TrigMissingET." ); // Initialize EDM by setting all components to zero met->setEx(0.); met->setEy(0.); met->setEz(0.); @@ -245,10 +245,10 @@ StatusCode EFMissingETFromHelper::execute(xAOD::TrigMissingET *met , if (skipAuxInfo) continue; // auxiliary info - uncorrected - if (comp == unsigned(nHelperComp-17) && helper_i < 24) { + if (nMetComp == unsigned(nHelperComp-17) && helper_i < 24) { ATH_MSG_DEBUG( "finest granularity"); copier.setMETCompFromHelper(helper_i, helper_i); - } else if(comp == unsigned(nHelperComp-17) && helper_i == static_cast<uint>(TrigEFMissingEtComponent::Muons)) { + } else if(nMetComp == unsigned(nHelperComp-17) && helper_i == static_cast<uint>(TrigEFMissingEtComponent::Muons)) { ATH_MSG_DEBUG( "save muons"); copier.setMETCompFromHelper(helper_i-17, helper_i); } else if (save6comp) { @@ -379,9 +379,7 @@ StatusCode EFMissingETFromHelper::execute(xAOD::TrigMissingET *met , ATH_MSG_DEBUG( message ); } - if(msgLvl(MSG::DEBUG)){ - unsigned int nMetComp = met->getNumberOfComponents(); - + if(msgLvl(MSG::DEBUG) && nMetComp > 0){ s="REGTEST __name____status_usedChannels__sumOfSigns__calib1_calib0"; s+="/MeV__ex/MeV_____ey/MeV_____ez/MeV___sumE/MeV__sumEt/CLHEP::MeV"; ATH_MSG_DEBUG( s ); diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.cxx b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.cxx new file mode 100644 index 00000000000..496c83bd771 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.cxx @@ -0,0 +1,185 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: EFMissingETFromJetsMT.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigEFMissingET +AUTHOR: Gabriel Gallardo +CREATED: Feb 19, 2018 + +BASED ON: EFMissingETFromJets.cxx +AUTHORS: Florian U. Bernlochner, Doug Schaefer, Justin Chiu + +PURPOSE: Updates TrigMissingETHelper using info from jets + + ********************************************************************/ + +#include "EFMissingETFromJetsMT.h" + +#include "TrigTimeAlgs/TrigTimerSvc.h" +#include "CxxUtils/sincosf.h" + +#include "JetEvent/JetCollection.h" +#include "JetEvent/Jet.h" +//#include "FourMomUtils/P4DescendingSorters.h" +#include "xAODJet/JetContainer.h" +#include "xAODJet/Jet.h" +#include "CaloGeoHelpers/CaloSampling.h" +#include "xAODJet/JetAccessorMap.h" + +#include "EventKernel/ISignalState.h" +#include "EventKernel/SignalStateHelper.h" + +#include <cmath> +#include <string> +using namespace std; + +EFMissingETFromJetsMT::EFMissingETFromJetsMT(const std::string& type, + const std::string& name, + const IInterface* parent) : base_class(type, name, parent) +{ + m_etacut = fabs(m_etacut); +} + + +EFMissingETFromJetsMT::~EFMissingETFromJetsMT() +{ +} + + +StatusCode EFMissingETFromJetsMT::initialize() +{ + ATH_MSG_DEBUG( "called EFMissingETFromJetsMT::initialize()" ); + + /// timers + if( service( "TrigTimerSvc", m_timersvc).isFailure() ) + ATH_MSG_WARNING( name() << ": Unable to locate TrigTimer Service" ); + + if (m_timersvc) { + // global time + std::string basename=name()+".TotalTime"; + m_glob_timer = m_timersvc->addItem(basename); + } // if timing service + + CHECK( m_jetsKey.initialize() ); + + return StatusCode::SUCCESS; +} + + +StatusCode EFMissingETFromJetsMT::update( xAOD::TrigMissingET *met, + TrigEFMissingEtHelper *metHelper, const EventContext& ctx ) const +{ + + ATH_MSG_DEBUG( "called EFMissingETFromJetsMT::update()" ); // + + const std::vector<std::string> vComp = {"Jets", "Muon"}; + met->defineComponents(vComp); + + if(m_timersvc) + m_glob_timer->start(); // total time + ATH_MSG_DEBUG( "started MET jet CPU timer" ); + + TrigEFMissingEtComponent* metComp = metHelper->GetComponent(TrigEFMissingEtComponent::JET); // fetch Jet component + if (metComp==0) { ATH_MSG_ERROR( "Could not fetch jet component!" ); return StatusCode::FAILURE; } + else ATH_MSG_DEBUG( "fetched metHelper component \"" << metComp->m_name << "\"" ); + + if ( (metComp->m_status & m_maskProcessed)==0 ){ // not yet processed + metComp->Reset(); // reset component... + } else { // skip if processed + return StatusCode::SUCCESS; + } + + auto jetsHandle = SG::makeHandle( m_jetsKey, ctx ); + std::vector<const xAOD::Jet*> MHTJetsVec(jetsHandle->begin(), jetsHandle->end()); + ATH_MSG_DEBUG( "num of jets: " << MHTJetsVec.size() ); + + //--- fetching the jet components + const std::map<TrigEFMissingEtComponent::Component, std::pair<float, float > > jetComponents = { + {TrigEFMissingEtComponent::JET , { 20, -20 }}, + {TrigEFMissingEtComponent::JETB1, { m_etacut, 0 }}, + {TrigEFMissingEtComponent::JETB2, { 0, -m_etacut}}, + {TrigEFMissingEtComponent::JETE1, { 5, m_etacut}}, + {TrigEFMissingEtComponent::JETE2, {-m_etacut, -5 }} }; + + for(auto const& [jetComp, etaLimits] : jetComponents) { + metComp = metHelper->GetComponent(jetComp); + + if(!metComp) { + ATH_MSG_ERROR("Could not fetch jet component " + << TrigEFMissingEtComponent::ComponentToName(jetComp) << "!"); + return StatusCode::FAILURE; + } + + for (const xAOD::Jet* aJet : MHTJetsVec) { + TLorentzVector p4 = aJet->p4(); + float scale = 1.; + p4*=scale; + + /* + // TileGap3Correction obsolete? Will remove in future MR if this is the case. + // Commented out for the time being because this block of code is not thread-safe and is raising warnings. @ggallard + + if (m_applyTileGap3Correction) { + // get the uncalibrated energy and tile gap 3 fractions + static const xAOD::JetAttributeAccessor::AccessorWrapper< std::vector<float> >& acc_ePerSample = + *xAOD::JetAttributeAccessor::accessor< std::vector<float> >(xAOD::JetAttribute::EnergyPerSampling); + static xAOD::JetAttributeAccessor::AccessorWrapper<xAOD::JetFourMom_t> acc_uncalibrated("JetConstitScaleMomentum"); + const std::vector<float>& eInSampling = acc_ePerSample.getAttribute(*aJet); + float e_tileGap3 = eInSampling.at(CaloSampling::TileGap3); + scale = 1 - e_tileGap3/acc_uncalibrated.getAttribute(*aJet).E(); + } + */ + + switch (jetComp) + { + case TrigEFMissingEtComponent::JETB1: + case TrigEFMissingEtComponent::JETB2: + if (p4.Pt() < m_central_ptcut) continue; + break; + + case TrigEFMissingEtComponent::JETE1: + case TrigEFMissingEtComponent::JETE2: + if (p4.Pt() < m_forward_ptcut) continue; + break; + case TrigEFMissingEtComponent::JET: + break; + default: + ATH_MSG_ERROR("You are somehow iterating over this non-jet component: " + << TrigEFMissingEtComponent::ComponentToName(jetComp) + << ". This is not okay, because this is supposed to be MET from jets!"); + return StatusCode::FAILURE; + } + + if (p4.Eta() < etaLimits.first && p4.Eta() > etaLimits.second) + { + metComp->m_ex -= p4.Px(); + metComp->m_ey -= p4.Py(); + metComp->m_ez -= p4.Pz(); + metComp->m_sumEt += p4.Pt(); + metComp->m_sumE += p4.E(); + metComp->m_usedChannels += 1; + metComp->m_sumOfSigns += copysign(1.0, p4.Pt() ); + } + + } // End loop over all jets + + // move from "processing" to "processed" state + metComp->m_status ^= m_maskProcessing; // switch off bit + metComp->m_status |= m_maskProcessed; // switch on bit + + } + + // fetch jet component and output MET value + metComp = metHelper->GetComponent(TrigEFMissingEtComponent::JET); + ATH_MSG_DEBUG( " calculated MET: " << sqrt((metComp->m_ex)*(metComp->m_ex)+(metComp->m_ey)*(metComp->m_ey)) ); + + + if(m_timersvc) + m_glob_timer->stop(); // total time + + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.h b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.h new file mode 100644 index 00000000000..1404bdf72e8 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/EFMissingETFromJetsMT.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGEFMISSINGET_EFMISSINGETFROMJETSMT_H +#define TRIGEFMISSINGET_EFMISSINGETFROMJETSMT_H + +/******************************************************************** + +NAME: EFMissingETFromJetsMT.h +PACKAGE: Trigger/TrigAlgorithms/TrigEFMissingET +AUTHOR: Gabriel Gallardo +CREATED: Feb 19, 2018 + +BASED ON: EFMissingETFromJets.h +AUTHORS: Florian U. Bernlochner, Doug Schaefer, Justin Chiu + + +PURPOSE: Updates TrigMissingETHelper using info from jets + + ********************************************************************/ + +#include "AthenaBaseComps/AthAlgTool.h" +#include "GaudiKernel/ServiceHandle.h" +#include "xAODJet/JetContainer.h" +#include "TrigEFMissingET/IMissingETTool.h" + +using xAOD::JetContainer; + +/** + @class EFMissingETFromJetsMT + \brief Updates metHelper object with jets + \author Gabriel Gallardo + \date Feb 19, 2019 + **/ + +class EFMissingETFromJetsMT : public extends<AthAlgTool, IMissingETTool> +{ + public: + + EFMissingETFromJetsMT(const std::string& type, + const std::string& name, + const IInterface* parent); + + ~EFMissingETFromJetsMT(); + + virtual StatusCode initialize() override; + + /** + This function does two things: + 1. It initializes the `met` object so that `EFMissingETFromHelper` knows that it will receive input from MetFromJets + 2. It fills in the jet components of the `metHelper` object + It is meant to be called by the `EFMissingETAlgMT` class + **/ + virtual StatusCode update( xAOD::TrigMissingET *met, + TrigEFMissingEtHelper *metHelper, const EventContext& ctx ) const override; + + + private: + EFMissingETFromJetsMT(); + + Gaudi::Property<float> m_etacut {this, "EtaSeparation", 2.2 , "Cut to split into forward and central jets -- needs to be positive"}; + Gaudi::Property<float> m_forward_ptcut {this, "CentralpTCut", 0.0 , "pT Cut for central jets"}; + Gaudi::Property<float> m_central_ptcut {this, "ForwardpTCut", 0.0 ," pT Cut for forward jets"}; + SG::ReadHandleKey<JetContainer> m_jetsKey {this, "JetsCollection", "jets", "Collection containing all jets" }; + + // TileGap3Correction obsolete? Will remove in future MR if this is the case. + // Commented out for the time being because the corresponding code is not thread-safe and is raising warnings. @ggallard + // Gaudi::Property<bool> m_applyTileGap3Correction {this, "ApplyTileGap3Correction", false, "ApplyTileGap3Correction"}; +}; + +#endif // TRIGEFMISSINGET_EFMISSINGETFROMJETSMT_H diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/src/components/TrigEFMissingET_entries.cxx b/Trigger/TrigAlgorithms/TrigEFMissingET/src/components/TrigEFMissingET_entries.cxx index 9e636d5423b..d968a355711 100644 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/src/components/TrigEFMissingET_entries.cxx +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/src/components/TrigEFMissingET_entries.cxx @@ -13,7 +13,9 @@ #include "TrigEFMissingET/EFMissingETFlags.h" #include "TrigEFMissingET/EFMissingETFromHelper.h" #include "TrigEFMissingET/EFMissingETAlgMT.h" -#include "TrigEFMissingET/EFMissingETFromCellsMT.h" +#include "../EFMissingETFromCellsMT.h" +#include "../EFMissingETFromClustersMT.h" +#include "../EFMissingETFromJetsMT.h" DECLARE_COMPONENT( EFMissingET ) DECLARE_COMPONENT( EFMissingETBaseTool ) @@ -31,4 +33,6 @@ DECLARE_COMPONENT( EFMissingETFlags ) DECLARE_COMPONENT( EFMissingETFromHelper ) DECLARE_COMPONENT( EFMissingETAlgMT ) DECLARE_COMPONENT( EFMissingETFromCellsMT ) +DECLARE_COMPONENT( EFMissingETFromClustersMT ) +DECLARE_COMPONENT( EFMissingETFromJetsMT ) diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes.sh b/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes.sh index 33591ac57d9..b18a3586d8c 100755 --- a/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes.sh +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes.sh @@ -2,9 +2,6 @@ # art-type: build # art-ci: master -STARDATE=`date +%g%m%d.%H%M` -RUN_LOG="run_${STARDATE}.log" - ## READ OPTIONS OPT_FOLLOW=0 @@ -20,42 +17,70 @@ OPT_INTERACTIVE=0 while [ ! $# -eq 0 ] do case "$1" in + # Set '-d' debug flag for athena -d ) OPT_DEBUG="-d" ;; - --debug) + + # Set '--debug' flag for athena, follow with one of ('conf', 'init', 'exec', 'fini') + # See `athena --help` + --debug) shift OPT_DEBUG="--debug ${1}" ;; + + # Follow the output of the job with `less +F` --follow | -f) OPT_FOLLOW=1 ;; + + # Maximum number of events to run on + # Sets the --evtMax option of athena --evtMax) shift OPT_EVT="$1" ;; + + # Number of threads to run on + # Set to >1 for multi-threaded --threads) shift OPT_THREADS="$1" ;; + + # Path to job option --jobo | -j) shift OPT_JOBO="$1" ;; + + # Print the command to be executed, then exit -n) OPT_DRY_RUN=1 ;; + + # Set --loglevel option of athena -l | --loglevel) shift OPT_LOG_LEVEL="--loglevel $1" ;; + + # Interactive athena, equivalent to `athena -i` -i ) OPT_INTERACTIVE=1 ;; + + # Comma separated list of files to run over\ + # Sets --filesInput option of athena --filesInput ) shift OPT_FILES_INPUT=$1 ;; + + # Clear current directory before execution + -o) + rm ./* + ;; esac shift done @@ -80,6 +105,9 @@ elif [ $OPT_DRY_RUN -eq 1 ];then exit fi +STARDATE=`date +%g%m%d.%H%M` +RUN_LOG="${OPT_JOBO##*/}_${STARDATE}.log" + athena $ATH_OPT &> ${RUN_LOG} & if [ ${OPT_FOLLOW} -eq 0 ]; then echo "Running in background. Log output to ${RUN_LOG}. " diff --git a/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes_cluster.sh b/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes_cluster.sh new file mode 100755 index 00000000000..349621d6109 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigEFMissingET/test/test_met_fexes_cluster.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# art-type: build +# art-ci: master + +STARDATE=`date +%g%m%d.%H%M` +RUN_LOG="run_${STARDATE}.log" + + +## READ OPTIONS +OPT_FOLLOW=0 +OPT_DEBUG="" +OPT_EVT=10 +OPT_THREADS=1 +OPT_FILES_INPUT=""/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1"" +OPT_JOBO="TrigEFMissingET/testMETCluster.py" +OPT_DRY_RUN=0 +OPT_LOG_LEVEL="" +OPT_INTERACTIVE=0 + +while [ ! $# -eq 0 ] +do + case "$1" in + -d ) + OPT_DEBUG="-d" + ;; + --debug) + shift + OPT_DEBUG="--debug ${1}" + ;; + --follow | -f) + OPT_FOLLOW=1 + ;; + --evtMax) + shift + OPT_EVT="$1" + ;; + --threads) + shift + OPT_THREADS="$1" + ;; + --jobo | -j) + shift + OPT_JOBO="$1" + ;; + -n) + OPT_DRY_RUN=1 + ;; + -l | --loglevel) + shift + OPT_LOG_LEVEL="--loglevel $1" + ;; + -i ) + OPT_INTERACTIVE=1 + ;; + --filesInput ) + shift + OPT_FILES_INPUT=$1 + ;; + esac + shift +done + + +## BUILD ATHENA COMMAND +ATH_OPT="--filesInput=${OPT_FILES_INPUT} --threads=${OPT_THREADS} --evtMax=${OPT_EVT}" +ATH_OPT="${OPT_DEBUG} ${ATH_OPT} ${OPT_LOG_LEVEL}" +ATH_OPT="${ATH_OPT} ${OPT_JOBO}" + +## EXECUTE AND FOLLOW LOG +echo "Executing..." +echo "athena ${ATH_OPT}" + +if [ "${OPT_DEBUG}" != "" ]; then + athena ${ATH_OPT} + exit +elif [ $OPT_INTERACTIVE -eq 1 ]; then + athena -i ${ATH_OPT} + exit +elif [ $OPT_DRY_RUN -eq 1 ];then + exit +fi + +athena $ATH_OPT &> ${RUN_LOG} & +if [ ${OPT_FOLLOW} -eq 0 ]; then + echo "Running in background. Log output to ${RUN_LOG}. " + echo "Execute 'tail -f ${RUN_LOG}' to follow. " +else + less +F "${RUN_LOG}" +fi diff --git a/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py b/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py index e3221afc9d6..dbb68c7b95b 100644 --- a/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py +++ b/Trigger/TrigHypothesis/TrigMissingETHypo/python/TrigMissingETHypoConfigMT.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from TrigMissingETHypo.TrigMissingETHypoConf import TrigMissingETHypoAlgMT, TrigMissingETHypoToolMT @@ -80,7 +80,7 @@ def TrigMETPufitHypoToolFromName(name, conf): def TrigMETPufitHypoToolFromName(name, conf): return MissingETHypoToolMT(name, alg='pufit') -def TrigMETMhtHypoToolFromName(name, conf): +def TrigMETJetHypoToolFromName(name, conf): return MissingETHypoToolMT(name, alg='mht') diff --git a/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt b/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt index 98bae9d7e5b..0a707cc9188 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt +++ b/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt @@ -215,12 +215,28 @@ atlas_add_test( bJetMenuALLTE ) -file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_standalone ) -atlas_add_test( met_standalone - SCRIPT test/test_met_standalone.sh +file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_fromCells ) +atlas_add_test( met_fromCells + SCRIPT test/test_met_fromCells.sh PROPERTIES TIMEOUT 1000 EXTRA_PATTERNS "-s METHypoAlg.*MET.*value" - PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_standalone + PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_fromCells + ) + +file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_fromClusters ) +atlas_add_test( met_fromClusters + SCRIPT test/test_met_fromClusters.sh + PROPERTIES TIMEOUT 1000 + EXTRA_PATTERNS "-s METHypoAlg.*MET.*value" + PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_fromClusters + ) + +file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_fromJets ) +atlas_add_test( met_fromJets + SCRIPT test/test_met_fromJets.sh + PROPERTIES TIMEOUT 1000 + EXTRA_PATTERNS "-s METHypoAlg.*MET.*value" + PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_fromJets ) file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_met_menu ) diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py index bb89d3c3b13..4ea7c2e2385 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/metDefs.py @@ -23,7 +23,7 @@ def metCellAthSequence(ConfigFlags): InputMakerAlg= clusterFSInputMaker() (recoSequence, sequenceOut) = metCellRecoSequence() - MetAthSequence = seqAND("MetAthSequence",[InputMakerAlg, recoSequence ]) + MetAthSequence = seqAND("MetCellAthSequence",[InputMakerAlg, recoSequence ]) return (MetAthSequence, InputMakerAlg, sequenceOut) @@ -79,3 +79,126 @@ def metCellRecoSequence(): seqOut = metAlg.METContainerKey return (metCellRecoSequence, seqOut) + +def metClusterAthSequence(ConfigFlags): + from TrigT2CaloCommon.CaloDef import clusterFSInputMaker + InputMakerAlg= clusterFSInputMaker() + (recoSequence, sequenceOut) = metClusterRecoSequence() + + MetClusterAthSequence = seqAND("MetClusterAthSequence",[InputMakerAlg, recoSequence ]) + return (MetClusterAthSequence, InputMakerAlg, sequenceOut) + + +def metClusterRecoSequence(): + + from TrigT2CaloCommon.CaloDef import HLTFSTopoRecoSequence + (metClusterRecoSequence, ClustersName) = HLTFSTopoRecoSequence() + + + ################################################# + # Add EFMissingETAlg and associated tools + ################################################# + from TrigEFMissingET.TrigEFMissingETConf import EFMissingETAlgMT, EFMissingETFromClustersMT, EFMissingETFromHelper + metAlg = EFMissingETAlgMT( name="EFMET" ) + metAlg.OutputLevel=WARNING + helperTool = EFMissingETFromHelper("theHelperTool") + metAlg.HelperTool= helperTool + metAlg.METContainerKey = "HLT_MET" + + #/////////////////////////////////////////// + # Setup monitoring for EFMissingETAlg + #/////////////////////////////////////////// + metMon = GenericMonitoringTool("METMonTool") + metMon.Histograms = [ defineHistogram( "TIME_Total", path='EXPERT', title="Time spent Alg", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "TIME_Loop", path='EXPERT', title="Time spent in Tools loop", xbins=100, xmin=0, xmax=100 )] + from TrigEFMissingET.TrigEFMissingETMonitoring import ( hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log, + hMET_lin, hSumEt_lin, + hXS, hMETPhi, hMETStatus, + hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE, + hCompEt_lin, hCompSumEt_lin ) + + metMon.Histograms = [ hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log ] + metMon.Histograms += [ hMET_lin, hSumEt_lin ] + metMon.Histograms += [ hXS, hMETPhi, hMETStatus] + metMon.Histograms += [ hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE ] + metMon.Histograms += [ hCompEt_lin, hCompSumEt_lin ] + metAlg.MonTool = metMon + + #/////////////////////////////////////////// + # Add EFMissingETFromClusters tool + #/////////////////////////////////////////// + from TrigEFMissingET.TrigEFMissingETConf import EFMissingETFromClustersMT + clusterTool = EFMissingETFromClustersMT( name="METFromClustersTool" ) + + ### WARNING: this setting does not work for the scheduler: the variable is set, but the scheduler retrieves the default one + clusterTool.ClustersCollection = ClustersName + + + metAlg.METTools.append(clusterTool) + + metClusterRecoSequence += metAlg + + seqOut = metAlg.METContainerKey + return (metClusterRecoSequence, seqOut) + +def metJetAthSequence(ConfigFlags): + from TrigT2CaloCommon.CaloDef import clusterFSInputMaker + InputMakerAlg= clusterFSInputMaker() + (recoSequence, sequenceOut) = metJetRecoSequence() + + MetAthSequence = seqAND("MetJetAthSequence",[InputMakerAlg, recoSequence ]) + return (MetAthSequence, InputMakerAlg, sequenceOut) + + +def metJetRecoSequence(RoIs = 'FSJetRoI'): + + from TrigUpgradeTest.jetDefs import jetRecoSequence + (recoSequence, JetsName) = jetRecoSequence(RoIs) + + + ################################################# + # Add EFMissingETAlg and associated tools + ################################################# + from TrigEFMissingET.TrigEFMissingETConf import EFMissingETAlgMT, EFMissingETFromHelper + metAlg = EFMissingETAlgMT( name="EFMET" ) + metAlg.OutputLevel=WARNING + helperTool = EFMissingETFromHelper("theHelperTool") + metAlg.HelperTool= helperTool + metAlg.METContainerKey = "HLT_MET_mht" + + #/////////////////////////////////////////// + # Setup monitoring for EFMissingETAlg + #/////////////////////////////////////////// + metMon = GenericMonitoringTool("METMonTool") + metMon.Histograms = [ defineHistogram( "TIME_Total", path='EXPERT', title="Time spent Alg", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "TIME_Loop", path='EXPERT', title="Time spent in Tools loop", xbins=100, xmin=0, xmax=100 )] + from TrigEFMissingET.TrigEFMissingETMonitoring import ( hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log, + hMET_lin, hSumEt_lin, + hXS, hMETPhi, hMETStatus, + hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE, + hCompEt_lin, hCompSumEt_lin ) + + metMon.Histograms = [ hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log ] + metMon.Histograms += [ hMET_lin, hSumEt_lin ] + metMon.Histograms += [ hXS, hMETPhi, hMETStatus] + metMon.Histograms += [ hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE ] + metMon.Histograms += [ hCompEt_lin, hCompSumEt_lin ] + metAlg.MonTool = metMon + + #/////////////////////////////////////////// + # Add EFMissingETFromCells tool + #/////////////////////////////////////////// + from TrigEFMissingET.TrigEFMissingETConf import EFMissingETFromJetsMT + mhtTool = EFMissingETFromJetsMT( name="METFromJetsTool" ) + + ### This warning was copied from metCellRecoSequence(). Does this apply here? - @ggallard + ### WARNING: this setting does not work for the scheduler: the variable is set, but the scheduler retrieves the default one + mhtTool.JetsCollection=JetsName + + metAlg.METTools.append(mhtTool) + + recoSequence += metAlg + + seqOut = metAlg.METContainerKey + return (recoSequence, seqOut) + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py index 0c57a73be3f..22a8dccca61 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/metMenuDefs.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # from AthenaCommon.Constants import VERBOSE,DEBUG,INFO,WARNING @@ -24,3 +24,38 @@ def metCellMenuSequence(): Hypo = metHypoAlg, HypoToolGen = TrigMETCellHypoToolFromDict ) + +def metClusterMenuSequence(): + # menu components + # retrieve the reco seuqnece + from TrigUpgradeTest.metDefs import metClusterAthSequence + (metClusterSequence, InputMakerAlg, sequenceOut) = RecoFragmentsPool.retrieve(metClusterAthSequence,ConfigFlags) + + #hypo + from TrigMissingETHypo.TrigMissingETHypoConfigMT import MissingETHypoAlgMT, TrigMETCellHypoToolFromDict, MissingETHypoToolMT + + metHypoAlg = MissingETHypoAlgMT("METHypoAlg") + metHypoAlg.METContainerKey=sequenceOut + metHypoAlg.OutputLevel=DEBUG + + return MenuSequence( Sequence = metClusterSequence, + Maker = InputMakerAlg, + Hypo = metHypoAlg, + HypoToolGen = TrigMETCellHypoToolFromDict ) +def metJetMenuSequence(): + # menu components + # retrieve the reco seuqnece + from TrigUpgradeTest.metDefs import metJetAthSequence + (metJetSequence, InputMakerAlg, sequenceOut) = RecoFragmentsPool.retrieve(metJetAthSequence,ConfigFlags) + + #hypo + from TrigMissingETHypo.TrigMissingETHypoConfigMT import MissingETHypoAlgMT, TrigMETJetHypoToolFromName, MissingETHypoToolMT + + metHypoAlg = MissingETHypoAlgMT("METHypoAlg") + metHypoAlg.METContainerKey=sequenceOut + metHypoAlg.OutputLevel=DEBUG + + return MenuSequence( Sequence = metJetSequence, + Maker = InputMakerAlg, + Hypo = metHypoAlg, + HypoToolGen = TrigMETJetHypoToolFromName ) diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/metTest.py b/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromCells.py similarity index 100% rename from Trigger/TrigValidation/TrigUpgradeTest/share/metTest.py rename to Trigger/TrigValidation/TrigUpgradeTest/share/met.fromCells.py diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromClusters.py b/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromClusters.py new file mode 100644 index 00000000000..79a8b8e9ae6 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromClusters.py @@ -0,0 +1,101 @@ +# +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +OutputLevel=WARNING +include("TrigUpgradeTest/testHLT_MT.py") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +import math +from TrigT2CaloCommon.TrigT2CaloCommonConf import TrigCaloDataAccessSvc#, TestCaloDataAccess +from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram + +mon = GenericMonitoringTool("CaloDataAccessSvcMon") +mon.Histograms += [defineHistogram( "TIME_locking_LAr_RoI", path='EXPERT', title="Time spent in unlocking the LAr collection", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "roiROBs_LAr", path='EXPERT', title="Number of ROBs unpacked in RoI requests", xbins=20, xmin=0, xmax=20 ), + defineHistogram( "TIME_locking_LAr_FullDet", path='EXPERT', title="Time spent in unlocking the LAr collection", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "roiEta_LAr,roiPhi_LAr", type="TH2F", path='EXPERT', title="Geometric usage", xbins=50, xmin=-5, xmax=5, ybins=64, ymin=-math.pi, ymax=math.pi )] + +svcMgr += TrigCaloDataAccessSvc() +svcMgr.TrigCaloDataAccessSvc.MonTool = mon +svcMgr.TrigCaloDataAccessSvc.OutputLevel=WARNING + +from L1Decoder.L1DecoderConf import CreateFullScanRoI +topSequence += CreateFullScanRoI() + + +################################################# +# Get topoclusters +################################################# +from TrigT2CaloCommon.CaloDef import HLTFSTopoRecoSequence +clusterSequence, clusterContainer = HLTFSTopoRecoSequence( RoIs="FullScanRoIs" ) +topSequence += clusterSequence + +################################################# +# Add EFMissingETFrom** algorithm +################################################# + +from TrigEFMissingET.TrigEFMissingETConf import EFMissingETAlgMT, EFMissingETFromClustersMT, EFMissingETFromHelper + +clusterTool = EFMissingETFromClustersMT( name="METFromClustersTool" ) +clusterTool.ClustersCollection = clusterContainer + +helperTool = EFMissingETFromHelper("theHelperTool") +helperTool.OutputLevel=DEBUG +metAlg = EFMissingETAlgMT( name="EFMET" ) + + +metAlg.METTools=[ clusterTool ] +metAlg.HelperTool= helperTool +metAlg.OutputLevel=DEBUG +metAlg.METContainerKey = "HLT_MET_Clusters" + +metMon = GenericMonitoringTool("METMonTool") +metMon.Histograms = [ defineHistogram( "TIME_Total", path='EXPERT', title="Time spent Alg", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "TIME_Loop", path='EXPERT', title="Time spent in Tools loop", xbins=100, xmin=0, xmax=100 )] +from TrigEFMissingET.TrigEFMissingETMonitoring import ( hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log, + hMET_lin, hSumEt_lin, + hXS, hMETPhi, hMETStatus, + hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE, + hCompEt_lin, hCompSumEt_lin ) + +metMon.Histograms = [ hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log ] +metMon.Histograms += [ hMET_lin, hSumEt_lin ] +metMon.Histograms += [ hXS, hMETPhi, hMETStatus] +metMon.Histograms += [ hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE ] +metMon.Histograms += [ hCompEt_lin, hCompSumEt_lin ] + +metAlg.MonTool = metMon +topSequence += metAlg + +################################################# +# Add TrigMissingETHypo algorithm and tool +################################################# +from TrigMissingETHypo.TrigMissingETHypoConfigMT import MissingETHypoAlgMT, MissingETHypoToolMT + +def makeMETHypoTool(): + hypoTool = MissingETHypoToolMT("HLT_xe10") + hypoTool.metThreshold = 10 + return hypoTool + +hypoAlg = MissingETHypoAlgMT("METHypoAlg") +hypoAlg.HypoTools=[makeMETHypoTool()] +for t in hypoAlg.HypoTools: + t.OutputLevel=VERBOSE +hypoAlg.METContainerKey=metAlg.METContainerKey + +# Not sure how to implement monitoring at the moment. +# Left here in case will be useful. +# Will be removed if not +''' +from TrigMissingETHypo.TrigMissingETHypoMonitoringTool import TrigMissingETHypoMonitoringTool +hypoMon = TrigMissingETHypoMonitoringTool() +hypoAlg.onlineMonitoring() +''' + +hypoAlg.OutputLevel=DEBUG +hypoAlg.HypoInputDecisions = "L1MET" +hypoAlg.HypoOutputDecisions = "EFMETDecisions" +topSequence += hypoAlg + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromJets.py b/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromJets.py new file mode 100644 index 00000000000..b0d9b222979 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met.fromJets.py @@ -0,0 +1,92 @@ +# +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +OutputLevel=WARNING +include("TrigUpgradeTest/testHLT_MT.py") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +import math +from TrigT2CaloCommon.TrigT2CaloCommonConf import TrigCaloDataAccessSvc#, TestCaloDataAccess +from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram + +mon = GenericMonitoringTool("CaloDataAccessSvcMon") +mon.Histograms += [defineHistogram( "TIME_locking_LAr_RoI", path='EXPERT', title="Time spent in unlocking the LAr collection", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "roiROBs_LAr", path='EXPERT', title="Number of ROBs unpacked in RoI requests", xbins=20, xmin=0, xmax=20 ), + defineHistogram( "TIME_locking_LAr_FullDet", path='EXPERT', title="Time spent in unlocking the LAr collection", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "roiEta_LAr,roiPhi_LAr", type="TH2F", path='EXPERT', title="Geometric usage", xbins=50, xmin=-5, xmax=5, ybins=64, ymin=-math.pi, ymax=math.pi )] + +svcMgr += TrigCaloDataAccessSvc() +svcMgr.TrigCaloDataAccessSvc.MonTool = mon +svcMgr.TrigCaloDataAccessSvc.OutputLevel=WARNING + + +################################################# +# Create RoI and get jets +################################################# +from L1Decoder.L1DecoderConf import CreateFullScanRoI +topSequence += CreateFullScanRoI() + +from TrigUpgradeTest.jetDefs import jetRecoSequence +(jetSequence, jetsKey) = jetRecoSequence( RoIs="FullScanRoIs" ) +topSequence += jetSequence + +################################################# +# Add EFMissingETFrom** algorithm +################################################# + +from TrigEFMissingET.TrigEFMissingETConf import EFMissingETAlgMT, EFMissingETFromJetsMT, EFMissingETFromHelper + +metAlg = EFMissingETAlgMT( name="EFMET" ) + +mhtTool = EFMissingETFromJetsMT( name="METFromJetsTool" ) +mhtTool.JetsCollection = jetsKey +mhtTool.OutputLevel=DEBUG +metAlg.METTools=[ mhtTool ] + +helperTool = EFMissingETFromHelper("theHelperTool") +metAlg.HelperTool= helperTool + +metAlg.OutputLevel=DEBUG +metAlg.METContainerKey="HLT_MET_mht" + +metMon = GenericMonitoringTool("METMonTool") +metMon.Histograms = [ defineHistogram( "TIME_Total", path='EXPERT', title="Time spent Alg", xbins=100, xmin=0, xmax=100 ), + defineHistogram( "TIME_Loop", path='EXPERT', title="Time spent in Tools loop", xbins=100, xmin=0, xmax=100 )] +from TrigEFMissingET.TrigEFMissingETMonitoring import ( hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log, + hMET_lin, hSumEt_lin, + hXS, hMETPhi, hMETStatus, + hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE, + hCompEt_lin, hCompSumEt_lin ) + +metMon.Histograms = [ hEx_log, hEy_log, hEz_log, hMET_log, hSumEt_log ] +metMon.Histograms += [ hMET_lin, hSumEt_lin ] +metMon.Histograms += [ hXS, hMETPhi, hMETStatus] +metMon.Histograms += [ hCompEx, hCompEy, hCompEz, hCompEt, hCompSumEt, hCompSumE ] +metMon.Histograms += [ hCompEt_lin, hCompSumEt_lin ] + +metAlg.MonTool = metMon +topSequence += metAlg + +################################################# +# Add TrigMissingETHypo algorithm and tool +################################################# +from TrigMissingETHypo.TrigMissingETHypoConfigMT import MissingETHypoAlgMT, MissingETHypoToolMT + +def makeMETHypoTool(): + hypoTool = MissingETHypoToolMT("HLT_xe10") + hypoTool.metThreshold = 10 + return hypoTool + +hypoAlg = MissingETHypoAlgMT("METHypoAlg") +hypoAlg.HypoTools=[makeMETHypoTool()] +for t in hypoAlg.HypoTools: + t.OutputLevel=VERBOSE +hypoAlg.METContainerKey=metAlg.METContainerKey + +hypoAlg.OutputLevel=DEBUG +hypoAlg.HypoInputDecisions = "L1MET" +hypoAlg.HypoOutputDecisions = "EFMETDecisions" +topSequence += hypoAlg + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py b/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py index c8c4b06111d..07534b576b7 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met.menu.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # import flags @@ -11,13 +11,14 @@ include("TrigUpgradeTest/testHLT_MT.py") from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep -from TrigUpgradeTest.metMenuDefs import metCellMenuSequence +from TrigUpgradeTest.metMenuDefs import metCellMenuSequence, metJetMenuSequence metCellSeq = metCellMenuSequence() metCellStep = ChainStep("Step1_met_cell", [metCellSeq]) + testChains = [ Chain(name="HLT_xe65_L1XE50", Seed="L1_XE50", ChainSteps=[metCellStep]), - Chain(name="HLT_xe30_L1XE10", Seed="L1_XE10", ChainSteps=[metCellStep]) + Chain(name="HLT_xe30_L1XE10", Seed="L1_XE10", ChainSteps=[metCellStep]), ] diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met_standalone.ref b/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromCells.ref similarity index 100% rename from Trigger/TrigValidation/TrigUpgradeTest/share/met_standalone.ref rename to Trigger/TrigValidation/TrigUpgradeTest/share/met_fromCells.ref diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromClusters.ref b/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromClusters.ref new file mode 100644 index 00000000000..b90c7d4a934 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromClusters.ref @@ -0,0 +1,10 @@ +METHypoAlg 0 0 DEBUG The MET value is 13 +METHypoAlg 1 0 DEBUG The MET value is 23 +METHypoAlg 2 0 DEBUG The MET value is 35 +METHypoAlg 3 0 DEBUG The MET value is 20 +METHypoAlg 4 0 DEBUG The MET value is 21 +METHypoAlg 5 0 DEBUG The MET value is 59 +METHypoAlg 6 0 DEBUG The MET value is 32 +METHypoAlg 7 0 DEBUG The MET value is 51 +METHypoAlg 8 0 DEBUG The MET value is 31 +METHypoAlg 9 0 DEBUG The MET value is 39 diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromJets.ref b/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromJets.ref new file mode 100644 index 00000000000..1d78a55d2ff --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/met_fromJets.ref @@ -0,0 +1,10 @@ +METHypoAlg 0 0 DEBUG The MET value is 11 +METHypoAlg 1 0 DEBUG The MET value is 47 +METHypoAlg 2 0 DEBUG The MET value is 12 +METHypoAlg 3 0 DEBUG The MET value is 34 +METHypoAlg 4 0 DEBUG The MET value is 13 +METHypoAlg 5 0 DEBUG The MET value is 43 +METHypoAlg 6 0 DEBUG The MET value is 12 +METHypoAlg 7 0 DEBUG The MET value is 52 +METHypoAlg 8 0 DEBUG The MET value is 19 +METHypoAlg 9 0 DEBUG The MET value is 48 diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromCells.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromCells.sh new file mode 100755 index 00000000000..0d21061f0e7 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromCells.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# art-type: build +# art-ci: master + +athena --threads=1 --evtMax=10 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/met.fromCells.py + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromClusters.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromClusters.sh new file mode 100755 index 00000000000..5a04d7ec91d --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromClusters.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# art-type: build +# art-ci: master + +athena --threads=1 --evtMax=10 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/met.fromClusters.py + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_standalone.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromJets.sh similarity index 90% rename from Trigger/TrigValidation/TrigUpgradeTest/test/test_met_standalone.sh rename to Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromJets.sh index a72ce3984e0..595ba52d0cb 100755 --- a/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_standalone.sh +++ b/Trigger/TrigValidation/TrigUpgradeTest/test/test_met_fromJets.sh @@ -2,5 +2,5 @@ # art-type: build # art-ci: master -athena --threads=1 --evtMax=10 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/metTest.py +athena --threads=1 --evtMax=10 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/met.fromJets.py -- GitLab