ATLAS Offline Software
JETM7.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 #!/usr/bin/env python
3 #====================================================================
4 # DAOD_JETM7.py
5 #====================================================================
6 # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DerivationFramework
7 
8 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory import CompFactory
10 from AthenaConfiguration.Enums import MetadataCategory
11 
12 # Main algorithm config
14  """Configure the skimming tool"""
15  acc = ComponentAccumulator()
16 
17 
18  jetSelection = '(count(AntiKt4EMPFlowJets.pt > 10.*GeV && abs(AntiKt4EMPFlowJets.eta) < 2.5) >= 1)'
19  JETM7OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(name = "JETM7OfflineSkimmingTool1",
20  expression = jetSelection)
21 
22  acc.addPublicTool(JETM7OfflineSkimmingTool, primary=True)
23 
24  return(acc)
25 
26 # Main algorithm config
27 def JETM7KernelCfg(flags, name='JETM7Kernel', **kwargs):
28  """Configure the derivation framework driving algorithm (kernel) for JETM7"""
29  acc = ComponentAccumulator()
30 
31  # Skimming
32  if not flags.Input.isMC:
33  skimmingTool = acc.getPrimaryAndMerge(JETM7SkimmingToolCfg(flags))
34 
35  # Common augmentations
36  from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
37  acc.merge(PhysCommonAugmentationsCfg(flags, TriggerListsHelper = kwargs['TriggerListsHelper']))
38 
39  from DerivationFrameworkInDet.InDetToolsConfig import InDetTrackSelectionToolWrapperCfg
40  DFCommonTrackSelection = acc.getPrimaryAndMerge(InDetTrackSelectionToolWrapperCfg(
41  flags,
42  name = "DFJETM7CommonTrackSelectionLoose",
43  CutLevel = "Loose",
44  DecorationName = "DFJETM7Loose"))
45 
46  acc.addEventAlgo(CompFactory.DerivationFramework.CommonAugmentation("JETM7CommonKernel", AugmentationTools = [DFCommonTrackSelection]))
47 
48  # Thinning tools...
49  from DerivationFrameworkInDet.InDetToolsConfig import MuonTrackParticleThinningCfg, EgammaTrackParticleThinningCfg, JetTrackParticleThinningCfg
50  # from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import GenericTruthThinningCfg
51  from DerivationFrameworkTools.DerivationFrameworkToolsConfig import GenericObjectThinningCfg
52 
53  muonSelectionString = "(Muons.pt > 5*GeV)"
54  electronSelectionString = "(Electrons.pt > 5*GeV)"
55  photonSelectionString = "(Photons.pt > 5*GeV)"
56  jetSelectionString = "(AntiKt4EMPFlowByVertexJets.pt > 7.*GeV && AntiKt4EMPFlowByVertexJets.Jvt > 0.4)"
57 
58  # Include inner detector tracks associated with muons
59  JETM7MuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(flags,
60  name = "JETM7MuonTPThinningTool",
61  StreamName = kwargs['StreamName'],
62  MuonKey = "Muons",
63  SelectionString = muonSelectionString,
64  InDetTrackParticlesKey = "InDetTrackParticles"))
65 
66  # Include inner detector tracks associated with electrons
67  JETM7ElectronTPThinningTool = acc.getPrimaryAndMerge(EgammaTrackParticleThinningCfg(flags,
68  name = "JETM7ElectronTPThinningTool",
69  StreamName = kwargs['StreamName'],
70  SGKey = "Electrons",
71  SelectionString = electronSelectionString,
72  InDetTrackParticlesKey = "InDetTrackParticles"))
73 
74  # Include inner detector tracks associated with by-vertex jets
75  JETM7Akt4JetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(flags,
76  name = "JETM7Akt4JetTPThinningTool",
77  StreamName = kwargs['StreamName'],
78  JetKey = "AntiKt4EMPFlowByVertexJets",
79  SelectionString = jetSelectionString,
80  InDetTrackParticlesKey = "InDetTrackParticles"))
81 
82 
83  # Store EMPFlowByVertexJets with JVT > 0.4. This will result in jets extending up to about 2.6 in |eta|
84  JETM7Akt4PFlowByVertexJetThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(flags,
85  name = "JETM7Akt4PFlowByVertexJetThinningTool",
86  ContainerName = "AntiKt4EMPFlowByVertexJets",
87  StreamName = kwargs['StreamName'],
88  SelectionString = jetSelectionString))
89 
90  # Store regular EMPFlowJets for |eta| > 2.4 to retain forward jets with a PV0 interpretation
91  JETM7Akt4PFlowJetThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(flags,
92  name = "JETM7Akt4PFlowJetThinningTool",
93  ContainerName = "AntiKt4EMPFlowJets",
94  StreamName = kwargs['StreamName'],
95  SelectionString = "(abs(AntiKt4EMPFlowJets.eta) > 2.4)"))
96 
97 
98  JETM7MuonThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(flags,
99  name = "JETM7MuonThinningTool",
100  ContainerName = "Muons",
101  StreamName = kwargs['StreamName'],
102  SelectionString = muonSelectionString))
103 
104 
105  JETM7ElectronThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(flags,
106  name = "JETM7ElectronThinningTool",
107  ContainerName = "Electrons",
108  StreamName = kwargs['StreamName'],
109  SelectionString = electronSelectionString))
110 
111 
112  JETM7PhotonThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(flags,
113  name = "JETM7PhotonThinningTool",
114  ContainerName = "Photons",
115  StreamName = kwargs['StreamName'],
116  SelectionString = photonSelectionString))
117 
118 
119  # Extra jet content:
120  acc.merge(JETM7ExtraContentCfg(flags))
121 
122  # Finally the kernel itself
123  thinningTools = [JETM7MuonTPThinningTool,
124  JETM7ElectronTPThinningTool,
125  JETM7Akt4JetTPThinningTool,
126  JETM7Akt4PFlowByVertexJetThinningTool,
127  JETM7Akt4PFlowJetThinningTool,
128  JETM7MuonThinningTool,
129  JETM7ElectronThinningTool,
130  JETM7PhotonThinningTool,
131  ]
132 
133  DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
134  acc.addEventAlgo(DerivationKernel(name,
135  ThinningTools = thinningTools,
136  SkimmingTools =[skimmingTool] if not flags.Input.isMC else []))
137 
138 
139  return acc
140 
142 
143  acc = ComponentAccumulator()
144 
145  from JetRecConfig.JetRecConfig import JetRecCfg
146  from JetRecConfig.StandardSmallRJets import AntiKt4PV0Track, AntiKt4EMPFlowByVertex
147 
148  #=======================================
149  # R = 0.4 track-jets (needed for Rtrk)
150  #=======================================
151  jetList = [AntiKt4PV0Track]
152 
153  #=======================================
154  # R = 0.4 by-vertex jets
155  #=======================================
156  jetList += [AntiKt4EMPFlowByVertex]
157 
158 
159  for jd in jetList:
160  acc.merge(JetRecCfg(flags,jd))
161 
162  #=======================================
163  # More detailed truth information
164  #=======================================
165 
166  if flags.Input.isMC:
167  from DerivationFrameworkMCTruth.MCTruthCommonConfig import AddTopQuarkAndDownstreamParticlesCfg
168  acc.merge(AddTopQuarkAndDownstreamParticlesCfg(flags, generations=4, rejectHadronChildren=True))
169 
170  #=======================================
171  # Add Run-2 jet trigger collections
172  # Only needed for Run-2 due to different aux container type (JetTrigAuxContainer) which required special wrapper for conversion to AuxContainerBase
173  # In Run-3, the aux. container type is directly JetAuxContainer (no conversion needed)
174  #=======================================
175 
176  if flags.Trigger.EDMVersion == 2:
177  triggerNames = ["JetContainer_a4tcemsubjesFS", "JetContainer_a4tcemsubjesISFS", "JetContainer_a10tclcwsubjesFS", "JetContainer_GSCJet"]
178 
179  for trigger in triggerNames:
180  wrapperName = trigger+'AuxWrapper'
181  auxContainerName = 'HLT_xAOD__'+trigger+'Aux'
182 
183  acc.addEventAlgo(CompFactory.xAODMaker.AuxStoreWrapper( wrapperName, SGKeys = [ auxContainerName+"." ] ))
184 
185  return acc
186 
187 def JETM7Cfg(flags):
188 
189  acc = ComponentAccumulator()
190 
191  # Get the lists of triggers needed for trigger matching.
192  # This is needed at this scope (for the slimming) and further down in the config chain
193  # for actually configuring the matching, so we create it here and pass it down
194  # TODO: this should ideally be called higher up to avoid it being run multiple times in a train
195  from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
196  JETM7TriggerListsHelper = TriggerListsHelper(flags)
197 
198  # Skimming, thinning, augmentation, extra content
199  acc.merge(JETM7KernelCfg(flags, name="JETM7Kernel", StreamName = 'StreamDAOD_JETM7', TriggerListsHelper = JETM7TriggerListsHelper))
200 
201  # ============================
202  # Define contents of the format
203  # =============================
204  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
205  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
206  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
207 
208  JETM7SlimmingHelper = SlimmingHelper("JETM7SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
209 
210  JETM7SlimmingHelper.SmartCollections = ["Electrons", "Photons", "Muons",
211  "PrimaryVertices",
212  "InDetTrackParticles",
213  "AntiKt4EMPFlowJets",
214  "EventInfo",
215  ]
216 
217 
218  JETM7SlimmingHelper.ExtraVariables = ["InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights"]
219 
220  # Truth containers
221  if flags.Input.isMC:
222 
223  from DerivationFrameworkMCTruth.MCTruthCommonConfig import addTruth3ContentToSlimmerTool
224  addTruth3ContentToSlimmerTool(JETM7SlimmingHelper)
225 
226  JETM7SlimmingHelper.AppendToDictionary.update({'TruthParticles': 'xAOD::TruthParticleContainer',
227  'TruthParticlesAux': 'xAOD::TruthParticleAuxContainer'})
228 
229  JETM7SlimmingHelper.SmartCollections += ["AntiKt4TruthWZJets"]
230 
231  JETM7SlimmingHelper.AllVariables += ["TruthTopQuarkWithDecayParticles","TruthTopQuarkWithDecayVertices",
232  "AntiKt4TruthJets", "InTimeAntiKt4TruthJets", "OutOfTimeAntiKt4TruthJets", "TruthParticles",
233  "TruthVertices", "TruthEvents"]
234  JETM7SlimmingHelper.ExtraVariables += ["InDetTrackParticles.truthMatchProbability", "TruthVertices.barcode.z"]
235 
236 
237  # Trigger content
238  JETM7SlimmingHelper.IncludeTriggerNavigation = True
239  JETM7SlimmingHelper.IncludeJetTriggerContent = False
240  JETM7SlimmingHelper.IncludeMuonTriggerContent = False
241  JETM7SlimmingHelper.IncludeEGammaTriggerContent = False
242  JETM7SlimmingHelper.IncludeTauTriggerContent = False
243  JETM7SlimmingHelper.IncludeEtMissTriggerContent = False
244  JETM7SlimmingHelper.IncludeBJetTriggerContent = False
245  JETM7SlimmingHelper.IncludeBPhysTriggerContent = False
246  JETM7SlimmingHelper.IncludeMinBiasTriggerContent = False
247 
248  # Trigger matching
249  # Run 2
250  if flags.Trigger.EDMVersion == 2:
251  from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
252  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = JETM7SlimmingHelper,
253  OutputContainerPrefix = "TrigMatch_",
254  TriggerList = JETM7TriggerListsHelper.Run2TriggerNamesTau)
255  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = JETM7SlimmingHelper,
256  OutputContainerPrefix = "TrigMatch_",
257  TriggerList = JETM7TriggerListsHelper.Run2TriggerNamesNoTau)
258  # Run 3, or Run 2 with navigation conversion
259  if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
260  from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
262 
263  jetOutputList = ["AntiKt4EMPFlowByVertexJets"]
264  from DerivationFrameworkJetEtMiss.JetCommonConfig import addJetsToSlimmingTool
265  addJetsToSlimmingTool(JETM7SlimmingHelper, jetOutputList, JETM7SlimmingHelper.SmartCollections)
266 
267  # Output stream
268  JETM7ItemList = JETM7SlimmingHelper.GetItemList()
269  acc.merge(OutputStreamCfg(flags, "DAOD_JETM7", ItemList=JETM7ItemList, AcceptAlgs=["JETM7Kernel"]))
270  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_JETM7", AcceptAlgs=["JETM7Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
271 
272  return acc
273 
274 
275 
276 
TrigNavSlimmingMTConfig.AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
def AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(slimmingHelper)
Definition: TrigNavSlimmingMTConfig.py:98
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.InDetToolsConfig.InDetTrackSelectionToolWrapperCfg
def InDetTrackSelectionToolWrapperCfg(flags, name, CutLevel="TightPrimary", **kwargs)
Definition: InDetToolsConfig.py:426
python.JETM7.JETM7ExtraContentCfg
def JETM7ExtraContentCfg(flags)
Definition: JETM7.py:141
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.JETM7.JETM7SkimmingToolCfg
def JETM7SkimmingToolCfg(flags)
Definition: JETM7.py:13
python.TriggerMatchingCommonConfig.AddRun2TriggerMatchingToSlimmingHelper
def AddRun2TriggerMatchingToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:49
python.JETM7.JETM7Cfg
def JETM7Cfg(flags)
Definition: JETM7.py:187
python.MCTruthCommonConfig.AddTopQuarkAndDownstreamParticlesCfg
def AddTopQuarkAndDownstreamParticlesCfg(flags, generations=1, rejectHadronChildren=False)
Definition: MCTruthCommonConfig.py:253
python.JetRecConfig.JetRecCfg
def JetRecCfg(flags, jetdef, returnConfiguredDef=False)
Top level functions returning ComponentAccumulator out of JetDefinition.
Definition: JetRecConfig.py:36
python.JetCommonConfig.addJetsToSlimmingTool
def addJetsToSlimmingTool(slimhelper, contentlist, smartlist=[])
Definition: JetCommonConfig.py:249
python.DerivationFrameworkToolsConfig.GenericObjectThinningCfg
def GenericObjectThinningCfg(ConfigFlags, name, **kwargs)
Definition: DerivationFrameworkToolsConfig.py:20
python.JETM7.JETM7KernelCfg
def JETM7KernelCfg(flags, name='JETM7Kernel', **kwargs)
Definition: JETM7.py:27
python.InDetToolsConfig.JetTrackParticleThinningCfg
def JetTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:560
python.InDetToolsConfig.MuonTrackParticleThinningCfg
def MuonTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:528
python.MCTruthCommonConfig.addTruth3ContentToSlimmerTool
def addTruth3ContentToSlimmerTool(slimmer)
Definition: MCTruthCommonConfig.py:462
python.InDetToolsConfig.EgammaTrackParticleThinningCfg
def EgammaTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:579
python.PhysCommonConfig.PhysCommonAugmentationsCfg
def PhysCommonAugmentationsCfg(flags, **kwargs)
Definition: PhysCommonConfig.py:14
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:219
SlimmingHelper
Definition: SlimmingHelper.py:1
python.HION12.DerivationKernel
DerivationKernel
Definition: HION12.py:67