ATLAS Offline Software
Loading...
Searching...
No Matches
STDM16.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2#!/usr/bin/env python
3#====================================================================
4# STDM16.py for c-fragmentation analysi
5# Contact: eleni.skorda@cern.ch or andrew.chisolm@cern.ch
6#====================================================================
7
8from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9from AthenaConfiguration.ComponentFactory import CompFactory
10from AthenaConfiguration.Enums import MetadataCategory
11from AthenaCommon.Logging import logging
12logSTDM16 = logging.getLogger('STDM16')
13
14# Particle masses
15massD0 = 1864.84 # MeV
16massPiPlus = 139.570 # MeV
17massKPlus = 493.677 # MeV
18
19CandidatesContainerName= "STDM16_D0Candidates"
20streamName = "StreamDAOD_STDM16"
21
22# Main algorithm config
23
24def DStarSelectionToolCfg(flags, name, **kwargs):
25 acc = ComponentAccumulator()
26 acc.addPublicTool(CompFactory.DerivationFramework.DStarSelectionTool(name = "STDM16_DStarSelectionTool",
27 InputVtxContainerName = CandidatesContainerName,
28 DeltaMassMax = 200.0), primary = True)
29 return acc
30
31
32def STDM16Kernel(flags, name='STDM16Kernel', **kwargs):
33 """Configure the derivation framework driving algorithm (kernel) for STDM16"""
34 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import (BPHY_V0ToolCfg, BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
35
36 acc = ComponentAccumulator()
37
38 # #============================================================================
39 # # Adding jets, from DerivationFrameworkPhys/python/PhysCommonConfig.py
40 # #============================================================================
41
42 # MC truth
43 if flags.Input.isMC:
44 from DerivationFrameworkMCTruth.MCTruthCommonConfig import (
45 AddStandardTruthContentsCfg,
46 #AddHFAndDownstreamParticlesCfg,
47 AddMiniTruthCollectionLinksCfg,
48 AddPVCollectionCfg,
49 AddTruthCollectionNavigationDecorationsCfg,
50 TruthClassificationAugmentationsCfg)
51 acc.merge(TruthClassificationAugmentationsCfg(flags))
52 from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import DFCommonTruthCharmToolCfg
53 STDM16CommonTruthCharmTool = acc.getPrimaryAndMerge(DFCommonTruthCharmToolCfg(
54 flags,
55 name = "STDM16CommonTruthCharmTool"))
56 CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
57 acc.addEventAlgo(CommonAugmentation("STDM16CommonTruthCharmKernel",AugmentationTools=[STDM16CommonTruthCharmTool]))
58
59 acc.merge(AddStandardTruthContentsCfg(flags))
60 acc.merge(AddTruthCollectionNavigationDecorationsCfg(
61 flags,
62 TruthCollections=["TruthMuons",
63 "TruthBottom",
64 "TruthCharm"
65 ],
66 prefix = 'STDM16_'))
67 # Re-point links on reco objects
68 acc.merge(AddMiniTruthCollectionLinksCfg(flags))
69 acc.merge(AddPVCollectionCfg(flags))
70
71 # InDet, Muon, Egamma common augmentations
72 from DerivationFrameworkInDet.InDetCommonConfig import InDetCommonCfg
73 from DerivationFrameworkMuons.MuonsCommonConfig import MuonsCommonCfg
74 from DerivationFrameworkEGamma.EGammaCommonConfig import EGammaCommonCfg
75
76 # TODO: need to find the new flags equivalent for the missing settings below, then we can
77 # drop these kwargs and do everything via the flags
78 acc.merge(InDetCommonCfg(flags,
79 DoVertexFinding = flags.Tracking.doVertexFinding,
80 AddPseudoTracks = flags.Tracking.doPseudoTracking,
81 DecoLRTTTVA = False,
82 DoR3LargeD0 = flags.Tracking.doLargeD0,
83 StoreSeparateLargeD0Container = flags.Tracking.storeSeparateLargeD0Container,
84 MergeLRT = False))
85 acc.merge(MuonsCommonCfg(flags))
86 acc.merge(EGammaCommonCfg(flags))
87
88
89 from DerivationFrameworkJetEtMiss.JetCommonConfig import JetCommonCfg
90 #from DerivationFrameworkFlavourTag.FtagDerivationConfig import FtagJetCollectionsCfg
91
92 acc.merge(JetCommonCfg(flags))
93
94 # FTagJetColl = ['AntiKt4EMPFlowJets', 'AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets']
95
96 #acc.merge(FtagJetCollectionsCfg(flags,FTagJetColl))
97
98 from TrkConfig.TrkV0FitterConfig import TrkV0VertexFitter_InDetExtrCfg
99
100 V0Tools = acc.popToolsAndMerge(BPHY_V0ToolCfg(flags, "STDM16"))
101 vkalvrt = acc.popToolsAndMerge(BPHY_TrkVKalVrtFitterCfg(flags, "STDM16")) # VKalVrt vertex fitter
102 trackselect = acc.popToolsAndMerge(BPHY_InDetDetailedTrackSelectorToolCfg(flags, "STDM16"))
103 vpest = acc.popToolsAndMerge(BPHY_VertexPointEstimatorCfg(flags, "STDM16"))
104 v0fitter = acc.popToolsAndMerge(TrkV0VertexFitter_InDetExtrCfg(flags))
105
106 acc.addPublicTool(vkalvrt)
107 acc.addPublicTool(V0Tools)
108 acc.addPublicTool(trackselect)
109 acc.addPublicTool(vpest)
110 acc.addPublicTool(v0fitter)
111
112 #====================================================================
113 # AUGMENTATION TOOLS
114 # Largely based on PhysicsAnalysis/DerivationFramework/DerivationFrameworkBPhys/share/BPHY1.py
115 #====================================================================
116
117 STDM16_AugmentationTools = []
118
119 #====================================================================
120 # Perform di-track vertex fit for D0 -> K- pi+ (and c.c.) candidates
121 #====================================================================
122
123 STDM16_Finder_D0 = CompFactory.Analysis.JpsiFinder(
124 name = "STDM16_Finder_D0",
125 # OutputLevel = INFO,
126 muAndMu = False,
127 muAndTrack = False,
128 TrackAndTrack = True,
129 assumeDiMuons = False,
130 invMassUpper = 3000.0,
131 invMassLower = 0.0,
132 Chi2Cut = 200.,
133 oppChargesOnly = True,
134 atLeastOneComb = False,
135 useCombinedMeasurement = False,
136 track1Mass = massPiPlus, # Not very important, only used to calculate inv. mass cut, leave it loose here
137 track2Mass = massPiPlus, # Not very important, only used to calculate inv. mass cut, leave it loose here
138 trackThresholdPt = 1000.0,
139 muonCollectionKey = "Muons",
140 TrackParticleCollection = "InDetTrackParticles",
141 V0VertexFitterTool = v0fitter, # V0 vertex fitter
142 useV0Fitter = False, # if False a TrkVertexFitterTool will be used
143 TrkVertexFitterTool = vkalvrt, # VKalVrt vertex fitter
144 TrackSelectorTool = trackselect,
145 VertexPointEstimator = vpest,
146 useMCPCuts = False)
147
148 acc.addPublicTool(STDM16_Finder_D0)
149
150
151 from JpsiUpsilonTools.JpsiUpsilonToolsConfig import PrimaryVertexRefittingToolCfg
152 STDM16_Reco_D0 = CompFactory.DerivationFramework.Reco_Vertex(
153 name = "STDM16_Reco_D0",
154 VertexSearchTool = STDM16_Finder_D0,
155 OutputVtxContainerName = "STDM16_D0Candidates",
156 PVContainerName = "PrimaryVertices",
157 V0Tools = V0Tools,
158 PVRefitter = acc.popToolsAndMerge(PrimaryVertexRefittingToolCfg(flags)),
159 DoVertexType = 7, #ES not sure how this actually works, it only takes 7(all) and 1 but what does it mean ?????
160 RefPVContainerName = "SHOULDNOTBEUSED",
161 RefitPV = False)
162
163 acc.addPublicTool(STDM16_Reco_D0)
164 STDM16_AugmentationTools += [STDM16_Reco_D0]
165
166 #====================================================================
167 # Perform some selection on the D0 vertex candidates
168 #====================================================================
169
170 # Loose D0 vertex cuts
171 cutMinLxy = -999 # mm
172 cutMinMass = 1600.0 # MeV
173 cutMaxMass = 2100.0 # MeV
174 cutMaxChiSq = 50.0
175
176 # Need two of these, one for each track mass hypothesis
177 STDM16_Select_D0 = CompFactory.DerivationFramework.Select_onia2mumu(
178 name = "STDM16_Select_D0",
179 HypothesisName = "D0",
180 InputVtxContainerName = STDM16_Reco_D0.OutputVtxContainerName,
181 TrkMasses = [massPiPlus,massKPlus],
182 VtxMassHypo = massD0,
183 MassMin = cutMinMass,
184 MassMax = cutMaxMass,
185 Chi2Max = cutMaxChiSq,
186 LxyMin = cutMinLxy)
187
188 acc.addPublicTool(STDM16_Select_D0)
189 STDM16_AugmentationTools += [STDM16_Select_D0]
190
191 STDM16_Select_D0b = CompFactory.DerivationFramework.Select_onia2mumu(
192 name = "STDM16_Select_D0b",
193 HypothesisName = "D0b",
194 InputVtxContainerName = STDM16_Reco_D0.OutputVtxContainerName,
195 TrkMasses = [massKPlus,massPiPlus],
196 VtxMassHypo = massD0,
197 MassMin = cutMinMass,
198 MassMax = cutMaxMass,
199 Chi2Max = cutMaxChiSq,
200 LxyMin = cutMinLxy)
201
202 acc.addPublicTool(STDM16_Select_D0b)
203 STDM16_AugmentationTools += [STDM16_Select_D0b]
204
205 #====================================================================
206 # Look for D*+ -> D0 + pi+ candidates by looking for tracks which
207 # lead to low DeltaM w.r.t. D0 candidates. Good candidates (tracks and vertices)
208 # are augmented with "passed_Dstar" flag
209 #====================================================================
210
211 STDM16_DStarSelectionTool = acc.getPrimaryAndMerge(DStarSelectionToolCfg(flags,
212 name = "STDM16_DStarSelectionTool",
213 InputVtxContainerName = STDM16_Reco_D0.OutputVtxContainerName,
214 DeltaMassMax = 200.0))
215
216 STDM16_AugmentationTools += [STDM16_DStarSelectionTool]
217
218
219 #=======================================
220 # SKIMMING TOOLS
221 #=======================================
222 STDM16_SkimmingTools = []
223
224 #====================================================================
225 # Only retain events with at least one D* candidate
226 #====================================================================
227
228 # Skimming based on number of vertex candidates
229 SelectExpression = "count(STDM16_D0Candidates.passed_Dstar) > 0"
230
231 STDM16_SelectEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(
232 name = "STDM16_SelectEvent",
233 expression = SelectExpression)
234 acc.addPublicTool(STDM16_SelectEvent)
235 STDM16_SkimmingTools += [STDM16_SelectEvent]
236
237 #====================================================================
238 # THINNING TOOLS
239 #====================================================================
240 STDM16_ThinningTools = []
241
242 #====================================================================
243 # Only retain vertices passing loose D0 selection in Select_onia2mumu tool
244 #====================================================================
245
246 STDM16_Thin_Vertex = CompFactory.DerivationFramework.Thin_vtxTrk(
247 name = "STDM16_Thin_Vertex",
248 StreamName = streamName,
249 ThinTracks = False,
250 VertexContainerNames = ["STDM16_D0Candidates"],
251 PassFlags = ["passed_Dstar"] )
252 STDM16_ThinningTools += [STDM16_Thin_Vertex]
253 acc.addPublicTool(STDM16_Thin_Vertex)
254
255 #====================================================================
256 # Only retain tracks associated with above D0 vertices and soft pion
257 # candiates found in DStarSelectionTool
258 #====================================================================
259
260 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import GenericObjectThinningCfg
261
262 track_thinning_expression = "(InDetTrackParticles.trackPassDstar == 1)"
263 STDM16_Thin_Tracks = acc.getPrimaryAndMerge(
264 GenericObjectThinningCfg(flags,
265 name = "STDM16_Thin_Tracks",
266 ContainerName = "InDetTrackParticles",
267 StreamName = streamName,
268 SelectionString = track_thinning_expression))
269 STDM16_ThinningTools += [STDM16_Thin_Tracks]
270 acc.addPublicTool(STDM16_Thin_Tracks)
271
272 acc.addPublicTool(STDM16_SelectEvent)
273 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("STDM16Kernel",
274 SkimmingTools = STDM16_SkimmingTools,
275 ThinningTools = STDM16_ThinningTools,
276 AugmentationTools = STDM16_AugmentationTools))
277
278 return acc
279
280
281def STDM16Cfg(flags):
282
283 acc = STDM16Kernel(flags)
284 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
285 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
286 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
287 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import getDefaultAllVariables
288
289 # PFlow augmentation tool
290
291 AllVariables = getDefaultAllVariables()
292 StaticContent = []
293
294
295
296 AllVariables += ["PrimaryVertices"]
297
298
299 AllVariables += ["InDetTrackParticles"]
300
301
302 #=======================================
303 # Decide what to save
304 #=======================================
305
306 StaticContent += ["xAOD::VertexContainer#%s" % CandidatesContainerName ]
307
308
309 StaticContent += ["xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % CandidatesContainerName]
310
311
312 # # Truth information for MC only
313 if flags.Input.isMC :
314 AllVariables += ["TruthEvents","TruthParticles", "TruthVertices","MuonTruthParticles", "AntiKt4TruthJets","AntiKt4TruthWZJets"]
315
316 STDM16SlimmingHelper = SlimmingHelper("STDM16SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
317
318
319 STDM16SlimmingHelper.SmartCollections = ["AntiKt4EMPFlowJets",
320 "EventInfo",
321 "Muons",
322 "PrimaryVertices",
323 "InDetTrackParticles"]
324
325 # This variable is augmented by DStarSelectionTool
326 STDM16SlimmingHelper.ExtraVariables += ["InDetTrackParticles.trackPassDstar",
327 "AntiKt4EMPFlowJets.DFCommonJets_QGTagger_truthjet_nCharged.DFCommonJets_QGTagger_truthjet_pt.DFCommonJets_QGTagger_truthjet_eta.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt.GhostPartons.isJvtHS.isJvtPU.IsoFixedCone5PtPUsub",
328 "TruthPrimaryVertices.t.x.y.z",
329 "InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights.eProbabilityHT.numberOfTRTHits.numberOfTRTOutliers",
330 "EventInfo.GenFiltHT.GenFiltMET.GenFiltHTinclNu.GenFiltPTZ.GenFiltFatJ.HF_Classification.HF_SimpleClassification",
331 "TauJets.dRmax.etOverPtLeadTrk", "TauJets_MuonRM.dRmax.etOverPtLeadTrk",
332 "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET.ex.ey",
333 "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_mht.ex.ey"]
334
335 # Needed for trigger objects
336
337 STDM16SlimmingHelper.IncludeJetTriggerContent = True
338 STDM16SlimmingHelper.IncludeMuonTriggerContent = True
339 STDM16SlimmingHelper.AllVariables = AllVariables
340 STDM16SlimmingHelper.StaticContent = StaticContent
341 STDM16ItemList = STDM16SlimmingHelper.GetItemList()
342
343 acc.merge(OutputStreamCfg(flags, "DAOD_STDM16", ItemList=STDM16ItemList, AcceptAlgs=["STDM16Kernel"]))
344 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_STDM16", AcceptAlgs=["STDM16Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
345 acc.printConfig(withDetails=True, summariseProps=True, onlyComponents = [], printDefaults=True)
346 return acc
STDM16Kernel(flags, name='STDM16Kernel', **kwargs)
Definition STDM16.py:32
STDM16Cfg(flags)
Definition STDM16.py:281
DStarSelectionToolCfg(flags, name, **kwargs)
Definition STDM16.py:24