ATLAS Offline Software
TrigElectronFactoriesCfg.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 __doc__ = "ToolFactories to configure egammaAlgs to be used at the HLT"
6 
7 """
8 This file defines the factories of the algorithms to be used in an electron trigger sequence in athenaMT
9 These are inspired by the offline factories, alhtough modified so they reflect the configuration we need for these algorithms at the HLT.
10 Offline configurations are available here:
11  https://gitlab.cern.ch/atlas/athena/blob/master/Reconstruction/egamma/egammaAlgs/python/
12 
13 
14 """
15 
16 from AthenaConfiguration.ComponentFactory import CompFactory
17 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
18 from AthenaConfiguration.Enums import BeamType
19 
20 def TrigEMTrackMatchBuilderToolCfg(flags,tag,trackparticles):
21  acc = ComponentAccumulator()
22  name='TrigEMTrackMatchBuilder'+tag
23  from egammaTrackTools.egammaTrackToolsConfig import EMExtrapolationToolsCfg
24  emExtrapolatorTools = acc.popToolsAndMerge(EMExtrapolationToolsCfg(flags))
25  builderTool = CompFactory.EMTrackMatchBuilder( name, #TODO, this is provate tool, it does not need to be specifically named
26  TrackParticlesName = trackparticles,
27  ExtrapolationTool = emExtrapolatorTools,
28  broadDeltaEta = 0.1, #candidate match is done in 2 times this so +- 0.2
29  broadDeltaPhi = 0.15, #candidate match is done in 2 times this so +- 0.3
30  useCandidateMatch = True,
31  useScoring = True,
32  SecondPassRescale = True,
33  UseRescaleMetric = True,
34  isCosmics = flags.Beam.Type is BeamType.Cosmics)
35  acc.setPrivateTools(builderTool)
36  return acc
37 
38 
39 def TrigEgammaRecElectronCfg(flags, tag, trackparticles, calocluster, egammaRecContainer):
40  acc = ComponentAccumulator()
41  name = 'TrigEgammaRecElectron'+tag
42  electronRec = CompFactory.egammaRecBuilder( name,
43  InputClusterContainerName= calocluster,
44  egammaRecContainer= egammaRecContainer,
45  doConversions = False,
46  TrackMatchBuilderTool = acc.popToolsAndMerge(TrigEMTrackMatchBuilderToolCfg(flags, tag, trackparticles)) )
47  acc.addEventAlgo(electronRec)
48  return acc
49 
50 
51 def TrigElectronSuperClusterBuilderCfg(flags, tag, InputEgammaRecContainerName, SuperElectronRecCollectionName,trackparticles):
52  acc = ComponentAccumulator()
53  from egammaTools.egammaSwToolConfig import egammaSwToolCfg
54  from egammaMVACalib.egammaMVACalibConfig import egammaMVASvcCfg
55  superClusterBuilder = CompFactory.electronSuperClusterBuilder( 'TrigElectronSuperClusterBuilder'+tag,
56  InputEgammaRecContainerName = InputEgammaRecContainerName,
57  OutputEgammaRecContainerKey = SuperElectronRecCollectionName,
58  ClusterCorrectionTool = acc.popToolsAndMerge(egammaSwToolCfg(flags)),
59  MVACalibSvc = acc.getPrimaryAndMerge(egammaMVASvcCfg(flags)),
60  EtThresholdCut = 1000,
61  TrackMatchBuilderTool = acc.popToolsAndMerge(TrigEMTrackMatchBuilderToolCfg(flags, tag, trackparticles)),
62  LinkToConstituents = False)
63  acc.addEventAlgo(superClusterBuilder)
64  return acc
65 
66 
67 
68 def TrigEMClusterToolCfg(flags,variant,OutputClusterContainerName):
69  acc = ComponentAccumulator()
70  from egammaMVACalib.egammaMVACalibConfig import egammaMVASvcCfg
71  tool = CompFactory.EMClusterTool('TrigEMClusterTool_electron'+variant,
72  OutputClusterContainerName = OutputClusterContainerName,
73  MVACalibSvc = acc.getPrimaryAndMerge(egammaMVASvcCfg(flags))
74  )
75  acc.setPrivateTools(tool)
76  return acc
77 
78 
79 def TrigTopoEgammaElectronCfg(flags, tag, variant, cellsName, InputElectronRecCollectionName, InputPhotonRecCollectionName, ElectronOutputName, PhotonOutputName, OutputClusterContainerName):
80  acc = ComponentAccumulator()
81  from egammaTools.EMShowerBuilderConfig import EMShowerBuilderCfg
82  builder = CompFactory.xAODEgammaBuilder(name='topoEgammaBuilder_TrigElectrons'+tag,
83  InputElectronRecCollectionName = InputElectronRecCollectionName,
84  InputPhotonRecCollectionName = InputPhotonRecCollectionName,
85  ElectronOutputName = ElectronOutputName,
86  PhotonOutputName = PhotonOutputName,
87  DummyElectronOutputName = "HLT_PrecisionDummyElectron",
88  AmbiguityTool = CompFactory.EGammaAmbiguityTool(),
89  EMClusterTool = acc.popToolsAndMerge(TrigEMClusterToolCfg(flags,variant,OutputClusterContainerName)),
90  EMShowerTool = acc.popToolsAndMerge(EMShowerBuilderCfg(flags, CellsName=cellsName)),
91  doPhotons = False,
92  doElectrons = True)
93  acc.addEventAlgo(builder)
94  return acc
95 
96 
97 def TrigTrackIsolationToolCfg(flags,tag,trackParticleLocation):
98  acc = ComponentAccumulator()
99 
100  tpicTool = CompFactory.xAOD.TrackParticlesInConeTool(TrackParticleLocation = trackParticleLocation)
101 
102  tiTool = CompFactory.xAOD.TrackIsolationTool(name='TrigTrackIsolationTool'+tag,
103  TrackParticleLocation = trackParticleLocation,
104  VertexLocation = '',
105  TracksInConeTool = tpicTool)
106  # configure default TrackSelectionTool
107  tiTool.TrackSelectionTool.maxZ0SinTheta = 3
108  tiTool.TrackSelectionTool.minPt = 1000
109  tiTool.TrackSelectionTool.CutLevel = "Loose"
110 
111  acc.setPrivateTools(tiTool)
112  return acc
113 
114 
115 def TrigElectronIsoBuilderCfg(flags, tag, TrackParticleLocation, electronCollectionContainerName, useBremAssoc):
116  acc = ComponentAccumulator()
117  from xAODPrimitives.xAODIso import xAODIso as isoPar
118  builder = CompFactory.IsolationBuilder(
119  name = 'TrigElectronIsolationBuilder'+tag,
120  ElectronCollectionContainerName = electronCollectionContainerName,
121  CaloCellIsolationTool = None,
122  CaloTopoIsolationTool = None,
123  PFlowIsolationTool = None,
124  useBremAssoc = useBremAssoc,
125  TrackIsolationTool = acc.popToolsAndMerge(TrigTrackIsolationToolCfg(flags,tag,TrackParticleLocation)),
126  ElIsoTypes = [[isoPar.ptcone30,isoPar.ptcone20]],
127  ElCorTypes = [[isoPar.coreTrackPtr]],
128  ElCorTypesExtra = [[]],
129  IsTrigger = True)
130  acc.addEventAlgo(builder)
131  return acc
132 
133 def PrecisionElectronTopoMonitorCfg(flags, tag, electronKey, isoVarKeys):
134  acc = ComponentAccumulator()
135  name = 'PrecisionElectronTopoMonitoring'+tag
136  from TrigEgammaMonitoring.egammaMonitorPrecisionConfig import egammaMonitorPrecisionCfg
137  monTool = egammaMonitorPrecisionCfg(flags, name)
138  PrecisionElectronTopoMonitor = CompFactory.egammaMonitorElectronAlgorithm(
139  name = name,
140  ElectronKey = electronKey,
141  IsoVarKeys = isoVarKeys,
142  MonTool = monTool)
143  acc.addEventAlgo(PrecisionElectronTopoMonitor)
144  return acc
145 
146 def PrecisionElectronSuperClusterMonitorCfg(flags, tag, inputEgammaRecContainerName):
147  acc = ComponentAccumulator()
148  name = 'PrecisionElectronSuperClusterMonitoring'+tag
149  from TrigEgammaMonitoring.egammaMonitorPrecisionConfig import egammaMonitorSuperClusterCfg
150  monTool = egammaMonitorSuperClusterCfg(flags, name)
151  PrecisionElectronSuperClusterMonitor = CompFactory.egammaMonitorSuperClusterAlgorithm(
152  name = name,
153  InputEgammaRecContainerName = inputEgammaRecContainerName,
154  MonTool = monTool)
155  acc.addEventAlgo(PrecisionElectronSuperClusterMonitor)
156  return acc
157 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.HLT.Electron.TrigElectronFactoriesCfg.TrigTrackIsolationToolCfg
def TrigTrackIsolationToolCfg(flags, tag, trackParticleLocation)
Definition: TrigElectronFactoriesCfg.py:97
python.HLT.Electron.TrigElectronFactoriesCfg.TrigElectronIsoBuilderCfg
def TrigElectronIsoBuilderCfg(flags, tag, TrackParticleLocation, electronCollectionContainerName, useBremAssoc)
Definition: TrigElectronFactoriesCfg.py:115
egammaSwToolConfig.egammaSwToolCfg
def egammaSwToolCfg(flags, name='egammaSwTool', **kwargs)
Definition: egammaSwToolConfig.py:42
python.egammaMonitorPrecisionConfig.egammaMonitorSuperClusterCfg
def egammaMonitorSuperClusterCfg(flags, name)
Definition: egammaMonitorPrecisionConfig.py:81
python.HLT.Electron.TrigElectronFactoriesCfg.TrigTopoEgammaElectronCfg
def TrigTopoEgammaElectronCfg(flags, tag, variant, cellsName, InputElectronRecCollectionName, InputPhotonRecCollectionName, ElectronOutputName, PhotonOutputName, OutputClusterContainerName)
Definition: TrigElectronFactoriesCfg.py:79
python.HLT.Electron.TrigElectronFactoriesCfg.TrigEgammaRecElectronCfg
def TrigEgammaRecElectronCfg(flags, tag, trackparticles, calocluster, egammaRecContainer)
Definition: TrigElectronFactoriesCfg.py:39
python.egammaMVACalibConfig.egammaMVASvcCfg
def egammaMVASvcCfg(flags, name="egammaMVASvc", **kwargs)
Definition: egammaMVACalibConfig.py:15
EMShowerBuilderConfig.EMShowerBuilderCfg
def EMShowerBuilderCfg(flags, name='EMShowerBuilder', **kwargs)
Definition: EMShowerBuilderConfig.py:12
python.HLT.Electron.TrigElectronFactoriesCfg.PrecisionElectronSuperClusterMonitorCfg
def PrecisionElectronSuperClusterMonitorCfg(flags, tag, inputEgammaRecContainerName)
Definition: TrigElectronFactoriesCfg.py:146
egammaTrackToolsConfig.EMExtrapolationToolsCfg
def EMExtrapolationToolsCfg(flags, **kwargs)
Definition: egammaTrackToolsConfig.py:13
python.HLT.Electron.TrigElectronFactoriesCfg.TrigEMClusterToolCfg
def TrigEMClusterToolCfg(flags, variant, OutputClusterContainerName)
Definition: TrigElectronFactoriesCfg.py:68
python.egammaMonitorPrecisionConfig.egammaMonitorPrecisionCfg
def egammaMonitorPrecisionCfg(flags, name)
Definition: egammaMonitorPrecisionConfig.py:9
python.HLT.Electron.TrigElectronFactoriesCfg.TrigEMTrackMatchBuilderToolCfg
def TrigEMTrackMatchBuilderToolCfg(flags, tag, trackparticles)
Definition: TrigElectronFactoriesCfg.py:20
python.HLT.Electron.TrigElectronFactoriesCfg.PrecisionElectronTopoMonitorCfg
def PrecisionElectronTopoMonitorCfg(flags, tag, electronKey, isoVarKeys)
Definition: TrigElectronFactoriesCfg.py:133
python.HLT.Electron.TrigElectronFactoriesCfg.TrigElectronSuperClusterBuilderCfg
def TrigElectronSuperClusterBuilderCfg(flags, tag, InputEgammaRecContainerName, SuperElectronRecCollectionName, trackparticles)
Definition: TrigElectronFactoriesCfg.py:51