diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py index e5be898d987fa04e401a946c05a89c91c1d5664a..9a53aa4eac9c9de07bd4421733d6c8803dde591c 100644 --- a/Control/AthenaConfiguration/python/AllConfigFlags.py +++ b/Control/AthenaConfiguration/python/AllConfigFlags.py @@ -182,6 +182,11 @@ def _createCfgFlags(): return createEgammaConfigFlags() _addFlagsCategory(acf, "Egamma", __egamma, 'egammaConfig' ) + def __met(): + from METReconstruction.METConfigFlags import createMETConfigFlags + return createMETConfigFlags() + _addFlagsCategory(acf,"MET",__met, 'METReconstruction') + def __pflow(): from eflowRec.PFConfigFlags import createPFConfigFlags return createPFConfigFlags() diff --git a/Reconstruction/MET/METReconstruction/CMakeLists.txt b/Reconstruction/MET/METReconstruction/CMakeLists.txt index e61c845b9a2c33d6b6c1dc219f157b6d252c7ce6..21c54268cf62626b71dbb687821063de1fdac1b6 100644 --- a/Reconstruction/MET/METReconstruction/CMakeLists.txt +++ b/Reconstruction/MET/METReconstruction/CMakeLists.txt @@ -20,6 +20,7 @@ atlas_depends_on_subdirs( PUBLIC Reconstruction/MET/METRecoInterface PRIVATE Calorimeter/CaloInterface + Calorimeter/CaloConditions Event/FourMomUtils InnerDetector/InDetRecTools/InDetTrackSelectionTool InnerDetector/InDetRecTools/TrackVertexAssociationTool @@ -53,5 +54,5 @@ atlas_add_dictionary( METReconstructionDict LINK_LIBRARIES ${ROOT_LIBRARIES} ) # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py python/LegacyRunII/*.py) atlas_install_joboptions( share/*.py ) diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h index 6a196aa102ddd07cd09f14a06837676155a6147d..b53a4712c3ebb2fee36b5fa054750de1685120ff 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h @@ -105,7 +105,6 @@ namespace met{ SG::WriteHandleKey<xAOD::MissingETAssociationMap> m_mapnameKey; - int m_signalstate; bool m_overwrite; ToolHandleArray<IMETAssocToolBase> m_metassociators; diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METBuilderTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METBuilderTool.h index 6a2271de1e8ba79e28a60632f0edd9008cd16fe3..c62a5b3bcc0c7fd31f5b323cc9b4f20359fb471a 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METBuilderTool.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METBuilderTool.h @@ -72,7 +72,6 @@ namespace met { std::string m_input_data_key; std::string m_output_met_key; std::string m_mod_clus_key; - int m_signalstate; // use an int for now - signal states seem to be defined in the object classes, e.g. CaloCluster and Jet bool m_useRapidity; // by default, use pseudorapidity for matching bool m_useModClus; // use modified e.g. origin-corrected clusters diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h index bc27b932fe88e02db39df2e2428c9e57d3e5ff97..41dc936f6bb5f9fa0150663b2e0d9c62efe3e3c9 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h @@ -127,6 +127,8 @@ namespace met{ #else SG::ReadCondHandleKey<CaloNoise> m_noiseCDOKey{this,"CaloNoiseKey","totalNoise","SG Key of CaloNoise data object"}; #endif + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_caloClusterKey{this,"CaloClusterKey","","SG Key of Calo Cluster Collection"}; + SG::ReadHandleKey<CaloCellContainer> m_caloCellKey{this,"CaloCellKey","","SG Key of Calo Cell Container"}; }; } diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METJetFilterTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METJetFilterTool.h deleted file mode 100644 index c2d8bffbe88055739b9f64dd568b3ef03e504f84..0000000000000000000000000000000000000000 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METJetFilterTool.h +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////// -*- C++ -*- ///////////////////////////// - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// METJetFilterTool.h -// Header file for class METJetFilterTool -// -// This is a scheduler for the MET Reconstruction, and sets up -// the sequence in which the individual terms are constructed. -// -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// -// Author: P Loch, S Resconi, TJ Khoo -/////////////////////////////////////////////////////////////////// -#ifndef METRECONSTRUCTION_METJETFILTERTOOL_H -#define METRECONSTRUCTION_METJETFILTERTOOL_H 1 - -// STL includes -#include <string> - -// METReconstruction includes -#include "METReconstruction/METRefinerTool.h" - -// Forward declaration -#include "xAODJet/Jet.h" - -namespace met{ - - class METJetFilterTool - : public METRefinerTool - { - // This macro defines the constructor with the interface declaration - ASG_TOOL_CLASS(METJetFilterTool, IMETToolBase) - - - /////////////////////////////////////////////////////////////////// - // Public methods: - /////////////////////////////////////////////////////////////////// - public: - - // Constructor with name (does this have to be a non-const - // std::string and not a const reference?) - METJetFilterTool(const std::string& name); - ~METJetFilterTool(); - - // AsgTool Hooks - StatusCode initialize(); - StatusCode finalize(); - - /////////////////////////////////////////////////////////////////// - // Const methods: - /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // Non-const methods: - /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // Private data: - /////////////////////////////////////////////////////////////////// - protected: - StatusCode executeTool(xAOD::MissingET* metTerm, xAOD::MissingETComponentMap* metMap) const; - // Accept functions - bool isHSJet (const xAOD::Jet* jet) const; - - private: - // Default constructor: - METJetFilterTool(); - - bool m_jet_doJVFCut; - double m_jet_minAbsJVF; - double m_jet_maxPtJVF; - double m_jet_maxEtaJVF; - }; - -} - -// I/O operators -////////////////////// - -/////////////////////////////////////////////////////////////////// -// Inline methods: -/////////////////////////////////////////////////////////////////// - - -#endif //> !METRECONSTRUCTION_METJETFILTERTOOL_H diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METSoftTermsTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METSoftTermsTool.h index f97799da74fd7170e0bdf34a0f29db0f38815887..b206bb0aef81681a9e0b5b85b59b2f2fa66e0dc7 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METSoftTermsTool.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METSoftTermsTool.h @@ -31,11 +31,9 @@ #include "xAODTracking/TrackParticleFwd.h" // PFlow EDM and helpers -#include "xAODPFlow/PFO.h" +#include "xAODPFlow/PFOContainer.h" +#include "PFlowUtils/IRetrievePFOTool.h" -namespace CP { - class IRetrievePFOTool; -} namespace met{ @@ -91,17 +89,17 @@ namespace met{ METSoftTermsTool(); // Use Case - Clusters OR Tracks OR PFOs std::string m_inputType; - unsigned short m_st_objtype; // should make this an enum somewhere + unsigned short m_st_objtype{0}; // should make this an enum somewhere // Cluster selection bool m_cl_vetoNegE; bool m_cl_onlyNegE; // temporary, until a track-vertex association tool is available //std::string m_pv_inputkey; - SG::ReadHandleKey<xAOD::VertexContainer> m_pv_inputkey; - SG::ReadHandleKey<xAOD::CaloClusterContainer> m_caloClusterKey; - SG::ReadHandleKey<xAOD::TrackParticleContainer> m_trackParticleKey; + SG::ReadHandleKey<xAOD::VertexContainer> m_pv_inputkey{this,"InputPVKey","PrimaryVertices",""}; + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_caloClusterKey{""}; + SG::ReadHandleKey<xAOD::TrackParticleContainer> m_trackParticleKey{""}; - ToolHandle<CP::IRetrievePFOTool> m_pfotool; + ToolHandle<CP::IRetrievePFOTool> m_pfotool{this,"PFOTool","",""}; }; } diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METTrackFilterTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METTrackFilterTool.h index 1b7b8c4ec02b5911b95a46e93f9d0336cf9b2b50..f7e51f4614f044c6bef53e151de8554fd31f29dd 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METTrackFilterTool.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METTrackFilterTool.h @@ -34,19 +34,13 @@ #include "xAODMuon/Muon.h" #include "xAODMuon/MuonContainer.h" +// Tool interfaces +#include "InDetTrackSelectionTool/IInDetTrackSelectionTool.h" +#include "TrackVertexAssociationTool/ITrackVertexAssociationTool.h" -namespace InDet { - class IInDetTrackSelectionTool; -} - -namespace xAOD { - class ITrackIsolationTool; - class ICaloTopoClusterIsolationTool; -} +#include "RecoToolInterfaces/ITrackIsolationTool.h" +#include "RecoToolInterfaces/ICaloTopoClusterIsolationTool.h" -namespace CP { - class ITrackVertexAssociationTool; -} namespace met{ @@ -104,32 +98,26 @@ namespace met{ bool isElTrack(const xAOD::TrackParticle &trk, const std::vector<const xAOD::Electron*>& electrons, size_t &el_index ) const; bool isMuTrack(const xAOD::TrackParticle &trk, const std::vector<const xAOD::Muon*>& muons) const; - ToolHandle<InDet::IInDetTrackSelectionTool> m_trkseltool; - ToolHandle<CP::ITrackVertexAssociationTool> m_trkToVertexTool; - ToolHandle<xAOD::ITrackIsolationTool> m_trkIsolationTool; - ToolHandle<xAOD::ICaloTopoClusterIsolationTool> m_caloIsolationTool; + ToolHandle<InDet::IInDetTrackSelectionTool> m_trkseltool{this,"TrackSelectorTool","",""}; + ToolHandle<CP::ITrackVertexAssociationTool> m_trkToVertexTool{this,"TrackVxAssocTool","",""}; + ToolHandle<xAOD::ITrackIsolationTool> m_trkIsolationTool{this,"TrackIsolationTool","",""}; + ToolHandle<xAOD::ICaloTopoClusterIsolationTool> m_caloIsolationTool{this,"CaloIsolationTool","",""}; void selectElectrons(const xAOD::ElectronContainer &elCont, std::vector<const xAOD::Electron*>& electrons) const; void selectMuons(const xAOD::MuonContainer &muCont, std::vector<const xAOD::Muon*>& muons) const; bool m_trk_doPVsel; - // double m_trk_d0Max; - // double m_trk_z0Max; - std::string m_pv_input; - std::string m_el_input; - std::string m_mu_input; - SG::ReadHandleKey<xAOD::ElectronContainer> m_el_inputkey; - SG::ReadHandleKey<xAOD::MuonContainer> m_mu_inputkey; - SG::ReadHandleKey<xAOD::VertexContainer> m_pv_inputkey; - SG::ReadHandleKey<xAOD::CaloClusterContainer> m_cl_inputkey; + SG::ReadHandleKey<xAOD::ElectronContainer> m_el_inputkey{this,"InputElectronKey","Electrons",""}; + SG::ReadHandleKey<xAOD::MuonContainer> m_mu_inputkey{this,"InputMuonKey","Muons",""}; + SG::ReadHandleKey<xAOD::VertexContainer> m_pv_inputkey{this,"InputPVKey","PrimaryVertices",""}; + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_cl_inputkey{this,"InputClusterKey","CaloCalTopoClusters",""}; bool m_doVxSep; bool m_doLepRecovery; bool m_useIsolationTools; bool m_trk_doEoverPsel; - std::string m_cl_input; double m_cenTrackPtThr; double m_forTrackPtThr; diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METTruthAssociator.h b/Reconstruction/MET/METReconstruction/METReconstruction/METTruthAssociator.h index 7e355eeaaaf1706f87bd4e757c76f5ebc0dab08d..093c518d5ba42573cc3a6ad54ceda496ec77bec7 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METTruthAssociator.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METTruthAssociator.h @@ -91,20 +91,12 @@ namespace met{ private: - std::string m_recoJet; - std::string m_recoEl; - std::string m_recoMu; - std::string m_recoGam; - std::string m_recoTau; - - SG::ReadHandleKey<xAOD::ElectronContainer> m_recoElKey; - SG::ReadHandleKey<xAOD::PhotonContainer> m_recoGamKey; - SG::ReadHandleKey<xAOD::TauJetContainer> m_recoTauKey; - SG::ReadHandleKey<xAOD::MuonContainer> m_recoMuKey; - SG::ReadHandleKey<xAOD::JetContainer> m_recoJetKey; - - std::string m_truthEvent; - SG::ReadHandleKey<xAOD::TruthEventContainer> m_truthEventKey; + SG::ReadHandleKey<xAOD::ElectronContainer> m_recoElKey{this,"RecoElKey","Electrons",""}; + SG::ReadHandleKey<xAOD::PhotonContainer> m_recoGamKey{this,"RecoGamKey","Photons",""}; + SG::ReadHandleKey<xAOD::TauJetContainer> m_recoTauKey{this,"RecoTauKey","TauJets",""}; + SG::ReadHandleKey<xAOD::MuonContainer> m_recoMuKey{this,"RecoMuKey","Muons",""}; + SG::ReadHandleKey<xAOD::JetContainer> m_recoJetKey{this,"RecoJetKey","",""}; + SG::ReadHandleKey<xAOD::TruthEventContainer> m_truthEventKey{this,"TruthEventKey","TruthEvents",""}; /// Default constructor: METTruthAssociator(); diff --git a/Reconstruction/MET/METReconstruction/Root/METAssociationTool.cxx b/Reconstruction/MET/METReconstruction/Root/METAssociationTool.cxx index 084915e2bb9638c1e191e5bcf7d12d43fcd521a3..44c5303c5a0120c449d6425f9c7d14edb4e5b66b 100644 --- a/Reconstruction/MET/METReconstruction/Root/METAssociationTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METAssociationTool.cxx @@ -48,7 +48,6 @@ namespace met { { declareProperty( "METAssociators", m_metassociators ); declareProperty( "METSuffix", m_metsuffix = "AntiKt4LCTopo" ); - declareProperty( "TCSignalState", m_signalstate = 1 ); declareProperty( "AllowOverwrite", m_overwrite = false ); declareProperty( "TimingDetail", m_timedetail = 0 ); diff --git a/Reconstruction/MET/METReconstruction/Root/METBuilderTool.cxx b/Reconstruction/MET/METReconstruction/Root/METBuilderTool.cxx index e6818a31ee631aa01858e0e1bc720c1bd6b121ab..5b7975720e0f5ee2ad6baa3c6a45731e087b74d6 100644 --- a/Reconstruction/MET/METReconstruction/Root/METBuilderTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METBuilderTool.cxx @@ -40,7 +40,6 @@ namespace met { { declareProperty( "InputCollection", m_input_data_key ); declareProperty( "MissingETKey", m_output_met_key ); - declareProperty( "SignalState", m_signalstate = 0 ); declareProperty( "UseRapidity", m_useRapidity = false ); declareProperty( "ModifiedClusKey", m_mod_clus_key = "" ); } diff --git a/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx b/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx index 4a45221c973267e606c2ea3a75342f96bf5e9b6b..3abd0603dca1164220f45bd45bbf773029257a6b 100644 --- a/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx @@ -75,6 +75,14 @@ namespace met { #else ATH_CHECK( m_noiseCDOKey.initialize() ); #endif + // Either Cells or Clusters + if(m_calo_useCells) { + ATH_CHECK( m_caloCellKey.assign(m_input_data_key)); + } else { + ATH_CHECK( m_caloClusterKey.assign(m_input_data_key)); + } // end if use clusters if/else + ATH_CHECK( m_caloCellKey.initialize(m_calo_useCells) ); + ATH_CHECK( m_caloClusterKey.initialize(!m_calo_useCells) ); return StatusCode::SUCCESS; } @@ -137,11 +145,12 @@ namespace met { // Either Cells or Clusters if(m_calo_useCells) { // Retrieve the cell container - SG::ReadHandle<CaloCellContainer> caloCellCont(m_input_data_key); + SG::ReadHandle<CaloCellContainer> caloCellCont(m_caloCellKey); #if defined(XAOD_STANDALONE) || defined(XAOD_ANALYSIS) #else if (!caloCellCont.isValid()) { + ATH_MSG_WARNING("Couldn't set up ReadHandle for Calo Cell Container "<<m_input_data_key); ATH_MSG_WARNING("Unable to retrieve input cell cluster container"); return StatusCode::SUCCESS; @@ -151,7 +160,7 @@ namespace met { sc = fillCellMet(metCont,caloCellCont.cptr()); } else { // Retrieve the calo container - SG::ReadHandle<CaloClusterContainer> caloClusCont(m_input_data_key); + SG::ReadHandle<CaloClusterContainer> caloClusCont(m_caloClusterKey); if (!caloClusCont.isValid()) { ATH_MSG_WARNING("Unable to retrieve input calo cluster container"); return StatusCode::SUCCESS; diff --git a/Reconstruction/MET/METReconstruction/Root/METSoftTermsTool.cxx b/Reconstruction/MET/METReconstruction/Root/METSoftTermsTool.cxx index 9d820fc86c2b174c87b255683ad92a822b629660..9364356484b7ea07157d8be9fcc3457a4a93e29a 100644 --- a/Reconstruction/MET/METReconstruction/Root/METSoftTermsTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METSoftTermsTool.cxx @@ -31,10 +31,6 @@ #include "xAODCaloEvent/CaloVertexedClusterBase.h" -// PFlow EDM and helpers -#include "xAODPFlow/PFOContainer.h" -#include "PFlowUtils/IRetrievePFOTool.h" - namespace met { using std::vector; @@ -64,17 +60,12 @@ namespace met { //////////////// METSoftTermsTool::METSoftTermsTool(const std::string& name) : AsgTool(name), - METBuilderTool(name), - m_st_objtype(0), - m_pv_inputkey("PrimaryVertices"), - m_caloClusterKey(""), - m_trackParticleKey("") + METBuilderTool(name) { declareProperty( "InputComposition", m_inputType = "Clusters" ); // Options : Clusters (default) OR Tracks OR PFOs //declareProperty( "InputPVKey", m_pv_inputkey = "PrimaryVertices" ); declareProperty( "VetoNegEClus", m_cl_vetoNegE = true ); declareProperty( "OnlyNegEClus", m_cl_onlyNegE = false ); - declareProperty( "PFOTool", m_pfotool ); } // Destructor diff --git a/Reconstruction/MET/METReconstruction/Root/METTrackFilterTool.cxx b/Reconstruction/MET/METReconstruction/Root/METTrackFilterTool.cxx index c9085f030b6549345d4a6ce5711d74d77bcead36..6324e00827776a58767f33fdde0d37d35547770c 100644 --- a/Reconstruction/MET/METReconstruction/Root/METTrackFilterTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METTrackFilterTool.cxx @@ -37,13 +37,6 @@ // ConstDV #include "AthContainers/ConstDataVector.h" -// Tool interfaces -#include "InDetTrackSelectionTool/IInDetTrackSelectionTool.h" -#include "TrackVertexAssociationTool/ITrackVertexAssociationTool.h" - -#include "RecoToolInterfaces/ITrackIsolationTool.h" -#include "RecoToolInterfaces/ICaloTopoClusterIsolationTool.h" - // DeltaR calculation #include "FourMomUtils/xAODP4Helpers.h" @@ -64,20 +57,10 @@ namespace met { METRefinerTool(name) { declareProperty( "DoPVSel", m_trk_doPVsel = true ); - // declareProperty( "TrackD0Max", m_trk_d0Max = 1.5 ); - // declareProperty( "TrackZ0Max", m_trk_z0Max = 1.5 ); - declareProperty( "InputPVKey", m_pv_input = "PrimaryVertices" ); declareProperty( "DoEoverPSel", m_trk_doEoverPsel = false ); - declareProperty( "InputClusterKey", m_cl_input = "CaloCalTopoClusters"); - declareProperty( "InputElectronKey", m_el_input = "Electrons" ); - declareProperty( "InputMuonKey", m_mu_input = "Muons" ); declareProperty( "DoVxSep", m_doVxSep = false ); - declareProperty( "TrackSelectorTool", m_trkseltool ); - declareProperty( "TrackVxAssocTool", m_trkToVertexTool ); declareProperty( "DoLepRecovery", m_doLepRecovery=false ); declareProperty( "UseIsolationTools", m_useIsolationTools=true ); - declareProperty( "TrackIsolationTool", m_trkIsolationTool ); - declareProperty( "CaloIsolationTool", m_caloIsolationTool ); declareProperty( "CentralTrackPtThr", m_cenTrackPtThr = 200e+3 ); declareProperty( "ForwardTrackPtThr", m_forTrackPtThr = 120e+3 ); } @@ -100,14 +83,10 @@ namespace met { if(m_doVxSep) ATH_MSG_INFO("Building TrackMET for each vertex"); - ATH_CHECK( m_cl_inputkey.assign(m_cl_input)); ATH_CHECK( m_cl_inputkey.initialize()); - ATH_CHECK( m_pv_inputkey.assign(m_pv_input)); ATH_CHECK( m_pv_inputkey.initialize()); if(m_doLepRecovery){ - ATH_CHECK( m_el_inputkey.assign(m_el_input)); ATH_CHECK( m_el_inputkey.initialize()); - ATH_CHECK( m_mu_inputkey.assign(m_mu_input)); ATH_CHECK( m_mu_inputkey.initialize()); } @@ -236,14 +215,14 @@ namespace met { { SG::ReadHandle<xAOD::ElectronContainer> elCont(m_el_inputkey); if (!elCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve electron container " << m_el_input); + ATH_MSG_WARNING("Unable to retrieve electron container " << m_el_inputkey.key()); return StatusCode::SUCCESS; } else { selectElectrons(*elCont, selElectrons); } SG::ReadHandle<xAOD::MuonContainer> muCont(m_mu_inputkey); if (!muCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve muon container " << m_mu_input); + ATH_MSG_WARNING("Unable to retrieve muon container " << m_mu_inputkey.key()); return StatusCode::SUCCESS; } else { selectMuons(*muCont, selMuons); diff --git a/Reconstruction/MET/METReconstruction/Root/METTruthAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METTruthAssociator.cxx index 4ce4a55be02854a0d2e9e3b82e7483a1a7ae1009..58af810cba3d597efc5a3ab0fe0de2feea2f931d 100644 --- a/Reconstruction/MET/METReconstruction/Root/METTruthAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METTruthAssociator.cxx @@ -47,16 +47,7 @@ namespace met { METTruthAssociator::METTruthAssociator(const std::string& name) : AsgTool(name), METAssociator(name) - { - - declareProperty("RecoJetKey", m_recoJet ); - declareProperty("RecoElKey", m_recoEl = "Electrons" ); - declareProperty("RecoMuKey", m_recoMu = "Muons" ); - declareProperty("RecoGamKey", m_recoGam = "Photons" ); - declareProperty("RecoTauKey", m_recoTau = "TauJets" ); - - declareProperty("TruthEventKey", m_truthEvent = "TruthEvents" ); - } + {} // Destructor /////////////// @@ -70,17 +61,11 @@ namespace met { ATH_CHECK( METAssociator::initialize() ); ATH_MSG_VERBOSE ("Initializing " << name() << "..."); //initialise ReadHandleKeys - ATH_CHECK( m_recoElKey.assign(m_recoEl)); ATH_CHECK( m_recoElKey.initialize()); - ATH_CHECK( m_recoJetKey.assign(m_recoJet)); ATH_CHECK( m_recoJetKey.initialize()); - ATH_CHECK( m_recoMuKey.assign(m_recoMu)); ATH_CHECK( m_recoMuKey.initialize()); - ATH_CHECK( m_recoGamKey.assign(m_recoGam)); ATH_CHECK( m_recoGamKey.initialize()); - ATH_CHECK( m_recoTauKey.assign(m_recoTau)); ATH_CHECK( m_recoTauKey.initialize()); - ATH_CHECK( m_truthEventKey.assign(m_truthEvent)); ATH_CHECK( m_truthEventKey.initialize()); return StatusCode::SUCCESS; @@ -112,48 +97,48 @@ namespace met { SG::ReadHandle<xAOD::ElectronContainer> electronCont(m_recoElKey); if (!electronCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input electron container " << m_recoEl); + ATH_MSG_WARNING("Unable to retrieve input electron container " << m_recoElKey.key()); return StatusCode::FAILURE; } ATH_MSG_DEBUG("Successfully retrieved electron collection"); if(fillAssocMap(metMap,electronCont.cptr()).isFailure()) { - ATH_MSG_WARNING("Unable to fill map with electron container " << m_recoEl); + ATH_MSG_WARNING("Unable to fill map with electron container " << m_recoElKey.key()); return StatusCode::FAILURE; } SG::ReadHandle<xAOD::PhotonContainer> photonCont(m_recoGamKey); if (!photonCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input photon container " << m_recoGam); + ATH_MSG_WARNING("Unable to retrieve input photon container " << m_recoGamKey.key()); return StatusCode::FAILURE; } ATH_MSG_DEBUG("Successfully retrieved photon collection"); if(fillAssocMap(metMap,photonCont.cptr()).isFailure()) { - ATH_MSG_WARNING("Unable to fill map with photon container " << m_recoGam); + ATH_MSG_WARNING("Unable to fill map with photon container " << m_recoGamKey.key()); return StatusCode::FAILURE; } SG::ReadHandle<xAOD::MuonContainer> muonCont(m_recoMuKey); if (!muonCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input muon container " << m_recoMu); + ATH_MSG_WARNING("Unable to retrieve input muon container " << m_recoMuKey.key()); return StatusCode::FAILURE; } ATH_MSG_DEBUG("Successfully retrieved muon collection"); if(fillAssocMap(metMap,muonCont.cptr()).isFailure()) { - ATH_MSG_WARNING("Unable to fill map with muon container " << m_recoMu); + ATH_MSG_WARNING("Unable to fill map with muon container " << m_recoMuKey.key()); return StatusCode::FAILURE; } SG::ReadHandle<xAOD::TauJetContainer> tauCont(m_recoTauKey); if (!tauCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input tau container " << m_recoTau); + ATH_MSG_WARNING("Unable to retrieve input tau container " << m_recoTauKey.key()); return StatusCode::FAILURE; } ATH_MSG_DEBUG("Successfully retrieved tau collection"); if(fillAssocMap(metMap,tauCont.cptr()).isFailure()) { - ATH_MSG_WARNING("Unable to fill map with tau container " << m_recoTau); + ATH_MSG_WARNING("Unable to fill map with tau container " << m_recoTauKey.key()); return StatusCode::FAILURE; } @@ -173,7 +158,7 @@ namespace met { // Retrieve the jet container SG::ReadHandle<xAOD::JetContainer> jetCont(m_recoJetKey); if (!jetCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input jet container " << m_recoJet); + ATH_MSG_WARNING("Unable to retrieve input jet container " << m_recoJetKey.key()); return StatusCode::FAILURE; } ATH_MSG_DEBUG("Successfully retrieved jet collection"); @@ -239,7 +224,7 @@ namespace met { // Retrieve the truth container SG::ReadHandle<xAOD::TruthEventContainer> truthEventCont(m_truthEventKey); if (!truthEventCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input truthEvent container " << m_truthEvent); + ATH_MSG_WARNING("Unable to retrieve input truthEvent container " << m_truthEventKey.key()); return StatusCode::FAILURE; } @@ -319,7 +304,7 @@ namespace met { // Retrieve the truth container SG::ReadHandle<xAOD::TruthEventContainer> truthEventCont(m_truthEventKey); if (!truthEventCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input truthEvent container " << m_truthEvent); + ATH_MSG_WARNING("Unable to retrieve input truthEvent container " << m_truthEventKey.key()); return StatusCode::SUCCESS; } @@ -413,7 +398,7 @@ namespace met { // Retrieve the truth container SG::ReadHandle<xAOD::TruthEventContainer> truthEventCont(m_truthEventKey); if (!truthEventCont.isValid()) { - ATH_MSG_WARNING("Unable to retrieve input truthEvent container " << m_truthEvent); + ATH_MSG_WARNING("Unable to retrieve input truthEvent container " << m_truthEventKey.key()); return StatusCode::SUCCESS; } diff --git a/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx b/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx index 863889c04b45d3125951cc7ce5e0fdc80877a93e..3ab6eeb831c34e65fd55e069dbc93dc22003e1b8 100644 --- a/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx @@ -120,7 +120,7 @@ namespace met { { // Apply cuts ATH_MSG_VERBOSE("Check if truth particle is accepted"); - + if(!object){return false;} if(object->type() != xAOD::Type::TruthParticle) { ATH_MSG_WARNING("METTruthTool::accept given an object of type" << object->type()); return false; diff --git a/Reconstruction/MET/METReconstruction/python/METAssocConfig.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py similarity index 95% rename from Reconstruction/MET/METReconstruction/python/METAssocConfig.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py index 29e27fd9519cef234300529f68587f1f815c5a26..7eda937940e6c2d8655119878ce64da7d90dad7a 100644 --- a/Reconstruction/MET/METReconstruction/python/METAssocConfig.py +++ b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py @@ -8,12 +8,6 @@ import six ################################################################################# # Define some default values -clusterSigStates = { - 'EMScale':0, - 'LocHad':1, - 'Mod':1 -} - defaultInputKey = { 'Ele' :'Electrons', 'Gamma' :'Photons', @@ -210,14 +204,9 @@ def getMETAssocTool(topconfig,msglvl): METAssociators = topconfig.assoclist, METSuffix = topconfig.suffix) else: - tcstate = clusterSigStates['LocHad'] - if 'EMTopo' in topconfig.suffix: tcstate = clusterSigStates['EMScale'] - if topconfig.modConstKey!="": - tcstate = clusterSigStates['Mod'] assocTool = CfgMgr.met__METAssociationTool('MET_AssociationTool_'+topconfig.suffix, METAssociators = topconfig.assoclist, METSuffix = topconfig.suffix, - TCSignalState=tcstate, TimingDetail=0, OutputLevel=msglvl) if metFlags.AllowOverwrite: @@ -232,11 +221,11 @@ def getMETAssocAlg(algName='METAssociation',configs={},tools=[],msglvl=INFO): from METReconstruction.METRecoFlags import metFlags if configs=={} and tools==[]: - print (prefix, 'Taking configurations from METRecoFlags') + print( prefix, 'Taking configurations from METRecoFlags') configs = metFlags.METAssocConfigs() - print (configs) + print(configs) for key,conf in six.iteritems(configs): - print (prefix, 'Generate METAssocTool for MET_'+key) + print( prefix, 'Generate METAssocTool for MET_'+key) assoctool = getMETAssocTool(conf,msglvl) assocTools.append(assoctool) metFlags.METAssocTools()[key] = assoctool diff --git a/Reconstruction/MET/METReconstruction/python/METAssocConfig_readAOD.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig_readAOD.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METAssocConfig_readAOD.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig_readAOD.py diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_Associator.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Associator.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METConfig_Associator.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Associator.py diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_Calo.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Calo.py similarity index 82% rename from Reconstruction/MET/METReconstruction/python/METConfig_Calo.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Calo.py index 5749e2c42a84211d783f716a6704e14ca5eb2b6f..b5be96d90cd5b18678a4eac603a9053ae41ce2c4 100644 --- a/Reconstruction/MET/METReconstruction/python/METConfig_Calo.py +++ b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Calo.py @@ -1,8 +1,7 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration from METReconstruction.METRecoFlags import metFlags -from METReconstruction.METRecoConfig import BuildConfig, RefConfig, METConfig,clusterSigStates -#from METReconstruction.METRecoConfig_Associator import BuildConfig, RefConfig, METConfig,clusterSigStates +from METReconstruction.METRecoConfig import BuildConfig, RefConfig, METConfig ############################################################################ # EMTopo @@ -11,7 +10,6 @@ cfg_emt = METConfig('EMTopo',[BuildConfig('SoftClus','EMTopo')], doRegions=True, doOriginCorrClus=False ) -cfg_emt.builders['SoftClus'].SignalState = clusterSigStates['EMScale'] metFlags.METConfigs()[cfg_emt.suffix] = cfg_emt metFlags.METOutputList().append(cfg_emt.suffix) @@ -24,7 +22,6 @@ cfg_lht = METConfig('LocHadTopo',[BuildConfig('SoftClus','LocHadTopo')], doRegions=True, doOriginCorrClus=False ) -cfg_lht.builders['SoftClus'].SignalState = clusterSigStates['LocHad'] metFlags.METConfigs()[cfg_lht.suffix] = cfg_lht metFlags.METOutputList().append(cfg_lht.suffix) diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_CaloReg.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_CaloReg.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METConfig_CaloReg.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_CaloReg.py diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_PFlow.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_PFlow.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METConfig_PFlow.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_PFlow.py diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_RefFinal.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_RefFinal.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METConfig_RefFinal.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_RefFinal.py diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_Track.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Track.py similarity index 95% rename from Reconstruction/MET/METReconstruction/python/METConfig_Track.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Track.py index 1307ff85f763895bea4f05637d49c994daa7a994..895e3612ff957850907a81ead129bdc54a1116d3 100644 --- a/Reconstruction/MET/METReconstruction/python/METConfig_Track.py +++ b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Track.py @@ -1,7 +1,7 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration from METReconstruction.METRecoFlags import metFlags -from METReconstruction.METRecoConfig import BuildConfig, RefConfig, METConfig,clusterSigStates +from METReconstruction.METRecoConfig import BuildConfig, RefConfig, METConfig cfg_trk = METConfig('Track',[BuildConfig('SoftTrk','Track')], [RefConfig('TrackFilter','PVTrack')], diff --git a/Reconstruction/MET/METReconstruction/python/METConfig_Truth.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Truth.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METConfig_Truth.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METConfig_Truth.py diff --git a/Reconstruction/MET/METReconstruction/python/METRecoConfig.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METRecoConfig.py similarity index 92% rename from Reconstruction/MET/METReconstruction/python/METRecoConfig.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METRecoConfig.py index e335fa1ae0558095377ceae3f8c901553fdc7d7c..01a0c21dc61f775bb5af306a809f5e43e4c3079d 100644 --- a/Reconstruction/MET/METReconstruction/python/METRecoConfig.py +++ b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METRecoConfig.py @@ -7,11 +7,6 @@ import six ################################################################################# # Define some default values -clusterSigStates = { - 'EMScale':0, - 'LocHad':1, - 'Mod':1 -} defaultSelection = { 'Ele':'Medium', @@ -83,10 +78,6 @@ def getBuilder(config,suffix,doTracks,doCells,doTriggerMET,doOriginCorrClus): if config.objType == 'Jet': tool = CfgMgr.met__METJetTool('MET_JetTool_'+suffix) tool.DoTracks = doTracks - if "EMTopo" in suffix: - tool.SignalState = clusterSigStates['EMScale'] - else: - tool.SignalState = clusterSigStates['LocHad'] if config.objType == 'Muon': tool = CfgMgr.met__METMuonTool('MET_MuonTool_'+suffix) if config.objType == 'SoftTrk': @@ -95,17 +86,10 @@ def getBuilder(config,suffix,doTracks,doCells,doTriggerMET,doOriginCorrClus): if config.objType.endswith('SoftClus'): tool = CfgMgr.met__METSoftTermsTool('MET_SoftClusTool_'+suffix) tool.InputComposition = 'Clusters' - if doOriginCorrClus: - tool.SignalState = clusterSigStates['Mod'] - else: - tool.SignalState = clusterSigStates['LocHad'] if config.objType == 'SoftPFlow': tool = CfgMgr.met__METSoftTermsTool('MET_SoftPFlowTool_'+suffix) tool.InputComposition = 'PFlow' pfotool = CfgMgr.CP__RetrievePFOTool('MET_PFOTool_'+suffix) - from AthenaCommon.AppMgr import ToolSvc - if not hasattr(ToolSvc,pfotool.name()): - ToolSvc += pfotool tool.PFOTool = pfotool if suffix == 'Truth': tool = CfgMgr.met__METTruthTool('MET_TruthTool_'+config.objType) @@ -138,7 +122,6 @@ def getBuilder(config,suffix,doTracks,doCells,doTriggerMET,doOriginCorrClus): config.outputKey = tool.MissingETKey else: tool.MissingETKey = config.outputKey - from AthenaCommon.AppMgr import ToolSvc return tool ################################################################################# @@ -152,7 +135,6 @@ class RefConfig: def getRefiner(config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,caloisotool=None): tool = None - from AthenaCommon.AppMgr import ToolSvc if config.type == 'TrackFilter': tool = CfgMgr.met__METTrackFilterTool('MET_TrackFilterTool_'+suffix) tool.InputPVKey = defaultInputKey['PrimaryVx'] @@ -184,7 +166,6 @@ def getRegions(config,suffix): tool.InputMETMap = 'METMap_'+suffix tool.InputMETKey = config.outputKey tool.RegionValues = [ 1.5, 3.2, 10 ] - from AthenaCommon.AppMgr import ToolSvc return tool ################################################################################# @@ -262,24 +243,14 @@ class METConfig: if doRegions: self.setupRegions(buildconfigs) # - from AthenaCommon.AppMgr import ToolSvc self.trkseltool=CfgMgr.InDet__InDetTrackSelectionTool("IDTrkSel_MET", CutLevel="TightPrimary", maxZ0SinTheta=3, maxD0=2, minPt=500) - if not hasattr(ToolSvc,self.trkseltool.name()): - ToolSvc += self.trkseltool - # self.trkvxtool=CfgMgr.CP__TrackVertexAssociationTool("TrackVertexAssociationTool_MET", WorkingPoint="Nominal") - if not hasattr(ToolSvc,self.trkvxtool.name()): - ToolSvc += self.trkvxtool - # self.trkisotool = CfgMgr.xAOD__TrackIsolationTool("TrackIsolationTool_MET") self.trkisotool.TrackSelectionTool = self.trkseltool # As configured above - if not hasattr(ToolSvc,self.trkisotool.name()): - ToolSvc += self.trkisotool - # from TrackToCalo.TrackToCaloConf import Trk__ParticleCaloExtensionTool, Rec__ParticleCaloCellAssociationTool from TrkExTools.AtlasExtrapolator import AtlasExtrapolator CaloExtensionTool= Trk__ParticleCaloExtensionTool(Extrapolator = AtlasExtrapolator()) @@ -289,8 +260,6 @@ class METConfig: addCaloExtensionDecoration=False, ParticleCaloExtensionTool = CaloExtensionTool, ParticleCaloCellAssociationTool = CaloCellAssocTool) - if not hasattr(ToolSvc,self.caloisotool.name()): - ToolSvc += self.caloisotool self.setupBuilders(buildconfigs) self.setupRefiners(refconfigs) @@ -339,7 +308,6 @@ def getMETRecoAlg(algName='METReconstruction',configs={},tools=[]): regiontool = getRegionRecoTool(conf) recoTools.append(regiontool) - from AthenaCommon.AppMgr import ToolSvc for tool in recoTools: print (prefix, 'Added METRecoTool \''+tool.name()+'\' to alg '+algName) diff --git a/Reconstruction/MET/METReconstruction/python/METRecoFlags.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METRecoFlags.py similarity index 100% rename from Reconstruction/MET/METReconstruction/python/METRecoFlags.py rename to Reconstruction/MET/METReconstruction/python/LegacyRunII/METRecoFlags.py diff --git a/Reconstruction/MET/METReconstruction/python/LegacyRunII/__init__.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Reconstruction/MET/METReconstruction/python/METAssocCfg.py b/Reconstruction/MET/METReconstruction/python/METAssocCfg.py new file mode 100644 index 0000000000000000000000000000000000000000..cd92a470c9bff9d338da593d6c6cff8458109f02 --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METAssocCfg.py @@ -0,0 +1,223 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function +from AthenaConfiguration.ComponentFactory import CompFactory + +from GaudiKernel.Constants import INFO +import six + +################################################################################# +# Define some default values + + +defaultInputKey = { + 'Ele' :'Electrons', + 'Gamma' :'Photons', + 'Tau' :'TauJets', + 'LCJet' :'AntiKt4LCTopoJets', + 'EMJet' :'AntiKt4EMTopoJets', + 'PFlowJet' :'AntiKt4EMPFlowJets', + 'Muon' :'Muons', + 'Soft' :'', + 'Clusters' :'CaloCalTopoClusters', + 'Tracks' :'InDetTrackParticles', + 'PFlowObj' :'CHSParticleFlowObjects', + 'PrimVxColl':'PrimaryVertices', + 'Truth' :'TruthEvents', + } + +prefix = 'METAssocConfig: ' + +################################################################################# +# Configuration of builders + +class AssocConfig: + def __init__(self,objType='',inputKey=''): + self.objType = objType + self.inputKey = inputKey + +def getAssociator(config,suffix,doPFlow=False, + trkseltool=None, + trkisotool=None,caloisotool=None, + modConstKey="", + modClusColls={}): + tool = None + + doModClus = (modConstKey!="" and not doPFlow) + if doModClus: + modLCClus = modClusColls['LC{0}Clusters'.format(modConstKey)] + modEMClus = modClusColls['EM{0}Clusters'.format(modConstKey)] + # Construct tool and set defaults for case-specific configuration + if config.objType == 'Ele': + from ROOT import met + tool = CompFactory.getComp("met::METElectronAssociator")('MET_ElectronAssociator_'+suffix,TCMatchMethod=met.ClusterLink) + if config.objType == 'Gamma': + from ROOT import met + tool = CompFactory.getComp("met::METPhotonAssociator")('MET_PhotonAssociator_'+suffix,TCMatchMethod=met.ClusterLink) + if config.objType == 'Tau': + tool = CompFactory.getComp("met::METTauAssociator")('MET_TauAssociator_'+suffix) + if config.objType == 'LCJet': + tool = CompFactory.getComp("met::METJetAssocTool")('MET_LCJetAssocTool_'+suffix) + if config.objType == 'EMJet': + tool = CompFactory.getComp("met::METJetAssocTool")('MET_EMJetAssocTool_'+suffix) + if config.objType == 'PFlowJet': + tool = CompFactory.getComp("met::METJetAssocTool")('MET_PFlowJetAssocTool_'+suffix) + if config.objType == 'Muon': + tool = CompFactory.getComp("met::METMuonAssociator")('MET_MuonAssociator_'+suffix) + if config.objType == 'Soft': + tool = CompFactory.getComp("met::METSoftAssociator")('MET_SoftAssociator_'+suffix) + tool.DecorateSoftConst = True + if doModClus: + tool.LCModClusterKey = modLCClus + tool.EMModClusterKey = modEMClus + if config.objType == 'Truth': + tool = CompFactory.getComp("met::METTruthAssociator")('MET_TruthAssociator_'+suffix) + tool.RecoJetKey = config.inputKey + if doPFlow: + tool.PFlow = True + tool.PFlowColl = modConstKey if modConstKey!="" else defaultInputKey["PFlowObj"] + else: + tool.UseModifiedClus = doModClus + # set input/output key names + if config.inputKey == '': + tool.InputCollection = defaultInputKey[config.objType] + config.inputKey = tool.InputCollection + else: + tool.InputCollection = config.inputKey + if doModClus: + tool.ClusColl = modLCClus + if 'EMTopo' in suffix: tool.ClusColl = modEMClus + tool.TrkColl = defaultInputKey['Tracks'] + + from METReconstruction.METRecoFlags import metFlags + tool.UseTracks = metFlags.UseTracks() + # + tool.TrackSelectorTool = trkseltool + # + tool.TrackIsolationTool = trkisotool + tool.CaloIsolationTool = caloisotool + + return tool + +################################################################################# +# Top level MET configuration + +class METAssocConfig: + def outputCollections(self): + if self.doTruth: return 'MET_Core_'+self.suffix + else: return 'MET_Core_'+self.suffix,'MET_Reference_'+self.suffix + # + def outputMap(self): + return 'METAssoc_'+self.suffix + return 'METAssoc_'+self.suffix + # + def setupAssociators(self,buildconfigs): + print("{} Setting up associators for MET config {}".format(prefix,self.suffix)) + for config in buildconfigs: + if config.objType in self.associators: + print ("{} Config {} already contains a associator of type {}".format(prefix,self.suffix,config.objType)) + raise LookupError + else: + associator = getAssociator(config=config,suffix=self.suffix, + doPFlow=self.doPFlow, + trkseltool=self.trkseltool, + trkisotool=self.trkisotool, + caloisotool=self.caloisotool, + modConstKey=self.modConstKey, + modClusColls=self.modClusColls) + from METReconstruction.METRecoFlags import metFlags + if config.objType == 'Soft' and metFlags.DecorateSoftConst: + print ("activate soft term decoration") + associator.DecorateSoftConst = True + self.associators[config.objType] = associator + self.assoclist.append(associator) + print("{} Added {} tool named {}".format(prefix,config.objType,associator.name)) + # + def __init__(self,suffix,inputFlags,buildconfigs=[], + doPFlow=False, doTruth=False, + trksel=None, + modConstKey="", + modClusColls={} + ): + # Set some sensible defaults + modConstKey_tmp = modConstKey + modClusColls_tmp = modClusColls + if doPFlow: + if modConstKey_tmp == "": modConstKey_tmp = "CHSParticleFlowObjects" + else: + if modConstKey_tmp == "": modConstKey_tmp = "OriginCorr" + if modClusColls_tmp == {}: modClusColls_tmp = {'LCOriginCorrClusters':'LCOriginTopoClusters', + 'EMOriginCorrClusters':'EMOriginTopoClusters'} + if doTruth: + print ("{} Creating MET TruthAssoc config {}".format(prefix,suffix)) + else: + print ("{} Creating MET Assoc config {}".format(prefix,suffix)) + self.suffix = suffix + self.doPFlow = doPFlow + self.modConstKey=modConstKey_tmp + self.modClusColls=modClusColls_tmp + self.doTruth = doTruth + if trksel: + self.trkseltool = trksel + else: + self.trkseltool=CompFactory.getComp("InDet::InDetTrackSelectionTool")("IDTrkSel_METAssoc", + CutLevel="TightPrimary", + maxZ0SinTheta=3, + maxD0=2, + minPt=500) + + self.trkisotool = CompFactory.getComp("xAOD::TrackIsolationTool")("TrackIsolationTool_MET") + self.trkisotool.TrackSelectionTool = self.trkseltool # As configured above + from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg + extrapCfg = AtlasExtrapolatorCfg(inputFlags) + CaloExtensionTool= CompFactory.getComp("Trk::ParticleCaloExtensionTool")(Extrapolator = extrapCfg.popPrivateTools()) + CaloCellAssocTool = CompFactory.getComp("Rec::ParticleCaloCellAssociationTool")(ParticleCaloExtensionTool = CaloExtensionTool) + self.caloisotool = CompFactory.getComp("xAOD::CaloIsolationTool")("CaloIsolationTool_MET", + saveOnlyRequestedCorrections=True, + addCaloExtensionDecoration=False, + ParticleCaloExtensionTool = CaloExtensionTool, + ParticleCaloCellAssociationTool = CaloCellAssocTool) + self.associators = {} + self.assoclist = [] # need an ordered list + # + self.setupAssociators(buildconfigs) + +# Set up a top-level tool with mostly defaults +def getMETAssocTool(topconfig,msglvl=INFO): + assocTool = None + from METReconstruction.METRecoFlags import metFlags + if topconfig.doTruth: + assocTool = CompFactory.getComp("met::METAssociationTool")('MET_TruthAssociationTool_'+topconfig.suffix, + METAssociators = topconfig.assoclist, + METSuffix = topconfig.suffix) + else: + assocTool = CompFactory.getComp("met::METAssociationTool")('MET_AssociationTool_'+topconfig.suffix, + METAssociators = topconfig.assoclist, + METSuffix = topconfig.suffix, + TimingDetail=0, + OutputLevel=msglvl) + if metFlags.AllowOverwrite: + assocTool.AllowOverwrite = True + return assocTool + +# Allow user to configure reco tools directly or get more default configurations +def getMETAssocAlg(algName='METAssociation',configs={},tools=[],msglvl=INFO): + + assocTools = [] + assocTools += tools + + from METReconstruction.METRecoFlags import metFlags + if configs=={} and tools==[]: + print ("{} Taking configurations from METRecoFlags".format(prefix)) + configs = metFlags.METAssocConfigs() + print (configs) + for key,conf in six.iteritems(configs): + print ("{} Generate METAssocTool for MET_{}".format(prefix,key)) + assoctool = getMETAssocTool(conf,msglvl) + assocTools.append(assoctool) + + for tool in assocTools: + print ("{} Added METAssocTool {} to alg {}".format(prefix,tool.name,algName)) + assocAlg = CompFactory.getComp("met::METRecoAlg")(name=algName, + RecoTools=assocTools) + return assocAlg diff --git a/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py b/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py new file mode 100644 index 0000000000000000000000000000000000000000..4cf56b15d4c035e5bad096cfbbe47f1a7562ded4 --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py @@ -0,0 +1,96 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +#from METReconstruction.METRecoFlags import metFlags +from METReconstruction.METAssocCfg import AssocConfig, METAssocConfig,getMETAssocAlg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from METUtilities.METMakerConfig import getMETMakerAlg + + +#attempt at migrating to the new configuration system +def METAssociatorCfg(configFlags): + sequencename = "METAssociation" + + components = ComponentAccumulator() + from AthenaConfiguration.ComponentFactory import CompFactory + AthSequencer=CompFactory.AthSequencer + components.addSequence( AthSequencer(sequencename) ) + + modConstKey = "" + modClusColls = {} + if configFlags.MET.UseTracks: + modConstKey="OriginCorr" + modClusColls={ + 'LCOriginCorrClusters':'LCOriginTopoClusters', + 'EMOriginCorrClusters':'EMOriginTopoClusters' + } + + ############################################################################ + # AntiKt4LCTopo + JetType = 'LCJet' + associators = [AssocConfig(JetType), + AssocConfig('Muon'), + AssocConfig('Ele'), + AssocConfig('Gamma'), + AssocConfig('Tau'), + AssocConfig('Soft')] + cfg_akt4lc = METAssocConfig('AntiKt4LCTopo', + configFlags, + associators, + doPFlow=False, + modConstKey=modConstKey, + modClusColls=modClusColls + ) + components_akt4lc= getAssocCA(cfg_akt4lc,sequencename='METAssoc_AntiKt4LCTopo',METName='AntiKt4LCTopo') + components.merge(components_akt4lc) + + ############################################################################ + # AntiKt4EMTopo + JetType = 'EMJet' + + associators = [AssocConfig(JetType), + AssocConfig('Muon'), + AssocConfig('Ele'), + AssocConfig('Gamma'), + AssocConfig('Tau'), + AssocConfig('Soft')] + cfg_akt4em = METAssocConfig('AntiKt4EMTopo', + configFlags, + associators, + doPFlow=False, + modConstKey=modConstKey, + modClusColls=modClusColls + ) + components_akt4em= getAssocCA(cfg_akt4em,sequencename='METAssoc_AntiKt4EMTopo',METName='AntiKt4EMTopo') + components.merge(components_akt4em) + + ############################################################################ + # PFlow + if configFlags.MET.DoPFlow and configFlags.MET.UseTracks: + JetType = 'PFlowJet' + associators = [AssocConfig(JetType), + AssocConfig('Muon'), + AssocConfig('Ele'), + AssocConfig('Gamma'), + AssocConfig('Tau'), + AssocConfig('Soft')] + cfg_akt4pf = METAssocConfig('AntiKt4EMPFlow', + configFlags, + associators, + doPFlow=True + ) + components_akt4pf= getAssocCA(cfg_akt4pf,sequencename='METAssoc_AntiKt4EMPFlow',METName='AntiKt4EMPFlow') + components.merge(components_akt4pf) + return components + + +def getAssocCA(config,sequencename='METAssociation',METName=''): + components = ComponentAccumulator() + from AthenaConfiguration.ComponentFactory import CompFactory + AthSequencer=CompFactory.AthSequencer + components.addSequence( AthSequencer(sequencename) ) + assocAlg = getMETAssocAlg(algName='METAssociation_'+METName,configs={config.suffix:config}) + components.addEventAlgo(assocAlg,sequencename) + if not METName=='': + makerAlg=getMETMakerAlg(METName) + components.addEventAlgo(makerAlg,sequencename) + return components diff --git a/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py b/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..765fac33e27d6736681253180f4575dc485f8f2a --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py @@ -0,0 +1,41 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +#from METReconstruction.METRecoFlags import metFlags +from METReconstruction.METRecoCfg import BuildConfig, METConfig,getMETRecoAlg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + + +def METCalo_Cfg(configFlags): + sequencename = "METReconstruction_Calo" + + components = ComponentAccumulator() + from AthenaConfiguration.ComponentFactory import CompFactory + AthSequencer=CompFactory.AthSequencer + components.addSequence( AthSequencer(sequencename) ) + ############################################################################ + # EMTopo + + cfg_emt = METConfig('EMTopo',configFlags,[BuildConfig('SoftClus','EMTopo')], + doRegions=True, + doOriginCorrClus=False + ) + + ############################################################################ + # LocHadTopo + + cfg_lht = METConfig('LocHadTopo',configFlags,[BuildConfig('SoftClus','LocHadTopo')], + doRegions=True, + doOriginCorrClus=False + ) + + ############################################################################ + # Calo regions + #SWITCH OFF CELLS WHEN RUNNING ON AOD + cfg_calo = METConfig('Calo',configFlags, + [BuildConfig('CaloReg')], + doCells=False + ) + + recoAlg_calo = getMETRecoAlg(algName='METRecoAlg_Calo',configs={"EMTopo":cfg_emt,"LocHadTopo":cfg_lht,"Calo":cfg_calo}) + components.addEventAlgo(recoAlg_calo,sequencename) + return components diff --git a/Reconstruction/MET/METReconstruction/python/METConfigFlags.py b/Reconstruction/MET/METReconstruction/python/METConfigFlags.py new file mode 100644 index 0000000000000000000000000000000000000000..4159714b7d701226e56e876996cebe0bfeadcc13 --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METConfigFlags.py @@ -0,0 +1 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration from AthenaConfiguration.AthConfigFlags import AthConfigFlags def createMETConfigFlags(): metConfigFlags=AthConfigFlags() metConfigFlags.addFlag("MET.UseTracks",True) metConfigFlags.addFlag("MET.DoPFlow",True) return metConfigFlags \ No newline at end of file diff --git a/Reconstruction/MET/METReconstruction/python/METRecoCfg.py b/Reconstruction/MET/METReconstruction/python/METRecoCfg.py new file mode 100644 index 0000000000000000000000000000000000000000..32fab8ba55a9a6d0eaa6a936f69610b8ec0e6aa9 --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METRecoCfg.py @@ -0,0 +1,272 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentFactory import CompFactory + +################################################################################# +# Define some default values + +defaultInputKey = { + 'Ele' :'Electrons', + 'Gamma' :'Photons', + 'Tau' :'TauJets', + 'Jet' :'AntiKt4EMTopoJets', + 'Muon' :'Muons', + 'SoftTrk' :'InDetTrackParticles', + 'SoftClus' :'CaloCalTopoClusters', + 'SoftPFlow':'JetETMissNeutralParticleFlowObjects', + 'PrimaryVx':'PrimaryVertices', + 'Truth' :'TruthEvents', + 'Calo' :'AllCalo', + 'LCOCSoftClus':'LCOriginTopoClusters', + 'EMOCSoftClus':'EMOriginTopoClusters', + } + +defaultOutputKey = { + 'Ele' :'RefEle', + 'Gamma' :'RefGamma', + 'Tau' :'RefTau', + 'Jet' :'RefJet', + 'Muon' :'Muons', + 'SoftTrk' :'SoftTrk', + 'SoftClus' :'SoftClus', + 'SoftPFlow':'SoftPFlow', + 'Total' :'Final', + 'Truth' :'Truth', + 'Calo' :'Calo' + } + +prefix = 'METRecoConfig: ' + +################################################################################# +# Configuration of builders + +class BuildConfig: + def __init__(self,objType='',outputKey='',inputKey=''): + self.objType = objType + self.outputKey = outputKey + self.inputKey = inputKey + +def getBuilder(config,suffix,doTracks,doCells,doTriggerMET,doOriginCorrClus): + tool = None + # Construct tool and set defaults for case-specific configuration + if config.objType == 'SoftTrk': + tool = CompFactory.getComp("met::METSoftTermsTool")('MET_SoftTrkTool_'+suffix) + tool.InputComposition = 'Tracks' + if config.objType.endswith('SoftClus'): + tool = CompFactory.getComp("met::METSoftTermsTool")('MET_SoftClusTool_'+suffix) + tool.InputComposition = 'Clusters' + if config.objType == 'SoftPFlow': + tool = CompFactory.getComp("met::METSoftTermsTool")('MET_SoftPFlowTool_'+suffix) + tool.InputComposition = 'PFlow' + pfotool = CompFactory.RetrievePFOTool('MET_PFOTool_'+suffix) + tool.PFOTool = pfotool + if suffix == 'Truth': + tool = CompFactory.getComp("met::METTruthTool")('MET_TruthTool_'+config.objType) + tool.InputComposition = config.objType + config.inputKey = defaultInputKey['Truth'] + config.outputKey = config.objType + if suffix == 'Calo': + from CaloTools.CaloNoiseCondAlg import CaloNoiseCondAlg + CaloNoiseCondAlg ('totalNoise') + tool = CompFactory.getComp("met::METCaloRegionsTool")('MET_CaloRegionsTool') + if doCells: + tool.UseCells = True + tool.DoTriggerMET = doTriggerMET + config.inputKey = defaultInputKey['Calo'] + else: + tool.UseCells = False + tool.DoTriggerMET = False + config.inputKey = defaultInputKey['SoftClus'] + config.outputKey = config.objType + + # set input/output key names + if config.inputKey == '': + tool.InputCollection = defaultInputKey[config.objType] + config.inputKey = tool.InputCollection + else: + tool.InputCollection = config.inputKey + if not suffix=='Calo': + if config.outputKey == '': + tool.MissingETKey = defaultOutputKey[config.objType] + config.outputKey = tool.MissingETKey + else: + tool.MissingETKey = config.outputKey + return tool + +################################################################################# +# Configuration of refiners + +class RefConfig: + def __init__(self,myType='',outputKey=''): + self.type = myType + self.outputKey = outputKey + +def getRefiner(config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,caloisotool=None): + tool = None + + if config.type == 'TrackFilter': + tool = CompFactory.getComp("met::METTrackFilterTool")('MET_TrackFilterTool_'+suffix) + tool.InputPVKey = defaultInputKey['PrimaryVx'] + tool.TrackSelectorTool=trkseltool + tool.TrackVxAssocTool=trkvxtool + # + tool.UseIsolationTools = False #True + tool.TrackIsolationTool = trkisotool + tool.CaloIsolationTool = caloisotool + from METReconstruction.METRecoFlags import metFlags + tool.DoPVSel = metFlags.UseTracks() + tool.DoVxSep = metFlags.UseTracks() + tool.MissingETKey = config.outputKey + return tool + +################################################################################# +# Region tools are a special case of refiners + +def getRegions(config,suffix): + if suffix == 'Truth': + config.outputKey = config.objType + tool = CompFactory.getComp("met::METRegionsTool")('MET_'+config.outputKey+'Regions_'+suffix) + tool.InputMETContainer = 'MET_'+suffix + tool.InputMETMap = 'METMap_'+suffix + tool.InputMETKey = config.outputKey + tool.RegionValues = [ 1.5, 3.2, 10 ] + return tool + +################################################################################# +# Top level MET configuration + +class METConfig: + def outputCollection(self): + return 'MET_'+self.suffix + # + def outputMap(self): + return 'METMap_'+self.suffix + # + def setupBuilders(self,buildconfigs): + print("{} Setting up builders for MET config {}".format(prefix,self.suffix)) + for config in buildconfigs: + if config.objType in self.builders: + print("{} Config {} already contains a builder of type {}".format(prefix,self.suffix,config.objType)) + raise LookupError + else: + builder = getBuilder(config,self.suffix,self.doTracks,self.doCells, + self.doTriggerMET,self.doOriginCorrClus) + self.builders[config.objType] = builder + self.buildlist.append(builder) + print("{} Added {} tool named {}".format(prefix,config.objType,builder.name)) + # + def setupRefiners(self,refconfigs): + print("{} Setting up refiners for MET config {}".format(prefix,self.suffix)) + for config in refconfigs: + # need to enforce this? + if config.type in self.refiners: + print("Config {} already contains a refiner of type {}".format(self.suffix,config.type)) + raise LookupError + else: + refiner = getRefiner(config=config,suffix=self.suffix, + trkseltool=self.trkseltool,trkvxtool=self.trkvxtool, + trkisotool=self.trkisotool,caloisotool=self.caloisotool) + self.refiners[config.type] = refiner + self.reflist.append(refiner) + print("{} Added {} tool named {}".format(prefix,config.type,refiner.name)) + # + def setupRegions(self,buildconfigs): + print("{} Setting up regions for MET config {}".format(prefix,self.suffix)) + for config in buildconfigs: + if config.objType in self.regions: + print("{} Config {} already contains a region tool of type {}".format(prefix,self.suffix,config.objType)) + raise LookupError + else: + regions = getRegions(config,self.suffix) + self.regions[config.objType] = regions + self.reglist.append(regions) + print("{} Added {} region tool named {}".format(prefix,config.objType,regions.name)) + # + def __init__(self,suffix,inputFlags,buildconfigs=[],refconfigs=[], + doTracks=False,doSum=False,doRegions=False, + doCells=False,doTriggerMET=True,duplicateWarning=True, + doOriginCorrClus=False): + print("{} Creating MET config {}".format(prefix,suffix)) + self.suffix = suffix + self.doSum = doSum + self.doTracks = doTracks + self.doRegions = doRegions + self.doCells = doCells, + self.doOriginCorrClus = doOriginCorrClus + self.doTriggerMET = doTriggerMET + self.duplicateWarning = duplicateWarning + # + self.builders = {} + self.buildlist = [] # need an ordered list + # + self.refiners = {} + self.reflist = [] # need an ordered list + # + self.regions = {} + self.reglist = [] # need an ordered list + if doRegions: + self.setupRegions(buildconfigs) + # + from AthenaConfiguration.ComponentFactory import CompFactory + self.trkseltool=CompFactory.getComp("InDet::InDetTrackSelectionTool")("IDTrkSel_MET", + CutLevel="TightPrimary", + maxZ0SinTheta=3, + maxD0=2, + minPt=500) + # + self.trkvxtool=CompFactory.getComp("CP::TrackVertexAssociationTool")("TrackVertexAssociationTool_MET", WorkingPoint="Nominal") + # + self.trkisotool = CompFactory.getComp("xAOD::TrackIsolationTool")("TrackIsolationTool_MET") + self.trkisotool.TrackSelectionTool = self.trkseltool # As configured above + ### + from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg + extrapCfg = AtlasExtrapolatorCfg(inputFlags) + CaloExtensionTool= CompFactory.getComp("Trk::ParticleCaloExtensionTool")(Extrapolator = extrapCfg.popPrivateTools()) + CaloCellAssocTool = CompFactory.getComp("Rec::ParticleCaloCellAssociationTool")(ParticleCaloExtensionTool = CaloExtensionTool) + self.caloisotool = CompFactory.getComp("xAOD::CaloIsolationTool")("CaloIsolationTool_MET", + saveOnlyRequestedCorrections=True, + addCaloExtensionDecoration=False, + ParticleCaloExtensionTool = CaloExtensionTool, + ParticleCaloCellAssociationTool = CaloCellAssocTool) + + self.setupBuilders(buildconfigs) + self.setupRefiners(refconfigs) + +# Set up a top-level tool with mostly defaults +def getMETRecoTool(topconfig): + recoTool = CompFactory.getComp("met::METRecoTool")('MET_RecoTool_'+topconfig.suffix, + METBuilders = topconfig.buildlist, + METRefiners = topconfig.reflist, + METContainer = topconfig.outputCollection(), + METComponentMap = topconfig.outputMap(), + WarnIfDuplicate = topconfig.duplicateWarning, + TimingDetail=0) + if topconfig.doSum: + recoTool.METFinalName = defaultOutputKey['Total'] + + return recoTool + +# Set up a METRecoTool that builds MET regions +def getRegionRecoTool(topconfig): + regTool = CompFactory.getComp("met::METRecoTool")('MET_RegionTool_'+topconfig.suffix, + METBuilders = [], + METRefiners = topconfig.reglist, + METContainer = topconfig.outputCollection()+'Regions', + METComponentMap = topconfig.outputMap()+'Regions', + WarnIfDuplicate = topconfig.duplicateWarning) + return regTool + +# Allow user to configure reco tools directly or get more default configurations +def getMETRecoAlg(algName='METReconstruction',configs={}): + recoTools = [] + for key,conf in configs.items(): + print("{} Generate METRecoTool for MET_{}".format(prefix,key)) + recotool = getMETRecoTool(conf) + recoTools.append(recotool) + if conf.doRegions: + regiontool = getRegionRecoTool(conf) + recoTools.append(regiontool) + for tool in recoTools: + print("{} Added METRecoTool {} to alg {}".format(prefix,tool.name,algName)) + recoAlg = CompFactory.getComp("met::METRecoAlg")(name=algName,RecoTools=recoTools) + return recoAlg diff --git a/Reconstruction/MET/METReconstruction/python/METTrack_Cfg.py b/Reconstruction/MET/METReconstruction/python/METTrack_Cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..142d14d2eb549fc80c60f49317ebdaf962769a17 --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METTrack_Cfg.py @@ -0,0 +1,24 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from METReconstruction.METRecoCfg import BuildConfig, RefConfig, METConfig,getMETRecoAlg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + + +def METTrack_Cfg(configFlags): + sequencename = "METReconstruction_Track" + + components = ComponentAccumulator() + from AthenaConfiguration.ComponentFactory import CompFactory + AthSequencer=CompFactory.AthSequencer + components.addSequence( AthSequencer(sequencename) ) + cfg_trk = METConfig('Track',configFlags,[BuildConfig('SoftTrk','Track')], + [RefConfig('TrackFilter','PVTrack')], + doTracks=configFlags.MET.UseTracks) + + cfg_trk.refiners['TrackFilter'].DoLepRecovery=True + cfg_trk.refiners['TrackFilter'].DoVxSep=configFlags.MET.UseTracks + cfg_trk.refiners['TrackFilter'].DoEoverPSel=True + recoAlg=getMETRecoAlg(algName='METRecoAlg_Track',configs={"Track":cfg_trk}) + components.addEventAlgo(recoAlg, sequencename) + return components + diff --git a/Reconstruction/MET/METReconstruction/python/METTruth_Cfg.py b/Reconstruction/MET/METReconstruction/python/METTruth_Cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..d93690565778937e49dff12e995603e5cf4c4846 --- /dev/null +++ b/Reconstruction/MET/METReconstruction/python/METTruth_Cfg.py @@ -0,0 +1,24 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from METReconstruction.METRecoCfg import BuildConfig, METConfig,getMETRecoAlg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + + +def METTruth_Cfg(configFlags): + sequencename = "METReconstruction_Truth" + components = ComponentAccumulator() + from AthenaConfiguration.ComponentFactory import CompFactory + AthSequencer=CompFactory.AthSequencer + components.addSequence( AthSequencer(sequencename) ) + ## Simple truth terms + cfg_truth = METConfig('Truth',configFlags, + [BuildConfig('NonInt'), + BuildConfig('Int'), + BuildConfig('IntOut'), + BuildConfig('IntMuons')], + doRegions=True + ) + recoAlg=getMETRecoAlg(algName='METRecoAlg_Truth',configs={"Truth":cfg_truth}) + components.addEventAlgo(recoAlg, sequencename) + return components + diff --git a/Reconstruction/MET/METReconstruction/share/METRecCfg.py b/Reconstruction/MET/METReconstruction/share/METRecCfg.py new file mode 100644 index 0000000000000000000000000000000000000000..535654a16e769dad2dd57e70804580c8a9d33f6c --- /dev/null +++ b/Reconstruction/MET/METReconstruction/share/METRecCfg.py @@ -0,0 +1 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration from AthenaCommon import Logging from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory if __name__=="__main__": # Setting needed for the ComponentAccumulator to do its thing from AthenaCommon.Configurable import Configurable Configurable.configurableRun3Behavior=True # Set message levels from AthenaCommon import Constants msgLvl = "WARNING" from AthenaCommon.Logging import log log.setLevel(msgLvl) # Config flags steer the job at various levels from AthenaConfiguration.AllConfigFlags import ConfigFlags ConfigFlags.Input.isMC = True ConfigFlags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/ASG/mc16_13TeV.410501.PowhegPythia8EvtGen_A14_ttbar_hdamp258p75_nonallhad.merge.AOD.e5458_s3126_r9364_r9315/AOD.11182705._000001.pool.root.1"] # Flags relating to multithreaded execution nthreads=0 ConfigFlags.Concurrency.NumThreads =nthreads if nthreads>0: ConfigFlags.Concurrency.NumThreads = 1 ConfigFlags.Concurrency.NumConcurrentEvents = 1 ConfigFlags.MET.UseTracks = True ConfigFlags.MET.DoPFlow = True if ConfigFlags.Beam.Type == 'cosmics' or ConfigFlags.Beam.Type == 'singlebeam':# used to have " or not rec.doInDet()" on the end ConfigFlags.MET.UseTracks = False ConfigFlags.MET.DoPFlow = False print("METReconstruction_jobOptions: detected cosmics/single-beam configuration -- switch off track-based MET reco") ConfigFlags.lock() # Get a ComponentAccumulator setting up the fundamental Athena job from AthenaConfiguration.MainServicesConfig import MainServicesCfg cfg=MainServicesCfg(ConfigFlags) # Add the components for reading in pool files from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg cfg.merge(PoolReadCfg(ConfigFlags)) StoreGateSvc=CompFactory.StoreGateSvc cfg.addService(StoreGateSvc("DetectorStore")) #Setup up general geometry modelConfig=ComponentAccumulator() from AtlasGeoModel.GeoModelConfig import GeoModelCfg modelConfig=GeoModelCfg(ConfigFlags) cfg.merge(modelConfig) from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg cfg.merge(MagneticFieldSvcCfg(ConfigFlags)) from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg cfg.merge(TrackingGeometrySvcCfg(ConfigFlags)) from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg cfg.merge(MuonGeoModelCfg(ConfigFlags)) # Nowadays the jet calibration tool requires the EventInfo # to be decorated with lumi info, which is not in Run 2 AODs from LumiBlockComps.LuminosityCondAlgConfig import LuminosityCondAlgCfg cfg.merge(LuminosityCondAlgCfg(ConfigFlags)) from AthenaConfiguration.ComponentFactory import CompFactory muWriter = CompFactory.LumiBlockMuWriter("LumiBlockMuWriter",LumiDataKey="LuminosityCondData") cfg.addEventAlgo(muWriter,"AthAlgSeq") # Get Jet Inputs from JetRecConfig.StandardJetDefs import EMTopoOrigin, LCTopoOrigin, CHSPFlow from JetRecConfig import JetRecConfig for jetdef in [EMTopoOrigin,LCTopoOrigin,CHSPFlow]: cfg.merge(JetRecConfig.JetInputCfg( [jetdef], ConfigFlags)) # Need to rename the collections in the xAOD in order to avoid conflicts from SGComps.AddressRemappingConfig import InputRenameCfg cfg.merge(InputRenameCfg('xAOD::MissingETContainer','MET_Track','MET_Track_Old')) cfg.merge(InputRenameCfg('xAOD::MissingETAuxContainer','MET_TrackAux.','MET_Track_OldAux.')) cfg.merge(InputRenameCfg('xAOD::MissingETContainer','MET_EMTopo','MET_EMTopo_Old')) cfg.merge(InputRenameCfg('xAOD::MissingETAuxContainer','MET_EMTopoAux.','MET_EMTopo_OldAux.')) cfg.merge(InputRenameCfg('xAOD::MissingETContainer','MET_LocHadTopo','MET_LocHadTopo_Old')) cfg.merge(InputRenameCfg('xAOD::MissingETAuxContainer','MET_LocHadTopoAux.','MET_LocHadTopo_OldAux.')) from METReconstruction.METTrack_Cfg import METTrack_Cfg cfg.merge(METTrack_Cfg(ConfigFlags)) from METReconstruction.METCalo_Cfg import METCalo_Cfg cfg.merge(METCalo_Cfg(ConfigFlags)) if ConfigFlags.Input.isMC: from METReconstruction.METTruth_Cfg import METTruth_Cfg cfg.merge(METTruth_Cfg(ConfigFlags)) from METReconstruction.METAssociatorCfg import METAssociatorCfg cfg.merge(METAssociatorCfg(ConfigFlags)) outputlist = ["EventInfo#*"] outputlist+=["xAOD::MissingETContainer#"+"MET_Track","xAOD::MissingETAuxContainer#"+"MET_Track"+"Aux."] outputlist+=["xAOD::MissingETContainer#"+"MET_Track_Old","xAOD::MissingETAuxContainer#"+"MET_Track_Old"+"Aux."] outputlist+=["xAOD::MissingETContainer#"+"MET_EMTopo","xAOD::MissingETAuxContainer#"+"MET_EMTopo"+"Aux."] outputlist+=["xAOD::MissingETContainer#"+"MET_EMTopo_Old","xAOD::MissingETAuxContainer#"+"MET_EMTopo_Old"+"Aux."] outputlist+=["xAOD::MissingETContainer#"+"MET_AntiKt4EMPFlow","xAOD::MissingETAuxContainer#"+"MET_AntiKt4EMPFlow"+"Aux."] from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg cfg.merge(OutputStreamCfg(ConfigFlags,"xAOD",ItemList=outputlist)) # Optionally, print the contents of the store every event cfg.getService("StoreGateSvc").Dump = False #cfg.printConfig() cfg.run(maxEvents=20) \ No newline at end of file diff --git a/Reconstruction/MET/METReconstruction/share/METReconstruction_jobOptions.py b/Reconstruction/MET/METReconstruction/share/METReconstruction_jobOptions.py index 4760ce8dc064fe06be5c541bc8ac1ff251533e74..f639a088cc75b467e0890c8d1e2946d4cf8f8d3a 100644 --- a/Reconstruction/MET/METReconstruction/share/METReconstruction_jobOptions.py +++ b/Reconstruction/MET/METReconstruction/share/METReconstruction_jobOptions.py @@ -36,8 +36,11 @@ topSequence += assocAlg from METUtilities.METMakerConfig import getMETMakerAlg metConfigs = list(metFlags.METAssocConfigs().keys()) metConfigs.sort() + for key in metConfigs: conf = metFlags.METAssocConfigs()[key] if not conf.doTruth: makerAlg = getMETMakerAlg(conf.suffix) topSequence += makerAlg + +svcMgr.StoreGateSvc.Dump=True \ No newline at end of file diff --git a/Reconstruction/MET/METUtilities/python/METMakerConfig.py b/Reconstruction/MET/METUtilities/python/METMakerConfig.py index 0f560775d8fa7d8d6cb388154708fa394eb5f07e..643831d4d5038742b47260b6c2362ccb11f3557e 100644 --- a/Reconstruction/MET/METUtilities/python/METMakerConfig.py +++ b/Reconstruction/MET/METUtilities/python/METMakerConfig.py @@ -1,45 +1,38 @@ # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration from __future__ import print_function +from AthenaConfiguration.ComponentFactory import CompFactory + def getMETMakerAlg(suffix,jetSelection="Tier0",jetColl=""): - from AthenaCommon import CfgMgr print ("Generate METMaker and METMakerAlg for METAssoc_"+suffix) - from AthenaCommon.AppMgr import ToolSvc - from AthenaCommon.AlgSequence import AlgSequence - topSequence = AlgSequence() doPFlow = 'PFlow' in suffix doTruth = suffix.startswith('Truth') - metMaker = CfgMgr.met__METMaker('METMaker_'+suffix, + metMaker = CompFactory.getComp("met::METMaker")('METMaker_'+suffix, DoPFlow=doPFlow, DoSoftTruth=doTruth, JetSelection=jetSelection, - ); - #ToolSvc += metMaker + ) - muonSel = CfgMgr.CP__MuonSelectionTool("MuonSelectionTool_METMakerAlg", + muonSel = CompFactory.getComp("CP::MuonSelectionTool")("MuonSelectionTool_METMakerAlg", MuQuality=1, # Medium MaxEta=2.4) - ToolSvc += muonSel - elecSelLH = CfgMgr.AsgElectronLikelihoodTool("EleSelLikelihood_METMakerAlg", + elecSelLH = CompFactory.AsgElectronLikelihoodTool("EleSelLikelihood_METMakerAlg", WorkingPoint="MediumLHElectron") - ToolSvc += elecSelLH - photonSelIsEM = CfgMgr.AsgPhotonIsEMSelector("PhotonSelIsEM_METMakerAlg", + photonSelIsEM = CompFactory.AsgPhotonIsEMSelector("PhotonSelIsEM_METMakerAlg", WorkingPoint="TightPhoton") - ToolSvc += photonSelIsEM - tauSel = CfgMgr.TauAnalysisTools__TauSelectionTool("TauSelectionTool_METMakerAlg") - ToolSvc += tauSel + tauSel = CompFactory.getComp("TauAnalysisTools::TauSelectionTool")("TauSelectionTool_METMakerAlg") if jetColl=="": jetColl = suffix+'Jets' if doTruth: jetColl = suffix.split('_')[1]+'Jets' - makerAlg = CfgMgr.met__METMakerAlg('METMakerAlg_'+suffix, + makerAlg = CompFactory.getComp("met::METMakerAlg")('METMakerAlg_'+suffix, METMapName='METAssoc_'+suffix, METCoreName='MET_Core_'+suffix, METName='MET_Reference_'+suffix, diff --git a/Reconstruction/MET/METUtilities/src/METMakerAlg.cxx b/Reconstruction/MET/METUtilities/src/METMakerAlg.cxx index 51d92a4ee0055257d4f678570991f0a28873392f..c8eca7407a178eb88104af920753166d4670104e 100644 --- a/Reconstruction/MET/METUtilities/src/METMakerAlg.cxx +++ b/Reconstruction/MET/METUtilities/src/METMakerAlg.cxx @@ -30,7 +30,6 @@ namespace met { ISvcLocator* pSvcLocator ) : ::AthAlgorithm( name, pSvcLocator ), m_metKey(""), - m_metMap("METAssoc"), m_metmaker(this), m_muonSelTool(this,""), m_elecSelLHTool(this,""), @@ -41,7 +40,7 @@ namespace met { declareProperty( "Maker", m_metmaker ); declareProperty( "METCoreName", m_CoreMetKey = "MET_Core" ); declareProperty("METName", m_metKey = std::string("MET_Reference"),"MET container"); - declareProperty("METMapName", m_metMap ); + declareProperty("METMapName", m_metMapKey = "METAssoc" ); declareProperty( "METSoftClName", m_softclname = "SoftClus" ); declareProperty( "METSoftTrkName", m_softtrkname = "PVSoftTrk" ); @@ -103,6 +102,7 @@ namespace met { ATH_CHECK( m_JetContainerKey.initialize() ); ATH_CHECK( m_CoreMetKey.initialize() ); ATH_CHECK( m_metKey.initialize() ); + ATH_CHECK( m_metMapKey.initialize() ); return StatusCode::SUCCESS; } @@ -125,9 +125,13 @@ namespace met { ATH_CHECK( metHandle.record (std::make_unique<xAOD::MissingETContainer>(), std::make_unique<xAOD::MissingETAuxContainer>()) ); xAOD::MissingETContainer* newMet=metHandle.ptr(); - ATH_CHECK( m_metMap.isValid() ); + SG::ReadHandle<xAOD::MissingETAssociationMap> metMap(m_metMapKey); + if (!metMap.isValid()) { + ATH_MSG_WARNING("Unable to retrieve MissingETAssociationMap: " << m_metMapKey.key()); + return StatusCode::FAILURE; + } - MissingETAssociationHelper metHelper(&(*m_metMap)); + MissingETAssociationHelper metHelper(&(*metMap)); // Retrieve containers *********************************************** /// MET diff --git a/Reconstruction/MET/METUtilities/src/METMakerAlg.h b/Reconstruction/MET/METUtilities/src/METMakerAlg.h index ca3b2c7e311309f01e66ccbf84f87080be84e432..cb27d3f9f27fe498a04e4ffd5a862e96fd09e265 100644 --- a/Reconstruction/MET/METUtilities/src/METMakerAlg.h +++ b/Reconstruction/MET/METUtilities/src/METMakerAlg.h @@ -77,7 +77,7 @@ namespace met { SG::ReadHandleKey<xAOD::MissingETContainer> m_CoreMetKey; SG::WriteHandleKey<xAOD::MissingETContainer> m_metKey; - SG::ReadHandle<xAOD::MissingETAssociationMap> m_metMap; + SG::ReadHandleKey<xAOD::MissingETAssociationMap> m_metMapKey; bool m_doTruthLep;