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