ATLAS Offline Software
JETM2.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_JETM2.py
5 #====================================================================
6 
7 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.Enums import MetadataCategory, LHCPeriod
10 
11 # Main algorithm config
12 def JETM2KernelCfg(flags, name='JETM2Kernel', **kwargs):
13  """Configure the derivation framework driving algorithm (kernel) for JETM2"""
14  acc = ComponentAccumulator()
15 
16  # Common augmentations
17  from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
18  acc.merge(PhysCommonAugmentationsCfg(flags, TriggerListsHelper = kwargs['TriggerListsHelper']))
19 
20  if flags.Input.isMC:
21  # thinning tools:
22  truthThinningTool = CompFactory.DerivationFramework.MenuTruthThinning(name = "JETM2TruthThinning",
23  StreamName = kwargs['StreamName'],
24  WriteAllStable = True,
25  WritePartons = False,
26  WriteHadrons = False,
27  WriteBHadrons = True,
28  WriteCHadrons = False,
29  WriteGeant = False,
30  WriteFirstN = 10)
31 
32  acc.addPublicTool(truthThinningTool)
33 
34  DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
35  acc.addEventAlgo(DerivationKernel(name, ThinningTools = [truthThinningTool] if flags.Input.isMC else []))
36 
37  # Extra jet content:
38  acc.merge(JETM2ExtraContentCfg(flags))
39 
40  return acc
41 
42 
44 
45  acc = ComponentAccumulator()
46 
47  from JetRecConfig.JetRecConfig import JetRecCfg, getInputAlgs, getConstitPJGAlg
48  from JetRecConfig.JetInputConfig import buildEventShapeAlg
49  from JetRecConfig.StandardJetConstits import stdConstitDic as cst
50  from JetRecConfig.StandardSmallRJets import AntiKt4UFOCSSKNoPtCut, AntiKt4EMPFlowNoPtCut, AntiKt4EMTopoNoPtCut
51  from JetRecConfig.StandardLargeRJets import AntiKt10TruthDressedWZSoftDrop
52 
53  #=======================================
54  # CHS R = 0.4 UFO jets
55  #=======================================
56 
57  algs = getInputAlgs(cst.UFO, flags=flags)
58  for alg in algs:
59  if isinstance(alg, ComponentAccumulator):
60  acc.merge(alg)
61  else:
62  acc.addEventAlgo(alg)
63 
64  #=======================================
65  # NoPtCut containers
66  #=======================================
67  jetList = [AntiKt4UFOCSSKNoPtCut,AntiKt4EMPFlowNoPtCut,AntiKt4EMTopoNoPtCut]
68 
69  #=======================================
70  # R = 1.0 truth WZ Dressed jets
71  #=======================================
72  if flags.Input.isMC:
73  jetList += [AntiKt10TruthDressedWZSoftDrop]
74 
75 
76  for jd in jetList:
77  acc.merge(JetRecCfg(flags,jd))
78 
79  #=======================================
80  # UFO CSSK event shape
81  #=======================================
82 
83  acc.addEventAlgo(buildEventShapeAlg(cst.UFOCSSK,'', suffix=None))
84  acc.addEventAlgo(getConstitPJGAlg(cst.UFOCSSK, suffix='Neut'))
85  acc.addEventAlgo(buildEventShapeAlg(cst.UFOCSSK,'', suffix='Neut'))
86 
87  #=======================================
88  # More detailed truth information
89  #=======================================
90 
91  if flags.Input.isMC:
92  from DerivationFrameworkMCTruth.MCTruthCommonConfig import AddTopQuarkAndDownstreamParticlesCfg, AddTruthCollectionNavigationDecorationsCfg
93  acc.merge(AddTopQuarkAndDownstreamParticlesCfg(flags))
94  acc.merge(AddTruthCollectionNavigationDecorationsCfg(flags, TruthCollections=["TruthTopQuarkWithDecayParticles","TruthBosonsWithDecayParticles"],prefix='Top'))
95 
96 
97  return acc
98 
99 
100 def JETM2Cfg(flags):
101 
102  acc = ComponentAccumulator()
103 
104  # Get the lists of triggers needed for trigger matching.
105  # This is needed at this scope (for the slimming) and further down in the config chain
106  # for actually configuring the matching, so we create it here and pass it down
107  # TODO: this should ideally be called higher up to avoid it being run multiple times in a train
108  from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
109  JETM2TriggerListsHelper = TriggerListsHelper(flags)
110 
111  # Skimming, thinning, augmentation, extra content
112  acc.merge(JETM2KernelCfg(flags, name="JETM2Kernel", StreamName = 'StreamDAOD_JETM2', TriggerListsHelper = JETM2TriggerListsHelper))
113 
114  # ============================
115  # Define contents of the format
116  # =============================
117  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
118  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
119  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
120 
121  JETM2SlimmingHelper = SlimmingHelper("JETM2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
122 
123  JETM2SlimmingHelper.SmartCollections = ["EventInfo","InDetTrackParticles", "PrimaryVertices",
124  "Electrons", "Photons", "Muons", "TauJets",
125  "MET_Baseline_AntiKt4EMPFlow",
126  "AntiKt4EMTopoNoPtCutJets","AntiKt4EMPFlowJets",
127  "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets",
128  "BTagging_AntiKt4EMPFlow",
129  "BTagging_AntiKtVR30Rmax4Rmin02Track"]
130 
131  JETM2SlimmingHelper.AllVariables = ["CaloCalFwdTopoTowers",
132  "CHSGChargedParticleFlowObjects","CHSGNeutralParticleFlowObjects",
133  "CSSKGChargedParticleFlowObjects","CSSKGNeutralParticleFlowObjects",
134  "Kt4EMTopoOriginEventShape","Kt4EMPFlowEventShape","Kt4EMPFlowPUSBEventShape",
135  "Kt4EMPFlowNeutEventShape","Kt4UFOCSSKEventShape","Kt4UFOCSSKNeutEventShape"]
136 
137  # Low-level inputs
138  from DerivationFrameworkJetEtMiss.CommonJETMXContent import ClusterVariables, FlowElementVariables, UFOVariables, TrackingVariables, TrackingVariablesHGTD, FELinks
139  JETM2SlimmingHelper.ExtraVariables += [".".join(["CaloCalTopoClusters"] + ClusterVariables)]
140  JETM2SlimmingHelper.ExtraVariables += [".".join(["GlobalChargedParticleFlowObjects"] + FlowElementVariables)]
141  JETM2SlimmingHelper.ExtraVariables += [".".join(["GlobalNeutralParticleFlowObjects"] + FlowElementVariables)]
142  JETM2SlimmingHelper.ExtraVariables += [".".join(["UFO"] + UFOVariables)]
143  JETM2SlimmingHelper.ExtraVariables += [".".join(["UFOCSSK"] + UFOVariables)]
144  JETM2SlimmingHelper.ExtraVariables += [".".join(["InDetTrackParticles"] + TrackingVariables)]
145  if flags.GeoModel.Run >= LHCPeriod.Run4:
146  JETM2SlimmingHelper.ExtraVariables += [".".join(["InDetTrackParticles"] + TrackingVariablesHGTD)]
147 
148  # Links of physics objects to FlowElements
149  JETM2SlimmingHelper.ExtraVariables += FELinks
150 
151  # Detailed substructure information
152  from DerivationFrameworkJetEtMiss.CommonJETMXContent import ExtraJSSVariables
153  JETM2SlimmingHelper.ExtraVariables += [".".join(["AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"] + ExtraJSSVariables)]
154 
155  JETM2SlimmingHelper.ExtraVariables += ["AntiKt4EMPFlowJets.GhostTower.IsoFixedCone5Pt.IsoFixedCone5PtPUsub",
156  "AntiKt4EMTopoNoPtCutJets.IsoFixedCone5Pt.IsoFixedCone5PtPUsub",
157  "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets.SizeParameter",
158  "GSFTrackParticles.particleHypothesis.vx.vy.vz",
159  "PrimaryVertices.x.y.z.covariance.trackWeights",
160  "TauJets.clusterLinks",
161  "Muons.energyLossType.EnergyLoss.ParamEnergyLoss.MeasEnergyLoss.EnergyLossSigma.MeasEnergyLossSigma.ParamEnergyLossSigmaPlus.ParamEnergyLossSigmaMinus.clusterLinks.FSR_CandidateEnergy",
162  "MuonSegments.x.y.z.px.py.pz",
163  "BTagging_AntiKt4EMPFlow.jetLink",
164  "BTagging_AntiKtVR30Rmax4Rmin02Track.jetLink"]
165 
166  JETM2SlimmingHelper.AppendToDictionary.update({'CSSKGNeutralParticleFlowObjects': 'xAOD::FlowElementContainer',
167  'CSSKGNeutralParticleFlowObjectsAux': 'xAOD::ShallowAuxContainer',
168  'CSSKGChargedParticleFlowObjects': 'xAOD::FlowElementContainer',
169  'CSSKGChargedParticleFlowObjectsAux': 'xAOD::ShallowAuxContainer',
170  'UFO': 'xAOD::FlowElementContainer',
171  'UFOAux': 'xAOD::FlowElementAuxContainer',
172  'Kt4UFOCSSKEventShape': 'xAOD::EventShape',
173  'Kt4UFOCSSKEventShapeAux': 'xAOD::EventShapeAuxInfo',
174  'Kt4UFOCSSKNeutEventShape': 'xAOD::EventShape',
175  'Kt4UFOCSSKNeutEventShapeAux': 'xAOD::EventShapeAuxInfo',
176  'AntiKt4EMTopoNoPtCutJets': 'xAOD::JetContainer',
177  'AntiKt4EMTopoNoPtCutJetsAux': 'xAOD::JetAuxContainer'})
178 
179  from DerivationFrameworkJetEtMiss.JetCommonConfig import addOriginCorrectedClustersToSlimmingTool
180  addOriginCorrectedClustersToSlimmingTool(JETM2SlimmingHelper,writeLC=True,writeEM=True)
181 
182  # Truth containers
183  if flags.Input.isMC:
184 
185  from DerivationFrameworkMCTruth.MCTruthCommonConfig import addTruth3ContentToSlimmerTool
186  addTruth3ContentToSlimmerTool(JETM2SlimmingHelper)
187 
188  JETM2SlimmingHelper.AppendToDictionary.update({'TruthParticles': 'xAOD::TruthParticleContainer',
189  'TruthParticlesAux': 'xAOD::TruthParticleAuxContainer'})
190 
191  JETM2SlimmingHelper.AllVariables += ["TruthTopQuarkWithDecayParticles","TruthTopQuarkWithDecayVertices","TruthHFWithDecayParticles",
192  "AntiKt4TruthJets", "InTimeAntiKt4TruthJets", "OutOfTimeAntiKt4TruthJets",
193  "TruthParticles", "TruthVertices","TruthEvents"]
194  JETM2SlimmingHelper.ExtraVariables += ["AntiKt10TruthSoftDropBeta100Zcut10Jets.SizeParameter"]
195  JETM2SlimmingHelper.SmartCollections += ["AntiKt4TruthJets","AntiKt10TruthJets","AntiKt4TruthWZJets","AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets"]
196 
197  JETM2SlimmingHelper.ExtraVariables += ["AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets.GhostTQuarksFinalCount.GhostHBosonsCount.GhostZBosonsCount.GhostWBosonsCount",
198  "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets.GhostTQuarksFinalPt.GhostHBosonsPt.GhostZBosonsPt.GhostWBosonsPt",
199  "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets.GhostBHadronsFinalPt.GhostCHadronsFinalPt",
200  "AntiKt4TruthWZJets.IsoFixedCone5Pt",
201  "AntiKt4TruthDressedWZJets.IsoFixedCone5Pt"]
202 
203  # Trigger content
204  JETM2SlimmingHelper.IncludeTriggerNavigation = False
205  JETM2SlimmingHelper.IncludeJetTriggerContent = False
206  JETM2SlimmingHelper.IncludeMuonTriggerContent = False
207  JETM2SlimmingHelper.IncludeEGammaTriggerContent = False
208  JETM2SlimmingHelper.IncludeTauTriggerContent = False
209  JETM2SlimmingHelper.IncludeEtMissTriggerContent = False
210  JETM2SlimmingHelper.IncludeBJetTriggerContent = False
211  JETM2SlimmingHelper.IncludeBPhysTriggerContent = False
212  JETM2SlimmingHelper.IncludeMinBiasTriggerContent = False
213 
214  jetOutputList = ["AntiKt4UFOCSSKNoPtCutJets","AntiKt4EMPFlowNoPtCutJets"]
215  from DerivationFrameworkJetEtMiss.JetCommonConfig import addJetsToSlimmingTool
216  addJetsToSlimmingTool(JETM2SlimmingHelper, jetOutputList, JETM2SlimmingHelper.SmartCollections)
217 
218  # Output stream
219  JETM2ItemList = JETM2SlimmingHelper.GetItemList()
220  acc.merge(OutputStreamCfg(flags, "DAOD_JETM2", ItemList=JETM2ItemList, AcceptAlgs=["JETM2Kernel"]))
221  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_JETM2", AcceptAlgs=["JETM2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
222 
223  return acc
224 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.JetRecConfig.getInputAlgs
def getInputAlgs(jetOrConstitdef, flags, context="default", monTool=None)
Definition: JetRecConfig.py:279
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.JetCommonConfig.addOriginCorrectedClustersToSlimmingTool
def addOriginCorrectedClustersToSlimmingTool(slimhelper, writeLC=False, writeEM=False)
Helper to add origin corrected clusters to output.
Definition: JetCommonConfig.py:263
python.JetInputConfig.buildEventShapeAlg
def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf=0.9, radius=0.4, suffix=None)
Definition: JetInputConfig.py:132
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.JETM2.JETM2ExtraContentCfg
def JETM2ExtraContentCfg(flags)
Definition: JETM2.py:43
python.JetCommonConfig.addJetsToSlimmingTool
def addJetsToSlimmingTool(slimhelper, contentlist, smartlist=[])
Definition: JetCommonConfig.py:249
python.JETM2.JETM2Cfg
def JETM2Cfg(flags)
Definition: JETM2.py:100
python.JETM2.JETM2KernelCfg
def JETM2KernelCfg(flags, name='JETM2Kernel', **kwargs)
Definition: JETM2.py:12
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.JetRecConfig.getConstitPJGAlg
def getConstitPJGAlg(constitdef, suffix=None, flags=None, parent_jetdef=None)
Definition: JetRecConfig.py:350
python.MCTruthCommonConfig.addTruth3ContentToSlimmerTool
def addTruth3ContentToSlimmerTool(slimmer)
Definition: MCTruthCommonConfig.py:462
python.MCTruthCommonConfig.AddTruthCollectionNavigationDecorationsCfg
def AddTruthCollectionNavigationDecorationsCfg(flags, TruthCollections=[], prefix='')
Definition: MCTruthCommonConfig.py:331
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