Skip to content
Snippets Groups Projects
Commit 46ad249d authored by Duc Ta's avatar Duc Ta
Browse files

Merge branch 'tstreble-24.0-patch-78ee' into '24.0'

Clean up legacy isolation configs

See merge request !69683
parents b66c8c6d a25070d6
No related branches found
No related tags found
2 merge requests!698222024-03-14: merge of 24.0 into main,!69683Clean up legacy isolation configs
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( IsolationAlgs )
......@@ -11,5 +11,4 @@ atlas_add_component( IsolationAlgs
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
atlas_install_joboptions( share/*.py )
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from AthenaCommon.Logging import logging
log = logging.getLogger(__name__)
def GetUpdatedIsoTrackCones(postfix="", object_types=("Electrons", "Photons", "Muons"),WP="Nonprompt_All_MaxWeight",TTVATool=None):
""" Return a list of IsolationBuilder algorithms to calculate TTVA moments
---------
Arguments
---------
postfix: Optionally provide a postfix to add to the names of the isolation
builder algorithm instances
object_types: The object types to which to add the moments
"""
import ROOT
# This is a doubly nested list
ptcone_list = [
[ROOT.xAOD.Iso.IsolationType.ptcone40, ROOT.xAOD.Iso.IsolationType.ptcone30, ROOT.xAOD.Iso.IsolationType.ptcone20]
]
trkcor_list = [[ROOT.xAOD.Iso.IsolationTrackCorrection.coreTrackPtr]]
do_egamma = any(x in object_types for x in ("Electrons", "Photons"))
algs = []
for track_pt in (500, 1000):
for loose_cone in (True, False):
if loose_cone and not do_egamma:
# Loose cone isolation variables only for electrons and photons
continue
cone_str = "LooseCone" if loose_cone else ""
name = f"{WP}TTVA{cone_str}_pt{track_pt}"
# Build up extra IsolationBuilder kwargs
kwargs = {}
if "Electrons" in object_types:
kwargs["ElIsoTypes"] = ptcone_list
kwargs["ElCorTypes"] = trkcor_list
kwargs["ElCorTypesExtra"] = [[]]
kwargs["CustomConfigurationNameEl"] = name
if "Electrons" in object_types and "LRT" in postfix:
kwargs["ElectronCollectionContainerName"] = "LRTElectrons"
if "Photons" in object_types:
kwargs["PhIsoTypes"] = ptcone_list
kwargs["PhCorTypes"] = trkcor_list
kwargs["PhCorTypesExtra"] = [[]]
kwargs["CustomConfigurationNamePh"] = name
if "Muons" in object_types and not loose_cone:
kwargs["MuIsoTypes"] = ptcone_list
kwargs["MuCorTypes"] = trkcor_list
kwargs["MuCorTypesExtra"] = [[]]
kwargs["CustomConfigurationNameMu"] = name
if "Muons" in object_types and not loose_cone and "LRT" in postfix:
kwargs["MuonCollectionContainerName"] = "MuonsLRT"
toolkwargs = {}
from AthenaCommon.BeamFlags import jobproperties
if jobproperties.Beam.beamType == 'cosmics':
toolkwargs['VertexLocation'] = ''
from AthenaCommon import CfgMgr
if TTVATool is None:
if WP != "MVATight":
TTVATool = CfgMgr.CP__TrackVertexAssociationTool(WP,
WorkingPoint=WP)
else:
TTVATool = CfgMgr.CP__MVATrackVertexAssociationTool(WP,
WorkingPoint="Tight")
algs.append(CfgMgr.IsolationBuilder(
f"IsolationBuilder{WP}{cone_str}{track_pt}{postfix}",
TrackIsolationTool=CfgMgr.xAOD__TrackIsolationTool(
f"TrackIsolationTool{WP}{track_pt}",
TrackSelectionTool=CfgMgr.InDet__InDetTrackSelectionTool(
minPt=track_pt, CutLevel="Loose"
),
TTVATool=TTVATool,
CoreTrackEtaRange=0.01 if loose_cone else 0.0,
**toolkwargs,
),
**kwargs,
)
)
return algs
def iso_vars():
# Get the list of isolation variables calculated by these functions
iso_vars = []
for track_pt in 500, 1000:
for cone_str in "", "LooseCone":
name = f"Nonprompt_All_MaxWeightTTVA{cone_str}_pt{track_pt}"
iso_vars += ["ptconeCorrBitset_"+name, "ptconecoreTrackPtrCorrection_"+name]
for cone_size in 20, 30, 40:
for var_str in "", "var":
iso_vars.append(f"pt{var_str}cone{cone_size}_{name}")
return iso_vars
from RecExConfig.RecFlags import rec
from RecExConfig.RecAlgsFlags import recAlgs
# ESD List
IsoESDList = []
if rec.doWriteAOD() or rec.doWriteESD():
if rec.doMuon() or rec.doEgamma():
IsoESDList += ["xAOD::EventShape#TopoClusterIsoCentralEventShape"]
IsoESDList += ["xAOD::EventShapeAuxInfo#TopoClusterIsoCentralEventShapeAux."]
IsoESDList += ["xAOD::EventShape#TopoClusterIsoForwardEventShape"]
IsoESDList += ["xAOD::EventShapeAuxInfo#TopoClusterIsoForwardEventShapeAux."]
if recAlgs.doEFlow():
IsoESDList += ["xAOD::EventShape#ParticleFlowIsoCentralEventShape"]
IsoESDList += ["xAOD::EventShapeAuxInfo#ParticleFlowIsoCentralEventShapeAux."]
IsoESDList += ["xAOD::EventShape#ParticleFlowIsoForwardEventShape"]
IsoESDList += ["xAOD::EventShapeAuxInfo#ParticleFlowIsoForwardEventShapeAux."]
IsoESDList += ["xAOD::EventShape#NeutralParticleFlowIsoCentralEventShape"]
IsoESDList += ["xAOD::EventShapeAuxInfo#NeutralParticleFlowIsoCentralEventShapeAux."]
IsoESDList += ["xAOD::EventShape#NeutralParticleFlowIsoForwardEventShape"]
IsoESDList += ["xAOD::EventShapeAuxInfo#NeutralParticleFlowIsoForwardEventShapeAux."]
# AOD List
IsoAODList = [i.replace('Aux.', 'Aux.-DensityArea.-DensitySigma')
for i in IsoESDList]
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# inputFile = '/net/s3_datac/dzhang/SAMPLES/R20/MC15/mc15_13TeV.402211.MGPy8EG_A14N_C1C1_800_10_LLE12k.merge.AOD.e4097_a766_a768_r6282/AOD.05819610._000001.pool.root.1'
#
# Input file
inputFile = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia8_AU2CT10_Zmumu/147807/valid1.147807.PowhegPythia8_AU2CT10_Zmumu.recon.AOD.e2658_s1967_s1964_r5787_v114/valid1.147807.PowhegPythia8_AU2CT10_Zmumu.recon.AOD.e2658_s1967_s1964_r5787_v114._000187.1";
#inputFile = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia_P2011C_ttbar/117050/valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5787_v111/valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5787_v111._000001.4";
#inputFile = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia8_AU2CT10_Zee/147806/valid1.147806.PowhegPythia8_AU2CT10_Zee.recon.AOD.e2658_s1967_s1964_r5787_v114/valid1.147806.PowhegPythia8_AU2CT10_Zee.recon.AOD.e2658_s1967_s1964_r5787_v114._000001.1";
#inputFile = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia8_AU2CT10_ggH125_gamgam/160009/valid1.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.recon.AOD.e2658_s1967_s1964_r5787_v114/valid1.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.recon.AOD.e2658_s1967_s1964_r5787_v114._000001.1";
# inputFile = "/afs/cern.ch/user/k/kaplan/public/DAOD_SUSY5.output.pool.root"
import AthenaPoolCnvSvc.ReadAthenaPool
svcMgr.EventSelector.InputCollections= [ inputFile ]
from AthenaCommon.GlobalFlags import globalflags
isMC = not globalflags.DataSource()=='data'
from IsolationCorrections.IsolationCorrectionsConf import CP__IsolationCorrectionTool
IsoCorrectionTool = CP__IsolationCorrectionTool ("NewLeakageCorrTool",IsMC = isMC)
ToolSvc += IsoCorrectionTool
from IsolationTool.IsolationToolConf import xAOD__TrackIsolationTool
TrackIsoTool = xAOD__TrackIsolationTool("TrackIsoTool")
TrackIsoTool.TrackSelectionTool.maxZ0SinTheta= 3.
TrackIsoTool.TrackSelectionTool.minPt= 1000.
TrackIsoTool.TrackSelectionTool.CutLevel= "Loose"
ToolSvc += TrackIsoTool
from CaloIdentifier import SUBCALO
from IsolationTool.IsolationToolConf import xAOD__CaloIsolationTool
CaloIsoTool = xAOD__CaloIsolationTool("CaloIsoTool")
CaloIsoTool.IsoLeakCorrectionTool = ToolSvc.NewLeakageCorrTool
CaloIsoTool.EMCaloNums = [SUBCALO.LAREM]
CaloIsoTool.HadCaloNums = [SUBCALO.LARHEC, SUBCALO.TILE]
CaloIsoTool.UseEMScale = True
CaloIsoTool.saveOnlyRequestedCorrections = True
# CaloIsoTool.OutputLevel = 2
ToolSvc += CaloIsoTool
# Import the xAOD isolation parameters.
from xAODPrimitives.xAODIso import xAODIso as isoPar
deco_ptcones = [isoPar.ptcone40, isoPar.ptcone30]
deco_topoetcones = [isoPar.topoetcone40, isoPar.topoetcone20]
deco_prefix = 'MUON1_'
algseq = CfgMgr.AthSequencer("AthAlgSeq")
algseq += CfgMgr.IsolationTool_AthTest("myIsolationToolTest")
algseq.myIsolationToolTest.TrackIsolationTool = TrackIsoTool
algseq.myIsolationToolTest.CaloIsolationTool = CaloIsoTool
algseq.myIsolationToolTest.ptcones = deco_ptcones
algseq.myIsolationToolTest.topoetcones = deco_topoetcones
algseq.myIsolationToolTest.Prefix = deco_prefix
algseq.myIsolationToolTest.TargetContainer = 'Muons'
algseq.myIsolationToolTest.OutputLevel = 2
theApp.EvtMax=10
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment