ATLAS Offline Software
TEST7.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 # TEST7.py - derivation framework example demonstrating skimming via means of string
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaCommon.CFElements import seqAND
8 
10  """Configure the example skimming tool"""
11  from TrigDecisionTool.TrigDecisionToolConfig import TrigDecisionToolCfg
12  acc = ComponentAccumulator()
13  tdt = acc.getPrimaryAndMerge(TrigDecisionToolCfg(flags))
14  acc.addPublicTool(CompFactory.DerivationFramework.xAODStringSkimmingTool(name = "TEST7StringSkimmingTool",
15  expression = "( count(Muons.pt > (6 * GeV)) + count(Electrons.pt > (6 * GeV)) ) >= 3",
16  TrigDecisionTool=tdt),
17  primary = True)
18  return(acc)
19 
20 def TEST7KernelCfg(flags, name='TEST7Kernel', **kwargs):
21  """Configure the derivation framework driving algorithm (kernel)"""
22  acc = ComponentAccumulator()
23  # The next three lines are necessary in case the string skimming tool accesses containers which haven't
24  # previously been accessed via ReadHandles (as here). One must create a new sequence, list all of the
25  # accessed container types and keys as ExtraDataForDynamicConsumers (just Muons here) and then set the property
26  # ProcessDynamicDataDependencies to True for that sequence. The relevant skimming tools must then be attached
27  # to this sequence. The use of seqAND here isn't relevant since there is only one sequence in use.
28  # This step isn't needed in case the common augmentations are run first (e.g. with PHYS/PHYSLITE etc). In
29  # such cases one can omit the next three lines and the sequenceName argument in addEventAlgo.
30  acc.addSequence( seqAND("TEST7Sequence") )
31  acc.getSequence("TEST7Sequence").ExtraDataForDynamicConsumers = ['xAOD::MuonContainer/Muons','xAOD::ElectronContainer/Electrons']
32  acc.getSequence("TEST7Sequence").ProcessDynamicDataDependencies = True
33  skimmingTool = acc.getPrimaryAndMerge(TEST7SkimmingToolCfg(flags))
34  DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
35  acc.addEventAlgo(DerivationKernel(name, SkimmingTools = [skimmingTool]), sequenceName="TEST7Sequence")
36  return acc
37 
38 
39 def TEST7Cfg(flags):
40 
41  acc = ComponentAccumulator()
42  acc.merge(TEST7KernelCfg(flags, name="TEST7Kernel"))
43 
44  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
45  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
46  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
47  TEST7SlimmingHelper = SlimmingHelper("TEST7SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
48  TEST7SlimmingHelper.SmartCollections = ["EventInfo",
49  "Electrons",
50  "Photons",
51  "Muons",
52  "PrimaryVertices",
53  "InDetTrackParticles",
54  "AntiKt4EMTopoJets",
55  "AntiKt4EMPFlowJets",
56  "BTagging_AntiKt4EMPFlow",
57  "BTagging_AntiKtVR30Rmax4Rmin02Track",
58  "MET_Baseline_AntiKt4EMTopo",
59  "MET_Baseline_AntiKt4EMPFlow",
60  "TauJets",
61  "DiTauJets",
62  "DiTauJetsLowPt",
63  "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets",
64  "AntiKtVR30Rmax4Rmin02PV0TrackJets"]
65  TEST7ItemList = TEST7SlimmingHelper.GetItemList()
66 
67  acc.merge(OutputStreamCfg(flags, "D2AOD_TEST7", ItemList=TEST7ItemList, AcceptAlgs=["TEST7Kernel"]))
68  acc.merge(SetupMetaDataForStreamCfg(flags, "D2AOD_TEST7", AcceptAlgs=["TEST7Kernel"], propagateMetadataFromInput=True))
69 
70  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.TEST7.TEST7SkimmingToolCfg
def TEST7SkimmingToolCfg(flags)
Definition: TEST7.py:9
HION12.DerivationKernel
DerivationKernel
Definition: HION12.py:67
python.CFElements.seqAND
def seqAND(name, subs=[])
Definition: CFElements.py:25
python.TEST7.TEST7Cfg
def TEST7Cfg(flags)
Definition: TEST7.py:39
python.TriggerInterface.TrigDecisionToolCfg
def TrigDecisionToolCfg(flags)
Definition: TriggerInterface.py:14
python.TEST7.TEST7KernelCfg
def TEST7KernelCfg(flags, name='TEST7Kernel', **kwargs)
Definition: TEST7.py:20
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:216
SlimmingHelper
Definition: SlimmingHelper.py:1