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.JetConfigFlags import jetInternalFlags
147  from JetRecConfig.StandardSmallRJets import AntiKt4PV0Track, AntiKt4EMPFlowByVertex
148 
149  #=======================================
150  # R = 0.4 track-jets (needed for Rtrk)
151  #=======================================
152  jetList = [AntiKt4PV0Track]
153 
154  #=======================================
155  # R = 0.4 by-vertex jets
156  #=======================================
157  jetList += [AntiKt4EMPFlowByVertex]
158 
159  jetInternalFlags.isRecoJob = True
160 
161  for jd in jetList:
162  acc.merge(JetRecCfg(flags,jd))
163 
164  #=======================================
165  # More detailed truth information
166  #=======================================
167 
168  if flags.Input.isMC:
169  from DerivationFrameworkMCTruth.MCTruthCommonConfig import AddTopQuarkAndDownstreamParticlesCfg
170  acc.merge(AddTopQuarkAndDownstreamParticlesCfg(flags, generations=4, rejectHadronChildren=True))
171 
172  #=======================================
173  # Add Run-2 jet trigger collections
174  # Only needed for Run-2 due to different aux container type (JetTrigAuxContainer) which required special wrapper for conversion to AuxContainerBase
175  # In Run-3, the aux. container type is directly JetAuxContainer (no conversion needed)
176  #=======================================
177 
178  if flags.Trigger.EDMVersion == 2:
179  triggerNames = ["JetContainer_a4tcemsubjesFS", "JetContainer_a4tcemsubjesISFS", "JetContainer_a10tclcwsubjesFS", "JetContainer_GSCJet"]
180 
181  for trigger in triggerNames:
182  wrapperName = trigger+'AuxWrapper'
183  auxContainerName = 'HLT_xAOD__'+trigger+'Aux'
184 
185  acc.addEventAlgo(CompFactory.xAODMaker.AuxStoreWrapper( wrapperName, SGKeys = [ auxContainerName+"." ] ))
186 
187  return acc
188 
189 def JETM7Cfg(flags):
190 
191  acc = ComponentAccumulator()
192 
193  # Get the lists of triggers needed for trigger matching.
194  # This is needed at this scope (for the slimming) and further down in the config chain
195  # for actually configuring the matching, so we create it here and pass it down
196  # TODO: this should ideally be called higher up to avoid it being run multiple times in a train
197  from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
198  JETM7TriggerListsHelper = TriggerListsHelper(flags)
199 
200  # Skimming, thinning, augmentation, extra content
201  acc.merge(JETM7KernelCfg(flags, name="JETM7Kernel", StreamName = 'StreamDAOD_JETM7', TriggerListsHelper = JETM7TriggerListsHelper))
202 
203  # ============================
204  # Define contents of the format
205  # =============================
206  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
207  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
208  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
209 
210  JETM7SlimmingHelper = SlimmingHelper("JETM7SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
211 
212  JETM7SlimmingHelper.SmartCollections = ["Electrons", "Photons", "Muons",
213  "PrimaryVertices",
214  "InDetTrackParticles",
215  "AntiKt4EMPFlowJets",
216  "EventInfo",
217  ]
218 
219 
220  JETM7SlimmingHelper.ExtraVariables = ["InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights"]
221 
222  # Truth containers
223  if flags.Input.isMC:
224 
225  from DerivationFrameworkMCTruth.MCTruthCommonConfig import addTruth3ContentToSlimmerTool
226  addTruth3ContentToSlimmerTool(JETM7SlimmingHelper)
227 
228  JETM7SlimmingHelper.AppendToDictionary.update({'TruthParticles': 'xAOD::TruthParticleContainer',
229  'TruthParticlesAux': 'xAOD::TruthParticleAuxContainer'})
230 
231  JETM7SlimmingHelper.SmartCollections += ["AntiKt4TruthWZJets"]
232 
233  JETM7SlimmingHelper.AllVariables += ["TruthTopQuarkWithDecayParticles","TruthTopQuarkWithDecayVertices",
234  "AntiKt4TruthJets", "InTimeAntiKt4TruthJets", "OutOfTimeAntiKt4TruthJets", "TruthParticles",
235  "TruthVertices", "TruthEvents"]
236  JETM7SlimmingHelper.ExtraVariables += ["InDetTrackParticles.truthMatchProbability", "TruthVertices.barcode.z"]
237 
238 
239  # Trigger content
240  JETM7SlimmingHelper.IncludeTriggerNavigation = True
241  JETM7SlimmingHelper.IncludeJetTriggerContent = False
242  JETM7SlimmingHelper.IncludeMuonTriggerContent = False
243  JETM7SlimmingHelper.IncludeEGammaTriggerContent = False
244  JETM7SlimmingHelper.IncludeJetTauEtMissTriggerContent = False
245  JETM7SlimmingHelper.IncludeTauTriggerContent = False
246  JETM7SlimmingHelper.IncludeEtMissTriggerContent = False
247  JETM7SlimmingHelper.IncludeBJetTriggerContent = False
248  JETM7SlimmingHelper.IncludeBPhysTriggerContent = False
249  JETM7SlimmingHelper.IncludeMinBiasTriggerContent = False
250 
251  # Trigger matching
252  # Run 2
253  if flags.Trigger.EDMVersion == 2:
254  from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
255  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = JETM7SlimmingHelper,
256  OutputContainerPrefix = "TrigMatch_",
257  TriggerList = JETM7TriggerListsHelper.Run2TriggerNamesTau)
258  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = JETM7SlimmingHelper,
259  OutputContainerPrefix = "TrigMatch_",
260  TriggerList = JETM7TriggerListsHelper.Run2TriggerNamesNoTau)
261  # Run 3
262  if flags.Trigger.EDMVersion == 3:
263  from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
265 
266 
267  jetOutputList = ["AntiKt4EMPFlowByVertexJets"]
268  from DerivationFrameworkJetEtMiss.JetCommonConfig import addJetsToSlimmingTool
269  addJetsToSlimmingTool(JETM7SlimmingHelper, jetOutputList, JETM7SlimmingHelper.SmartCollections)
270 
271  # Output stream
272  JETM7ItemList = JETM7SlimmingHelper.GetItemList()
273  acc.merge(OutputStreamCfg(flags, "DAOD_JETM7", ItemList=JETM7ItemList, AcceptAlgs=["JETM7Kernel"]))
274  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_JETM7", AcceptAlgs=["JETM7Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
275 
276  return acc
277 
278 
279 
280 
TrigNavSlimmingMTConfig.AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
def AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(slimmingHelper)
Definition: TrigNavSlimmingMTConfig.py:97
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.InDetToolsConfig.InDetTrackSelectionToolWrapperCfg
def InDetTrackSelectionToolWrapperCfg(flags, name, CutLevel="TightPrimary", **kwargs)
Definition: InDetToolsConfig.py:392
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
HION12.DerivationKernel
DerivationKernel
Definition: HION12.py:67
python.JETM7.JETM7SkimmingToolCfg
def JETM7SkimmingToolCfg(flags)
Definition: JETM7.py:13
python.TriggerMatchingCommonConfig.AddRun2TriggerMatchingToSlimmingHelper
def AddRun2TriggerMatchingToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:30
python.JETM7.JETM7Cfg
def JETM7Cfg(flags)
Definition: JETM7.py:189
python.MCTruthCommonConfig.AddTopQuarkAndDownstreamParticlesCfg
def AddTopQuarkAndDownstreamParticlesCfg(flags, generations=1, rejectHadronChildren=False)
Definition: MCTruthCommonConfig.py:254
python.JetRecConfig.JetRecCfg
def JetRecCfg(flags, jetdef, returnConfiguredDef=False)
Top level functions returning ComponentAccumulator out of JetDefinition.
Definition: JetRecConfig.py:37
python.JetCommonConfig.addJetsToSlimmingTool
def addJetsToSlimmingTool(slimhelper, contentlist, smartlist=[])
Definition: JetCommonConfig.py:228
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:526
python.InDetToolsConfig.MuonTrackParticleThinningCfg
def MuonTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:494
python.MCTruthCommonConfig.addTruth3ContentToSlimmerTool
def addTruth3ContentToSlimmerTool(slimmer)
Definition: MCTruthCommonConfig.py:469
python.InDetToolsConfig.EgammaTrackParticleThinningCfg
def EgammaTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:545
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:216
SlimmingHelper
Definition: SlimmingHelper.py:1