ATLAS Offline Software
TrigTauRecConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 def trigTauRecMergedPrecisionMVACfg(flags, name='', inputRoIs='', tracks=''):
4 
5  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6  from AthenaConfiguration.ComponentFactory import CompFactory
7  from TrigEDMConfig.TriggerEDM import recordable
9 
10  doLLP = False
11  postfix = ''
12 
13  if "MVA" in name:
14  postfix = "MVA"
15  trigTauJetOutputContainer = recordable("HLT_TrigTauRecMerged_MVA")
16  trigTauTrackOutputContainer = recordable("HLT_tautrack_MVA")
17  elif "LLP" in name:
18  postfix = "LLP"
19  trigTauJetOutputContainer = recordable("HLT_TrigTauRecMerged_LLP")
20  trigTauTrackOutputContainer = recordable("HLT_tautrack_LLP")
21  doLLP = True
22  elif "LRT" in name:
23  postfix = "LRT"
24  trigTauJetOutputContainer = recordable("HLT_TrigTauRecMerged_LRT")
25  trigTauTrackOutputContainer = recordable("HLT_tautrack_LRT")
26  doLLP = True
27  else:
28  raise Exception( "algTauPrecision : called with incorrect non existent name: "+name )
29  return None
30 
31  # prepare tools
32  tools = []
33  vftools = []
34  tftools = []
35  vvtools = []
36  idtools = []
37 
38 
39  from TrigTauRec.TrigTauToolsConfig import (trigTauVertexFinderCfg, trigTauTrackFinderCfg, tauVertexVariablesCfg, trigTauJetRNNEvaluatorCfg, trigTauWPDecoratorJetRNNCfg)
40 
41  # Associate RoI vertex or Beamspot to tau - don't use TJVA
42  vftools.append(acc.popToolsAndMerge(trigTauVertexFinderCfg(flags,name='TrigTau_TauVertexFinder')))
43 
44  # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
45  tools.append(CompFactory.TauAxisSetter(name='TrigTau_TauAxis',VertexCorrection = False))
46 
47  # tightened to 0.75 mm for tracktwoMVA (until the track BDT can be used)
48  tftools.append(acc.popToolsAndMerge(trigTauTrackFinderCfg(flags,name='TrigTauTightDZ_TauTrackFinder',TrackParticlesContainer=tracks)))
49 
50  # Decorate the clusters
51  tools.append(CompFactory.TauClusterFinder(name='TrigTau_TauClusterFinder',UseOriginalCluster = False))
52  tools.append(CompFactory.TauVertexedClusterDecorator(name='TrigTau_TauVertexedClusterDecorator',SeedJet = ''))
53 
54  # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
55  tools.append(CompFactory.TauCellVariables(name='TrigTau_CellVariables',VertexCorrection = False))
56 
57  # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt()
58  tools.append(CompFactory.MvaTESVariableDecorator(name='TrigTau_MvaTESVariableDecorator',
59  Key_vertexInputContainer='',
60  EventShapeKey='',
61  VertexCorrection = False))
62  acc.addPublicTool(tools[-1])
63  tools.append(CompFactory.MvaTESEvaluator(name='TrigTau_MvaTESEvaluator',
64  WeightFileName = flags.Trigger.Offline.Tau.MvaTESConfig))
65  acc.addPublicTool(tools[-1])
66 
67  vvtools.append(acc.popToolsAndMerge(tauVertexVariablesCfg(flags,name='TrigTau_TauVertexVariables')))
68 
69  # Variables combining tracking and calorimeter information
70  idtools.append(CompFactory.TauCommonCalcVars(name='TrigTau_TauCommonCalcVars'))
71 
72  # Cluster-based sub-structure, with dRMax also
73  idtools.append(CompFactory.TauSubstructureVariables(name='TrigTau_TauSubstructure',VertexCorrection = False))
74 
75  # RNN tau ID, either nominal or LLP
76  idtools.append(acc.popToolsAndMerge(trigTauJetRNNEvaluatorCfg(flags,name="TrigTau_TauJetRNNEvaluator",LLP=doLLP)))
77  acc.addPublicTool(idtools[-1])
78 
79  # flattened RNN score and WP
80  idtools.append(acc.popToolsAndMerge(trigTauWPDecoratorJetRNNCfg(flags,name="TrigTau_TauWPDecoratorJetRNN",LLP=doLLP)))
81  acc.addPublicTool(idtools[-1])
82 
83  for tool in (tools + vftools + tftools + vvtools + idtools):
84  tool.inTrigger = True
85  tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
86 
87  from TrigTauRec.TrigTauRecMonitoring import tauMonitoringPrecisionMVA
88 
89  alg = CompFactory.TrigTauRecMerged("TrigTauRecMerged_TauPrecision_Precision"+postfix,
90  ComTools = tools,
91  VFTools = vftools,
92  TFTools = tftools,
93  VVTools = vvtools,
94  IDTools = idtools,
95  MonTool = tauMonitoringPrecisionMVA(flags),
96  Key_trigTauTrackInputContainer = "HLT_tautrack_dummy",
97  Key_trigTauJetInputContainer = "HLT_TrigTauRecMerged_CaloMVAOnly",
98  Key_trigJetSeedOutputKey = recordable("HLT_jet_seed"),
99  RoIInputKey = inputRoIs,
100  clustersKey = "",
101  Key_vertexInputContainer = flags.Tracking.ActiveConfig.vertex,
102  Key_trackPartInputContainer = tracks,
103  Key_trigTauJetOutputContainer = trigTauJetOutputContainer,
104  Key_trigTauTrackOutputContainer = trigTauTrackOutputContainer
105  )
106 
107  acc.addEventAlgo(alg)
108 
109  return acc
110 
111 
113  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
114  from AthenaConfiguration.ComponentFactory import CompFactory
115  acc = ComponentAccumulator()
116  # prepare tools
117  tools = []
118  # Set seedcalo energy scale (Full RoI)
119  tools.append(CompFactory.JetSeedBuilder())
120 
121  # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
122  tools.append(CompFactory.TauAxisSetter(ClusterCone = 0.2,
123  VertexCorrection = False))
124  # Decorate the clusters
125  tools.append(CompFactory.TauClusterFinder(UseOriginalCluster = False)) # TODO use JetRec.doVertexCorrection once available
126 
127  tools.append(CompFactory.TauVertexedClusterDecorator(SeedJet = ''))
128 
129  # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
130  from AthenaCommon.SystemOfUnits import GeV
131  tools.append(CompFactory.TauCellVariables(StripEthreshold = 0.2*GeV,
132  CellCone = 0.2,
133  VertexCorrection = False))
134  # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt()
135  tools.append(CompFactory.MvaTESVariableDecorator(Key_vertexInputContainer='',
136  EventShapeKey='',
137  VertexCorrection = False))
138  acc.addPublicTool(tools[-1])
139  tools.append(CompFactory.MvaTESEvaluator(WeightFileName = flags.Trigger.Offline.Tau.MvaTESConfig))
140  acc.addPublicTool(tools[-1])
141 
142  for tool in tools:
143  tool.inTrigger = True
144  tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
145 
146  from TrigTauRec.TrigTauRecMonitoring import tauMonitoringCaloOnlyMVA
147 
148  alg = CompFactory.TrigTauRecMerged("TrigTauRecMerged_TauCaloOnlyMVA",
149  ComTools = tools,
150  MonTool = tauMonitoringCaloOnlyMVA(flags),
151  Key_trackPartInputContainer = '',
152  Key_trigJetSeedOutputKey = 'HLT_jet_seed',
153  Key_trigTauJetInputContainer = '',
154  Key_trigTauJetOutputContainer = 'HLT_TrigTauRecMerged_CaloMVAOnly',
155  Key_trigTauTrackInputContainer = '',
156  Key_trigTauTrackOutputContainer = 'HLT_tautrack_dummy',
157  Key_vertexInputContainer = '',
158  clustersKey = 'HLT_TopoCaloClustersLC',
159  RoIInputKey = 'UpdatedCaloRoI')
160  acc.addEventAlgo(alg)
161 
162  return acc
163 
164 
165 if __name__ == "__main__":
166  from AthenaConfiguration.AllConfigFlags import initConfigFlags
167  from AthenaConfiguration.TestDefaults import defaultTestFiles
168  flags = initConfigFlags()
169  flags.Input.Files = defaultTestFiles.RAW_RUN2
170  flags.lock()
171 
173  acc.printConfig(withDetails=True, summariseProps=True)
174  acc.wasMerged() # do not run, do not save, we just want to see the config
SystemOfUnits
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TrigTauToolsConfig.trigTauJetRNNEvaluatorCfg
def trigTauJetRNNEvaluatorCfg(flags, name='', LLP=False)
Definition: TrigTauToolsConfig.py:124
TrigTauToolsConfig.trigTauWPDecoratorJetRNNCfg
def trigTauWPDecoratorJetRNNCfg(flags, name='', LLP=False)
Definition: TrigTauToolsConfig.py:155
TrigTauToolsConfig.trigTauTrackFinderCfg
def trigTauTrackFinderCfg(flags, name='', TrackParticlesContainer='')
Definition: TrigTauToolsConfig.py:25
TrigTauToolsConfig.tauVertexVariablesCfg
def tauVertexVariablesCfg(flags, name='')
Definition: TrigTauToolsConfig.py:87
TrigTauRecConfig.trigTauRecMergedPrecisionMVACfg
def trigTauRecMergedPrecisionMVACfg(flags, name='', inputRoIs='', tracks='')
Definition: TrigTauRecConfig.py:3
TrigTauRecMonitoring.tauMonitoringCaloOnlyMVA
def tauMonitoringCaloOnlyMVA(flags)
Definition: TrigTauRecMonitoring.py:5
TrigTauToolsConfig.trigTauVertexFinderCfg
def trigTauVertexFinderCfg(flags, name='')
Definition: TrigTauToolsConfig.py:7
TrigTauRecMonitoring.tauMonitoringPrecisionMVA
def tauMonitoringPrecisionMVA(flags)
Definition: TrigTauRecMonitoring.py:64
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.TriggerEDM.recordable
def recordable(arg, runVersion=3)
Definition: TriggerEDM.py:30
TrigTauRecConfig.trigTauRecMergedCaloOnlyMVACfg
def trigTauRecMergedCaloOnlyMVACfg(flags)
Definition: TrigTauRecConfig.py:112