From f1624c4c2a014b37feee72892d183c039e00ed83 Mon Sep 17 00:00:00 2001 From: Bill Balunas Date: Thu, 26 May 2022 15:53:08 +0200 Subject: [PATCH 1/5] Clean up MET config strucutre --- .../python/METCommonConfig.py | 20 +++++++++++-------- .../python/PhysCommonConfig.py | 4 ++-- .../python/METAssociatorCfg.py | 3 +-- .../python/METConfigFlags.py | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/METCommonConfig.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/METCommonConfig.py index e2caf12820c..fe803ee7827 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/METCommonConfig.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkJetEtMiss/python/METCommonConfig.py @@ -6,19 +6,23 @@ # Component accumulator version #******************************************************************** -from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -def METAssociationAlgCfg(ConfigFlags, algname = 'METStandardAssociationAlg'): + +def METCommonCfg(ConfigFlags): """Configure MET for the derivation framework""" - + + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + from METReconstruction.METAssociatorCfg import METAssociatorCfg + acc = ComponentAccumulator() - from METReconstruction.METAssocCfg import getMETAssocAlg - from METReconstruction.METRecoFlags import metFlags - standardConfigs = {k : v for k, v in metFlags.METAssocConfigs().items() if ("EMTopo" in k or "EMPFlow" in k)} + metDefs = ['AntiKt4EMTopo'] + if ConfigFlags.MET.DoPFlow: + metDefs.append('AntiKt4EMPFlow') + + for metDef in metDefs: + acc.merge(METAssociatorCfg(ConfigFlags, metDef)) - assocAlg = getMETAssocAlg(algname, standardConfigs) - acc.addEventAlgo(assocAlg) return acc diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommonConfig.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommonConfig.py index bc4dba777fa..74e0e0421a1 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommonConfig.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommonConfig.py @@ -73,12 +73,12 @@ def PhysCommonAugmentationsCfg(ConfigFlags,**kwargs): from DerivationFrameworkFlavourTag.FtagRun3DerivationConfig import FtagJetCollectionsCfg from DerivationFrameworkTau.TauCommonConfig import AddDiTauLowPtCfg from DerivationFrameworkTau.TauCommonConfig import AddTauWPDecorationCfg - from DerivationFrameworkJetEtMiss.METCommonConfig import METAssociationAlgCfg + from DerivationFrameworkJetEtMiss.METCommonConfig import METCommonCfg acc.merge(JetCommonCfg(ConfigFlags)) acc.merge(AddDiTauLowPtCfg(ConfigFlags, prefix = 'PhysCommon')) acc.merge(AddTauWPDecorationCfg(ConfigFlags, prefix = 'PhysCommon', evetoFixTag="v1")) acc.merge(FtagJetCollectionsCfg(ConfigFlags,['AntiKt4EMPFlowJets','AntiKtVR30Rmax4Rmin02TrackJets'])) - acc.merge(METAssociationAlgCfg(ConfigFlags)) + acc.merge(METCommonCfg(ConfigFlags)) # Trigger matching from DerivationFrameworkPhys.TriggerMatchingCommonConfig import TriggerMatchingCommonRun2Cfg from DerivationFrameworkPhys.TriggerMatchingCommonConfig import TriggerMatchingCommonRun3Cfg diff --git a/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py b/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py index 160a65411ea..8759bff30d9 100644 --- a/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py +++ b/Reconstruction/MET/METReconstruction/python/METAssociatorCfg.py @@ -1,6 +1,5 @@ # 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 @@ -72,7 +71,7 @@ def METAssociatorCfg(configFlags, jetType): configFlags, associators, doPFlow=True, - usePFOLinks=metFlags.UseFELinks() + usePFOLinks=configFlags.MET.UseFELinks ) components_akt4pf= getAssocCA(cfg_akt4pf,sequencename='METAssoc_AntiKt4EMPFlow',METName='AntiKt4EMPFlow') components.merge(components_akt4pf) diff --git a/Reconstruction/MET/METReconstruction/python/METConfigFlags.py b/Reconstruction/MET/METReconstruction/python/METConfigFlags.py index 42e8d8b1153..aad1868328c 100644 --- a/Reconstruction/MET/METReconstruction/python/METConfigFlags.py +++ b/Reconstruction/MET/METReconstruction/python/METConfigFlags.py @@ -6,5 +6,6 @@ def createMETConfigFlags(): metConfigFlags=AthConfigFlags() metConfigFlags.addFlag("MET.UseTracks",True) metConfigFlags.addFlag("MET.DoPFlow",True) + metConfigFlags.addFlag("MET.UseFELinks",True) metConfigFlags.addFlag("MET.WritetoAOD",False) return metConfigFlags \ No newline at end of file -- GitLab From 1281a36a943f48a125a3936ba08a20449ecd4f5e Mon Sep 17 00:00:00 2001 From: Bill Balunas Date: Thu, 26 May 2022 16:52:41 +0200 Subject: [PATCH 2/5] Phase out old MET flags, simplify FE link config --- .../METReconstruction/METAssociationTool.h | 1 - .../METReconstruction/METEgammaAssociator.h | 4 --- .../METReconstruction/METMuonAssociator.h | 1 - .../METReconstruction/METTauAssociator.h | 1 - .../Root/METEgammaAssociator.cxx | 19 +++-------- .../Root/METElectronAssociator.cxx | 4 +-- .../Root/METMuonAssociator.cxx | 8 ++--- .../Root/METPhotonAssociator.cxx | 4 +-- .../Root/METTauAssociator.cxx | 8 ++--- .../METReconstruction/python/METAssocCfg.py | 32 +++++-------------- .../METReconstruction/python/METCalo_Cfg.py | 1 - .../python/METConfigFlags.py | 1 + .../METReconstruction/python/METRecoCfg.py | 15 ++++----- 13 files changed, 30 insertions(+), 69 deletions(-) diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h index 765961fafb0..749f4ebdf63 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METAssociationTool.h @@ -104,7 +104,6 @@ namespace met{ SG::WriteHandleKey m_coreKey{this, "CoreOutputKey", "", ""}; SG::WriteHandleKey m_mapKey{this, "AssociationOutputKey", "", ""}; - Gaudi::Property m_overwrite{this, "AllowOverwrite", false, ""}; ToolHandleArray m_metAssociators{this, "METAssociators", {}, ""}; // Monitor timing diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h b/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h index 1aac914218e..81bbbf3dcf2 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h @@ -119,10 +119,6 @@ namespace met{ SG::ReadDecorHandleKey m_electronNeutralFEReadDecorKey{this,"electronNeutralFEReadDecorKey","", "Neutral FE links key"}; SG::ReadDecorHandleKey m_electronChargedFEReadDecorKey{this,"electronCargedFEReadDecorKey","", "Charged FE links key"}; - bool m_usePFOElectronLinks; - bool m_usePFOPhotonLinks; - bool m_useFEElectronLinks; - bool m_useFEPhotonLinks; bool m_checkUnmatched; private: diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METMuonAssociator.h b/Reconstruction/MET/METReconstruction/METReconstruction/METMuonAssociator.h index 07c4ae5886a..390c79d5874 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METMuonAssociator.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METMuonAssociator.h @@ -80,7 +80,6 @@ namespace met{ private: Gaudi::Property m_doMuonClusterMatch{this, "DoClusterMatch", true, ""}; - Gaudi::Property m_useFEMuonLinks{this, "UseFEMuonLinks", false, ""}; /// Default constructor: METMuonAssociator(); diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METTauAssociator.h b/Reconstruction/MET/METReconstruction/METReconstruction/METTauAssociator.h index 2c6f8836fa9..8934e3e2570 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METTauAssociator.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METTauAssociator.h @@ -89,7 +89,6 @@ namespace met{ SG::ReadHandleKey m_tauContKey{this, "InputCollection", "TauJets", "taus input key"}; SG::ReadDecorHandleKey m_neutralFEReadDecorKey{this,"NeutralFEReadDecorKey","", "Neutral FlowElement links key"}; SG::ReadDecorHandleKey m_chargedFEReadDecorKey{this,"ChargedFEReadDecorKey","", "Charged FlowElement links key"}; - Gaudi::Property m_useFETauLinks{this, "UseFETauLinks", false, ""}; }; } diff --git a/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx index 91056a36b42..213a3e46904 100644 --- a/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx @@ -44,16 +44,9 @@ namespace met { // 0 is delta-R geometrical matching // 1 is using TopoClusterLink decoration on clusters declareProperty( "TCMatchMethod", m_tcMatch_method = DeltaR ); - declareProperty( "TCMatchMaxRat", m_tcMatch_maxRat = 1.5 ); declareProperty( "TCMatchDeltaR", m_tcMatch_dR = 0.1 ); - declareProperty( "ExtraTrackMatchDeltaR", m_extraTrkMatch_dR = 0.05 ); - - declareProperty( "UsePFOElectronLinks", m_usePFOElectronLinks = false ); - declareProperty( "UsePFOPhotonLinks", m_usePFOPhotonLinks = false); - declareProperty( "UseFEElectronLinks", m_useFEElectronLinks = false ); - declareProperty( "UseFEPhotonLinks", m_useFEPhotonLinks = false); declareProperty( "CheckUnmatched", m_checkUnmatched = false); } @@ -164,12 +157,10 @@ namespace met { { const xAOD::Egamma *eg = static_cast(obj); - if (((m_usePFOElectronLinks || m_usePFOLinks)&& eg->type() == xAOD::Type::Electron) || ((m_usePFOPhotonLinks || m_usePFOLinks) && eg->type() == xAOD::Type::Photon)) { + if (m_usePFOLinks) ATH_CHECK( extractPFOsFromLinks(eg, pfolist,constits) ); - } - else { + else ATH_CHECK( extractPFOs(eg, pfolist, constits) ); - } return StatusCode::SUCCESS; } @@ -329,12 +320,10 @@ namespace met { { const xAOD::Egamma *eg = static_cast(obj); - if (((m_useFEElectronLinks || m_useFELinks) && eg->type() == xAOD::Type::Electron) || ((m_useFEPhotonLinks || m_useFELinks) && eg->type() == xAOD::Type::Photon)) { + if (m_useFELinks) ATH_CHECK( extractFEsFromLinks(eg, felist,constits) ); - } - else { + else ATH_CHECK( extractFEs(eg, felist, constits) ); - } return StatusCode::SUCCESS; } diff --git a/Reconstruction/MET/METReconstruction/Root/METElectronAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METElectronAssociator.cxx index d68c1d1dae6..0f23d2ee15f 100644 --- a/Reconstruction/MET/METReconstruction/Root/METElectronAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METElectronAssociator.cxx @@ -40,13 +40,13 @@ namespace met { ATH_CHECK( m_elContKey.initialize()); ATH_CHECK( METEgammaAssociator::initialize() ); - if (m_usePFOLinks || m_usePFOElectronLinks) { + if (m_usePFOLinks) { if (m_electronNeutralPFOReadDecorKey.empty()) {ATH_CHECK( m_electronNeutralPFOReadDecorKey.assign(m_elContKey.key()+"."+m_neutralPFOLinksKey));} if (m_electronChargedPFOReadDecorKey.empty()) {ATH_CHECK( m_electronChargedPFOReadDecorKey.assign(m_elContKey.key()+"."+m_chargedPFOLinksKey));} ATH_CHECK(m_electronNeutralPFOReadDecorKey.initialize()); ATH_CHECK(m_electronChargedPFOReadDecorKey.initialize()); } - if (m_useFELinks || m_useFEElectronLinks) { + if (m_useFELinks) { if (m_electronNeutralFEReadDecorKey.empty()) {ATH_CHECK( m_electronNeutralFEReadDecorKey.assign(m_elContKey.key()+"."+m_neutralFELinksKey));} if (m_electronChargedFEReadDecorKey.empty()) {ATH_CHECK( m_electronChargedFEReadDecorKey.assign(m_elContKey.key()+"."+m_chargedFELinksKey));} ATH_CHECK(m_electronNeutralFEReadDecorKey.initialize()); diff --git a/Reconstruction/MET/METReconstruction/Root/METMuonAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METMuonAssociator.cxx index f9df3793029..e53ff20e7a2 100644 --- a/Reconstruction/MET/METReconstruction/Root/METMuonAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METMuonAssociator.cxx @@ -45,7 +45,7 @@ namespace met { ATH_CHECK( METAssociator::initialize() ); ATH_MSG_VERBOSE ("Initializing " << name() << "..."); ATH_CHECK( m_muContKey.initialize()); - if (m_useFEMuonLinks || m_useFELinks) { + if (m_useFELinks) { if (m_neutralFEReadDecorKey.empty()) {ATH_CHECK( m_neutralFEReadDecorKey.assign(m_muContKey.key()+"."+m_neutralFELinksKey));} if (m_chargedFEReadDecorKey.empty()) {ATH_CHECK( m_chargedFEReadDecorKey.assign(m_muContKey.key()+"."+m_chargedFELinksKey));} ATH_CHECK( m_neutralFEReadDecorKey.initialize()); @@ -211,12 +211,10 @@ namespace met { { const xAOD::Muon *mu = static_cast(obj); - if (m_useFEMuonLinks) { + if (m_useFELinks) ATH_CHECK( extractFEsFromLinks(mu, felist,constits) ); - } - else { + else ATH_CHECK( extractFEs(mu, felist, constits) ); - } return StatusCode::SUCCESS; } diff --git a/Reconstruction/MET/METReconstruction/Root/METPhotonAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METPhotonAssociator.cxx index 44e2dff88ff..71d0849a5af 100644 --- a/Reconstruction/MET/METReconstruction/Root/METPhotonAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METPhotonAssociator.cxx @@ -41,14 +41,14 @@ namespace met { ATH_CHECK( METEgammaAssociator::initialize() ); - if (m_usePFOLinks || m_usePFOPhotonLinks) { + if (m_usePFOLinks) { if (m_photonNeutralPFOReadDecorKey.empty()) {ATH_CHECK( m_photonNeutralPFOReadDecorKey.assign(m_phContKey.key()+"."+m_neutralPFOLinksKey));} if (m_photonChargedPFOReadDecorKey.empty()) {ATH_CHECK( m_photonChargedPFOReadDecorKey.assign(m_phContKey.key()+"."+m_chargedPFOLinksKey));} ATH_CHECK(m_photonNeutralPFOReadDecorKey.initialize()); ATH_CHECK(m_photonChargedPFOReadDecorKey.initialize()); } - if (m_useFELinks || m_useFEPhotonLinks) { + if (m_useFELinks) { if (m_photonNeutralFEReadDecorKey.empty()) {ATH_CHECK( m_photonNeutralFEReadDecorKey.assign(m_phContKey.key()+"."+m_neutralFELinksKey));} if (m_photonChargedFEReadDecorKey.empty()) {ATH_CHECK( m_photonChargedFEReadDecorKey.assign(m_phContKey.key()+"."+m_chargedFELinksKey));} ATH_CHECK(m_photonNeutralFEReadDecorKey.initialize()); diff --git a/Reconstruction/MET/METReconstruction/Root/METTauAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METTauAssociator.cxx index 1beafebd817..2981e167feb 100644 --- a/Reconstruction/MET/METReconstruction/Root/METTauAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METTauAssociator.cxx @@ -58,7 +58,7 @@ namespace met { ATH_MSG_VERBOSE ("Initializing " << name() << "..."); ATH_CHECK( m_tauContKey.initialize()); - if (m_useFETauLinks || m_useFELinks) { + if (m_useFELinks) { if (m_neutralFEReadDecorKey.key().empty()) {ATH_CHECK( m_neutralFEReadDecorKey.assign(m_tauContKey.key() + "." + m_neutralFELinksKey));} if (m_chargedFEReadDecorKey.key().empty()) {ATH_CHECK( m_chargedFEReadDecorKey.assign(m_tauContKey.key() + "." + m_chargedFELinksKey));} ATH_CHECK( m_neutralFEReadDecorKey.initialize()); @@ -196,12 +196,10 @@ namespace met { std::map &/*momenta*/) const { const TauJet* tau = static_cast(obj); - if (m_useFETauLinks) { + if (m_useFELinks) ATH_CHECK( extractFEsFromLinks(tau, felist,constits) ); - } - else { + else ATH_CHECK( extractFEs(tau, felist, constits) ); - } return StatusCode::SUCCESS; } diff --git a/Reconstruction/MET/METReconstruction/python/METAssocCfg.py b/Reconstruction/MET/METReconstruction/python/METAssocCfg.py index fcb04347c1d..1eac8b9c285 100644 --- a/Reconstruction/MET/METReconstruction/python/METAssocCfg.py +++ b/Reconstruction/MET/METReconstruction/python/METAssocCfg.py @@ -36,7 +36,7 @@ class AssocConfig: self.objType = objType self.inputKey = inputKey -def getAssociator(config,suffix,doPFlow=False, +def getAssociator(configFlags, config,suffix,doPFlow=False, trkseltool=None, trkisotool=None,caloisotool=None, useFELinks=False, @@ -48,17 +48,13 @@ def getAssociator(config,suffix,doPFlow=False, modLCClus = modClusColls['LC{0}Clusters'.format(modConstKey)] modEMClus = modClusColls['EM{0}Clusters'.format(modConstKey)] - from METReconstruction.METRecoFlags import metFlags # Construct tool and set defaults for case-specific configuration if config.objType == 'Ele': tool = CompFactory.getComp("met::METElectronAssociator")('MET_ElectronAssociator_'+suffix,TCMatchMethod=1) - tool.UseFEElectronLinks = metFlags.UseFEElectronLinks() if config.objType == 'Gamma': tool = CompFactory.getComp("met::METPhotonAssociator")('MET_PhotonAssociator_'+suffix,TCMatchMethod=1) - tool.UseFEPhotonLinks = metFlags.UseFEPhotonLinks() if config.objType == 'Tau': tool = CompFactory.getComp("met::METTauAssociator")('MET_TauAssociator_'+suffix) - tool.UseFETauLinks = metFlags.UseFETauLinks() if config.objType == 'LCJet': tool = CompFactory.getComp("met::METJetAssocTool")('MET_LCJetAssocTool_'+suffix) if config.objType == 'EMJet': @@ -67,7 +63,6 @@ def getAssociator(config,suffix,doPFlow=False, tool = CompFactory.getComp("met::METJetAssocTool")('MET_PFlowJetAssocTool_'+suffix) if config.objType == 'Muon': tool = CompFactory.getComp("met::METMuonAssociator")('MET_MuonAssociator_'+suffix) - tool.UseFEMuonLinks = metFlags.UseFEMuonLinks() if config.objType == 'Soft': tool = CompFactory.getComp("met::METSoftAssociator")('MET_SoftAssociator_'+suffix) tool.DecorateSoftConst = True @@ -93,12 +88,8 @@ def getAssociator(config,suffix,doPFlow=False, tool.ClusColl = modLCClus if 'EMTopo' in suffix: tool.ClusColl = modEMClus tool.TrkColl = defaultInputKey['Tracks'] - - from METReconstruction.METRecoFlags import metFlags - tool.UseTracks = metFlags.UseTracks() - # + tool.UseTracks = configFlags.MET.UseTracks tool.TrackSelectorTool = trkseltool - # tool.TrackIsolationTool = trkisotool tool.CaloIsolationTool = caloisotool @@ -115,14 +106,14 @@ class METAssocConfig: def outputMap(self): return 'METAssoc_'+self.suffix # - def setupAssociators(self,buildconfigs): + def setupAssociators(self, configFlags, 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, + associator = getAssociator(configFlags, config=config,suffix=self.suffix, doPFlow=self.doPFlow, useFELinks=self.useFELinks, trkseltool=self.trkseltool, @@ -130,8 +121,7 @@ class METAssocConfig: caloisotool=self.caloisotool, modConstKey=self.modConstKey, modClusColls=self.modClusColls) - from METReconstruction.METRecoFlags import metFlags - if config.objType == 'Soft' and metFlags.DecorateSoftConst: + if config.objType == 'Soft' and configFlags.MET.DecorateSoftConst: print ("activate soft term decoration") associator.DecorateSoftConst = True self.associators[config.objType] = associator @@ -190,12 +180,11 @@ class METAssocConfig: self.associators = {} self.assoclist = [] # need an ordered list # - self.setupAssociators(buildconfigs) + self.setupAssociators(inputFlags, 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, @@ -206,21 +195,16 @@ def getMETAssocTool(topconfig,msglvl=INFO): 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 +# Convert the provided METAssocConfigs into a concrete algorithm 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) + print ("{} Empty list of MET association configs provided. None will be reconstructed.".format(prefix)) for key,conf in six.iteritems(configs): print ("{} Generate METAssocTool for MET_{}".format(prefix,key)) assoctool = getMETAssocTool(conf,msglvl) diff --git a/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py b/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py index dd6119a9efa..e525ae5ef4c 100644 --- a/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py +++ b/Reconstruction/MET/METReconstruction/python/METCalo_Cfg.py @@ -1,6 +1,5 @@ # Copyright (C) 2002-2022 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 diff --git a/Reconstruction/MET/METReconstruction/python/METConfigFlags.py b/Reconstruction/MET/METReconstruction/python/METConfigFlags.py index aad1868328c..78df02150a7 100644 --- a/Reconstruction/MET/METReconstruction/python/METConfigFlags.py +++ b/Reconstruction/MET/METReconstruction/python/METConfigFlags.py @@ -8,4 +8,5 @@ def createMETConfigFlags(): metConfigFlags.addFlag("MET.DoPFlow",True) metConfigFlags.addFlag("MET.UseFELinks",True) metConfigFlags.addFlag("MET.WritetoAOD",False) + metConfigFlags.addFlag("MET.DecorateSoftConst",False) return metConfigFlags \ No newline at end of file diff --git a/Reconstruction/MET/METReconstruction/python/METRecoCfg.py b/Reconstruction/MET/METReconstruction/python/METRecoCfg.py index 980914e4b22..960846facbb 100644 --- a/Reconstruction/MET/METReconstruction/python/METRecoCfg.py +++ b/Reconstruction/MET/METReconstruction/python/METRecoCfg.py @@ -106,7 +106,7 @@ class RefConfig: self.type = myType self.outputKey = outputKey -def getRefiner(config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,caloisotool=None): +def getRefiner(flags,config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,caloisotool=None): tool = None if config.type == 'TrackFilter': @@ -118,10 +118,9 @@ def getRefiner(config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,calo tool.UseIsolationTools = False #True tool.TrackIsolationTool = trkisotool tool.CaloIsolationTool = caloisotool - # TODO: flags? - # from METReconstruction.METRecoFlags import metFlags - tool.DoPVSel = True # metFlags.UseTracks() - tool.DoVxSep = True # metFlags.UseTracks() + # + tool.DoPVSel = flags.MET.UseTracks + tool.DoVxSep = flags.MET.UseTracks tool.MissingETKey = config.outputKey return tool @@ -161,7 +160,7 @@ class METConfig: self.buildlist.append(builder) print("{} Added {} tool named {}".format(prefix,config.objType,builder.name)) # - def setupRefiners(self,refconfigs): + def setupRefiners(self,flags,refconfigs): print("{} Setting up refiners for MET config {}".format(prefix,self.suffix)) for config in refconfigs: # need to enforce this? @@ -169,7 +168,7 @@ class METConfig: print("Config {} already contains a refiner of type {}".format(self.suffix,config.type)) raise LookupError else: - refiner = getRefiner(config=config,suffix=self.suffix, + refiner = getRefiner(flags, config=config,suffix=self.suffix, trkseltool=self.trkseltool,trkvxtool=self.trkvxtool, trkisotool=self.trkisotool,caloisotool=self.caloisotool) self.refiners[config.type] = refiner @@ -240,7 +239,7 @@ class METConfig: ParticleCaloCellAssociationTool = CaloCellAssocTool) self.setupBuilders(buildconfigs) - self.setupRefiners(refconfigs) + self.setupRefiners(inputFlags,refconfigs) # Set up a top-level tool with mostly defaults def getMETRecoTool(topconfig): -- GitLab From fd91dc35533e736240276c4e46d3910e591dde7d Mon Sep 17 00:00:00 2001 From: Bill Balunas Date: Sun, 29 May 2022 14:24:51 +0200 Subject: [PATCH 3/5] Propagate obsolete flag removal to legacy config --- .../METReconstruction/python/LegacyRunII/METAssocConfig.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py index 72b56ec3e83..43ee9c67082 100644 --- a/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py +++ b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py @@ -60,16 +60,13 @@ def getAssociator(config,suffix,doPFlow=False,usePFOLinks=False,useFELinks=False if config.objType == 'Ele': from ROOT import met tool = CfgMgr.met__METElectronAssociator('MET_ElectronAssociator_'+suffix,TCMatchMethod=met.ClusterLink) - tool.UseFEElectronLinks = metFlags.UseFEElectronLinks() if config.objType == 'Gamma': from ROOT import met tool = CfgMgr.met__METPhotonAssociator('MET_PhotonAssociator_'+suffix,TCMatchMethod=met.ClusterLink) - tool.UseFEPhotonLinks = metFlags.UseFEPhotonLinks() if config.objType == 'Tau': tool = CfgMgr.met__METTauAssociator('MET_TauAssociator_'+suffix) - tool.UseFETauLinks = metFlags.UseFETauLinks() if config.objType == 'LCJet': tool = CfgMgr.met__METJetAssocTool('MET_LCJetAssocTool_'+suffix) if config.objType == 'EMJet': @@ -80,7 +77,6 @@ def getAssociator(config,suffix,doPFlow=False,usePFOLinks=False,useFELinks=False tool = CfgMgr.met__METJetAssocTool('MET_OverlapRemovedPFlowJetAssocTool_'+suffix) if config.objType == 'Muon': tool = CfgMgr.met__METMuonAssociator('MET_MuonAssociator_'+suffix) - tool.UseFEMuonLinks = metFlags.UseFEMuonLinks() if config.objType == 'Soft': tool = CfgMgr.met__METSoftAssociator('MET_SoftAssociator_'+suffix) tool.DecorateSoftConst = True -- GitLab From f96725cc48ed3059e459bde8cedca8e197858283 Mon Sep 17 00:00:00 2001 From: Bill Balunas Date: Sun, 29 May 2022 21:49:47 +0200 Subject: [PATCH 4/5] Trivial changes necessitated by MET flag cleanup --- .../DerivationFrameworkPhys/share/PHYSLITE.py | 3 ++- .../MET/METReconstruction/python/LegacyRunII/METAssocConfig.py | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py index 886d8a14440..df64130a2f1 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py @@ -271,7 +271,8 @@ associators = [AssocConfig('PFlowJet', 'AnalysisJets'), AssocConfig('Soft', '')] PHYSLITE_cfg = METAssocConfig('AnalysisMET', associators, - doPFlow=True) + doPFlow=True, + usePFOLinks=True) METCommon.customMETConfigs.setdefault('AnalysisMET',{})[PHYSLITE_cfg.suffix] = PHYSLITE_cfg scheduleMETAssocAlg(sequence=SeqPHYSLITE,configlist="AnalysisMET") diff --git a/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py index 43ee9c67082..2387ade834b 100644 --- a/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py +++ b/Reconstruction/MET/METReconstruction/python/LegacyRunII/METAssocConfig.py @@ -54,9 +54,6 @@ def getAssociator(config,suffix,doPFlow=False,usePFOLinks=False,useFELinks=False modEMClus = modClusColls['EM{0}Clusters'.format(modConstKey)] # Construct tool and set defaults for case-specific configuration - - from METReconstruction.METRecoFlags import metFlags - if config.objType == 'Ele': from ROOT import met tool = CfgMgr.met__METElectronAssociator('MET_ElectronAssociator_'+suffix,TCMatchMethod=met.ClusterLink) -- GitLab From 831861536457697d2648228c5906bf3b37721b2e Mon Sep 17 00:00:00 2001 From: Bill Balunas Date: Mon, 30 May 2022 17:42:35 +0200 Subject: [PATCH 5/5] Improve logging for MET config --- .../METReconstruction/python/METAssocCfg.py | 22 ++++++++------- .../METReconstruction/python/METRecoCfg.py | 27 ++++++++++--------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Reconstruction/MET/METReconstruction/python/METAssocCfg.py b/Reconstruction/MET/METReconstruction/python/METAssocCfg.py index 1eac8b9c285..dee55064f25 100644 --- a/Reconstruction/MET/METReconstruction/python/METAssocCfg.py +++ b/Reconstruction/MET/METReconstruction/python/METAssocCfg.py @@ -1,8 +1,10 @@ # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -from __future__ import print_function from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaCommon import Logging +metlog = Logging.logging.getLogger('METConfig') + from GaudiKernel.Constants import INFO import six @@ -107,10 +109,10 @@ class METAssocConfig: return 'METAssoc_'+self.suffix # def setupAssociators(self, configFlags, buildconfigs): - print("{} Setting up associators for MET config {}".format(prefix,self.suffix)) + metlog.info("{} 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)) + metlog.error("{} Config {} already contains a associator of type {}".format(prefix,self.suffix,config.objType)) raise LookupError else: associator = getAssociator(configFlags, config=config,suffix=self.suffix, @@ -122,11 +124,11 @@ class METAssocConfig: modConstKey=self.modConstKey, modClusColls=self.modClusColls) if config.objType == 'Soft' and configFlags.MET.DecorateSoftConst: - print ("activate soft term decoration") + metlog.verbose("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)) + metlog.info("{} Added {} tool named {}".format(prefix,config.objType,associator.name)) # def __init__(self,suffix,inputFlags,buildconfigs=[], doPFlow=False, doTruth=False, @@ -147,9 +149,9 @@ class METAssocConfig: if modClusColls_tmp == {}: modClusColls_tmp = {'LCOriginCorrClusters':'LCOriginTopoClusters', 'EMOriginCorrClusters':'EMOriginTopoClusters'} if doTruth: - print ("{} Creating MET TruthAssoc config {}".format(prefix,suffix)) + metlog.info("{} Creating MET TruthAssoc config {}".format(prefix,suffix)) else: - print ("{} Creating MET Assoc config {}".format(prefix,suffix)) + metlog.info("{} Creating MET Assoc config {}".format(prefix,suffix)) self.suffix = suffix self.doPFlow = doPFlow self.useFELinks = usePFOLinks @@ -204,14 +206,14 @@ def getMETAssocAlg(algName='METAssociation',configs={},tools=[],msglvl=INFO): assocTools += tools if configs=={} and tools==[]: - print ("{} Empty list of MET association configs provided. None will be reconstructed.".format(prefix)) + metlog.info("{} Empty list of MET association configs provided. None will be reconstructed.".format(prefix)) for key,conf in six.iteritems(configs): - print ("{} Generate METAssocTool for MET_{}".format(prefix,key)) + metlog.info("{} 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)) + metlog.info("{} 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/METRecoCfg.py b/Reconstruction/MET/METReconstruction/python/METRecoCfg.py index 960846facbb..4009ce18531 100644 --- a/Reconstruction/MET/METReconstruction/python/METRecoCfg.py +++ b/Reconstruction/MET/METReconstruction/python/METRecoCfg.py @@ -2,6 +2,9 @@ from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaCommon import Logging +metlog = Logging.logging.getLogger('METConfig') + ################################################################################# # Define some default values @@ -148,24 +151,24 @@ class METConfig: return 'METMap_'+self.suffix # def setupBuilders(self,buildconfigs): - print("{} Setting up builders for MET config {}".format(prefix,self.suffix)) + metlog.info("{} 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)) + metlog.error("{} 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)) + metlog.info("{} Added {} tool named {}".format(prefix,config.objType,builder.name)) # def setupRefiners(self,flags,refconfigs): - print("{} Setting up refiners for MET config {}".format(prefix,self.suffix)) + metlog.info("{} 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)) + metlog.error("Config {} already contains a refiner of type {}".format(self.suffix,config.type)) raise LookupError else: refiner = getRefiner(flags, config=config,suffix=self.suffix, @@ -173,25 +176,25 @@ class METConfig: 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)) + metlog.info("{} Added {} tool named {}".format(prefix,config.type,refiner.name)) # def setupRegions(self,buildconfigs): - print("{} Setting up regions for MET config {}".format(prefix,self.suffix)) + metlog.info("{} 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)) + metlog.error("{} 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)) + metlog.info("{} 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)) + metlog.info("{} Creating MET config {}".format(prefix,suffix)) self.suffix = suffix self.doSum = doSum self.doTracks = doTracks @@ -269,13 +272,13 @@ def getRegionRecoTool(topconfig): def getMETRecoAlg(algName='METReconstruction',configs={}): recoTools = [] for key,conf in configs.items(): - print("{} Generate METRecoTool for MET_{}".format(prefix,key)) + metlog.info("{} 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)) + metlog.info("{} Added METRecoTool {} to alg {}".format(prefix,tool.name,algName)) recoAlg = CompFactory.getComp("met::METRecoAlg")(name=algName,RecoTools=recoTools) return recoAlg -- GitLab