Commit 7ae4f8e0 authored by Tomasz Bold's avatar Tomasz Bold Committed by Walter Lampl
Browse files

EMVertesBuilderConfig in newJO

parent df8cc2dc
......@@ -205,4 +205,7 @@ def createInDetConfigFlags():
icf.addFlagsCategory ("InDet.SCTandTRTTracking", createSCTandTRTTrackingFlags, prefix=True)
icf.addFlagsCategory ("InDet.DBMTracking", createDBMTrackingFlags, prefix=True)
from InDetConfig.VertexFindingFlags import createSecVertexingFlags, createEGammaPileUpSecVertexingFlags
icf.addFlagsCategory("InDet.SecVertex", createSecVertexingFlags, prefix=True)
icf.addFlagsCategory("InDet.SecVertexEGammaPileUp", createEGammaPileUpSecVertexingFlags, prefix=True)
return icf
......@@ -71,3 +71,120 @@ def primaryVertexFindingCfg(flags):
#acc.merge(addToESD(flags, verticesContainer))
return acc
###################################################################
# secondary vertex finding (for egamma)
def ConversionPostSelectorCfg(flags, name="ConversionPostSelector"):
acc = ComponentAccumulator()
kwargs = {}
kwargs["MaxChi2Vtx"] = flags.InDet.SecVertex.SecVtxPost.MaxChi2Vtx
kwargs["MaxInvariantMass"] = flags.InDet.SecVertex.SecVtxPost.MaxInvariantMass
kwargs["MaxPhiVtxTrk"] = flags.InDet.SecVertex.SecVtxPost.MaxPhiVtxTrk
kwargs["MaxdR"] = flags.InDet.SecVertex.SecVtxPost.MaxdR
kwargs["MinFitMomentum"] = flags.InDet.SecVertex.SecVtxPost.MinFitMomentum
kwargs["MinPt"] = flags.InDet.SecVertex.SecVtxPost.MinPt
kwargs["MinRadius"] = flags.InDet.SecVertex.SecVtxPost.MinRadius
tool = CompFactory.InDet.ConversionPostSelector(name, **kwargs)
acc.setPrivateTools(tool)
return acc
def SingleTrackConversionToolCfg(flags, name="SingleTrackConversionTool"):
acc = ComponentAccumulator()
kwargs ={}
# from InDetConfig.InDetRecToolConfig import InDetExtrapolatorCfg
# kwargs["Extrapolator"] = acc.popToolsAndMerge(InDetExtrapolatorCfg(flags))
kwargs["MaxBLayerHits"] = flags.InDet.SecVertex.SingleTrk.MaxBLayerHits
kwargs["MinInitialHitRadius"] = flags.InDet.SecVertex.SingleTrk.MinInitialHitRadius
kwargs["MinInitialHitRadius_noBlay"] = flags.InDet.SecVertex.SingleTrk.MinInitialHitRadius_noBlay
kwargs["MinRatioOfHLhits"] = flags.InDet.SecVertex.SingleTrk.MinRatioOfHLhits
tool = CompFactory.InDet.SingleTrackConversionTool(name, **kwargs)
acc.setPrivateTools(tool)
return acc
def TrackPairsSelectorCfg(flags, name="TrackPairsSelector"):
acc = ComponentAccumulator()
kwargs = {}
kwargs["ConversionFinderHelperTool"] = CompFactory.InDet.ConversionFinderUtils()
kwargs["DistanceTool"] = CompFactory.Trk.SeedNewtonTrkDistanceFinder()
kwargs["MaxDistBetweenTracks"] = flags.InDet.SecVertex.TrkPairSel.MaxDistBetweenTracks
kwargs["MaxEta"] = flags.InDet.SecVertex.TrkPairSel.MaxEta
kwargs["MaxFirstHitRadius"] = flags.InDet.SecVertex.TrkPairSel.MaxFirstHitRadius
kwargs["MaxInitDistance"] = flags.InDet.SecVertex.TrkPairSel.MaxInitDistance
kwargs["MinTrackAngle"] = flags.InDet.SecVertex.TrkPairSel.MinTrackAngle
tool = CompFactory.InDet.TrackPairsSelector(name, **kwargs)
acc.setPrivateTools(tool)
return acc
def InDetConversionTrackSelectorToolCfg(flags, name="InDetConversionTrackSelectorTool"):
acc = ComponentAccumulator()
kwargs = {}
from InDetConfig.InDetRecToolConfig import InDetExtrapolatorCfg
kwargs["Extrapolator"] = acc.getPrimaryAndMerge(InDetExtrapolatorCfg(flags))
kwargs["RatioCut1"] = flags.InDet.SecVertex.TrkSel.RatioCut1
kwargs["RatioCut3"] = flags.InDet.SecVertex.TrkSel.RatioCut3
kwargs["RatioTRT"] = flags.InDet.SecVertex.TrkSel.RatioTRT
kwargs["RatioV0"] = flags.InDet.SecVertex.TrkSel.RatioV0
kwargs["maxSiD0"] = flags.InDet.SecVertex.TrkSel.maxSiD0
kwargs["maxSiZ0"] = flags.InDet.SecVertex.TrkSel.maxSiZ0
kwargs["maxTrtD0"] = flags.InDet.SecVertex.TrkSel.maxTrtD0
kwargs["maxTrtZ0"] = flags.InDet.SecVertex.TrkSel.maxTrtZ0
kwargs["minPt"] = flags.InDet.SecVertex.TrkSel.minPt
kwargs["significanceD0_Si"] = flags.InDet.SecVertex.TrkSel.significanceD0_Si
tool = CompFactory.InDet.InDetConversionTrackSelectorTool(name, **kwargs)
acc.setPrivateTools(tool)
return acc
def TrkVKalVrtFitterCfg(flags, name="TrkVKalVrtFitter"):
acc = ComponentAccumulator()
kwargs= {}
from InDetConfig.InDetRecToolConfig import InDetExtrapolatorCfg
kwargs["Extrapolator"] = acc.popToolsAndMerge(InDetExtrapolatorCfg(flags))
kwargs["FirstMeasuredPoint"] = flags.InDet.SecVertex.Fitter.FirstMeasuredPoint
kwargs["FirstMeasuredPointLimit"] = flags.InDet.SecVertex.Fitter.FirstMeasuredPointLimit
kwargs["InputParticleMasses"] = flags.InDet.SecVertex.Fitter.InputParticleMasses
kwargs["IterationNumber"] = flags.InDet.SecVertex.Fitter.IterationNumber
kwargs["MakeExtendedVertex"] = flags.InDet.SecVertex.Fitter.MakeExtendedVertex
kwargs["Robustness"] = flags.InDet.SecVertex.Fitter.Robustness
kwargs["usePhiCnst"] = flags.InDet.SecVertex.Fitter.usePhiCnst
kwargs["useThetaCnst"] = flags.InDet.SecVertex.Fitter.useThetaCnst
tool = CompFactory.Trk.TrkVKalVrtFitter(name, **kwargs)
acc.setPrivateTools(tool)
return acc
def VertexPointEstimatorCfg(flags, name="VertexPointEstimator"):
acc = ComponentAccumulator()
kwargs={}
# TODO find out where this setting comes from (flags?)
kwargs["MaxPhi"] = [0.05, 0.2, 0.2]
tool = CompFactory.InDet.VertexPointEstimator(name, **kwargs)
acc.setPrivateTools(tool)
return acc
def ConversionFinderCfg(flags, name="ConversionFinderTool"):
"""Configures InDet::InDetConversionFinderTools """
acc = ComponentAccumulator()
kwargs = {}
from InDetConfig.InDetRecToolConfig import InDetExtrapolatorCfg
kwargs["Extrapolator"] = acc.getPrimaryAndMerge(InDetExtrapolatorCfg(flags))
kwargs["PostSelector"] = acc.getPrimaryAndMerge(ConversionPostSelectorCfg(flags))
kwargs["SingleTrackConversionTool"] = acc.getPrimaryAndMerge(SingleTrackConversionToolCfg(flags))
kwargs["TrackPairsSelector"] = acc.getPrimaryAndMerge(TrackPairsSelectorCfg(flags))
kwargs["TrackSelectorTool"] = acc.getPrimaryAndMerge(InDetConversionTrackSelectorToolCfg(flags))
kwargs["VertexFitterTool"] = acc.getPrimaryAndMerge(TrkVKalVrtFitterCfg(flags))
kwargs["VertexPointEstimator"] = acc.getPrimaryAndMerge(VertexPointEstimatorCfg(flags))
kwargs["TrackParticleCollection"] = flags.Egamma.Keys.Output.GSFTrackParticles
kwargs["IsConversion"] = True
print("HERE")
print(kwargs)
tool = CompFactory.InDet.InDetConversionFinderTools(name, **kwargs)
acc.setPrivateTools(tool)
return acc
\ No newline at end of file
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
def createSecVertexingFlags():
from AthenaConfiguration.AthConfigFlags import AthConfigFlags
flags = AthConfigFlags()
flags.addFlag("Fitter.IterationNumber" , 10)
flags.addFlag("Fitter.MakeExtendedVertex" , False)
flags.addFlag("Fitter.FirstMeasuredPoint" , True)
flags.addFlag("Fitter.Robustness" , 6)
flags.addFlag("Fitter.InputParticleMasses" , [139.57018,139.57018])
flags.addFlag("Fitter.VertexForConstraint" , [0.,0.,0.])
flags.addFlag("Fitter.CovVrtForConstraint" , [0.015*0.015,0.,0.015*0.015,0.,0.,10000.*10000.])
flags.addFlag("Fitter.FirstMeasuredPointLimit" , False)
flags.addFlag("Fitter.usePhiCnst" , False)
flags.addFlag("Fitter.useThetaCnst" , False)
# Track selector tool
flags.addFlag("TrkSel.maxSiD0" , 80.0)
flags.addFlag("TrkSel.maxTrtD0" , 10000.)
flags.addFlag("TrkSel.maxSiZ0" , 10000.)
flags.addFlag("TrkSel.maxTrtZ0" , 10000.)
flags.addFlag("TrkSel.minPt" , lambda pcf: pcf.InDet.Tracking.minPT)
flags.addFlag("TrkSel.RatioCut1" , 0.0) # e-prob for Si conversion tracks (affects 1Si, 2Si, SiTRT): Ntrt < 15
flags.addFlag("TrkSel.RatioCut2" , 0.0) # e-prob for Si conversion tracks (affects 1Si, 2Si, SiTRT): 15 < Ntrt < 25
flags.addFlag("TrkSel.RatioCut3" , 0.0) # e-prob for Si conversion tracks (affects 1Si, 2Si, SiTRT): Ntrt > 25
flags.addFlag("TrkSel.RatioTRT" , 0.0) # e-prob cut for TRT conversion tracks (affects 1TRT, 2TRT, SiTRT) (see also below)
flags.addFlag("TrkSel.TRTTrksEtaBins" , [ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999]) # eta bins (10) for eta-dep cuts on TRT conversion tracks
flags.addFlag("TrkSel.TRTTrksBinnedRatioTRT" , [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) # eta-dep e-prob cut for TRT conversion tracks
flags.addFlag("TrkSel.IsConversion" , False)
flags.addFlag("TrkSel.significanceD0_Si" , 2.)
flags.addFlag("TrkSel.RatioV0" , 0.95)
# Track pairs selector
flags.addFlag("TrkPairSel.MaxFirstHitRadius" , 510.)
flags.addFlag("TrkPairSel.MaxDistBetweenTracks" , [4.,90.,30.])
flags.addFlag("TrkPairSel.MaxEta" , [1.2,0.9,0.4])
flags.addFlag("TrkPairSel.MaxInitDistance" , [100000.,640.,80.])
flags.addFlag("TrkPairSel.MinTrackAngle" , 0.6)
# Vertex point estimator
flags.addFlag("VtxPt.MinDeltaR" , [-10000.,-10000.,-10000.])
flags.addFlag("VtxPt.MaxDeltaR" , [10000.,10000.,10000.])
flags.addFlag("VtxPt.MaxPhi" , [10000., 10000., 10000.])
# Secondary Vertex post selector
flags.addFlag("SecVtxPost.MaxChi2Vtx" , [15.,50.,25.])
flags.addFlag("SecVtxPost.MaxInvariantMass" , [10000.,50.,25.])
flags.addFlag("SecVtxPost.MinFitMomentum" , [1100.,2000.,2000.])
flags.addFlag("SecVtxPost.MinRadius" , [0.,35.,350.] )
flags.addFlag("SecVtxPost.MinPt" , 0.0) # off
flags.addFlag("SecVtxPost.MaxdR" , -10000.) # off
flags.addFlag("SecVtxPost.MaxPhiVtxTrk" , 10000.)
# Single track secondary vertex tool
flags.addFlag("SingleTrk.MaxBLayerHits" , 0)
flags.addFlag("SingleTrk.MinInitialHitRadius" , 0.0)
flags.addFlag("SingleTrk.MinInitialHitRadius_noBlay" , 0.0)
flags.addFlag("SingleTrk.MinRatioOfHLhits" , 0.0) # e-prob cut for 1TRT and 1Si converisons
# InDetSecVtxFinderTool
flags.addFlag("Finder.RemoveTrtTracks" , True)
flags.addFlag("Finder.IsConversion" , False)
flags.addFlag("Finder.MinDistVtxHit" , -200.)
flags.addFlag("Finder.MaxDistVtxHit" , 50.)
flags.addFlag("Finder.MinFlightAngle" , -0.5)
flags.addFlag("Finder.MinInitVtxR" , 5.)
return flags
def createEGammaPileUpSecVertexingFlags():
flags = createSecVertexingFlags()
#InDetSecVxFitterTool
flags.Fitter.IterationNumber = 30 # huge number of iterations ?
flags.Fitter.MakeExtendedVertex = True
flags.Fitter.FirstMeasuredPoint = True
flags.Fitter.Robustness = 6
flags.Fitter.InputParticleMasses = [0.511,0.511]
flags.Fitter.VertexForConstraint = [0.,0.,0.]
flags.Fitter.CovVrtForConstraint = [0.015*0.015,0.,0.015*0.015,0.,0.,10000.*10000.]
flags.Fitter.FirstMeasuredPointLimit = True
flags.Fitter.usePhiCnst = True
flags.Fitter.useThetaCnst = True
# Track selector tool
flags.TrkSel.maxSiD0 = 10000. # off ?
flags.TrkSel.maxTrtD0 = 10000. # off ?
flags.TrkSel.maxSiZ0 = 10000. # off ?
flags.TrkSel.maxTrtZ0 = 10000. # off ?
flags.TrkSel.RatioCut1 = 0.0 # e-prob for Si conversion tracks (affects 1Si, 2Si, SiTRT): Ntrt < 15
flags.TrkSel.RatioCut2 = 0.0 # e-prob for Si conversion tracks (affects 1Si, 2Si, SiTRT): 15 < Ntrt < 25
flags.TrkSel.RatioCut3 = 0.0 # e-prob for Si conversion tracks (affects 1Si, 2Si, SiTRT): Ntrt > 25
flags.TrkSel.RatioTRT = 0.0 # e-prob cut for TRT conversion tracks (affects 1TRT, 2TRT, SiTRT) (see also below)
flags.TrkSel.TRTTrksEtaBins = [ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999] # eta bins (10) for eta-dep cuts on TRT conversion tracks
flags.TrkSel.TRTTrksBinnedRatioTRT = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # eta-dep e-prob cut for TRT conversion tracks
flags.TrkSel.IsConversion = True
flags.TrkSel.significanceD0_Si = -1. # V0 only cuts
flags.TrkSel.RatioV0 = -1. # V0 only cuts
# Track pairs selector
flags.TrkPairSel.MaxFirstHitRadius = 500. # hacky way to determine if TRT only of SI
flags.TrkPairSel.MaxDistBetweenTracks = [10.,50.,50.] # minimum distance cut at vertex
flags.TrkPairSel.MaxEta = [0.3,0.5,0.5] # delta cotan(theta) cuts, no cut in barrel for TRT only in code
flags.TrkPairSel.MaxInitDistance = [10000.0, 10000.0, 10000.0] # off
flags.TrkPairSel.MinTrackAngle = 0.0 # off, V0 cut
# Vertex point estimator
flags.VtxPt.MinDeltaR = [-5.,-25.,-50.] # D-R1-R2 min cut
flags.VtxPt.MaxDeltaR = [5.,10.,10.] # D-R1-R2 max cut
flags.VtxPt.MaxPhi = [0.05, 0.5, 0.5] # dphi cut at vertex
# Secondary Vertex post selector
flags.SecVtxPost.MaxChi2Vtx = [50.,50.,50.] # was [40.,100.,80.]
flags.SecVtxPost.MaxInvariantMass = [10000.,10000.,10000.] # off, was [60.,60.,30.]
flags.SecVtxPost.MinFitMomentum = [0.,0.,0.] # off, was [2000.,2000.,2000.]
flags.SecVtxPost.MinRadius = [-10000.0, -10000.0, -10000.0] # off
flags.SecVtxPost.MinPt = 0. # off
flags.SecVtxPost.MaxdR = -10000. # off, -250.
flags.SecVtxPost.MaxPhiVtxTrk = 10000. # off, was 0.2
# Single track secondary vertex tool
flags.SingleTrk.MaxBLayerHits = 0
flags.SingleTrk.MinInitialHitRadius = 70.
flags.SingleTrk.MinInitialHitRadius_noBlay = 70.
flags.SingleTrk.MinRatioOfHLhits = 0.95 # e-prob cut for 1TRT and 1Si converisons
# InDetSecVtxFinderTool
flags.Finder.RemoveTrtTracks = False
flags.Finder.IsConversion = True
flags.Finder.MinDistVtxHit = -350.0 # off
flags.Finder.MaxDistVtxHit = 250.0 # off
flags.Finder.MinFlightAngle = 0.0 # off
flags.Finder.MinInitVtxR = 0.0 # off
return flags
# TODO add more variants
\ No newline at end of file
......@@ -61,6 +61,11 @@ def RecoSteering(flags):
acc.merge(egammaSelectedTrackCopyCfg(flags))
from egammaAlgs.EMBremCollectionBuilderConfig import EMBremCollectionBuilderCfg
acc.merge(EMBremCollectionBuilderCfg(flags))
from egammaAlgs.EMGSFCaloExtensionBuilderConfig import EMGSFCaloExtensionBuilderCfg
acc.merge(EMGSFCaloExtensionBuilderCfg(flags))
from egammaAlgs.EMVertexBuilderConfig import EMVertexBuilderCfg
acc.merge(EMVertexBuilderCfg(flags))
# TBC
# from egammaAlgs.egammaRecBuilderConfig import egammaRecBuilderCfg
......@@ -143,11 +148,16 @@ def _run(input):
log.info("configured in %d seconds", (confStamp-startStamp).seconds )
acc.printConfig(withDetails=True)
confFileName=f"recoConfig{input}.pkl"
if args.configOnly:
confFileName=args.configOnly
with open(confFileName, "wb") as confFile:
acc.store(confFile)
log.info("configOnly option specified. Saved in: %s ... exiting now.", args.configOnly )
if args.configOnly:
with open(args.configOnly, "wb") as confFile:
acc.store(confFile)
log.info("configOnly option specified. Saved in: %s ... exiting now.", args.configOnly )
sys.exit(0)
sys.exit(0)
# running
statusCode = acc.run()
endStamp = datetime.datetime.now()
......
......@@ -17,3 +17,7 @@ atlas_add_component( egammaAlgs
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
atlas_add_test( EMVertexBuilderConfig_test
SCRIPT python -m egammaAlgs.EMVertexBuilderConfig
POST_EXEC_SCRIPT nopost.sh)
\ No newline at end of file
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
def EMVertexBuilderCfg(flags, name="EMVertexBuilder", **kwargs):
acc = ComponentAccumulator()
if "ExtrapolationTool" not in kwargs:
from egammaTrackTools.egammaTrackToolsConfig import EMExtrapolationToolsCfg
kwargs["ExtrapolationTool"] = acc.popToolsAndMerge(EMExtrapolationToolsCfg(flags))
if "VertexFinderTool" not in kwargs:
vtxFlags = flags.cloneAndReplace("InDet.SecVertex", "InDet.SecVertexEGammaPileUp" )
from InDetConfig.VertexFindingConfig import ConversionFinderCfg
kwargs["VertexFinderTool"] = acc.popToolsAndMerge( ConversionFinderCfg(vtxFlags) )
alg = CompFactory.EMVertexBuilder(name, **kwargs)
acc.addEventAlgo(alg)
return acc
if __name__ == "__main__":
from AthenaCommon.Configurable import Configurable
Configurable.configurableRun3Behavior=1
from AthenaConfiguration.AllConfigFlags import ConfigFlags as flags
from AthenaConfiguration.TestDefaults import defaultTestFiles
from AthenaConfiguration.MainServicesConfig import MainServicesCfg
flags.Input.Files = defaultTestFiles.RAW
acc = MainServicesCfg(flags)
acc.merge(EMVertexBuilderCfg(flags))
with open("vertexbuilder.pkl", "wb") as f:
acc.store(f)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment