ATLAS Offline Software
JETM5.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_JETM5.py
5 #====================================================================
6 
7 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.Enums import MetadataCategory
10 
11 # Main algorithm config
13  """Configure the skimming tool"""
14  acc = ComponentAccumulator()
15 
16  expression = '( HLT_noalg_zb_L1ZB || HLT_noalg_L1ZB )'
17  JETM5SkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(name = "JETM5SkimmingTool1",
18  expression = expression)
19 
20  acc.addPublicTool(JETM5SkimmingTool, primary = True)
21 
22  return(acc)
23 
24 
25 # Main algorithm config
26 def JETM5KernelCfg(flags, name='JETM5Kernel', **kwargs):
27  """Configure the derivation framework driving algorithm (kernel) for JETM5"""
28  acc = ComponentAccumulator()
29 
30  # Skimming
31  if not flags.Input.isMC:
32  skimmingTool = acc.getPrimaryAndMerge(JETM5SkimmingToolCfg(flags))
33 
34  # Common augmentations
35  from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
36  acc.merge(PhysCommonAugmentationsCfg(flags, TriggerListsHelper = kwargs['TriggerListsHelper']))
37 
38  # Thinning tools...
39  from DerivationFrameworkInDet.InDetToolsConfig import MuonTrackParticleThinningCfg, EgammaTrackParticleThinningCfg
40 
41  # Include inner detector tracks associated with muons
42  JETM5MuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(
43  flags,
44  name = "JETM5MuonTPThinningTool",
45  StreamName = kwargs['StreamName'],
46  MuonKey = "Muons",
47  InDetTrackParticlesKey = "InDetTrackParticles"))
48 
49  # Include inner detector tracks associated with electonrs
50  JETM5ElectronTPThinningTool = acc.getPrimaryAndMerge(EgammaTrackParticleThinningCfg(
51  flags,
52  name = "JETM5ElectronTPThinningTool",
53  StreamName = kwargs['StreamName'],
54  SGKey = "Electrons",
55  InDetTrackParticlesKey = "InDetTrackParticles"))
56 
57  # Include inner detector tracks associated with photons
58  JETM5PhotonTPThinningTool = acc.getPrimaryAndMerge(EgammaTrackParticleThinningCfg(
59  flags,
60  name = "JETM5PhotonTPThinningTool",
61  StreamName = kwargs['StreamName'],
62  SGKey = "Photons",
63  InDetTrackParticlesKey = "InDetTrackParticles",
64  GSFConversionVerticesKey = "GSFConversionVertices"))
65 
66 
67  thinningTools = [JETM5MuonTPThinningTool,
68  JETM5ElectronTPThinningTool,
69  JETM5PhotonTPThinningTool]
70 
71  # Truth particle thinning
72  if flags.Input.isMC:
73  truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs
74  truth_cond_Lepton = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16) && (TruthParticles.barcode < 200000))" # Leptons
75  truth_cond_Quark = "((abs(TruthParticles.pdgId) <= 5 && (TruthParticles.pt > 10000.)) || (abs(TruthParticles.pdgId) == 6))" # Quarks
76  truth_cond_Gluon = "((abs(TruthParticles.pdgId) == 21) && (TruthParticles.pt > 10000.))" # Gluons
77  truth_cond_Photon = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 10000.) && (TruthParticles.barcode < 200000))" # Photon
78 
79  truth_expression = '('+truth_cond_WZH+' || '+truth_cond_Lepton +' || '+truth_cond_Quark+'||'+truth_cond_Gluon+' || '+truth_cond_Photon+')'
80 
81  preserveAllDescendants = False
82 
83  JETM5TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning ( name = "JETM5TruthThinningTool",
84  StreamName = kwargs['StreamName'],
85  ParticleSelectionString = truth_expression,
86  PreserveDescendants = preserveAllDescendants,
87  PreserveGeneratorDescendants = not preserveAllDescendants,
88  PreserveAncestors = True)
89 
90  acc.addPublicTool(JETM5TruthThinningTool)
91  thinningTools.append(JETM5TruthThinningTool)
92 
93  # Finally the kernel itself
94  DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
95  acc.addEventAlgo(DerivationKernel(name,
96  ThinningTools = thinningTools,
97  SkimmingTools = [skimmingTool] if not flags.Input.isMC else []))
98 
99 
100  # PFlow augmentation tool
101  from DerivationFrameworkJetEtMiss.PFlowCommonConfig import PFlowCommonCfg
102  acc.merge(PFlowCommonCfg(flags))
103 
104  return acc
105 
106 
107 def JETM5Cfg(flags):
108 
109  acc = ComponentAccumulator()
110 
111  # Get the lists of triggers needed for trigger matching.
112  # This is needed at this scope (for the slimming) and further down in the config chain
113  # for actually configuring the matching, so we create it here and pass it down
114  # TODO: this should ideally be called higher up to avoid it being run multiple times in a train
115  from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
116  JETM5TriggerListsHelper = TriggerListsHelper(flags)
117 
118  # Skimming, thinning, augmentation, extra content
119  acc.merge(JETM5KernelCfg(flags, name="JETM5Kernel", StreamName = 'StreamDAOD_JETM5', TriggerListsHelper = JETM5TriggerListsHelper))
120 
121  # ============================
122  # Define contents of the format
123  # =============================
124  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
125  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
126  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
127 
128  JETM5SlimmingHelper = SlimmingHelper("JETM5SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
129 
130  JETM5SlimmingHelper.SmartCollections = ["EventInfo", "InDetTrackParticles", "PrimaryVertices",
131  "Electrons", "Photons", "Muons", "TauJets",
132  "MET_Baseline_AntiKt4EMTopo","MET_Baseline_AntiKt4EMPFlow",
133  "AntiKt4EMTopoJets","AntiKt4EMPFlowJets",
134  "BTagging_AntiKt4EMPFlow"]
135 
136  JETM5SlimmingHelper.AllVariables = ["CaloCalTopoClusters",
137  "MuonSegments",
138  "Kt4EMTopoOriginEventShape","Kt4EMPFlowEventShape",
139  "GlobalNeutralParticleFlowObjects", "GlobalChargedParticleFlowObjects",
140  "CHSGChargedParticleFlowObjects", "CHSGNeutralParticleFlowObjects",
141  "UFOCSSK"]
142 
143 
144  JETM5SlimmingHelper.ExtraVariables += ["AntiKt4EMPFlowJets.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1"]
145 
146  if flags.Input.isMC:
147  JETM5SlimmingHelper.AppendToDictionary.update({'TruthParticles': 'xAOD::TruthParticleContainer',
148  'TruthParticlesAux': 'xAOD::TruthParticleAuxContainer',
149  'TruthVertices': 'xAOD::TruthVertexContainer',
150  'TruthVerticesAux': 'xAOD::TruthVertexAuxContainer'})
151 
152  JETM5SlimmingHelper.AllVariables += ["MuonTruthParticles", "egammaTruthParticles",
153  "TruthParticles", "TruthEvents", "TruthVertices"]
154 
155  # Trigger content
156  JETM5SlimmingHelper.IncludeTriggerNavigation = False
157  JETM5SlimmingHelper.IncludeJetTriggerContent = False
158  JETM5SlimmingHelper.IncludeMuonTriggerContent = False
159  JETM5SlimmingHelper.IncludeEGammaTriggerContent = False
160  JETM5SlimmingHelper.IncludeJetTauEtMissTriggerContent = False
161  JETM5SlimmingHelper.IncludeTauTriggerContent = False
162  JETM5SlimmingHelper.IncludeEtMissTriggerContent = False
163  JETM5SlimmingHelper.IncludeBJetTriggerContent = False
164  JETM5SlimmingHelper.IncludeBPhysTriggerContent = False
165  JETM5SlimmingHelper.IncludeMinBiasTriggerContent = False
166 
167  # Output stream
168  JETM5ItemList = JETM5SlimmingHelper.GetItemList()
169  acc.merge(OutputStreamCfg(flags, "DAOD_JETM5", ItemList=JETM5ItemList, AcceptAlgs=["JETM5Kernel"]))
170  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_JETM5", AcceptAlgs=["JETM5Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
171 
172  return acc
173 
python.PFlowCommonConfig.PFlowCommonCfg
def PFlowCommonCfg(ConfigFlags)
Definition: PFlowCommonConfig.py:6
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.JETM5.JETM5SkimmingToolCfg
def JETM5SkimmingToolCfg(flags)
Definition: JETM5.py:12
python.JETM5.JETM5KernelCfg
def JETM5KernelCfg(flags, name='JETM5Kernel', **kwargs)
Definition: JETM5.py:26
python.InDetToolsConfig.MuonTrackParticleThinningCfg
def MuonTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:494
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
python.JETM5.JETM5Cfg
def JETM5Cfg(flags)
Definition: JETM5.py:107