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